2010-09-26 87 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