handle issue

Apr 16, 2010 at 4:51 PM
Edited Apr 16, 2010 at 6:37 PM

There's a minor issue in 1.7 that you can't properly unpair wiimote when lib is using it (even after .Disconnect() call). I think I've found a solution.

In Wiimote.cs, FindWiimote() function:

1. Replace 

SafeFileHandle mHandle;


SafeFileHandle mHandle = null;


2. After line HIDImports.SetupDiDestroyDeviceInfoList(hDevInfo);


if (mHandle != null)                



That's it. I have no idea WHY this helps, but it definitely does.


Apr 17, 2010 at 8:22 AM

Nevermind my previous, I've found the REAL issue.

In Wiimote.cs, FindWiimote() function:

after found = true; line add




The problem was that at some point (e.g right after reboot, when wiimote still remains on devices list (Start->Devices and Printers in Win7) and isnt really paired to PC), subsequent wiimoteFound() callback call throws an exception (can't read data) and thus these handles stay open. So after you called Connect() once, you can't remove device properly (it leaves a "HID input device" record on the list) until you close your app. With the fix above unpairing after Connect() works like a charm.