| 360 | static IOHIDManagerRef hid_manager=NULL; |
| 361 | |
| 362 | void attach_callback(void *context, IOReturn r, void *hid_mgr, IOHIDDeviceRef dev) |
| 363 | { |
| 364 | CFTypeRef type; |
| 365 | struct usb_list_struct *n, *p; |
| 366 | int32_t pid, vid; |
| 367 | |
| 368 | if (!dev) return; |
| 369 | type = IOHIDDeviceGetProperty(dev, CFSTR(kIOHIDVendorIDKey)); |
| 370 | if (!type || CFGetTypeID(type) != CFNumberGetTypeID()) return; |
| 371 | if (!CFNumberGetValue((CFNumberRef)type, kCFNumberSInt32Type, &vid)) return; |
| 372 | type = IOHIDDeviceGetProperty(dev, CFSTR(kIOHIDProductIDKey)); |
| 373 | if (!type || CFGetTypeID(type) != CFNumberGetTypeID()) return; |
| 374 | if (!CFNumberGetValue((CFNumberRef)type, kCFNumberSInt32Type, &pid)) return; |
| 375 | n = (struct usb_list_struct *)malloc(sizeof(struct usb_list_struct)); |
| 376 | if (!n) return; |
| 377 | //printf("attach callback: vid=%04X, pid=%04X\n", vid, pid); |
| 378 | n->ref = dev; |
| 379 | n->vid = vid; |
| 380 | n->pid = pid; |
| 381 | n->next = NULL; |
| 382 | if (usb_list == NULL) { |
| 383 | usb_list = n; |
| 384 | } else { |
| 385 | for (p = usb_list; p->next; p = p->next) ; |
| 386 | p->next = n; |
| 387 | } |
| 388 | } |
| 389 | |
| 390 | void detach_callback(void *context, IOReturn r, void *hid_mgr, IOHIDDeviceRef dev) |
| 391 | { |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…