| 410 | } |
| 411 | |
| 412 | void init_hid_manager(void) |
| 413 | { |
| 414 | CFMutableDictionaryRef dict; |
| 415 | IOReturn ret; |
| 416 | |
| 417 | if (hid_manager) return; |
| 418 | hid_manager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone); |
| 419 | if (hid_manager == NULL || CFGetTypeID(hid_manager) != IOHIDManagerGetTypeID()) { |
| 420 | if (hid_manager) CFRelease(hid_manager); |
| 421 | printf_verbose("no HID Manager - maybe this is a pre-Leopard (10.5) system?\n"); |
| 422 | return; |
| 423 | } |
| 424 | dict = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, |
| 425 | &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); |
| 426 | if (!dict) return; |
| 427 | IOHIDManagerSetDeviceMatching(hid_manager, dict); |
| 428 | CFRelease(dict); |
| 429 | IOHIDManagerScheduleWithRunLoop(hid_manager, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode); |
| 430 | IOHIDManagerRegisterDeviceMatchingCallback(hid_manager, attach_callback, NULL); |
| 431 | IOHIDManagerRegisterDeviceRemovalCallback(hid_manager, detach_callback, NULL); |
| 432 | ret = IOHIDManagerOpen(hid_manager, kIOHIDOptionsTypeNone); |
| 433 | if (ret != kIOReturnSuccess) { |
| 434 | IOHIDManagerUnscheduleFromRunLoop(hid_manager, |
| 435 | CFRunLoopGetCurrent(), kCFRunLoopDefaultMode); |
| 436 | CFRelease(hid_manager); |
| 437 | printf_verbose("Error opening HID Manager"); |
| 438 | } |
| 439 | } |
| 440 | |
| 441 | static void do_run_loop(void) |
| 442 | { |
no test coverage detected
searching dependent graphs…