我正在尝试使用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?
}
}我评论的那句话是“这里我很困惑!……”就是一直在搞乱的东西。有人能帮我一个接一个地连接到所有的wiimote,然后从他们的流中读取吗?
发布于 2010-09-26 22:18:08
不要试图重新发明轮子,使用现有的库:http://wiimotelib.codeplex.com/
https://stackoverflow.com/questions/3798145
复制相似问题