private static bool IsWiimoteConnected(SafeHandle wiimoteHandle) { var _mBuff = new byte[22]; _mBuff[0] = 0x15; bool good = WiimoteEnumerator.HidD_SetOutputReport(wiimoteHandle.DangerousGetHandle(), _mBuff, (uint)_mBuff.Length); int error = Marshal.GetLastWin32Error(); return(error != 0x1F && good); }
/// <inheritdoc/> public override IEnumerable <IInputDevice> GetConnectedDevices() { var guid = new Guid("0306057e-0000-0000-0000-504944564944"); return(from device in this.inputManager.GetAllDevices() where device?.DI_ProductGUID == guid let wiimoteHandle = WiimoteEnumerator.CreateFile(device.DI_InterfacePath) let deviceId = "DEVICE_WII_REMOTE" where WiimoteEnumerator.IsWiimoteConnected(wiimoteHandle) select new InputDevice(InputApi.Other, device, this.ControllerLayout)); }
public static SafeHandle CreateFile(string devicePath) { return(WiimoteEnumerator.CreateFile(devicePath, FileAccess.ReadWrite, FileShare.ReadWrite, IntPtr.Zero, FileMode.Open, 0x40000000, IntPtr.Zero)); }