Skip to content

Commit a88c724

Browse files
committed
mac: Fix incorrect device list after device removal
On Mac OS X 10.8.x (Mountain Lion), if a device is connected, opened, then closed, then unplugged, subsequent calls to hid_enumerate() will still list the device (even though it's been unplugged). If the device is plugged in again, a second instance will show up in the list and often it will be impossible to open either. Github user TamToucan figured out that in hid_enumerate() if a call is made to IOHIDManagerSetDeviceMatching() before the call to IOHIDManagerCopyDevices() that this will clear the problem. Thanks to TamToucan for figuring this out.
1 parent 1ec76ad commit a88c724

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

mac/hid.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ struct hid_device_info HID_API_EXPORT *hid_enumerate(unsigned short vendor_id,
420420
process_pending_events();
421421

422422
/* Get a list of the Devices */
423+
IOHIDManagerSetDeviceMatching(hid_mgr, NULL);
423424
CFSetRef device_set = IOHIDManagerCopyDevices(hid_mgr);
424425

425426
/* Convert the list into a C array so we can iterate easily. */

0 commit comments

Comments
 (0)