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.
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.