mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-05 19:08:12 +00:00
hidapi: check each usage on a device before ignoring it completely
This commit is contained in:
@@ -900,6 +900,32 @@ static struct hid_device_info * create_device_info_for_device(struct udev_device
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HIDAPI_IGNORE_DEVICE
|
||||
{
|
||||
struct hid_device_info *prev_dev = NULL;
|
||||
|
||||
cur_dev = root;
|
||||
while (cur_dev) {
|
||||
if (HIDAPI_IGNORE_DEVICE(cur_dev->bus_type, cur_dev->vendor_id, cur_dev->product_id, cur_dev->usage_page, cur_dev->usage)) {
|
||||
struct hid_device_info *tmp = cur_dev;
|
||||
|
||||
cur_dev = tmp->next;
|
||||
if (prev_dev) {
|
||||
prev_dev->next = cur_dev;
|
||||
} else {
|
||||
root = cur_dev;
|
||||
}
|
||||
tmp->next = NULL;
|
||||
|
||||
hid_free_enumeration(tmp);
|
||||
} else {
|
||||
prev_dev = cur_dev;
|
||||
cur_dev = cur_dev->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
end:
|
||||
free(serial_number_utf8);
|
||||
free(product_name_utf8);
|
||||
@@ -1030,44 +1056,6 @@ struct hid_device_info HID_API_EXPORT *hid_enumerate(unsigned short vendor_id,
|
||||
continue;
|
||||
}
|
||||
|
||||
#ifdef HIDAPI_IGNORE_DEVICE
|
||||
/* See if there are any devices we should skip in enumeration */
|
||||
if (!parse_hid_vid_pid_from_sysfs(sysfs_path, &bus_type, &dev_vid, &dev_pid))
|
||||
continue;
|
||||
|
||||
struct hidraw_report_descriptor report_desc;
|
||||
unsigned short page = 0, usage = 0;
|
||||
if (get_hid_report_descriptor_from_sysfs(sysfs_path, &report_desc) >= 0) {
|
||||
struct hid_usage_iterator usage_iterator;
|
||||
memset(&usage_iterator, 0, sizeof(usage_iterator));
|
||||
get_next_hid_usage(report_desc.value, report_desc.size, &usage_iterator, &page, &usage);
|
||||
}
|
||||
|
||||
/* Convert from Linux bus types to standard HIDAPI ones */
|
||||
hid_bus_type hidapi_bus_type;
|
||||
switch (bus_type) {
|
||||
case BUS_USB:
|
||||
hidapi_bus_type = HID_API_BUS_USB;
|
||||
break;
|
||||
case BUS_BLUETOOTH:
|
||||
hidapi_bus_type = HID_API_BUS_BLUETOOTH;
|
||||
break;
|
||||
case BUS_I2C:
|
||||
hidapi_bus_type = HID_API_BUS_I2C;
|
||||
break;
|
||||
case BUS_SPI:
|
||||
hidapi_bus_type = HID_API_BUS_SPI;
|
||||
break;
|
||||
default:
|
||||
hidapi_bus_type = HID_API_BUS_UNKNOWN;
|
||||
break;
|
||||
}
|
||||
|
||||
if (HIDAPI_IGNORE_DEVICE(hidapi_bus_type, dev_vid, dev_pid, page, usage)) {
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
raw_dev = udev_device_new_from_syspath(udev, sysfs_path);
|
||||
if (!raw_dev)
|
||||
continue;
|
||||
|
Reference in New Issue
Block a user