mirror of https://github.com/encounter/SDL.git
Don't enumerate devices we can't open
This commit is contained in:
parent
adb53d0b1f
commit
5e649983e7
|
@ -608,6 +608,9 @@ struct hid_device_info HID_API_EXPORT *hid_enumerate(unsigned short vendor_id,
|
||||||
/* Check the VID/PID against the arguments */
|
/* Check the VID/PID against the arguments */
|
||||||
if ((vendor_id == 0x0 || vendor_id == dev_vid) &&
|
if ((vendor_id == 0x0 || vendor_id == dev_vid) &&
|
||||||
(product_id == 0x0 || product_id == dev_pid)) {
|
(product_id == 0x0 || product_id == dev_pid)) {
|
||||||
|
res = libusb_open(dev, &handle);
|
||||||
|
|
||||||
|
if (res >= 0) {
|
||||||
struct hid_device_info *tmp;
|
struct hid_device_info *tmp;
|
||||||
|
|
||||||
/* VID/PID match. Create the record. */
|
/* VID/PID match. Create the record. */
|
||||||
|
@ -624,9 +627,6 @@ struct hid_device_info HID_API_EXPORT *hid_enumerate(unsigned short vendor_id,
|
||||||
cur_dev->next = NULL;
|
cur_dev->next = NULL;
|
||||||
cur_dev->path = make_path(dev, interface_num);
|
cur_dev->path = make_path(dev, interface_num);
|
||||||
|
|
||||||
res = libusb_open(dev, &handle);
|
|
||||||
|
|
||||||
if (res >= 0) {
|
|
||||||
/* Serial Number */
|
/* Serial Number */
|
||||||
if (desc.iSerialNumber > 0)
|
if (desc.iSerialNumber > 0)
|
||||||
cur_dev->serial_number =
|
cur_dev->serial_number =
|
||||||
|
@ -704,7 +704,7 @@ struct hid_device_info HID_API_EXPORT *hid_enumerate(unsigned short vendor_id,
|
||||||
#endif /* INVASIVE_GET_USAGE */
|
#endif /* INVASIVE_GET_USAGE */
|
||||||
|
|
||||||
libusb_close(handle);
|
libusb_close(handle);
|
||||||
}
|
|
||||||
/* VID/PID */
|
/* VID/PID */
|
||||||
cur_dev->vendor_id = dev_vid;
|
cur_dev->vendor_id = dev_vid;
|
||||||
cur_dev->product_id = dev_pid;
|
cur_dev->product_id = dev_pid;
|
||||||
|
@ -717,6 +717,9 @@ struct hid_device_info HID_API_EXPORT *hid_enumerate(unsigned short vendor_id,
|
||||||
cur_dev->interface_class = intf_desc->bInterfaceClass;
|
cur_dev->interface_class = intf_desc->bInterfaceClass;
|
||||||
cur_dev->interface_subclass = intf_desc->bInterfaceSubClass;
|
cur_dev->interface_subclass = intf_desc->bInterfaceSubClass;
|
||||||
cur_dev->interface_protocol = intf_desc->bInterfaceProtocol;
|
cur_dev->interface_protocol = intf_desc->bInterfaceProtocol;
|
||||||
|
|
||||||
|
} else
|
||||||
|
LOG("Can't open device 0x%.4x/0x%.4x during enumeration: %d\n", dev_vid, dev_pid, res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} /* altsettings */
|
} /* altsettings */
|
||||||
|
|
Loading…
Reference in New Issue