2010-09-26 85 views
0

我想配對我的Wiimotes使用32Feet API,我成功地通過以下代碼這樣做。32Feet API與C#.NET - 卡住

var client = new InTheHand.Net.Sockets.BluetoothClient(); 

var devices = client.DiscoverDevices(); 

var count = (from d in devices 
      where d.DeviceName.Contains("Nintendo") 
      select d).Count(); 

foreach (var device in devices) 
{ 
    if (device.DeviceName.Contains("Nintendo")) 
    { 
     if (device.InstalledServices.Length > 0) 
     { 
     InTheHand.Net.Bluetooth.BluetoothSecurity.RemoveDevice(device.DeviceAddress); 

     //while it's being removed 
     Thread.Sleep(2000); 
     } 

     device.SetServiceState(InTheHand.Net.Bluetooth.BluetoothService.HumanInterfaceDevice, false); 
     device.SetServiceState(InTheHand.Net.Bluetooth.BluetoothService.HumanInterfaceDevice, true); 

     //Here I am confused! What to do to read from stream? 
    } 
} 

我曾經評論過的「我在這裏很困惑!」這句話是一直在搞的東西。有人可以幫助我如何連接所有的wiimotes,然後從他們的流中讀取嗎?

回答

-1

不要試圖重新發明輪子,使用現有的圖書館:http://wiimotelib.codeplex.com/

+0

我想我需要糾正你。你提到的API是我目前使用的API,但是API是HID包裝,並且不允許人們配對。 32Feet API允許我配對和讀取數據。如果你能告訴我那將會很棒。 – Neutralizer 2010-09-26 14:27:22

+0

在配對遙控器後不能使用Wiimotelib嗎? – ZippyV 2010-09-26 15:05:52