使用C#.NET的32Feet API - Stuck

时间:2010-09-26 14:08:11

标签: c# wiimote

我正在尝试使用32Feet API配对我的Wiimotes,我通过以下代码成功完成了这项工作。

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 个答案:

答案 0 :(得分:-1)

不要尝试重新发明轮子,使用现有的库:http://wiimotelib.codeplex.com/