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,25 +608,25 @@ 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)) {
|
||||||
struct hid_device_info *tmp;
|
|
||||||
|
|
||||||
/* VID/PID match. Create the record. */
|
|
||||||
tmp = (struct hid_device_info*) calloc(1, sizeof(struct hid_device_info));
|
|
||||||
if (cur_dev) {
|
|
||||||
cur_dev->next = tmp;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
root = tmp;
|
|
||||||
}
|
|
||||||
cur_dev = tmp;
|
|
||||||
|
|
||||||
/* Fill out the record */
|
|
||||||
cur_dev->next = NULL;
|
|
||||||
cur_dev->path = make_path(dev, interface_num);
|
|
||||||
|
|
||||||
res = libusb_open(dev, &handle);
|
res = libusb_open(dev, &handle);
|
||||||
|
|
||||||
if (res >= 0) {
|
if (res >= 0) {
|
||||||
|
struct hid_device_info *tmp;
|
||||||
|
|
||||||
|
/* VID/PID match. Create the record. */
|
||||||
|
tmp = (struct hid_device_info*) calloc(1, sizeof(struct hid_device_info));
|
||||||
|
if (cur_dev) {
|
||||||
|
cur_dev->next = tmp;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
root = tmp;
|
||||||
|
}
|
||||||
|
cur_dev = tmp;
|
||||||
|
|
||||||
|
/* Fill out the record */
|
||||||
|
cur_dev->next = NULL;
|
||||||
|
cur_dev->path = make_path(dev, interface_num);
|
||||||
|
|
||||||
/* Serial Number */
|
/* Serial Number */
|
||||||
if (desc.iSerialNumber > 0)
|
if (desc.iSerialNumber > 0)
|
||||||
cur_dev->serial_number =
|
cur_dev->serial_number =
|
||||||
|
@ -704,19 +704,22 @@ 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 */
|
|
||||||
cur_dev->vendor_id = dev_vid;
|
|
||||||
cur_dev->product_id = dev_pid;
|
|
||||||
|
|
||||||
/* Release Number */
|
/* VID/PID */
|
||||||
cur_dev->release_number = desc.bcdDevice;
|
cur_dev->vendor_id = dev_vid;
|
||||||
|
cur_dev->product_id = dev_pid;
|
||||||
|
|
||||||
/* Interface Number */
|
/* Release Number */
|
||||||
cur_dev->interface_number = interface_num;
|
cur_dev->release_number = desc.bcdDevice;
|
||||||
cur_dev->interface_class = intf_desc->bInterfaceClass;
|
|
||||||
cur_dev->interface_subclass = intf_desc->bInterfaceSubClass;
|
/* Interface Number */
|
||||||
cur_dev->interface_protocol = intf_desc->bInterfaceProtocol;
|
cur_dev->interface_number = interface_num;
|
||||||
|
cur_dev->interface_class = intf_desc->bInterfaceClass;
|
||||||
|
cur_dev->interface_subclass = intf_desc->bInterfaceSubClass;
|
||||||
|
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