MCPcopy Create free account
hub / github.com/kiibohd/controller / attach_callback

Function attach_callback

LoadFile/teensy_loader_cli.c:362–388  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

360static IOHIDManagerRef hid_manager=NULL;
361
362void 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
390void detach_callback(void *context, IOReturn r, void *hid_mgr, IOHIDDeviceRef dev)
391{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…