Skip to content

Commit

Permalink
Hotplug implementation for MacOS (HidManager approach)
Browse files Browse the repository at this point in the history
  • Loading branch information
k1-801 committed Mar 11, 2024
1 parent 79a3516 commit 4d851df
Show file tree
Hide file tree
Showing 2 changed files with 437 additions and 32 deletions.
39 changes: 21 additions & 18 deletions hidtest/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,24 +134,27 @@ int device_callback(
{
(void)user_data;

if (event & HID_API_HOTPLUG_EVENT_DEVICE_ARRIVED)
printf("Handle %d: New device is connected: %s.\n", callback_handle, device->path);
else
printf("Handle %d: Device was disconnected: %s.\n", callback_handle, device->path);

printf("type: %04hx %04hx\n serial_number: %ls", device->vendor_id, device->product_id, device->serial_number);
printf("\n");
printf(" Manufacturer: %ls\n", device->manufacturer_string);
printf(" Product: %ls\n", device->product_string);
printf(" Release: %hx\n", device->release_number);
printf(" Interface: %d\n", device->interface_number);
printf(" Usage (page): 0x%hx (0x%hx)\n", device->usage, device->usage_page);
printf("\n");

//if (device->product_id == 0x0ce6)
// return 1;

return 0;
if (event & HID_API_HOTPLUG_EVENT_DEVICE_ARRIVED)
printf("Handle %d: New device is connected: %s.\n", callback_handle, device->path);
else
printf("Handle %d: Device was disconnected: %s.\n", callback_handle, device->path);

printf("type: %04hx %04hx\n serial_number: %ls", device->vendor_id, device->product_id, device->serial_number);
printf("\n");
printf(" Manufacturer: %ls\n", device->manufacturer_string);
printf(" Product: %ls\n", device->product_string);
printf(" Release: %hx\n", device->release_number);
printf(" Interface: %d\n", device->interface_number);
printf(" Usage (page): 0x%hx (0x%hx)\n", device->usage, device->usage_page);
printf("\n");

//if (device->product_id == 0x0ce6)
// return 1;

/* Printed data might not show on the screen - force it out */
fflush(stdout);

return 0;
}

int main(int argc, char* argv[])
Expand Down
Loading

0 comments on commit 4d851df

Please sign in to comment.