signal11/hidapi — pull request #40 by mrpippy (2012-01-26 07:25:37+00:00)
Title: Mac: Use IOKit paths

These commits change hid_enumerate() and hid_open_path() to use IOKit IOService:/ paths for devices.

On 10.6 and above, it's real clean and much simpler than the previous hid_open_path() implementation.

On 10.5, it's a little sticky since IOHIDDeviceGetService() isn't available. First, I'm weakly linking to IOHIDDeviceGetService(), so its availability gets checked at runtime and used if it exists (10.6 and up). For 10.5, the backup plan is to just get the io_service_t directly out of the IOHIDDevice struct. The IOHIDDevice struct never changed throughout 10.5, and I've tested (with hidtest) successfully on 10.5.8 ppc, i386, and x86_64. It's naughty, but it works :)

Also, the device_list removal patches are needed for disconnect detection to work right. I guess since the IOHIDDevice is being created without going through the manager, assigning the removal callback to the manager wouldn't work (the callback wasn't getting called).