Skip to content

Commit ce92386

Browse files
authored
Windows hotplug: Mutex for callback actions (#646)
1 parent 79a3516 commit ce92386

2 files changed

Lines changed: 181 additions & 116 deletions

File tree

hidtest/test.c

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -127,31 +127,34 @@ void print_devices_with_descriptor(struct hid_device_info *cur_dev) {
127127
}
128128

129129
int device_callback(
130-
hid_hotplug_callback_handle callback_handle,
131-
struct hid_device_info* device,
132-
hid_hotplug_event event,
133-
void* user_data)
130+
hid_hotplug_callback_handle callback_handle,
131+
struct hid_device_info* device,
132+
hid_hotplug_event event,
133+
void* user_data)
134134
{
135135
(void)user_data;
136136

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

142-
printf("type: %04hx %04hx\n serial_number: %ls", device->vendor_id, device->product_id, device->serial_number);
143-
printf("\n");
144-
printf(" Manufacturer: %ls\n", device->manufacturer_string);
145-
printf(" Product: %ls\n", device->product_string);
146-
printf(" Release: %hx\n", device->release_number);
147-
printf(" Interface: %d\n", device->interface_number);
148-
printf(" Usage (page): 0x%hx (0x%hx)\n", device->usage, device->usage_page);
149-
printf("\n");
142+
printf("type: %04hx %04hx\n serial_number: %ls", device->vendor_id, device->product_id, device->serial_number);
143+
printf("\n");
144+
printf(" Manufacturer: %ls\n", device->manufacturer_string);
145+
printf(" Product: %ls\n", device->product_string);
146+
printf(" Release: %hx\n", device->release_number);
147+
printf(" Interface: %d\n", device->interface_number);
148+
printf(" Usage (page): 0x%hx (0x%hx)\n", device->usage, device->usage_page);
149+
printf("\n");
150150

151-
//if (device->product_id == 0x0ce6)
152-
// return 1;
151+
/* Printed data might not show on the screen - force it out */
152+
fflush(stdout);
153153

154-
return 0;
154+
//if (device->product_id == 0x0ce6)
155+
// return 1;
156+
157+
return 0;
155158
}
156159

157160
int main(int argc, char* argv[])

0 commit comments

Comments
 (0)