gbishop / cython-hidapi

Python wrapper for the hidapi (not active, use one of the forks)
Other
50 stars 56 forks source link

Workaround for a bug present in the Mac OS X IOHIDManagerOpen. #16

Closed bremoran closed 9 years ago

bremoran commented 10 years ago

Fix for a segmentation fault in cython-hidapi: Check if hid_init exits successfully and fail cleanly if not. The side effect of the change on Line 417 is that a failure of hid_init will lead to the calling application believing that there are no HID devices connected, rather than reporting an error. The segmentation fault is only triggered by the bug in IOKit, which is also fixed in this change.

Workaround for a bug in IOKit: If IOHIDManagerOpen is called while a keyboard or mouse is attached, it will fail with kIOReturnExclusiveAccess. Comparing hid_init to the equivalent implementation in hidapi, it seems that hidapi doesn't call IOHIDManagerOpen, so this change ports that behaviour.