gbishop/cython-hidapi — pull request #16 by bremoran (2014-11-07 15:23:14+00:00)
Title: Workaround for a bug present in the Mac OS X IOHIDManagerOpen.

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.