-
Notifications
You must be signed in to change notification settings - Fork 900
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mac: Use IOKit paths #40
Conversation
3d75ba3
to
f66c04c
Compare
Change hid_enumerate() and hid_open_path() to use IOKit IOService:/ paths to uniquely identify devices, instead of creating a path (done by the make_path() function). The path passed to hid_open_path() now must be a valid path to an IOHIDDevice in the IOService plane, like: "IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/EHC1@1D,7/ AppleUSBEHCI/PLAYSTATION(R)3 Controller@fd120000/IOUSBInterface@0/IOUSBHIDDriver"
Remove get_string_property_utf8(), it's not used since make_path() was removed
Disable get_location_id(), it's not used in active code since make_path() was removed
I was making the changes you suggested and realized that using In particular, with weak-linking if hidapi was compiled on 10.5, the fallback method (pulling it out of IOHIDDevice) would always be used (regardless of what OS the binary was running on). I'll push a new version with these changes |
After you get that done can you verify my PR #199? I'm not aware of anyone else on here who can test hidapi on a Mac. I'd gladly accept any changes. |
As per discussion in #288, can we please get this fix in? At the moment HIDAPI is unusable under OS X for devices with more than one interface. |
Let's get this in. There are 2+ ACKs in #288 thread. |
hey, is this moving along? |
Thanks a lot to both of you :) |
Thank you! |
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).