| 563 | } |
| 564 | |
| 565 | hid_device * hid_open(unsigned short vendor_id, unsigned short product_id, const wchar_t *serial_number) |
| 566 | { |
| 567 | struct hid_device_info *devs, *cur_dev; |
| 568 | const char *path_to_open = NULL; |
| 569 | hid_device *handle = NULL; |
| 570 | |
| 571 | devs = hid_enumerate(vendor_id, product_id); |
| 572 | cur_dev = devs; |
| 573 | while (cur_dev) { |
| 574 | if (cur_dev->vendor_id == vendor_id && |
| 575 | cur_dev->product_id == product_id) { |
| 576 | if (serial_number) { |
| 577 | if (cur_dev->serial_number && |
| 578 | wcscmp(serial_number, cur_dev->serial_number) == 0) { |
| 579 | path_to_open = cur_dev->path; |
| 580 | break; |
| 581 | } |
| 582 | } |
| 583 | else { |
| 584 | path_to_open = cur_dev->path; |
| 585 | break; |
| 586 | } |
| 587 | } |
| 588 | cur_dev = cur_dev->next; |
| 589 | } |
| 590 | |
| 591 | if (path_to_open) { |
| 592 | /* Open the device */ |
| 593 | handle = hid_open_path(path_to_open); |
| 594 | } |
| 595 | |
| 596 | hid_free_enumeration(devs); |
| 597 | |
| 598 | return handle; |
| 599 | } |
| 600 | |
| 601 | static void read_callback(struct libusb_transfer *transfer) |
| 602 | { |
nothing calls this directly
no test coverage detected