-
Notifications
You must be signed in to change notification settings - Fork 904
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] Set a valid interface number on hid_device_info for USB HID devices #380
base: master
Are you sure you want to change the base?
Conversation
ef1a735
to
d483207
Compare
d483207
to
2bfcd3e
Compare
mac/hid.c
Outdated
@@ -432,6 +433,7 @@ struct hid_device_info HID_API_EXPORT *hid_enumerate(unsigned short vendor_id, | |||
if ((vendor_id == 0x0 || vendor_id == dev_vid) && | |||
(product_id == 0x0 || product_id == dev_pid)) { | |||
struct hid_device_info *tmp; | |||
bool is_hid; /* Is this an actual HID usb device */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe rename this to is_usb_hid
since technically an IOHIDDeviceRef is a HID device object
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have updated it and pushed
…ices Previously the interface would never be set on Mac. This presents a big pain because retrieving interface numbers can be the only way to distinguish between the interfaces returned by HIDAPI. This change makes it possible to retrieve interface number from an hid_device_info on Mac for USB HID devices only. It is unclear if the Mac OS IOKit library returns valid interface numbers for non-HID USB devices. Because of this, I have opted to simply skip that case - leave it initialised to `-1`. In the future, we can easily relax this restriction if it turns out IOKit correctly returns interface number with non-HID USB devices. For now, this PR brings 90% of the value at 5% of the risk.
2bfcd3e
to
c283c71
Compare
I would vote yes on this pull request. Interface number definitely comes in handy |
Can confirm this patch working for OpenHMD on OSX, please merge as it currently means that OSX is broken for our library. |
Instead of trying to parse the device path to match the interface number, use the interface_number field in hid_device_info. This currently does not work on recent Mac OS X [1]. Since there is nothing we can do about it here, warn loudly. Also ignore all but the IMU interfaces when building the device list. Besides removing bogus devices from the list, this should also fix multiple PSVR headsets connected at the same time. [1] signal11/hidapi#380
…ices Previously the interface would never be set on Mac. This presents a big pain because retrieving interface numbers can be the only way to distinguish between the interfaces returned by HIDAPI. This change makes it possible to retrieve interface number from an hid_device_info on Mac for USB HID devices only. It is unclear if the Mac OS IOKit library returns valid interface numbers for non-HID USB devices. Because of this, I have opted to simply skip that case - leave it initialised to `-1`. In the future, we can easily relax this restriction if it turns out IOKit correctly returns interface number with non-HID USB devices. For now, this PR brings 90% of the value at 5% of the risk.
23cb76c
to
2357fb5
Compare
Gentle ping |
Previously the interface would never be set on Mac.
This presents a big pain because retrieving interface numbers can be the
only way to distinguish between the interfaces returned by HIDAPI.
This change makes it possible to retrieve interface number from an
hid_device_info on Mac for USB HID devices only.
It is unclear if the Mac OS IOKit library returns valid interface numbers for non-HID USB devices. Because of this, I have opted to simply skip that case - leave it initialised to
-1
.In the future, we can easily relax this restriction if it turns out IOKit correctly returns interface number with non-HID USB devices. For now, this PR brings 90% of the value at 5% of the risk.