Skip to content
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

Fixed a crash in the mac part of hidapi. #27

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions mac/hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,11 @@ static int init_hid_manager(void)
IOHIDManagerSetDeviceMatching(hid_mgr, NULL);
IOHIDManagerScheduleWithRunLoop(hid_mgr, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
res = IOHIDManagerOpen(hid_mgr, kIOHIDOptionsTypeNone);
return (res == kIOReturnSuccess)? 0: -1;
if(res == kIOReturnSuccess)
return 0;

fprintf(stderr, "IOReturn error code: 0x%x\n", err_get_code(res));
return -1;
}

int HID_API_EXPORT hid_init(void)
Expand Down Expand Up @@ -414,7 +418,8 @@ struct hid_device_info HID_API_EXPORT *hid_enumerate(unsigned short vendor_id,
setlocale(LC_ALL,"");

/* Set up the HID Manager if it hasn't been done */
hid_init();
if(hid_init() < 0)
return NULL;

/* Get a list of the Devices */
CFSetRef device_set = IOHIDManagerCopyDevices(hid_mgr);
Expand Down Expand Up @@ -700,7 +705,8 @@ hid_device * HID_API_EXPORT hid_open_path(const char *path)
dev = new_hid_device();

/* Set up the HID Manager if it hasn't been done */
hid_init();
if(hid_init() < 0)
return NULL;

CFSetRef device_set = IOHIDManagerCopyDevices(hid_mgr);

Expand Down