From e67ae274a54484480123ceeda5e198f5b5e24e10 Mon Sep 17 00:00:00 2001
From: Cameron Gutman <[EMAIL REDACTED]>
Date: Wed, 13 Nov 2024 22:04:05 -0600
Subject: [PATCH] hidapi: Fix bus type in HIDAPI_IGNORE_DEVICE() on Linux
This bug prevented the Steam Controller's keyboard and mouse
interfaces from being properly ignored by the HIDAPI joystick
driver on Linux.
---
src/hidapi/linux/hid.c | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/src/hidapi/linux/hid.c b/src/hidapi/linux/hid.c
index 6c17fac363844..dbaa9437738f6 100644
--- a/src/hidapi/linux/hid.c
+++ b/src/hidapi/linux/hid.c
@@ -1042,7 +1042,28 @@ struct hid_device_info HID_API_EXPORT *hid_enumerate(unsigned short vendor_id,
memset(&usage_iterator, 0, sizeof(usage_iterator));
get_next_hid_usage(report_desc.value, report_desc.size, &usage_iterator, &page, &usage);
}
- if (HIDAPI_IGNORE_DEVICE(bus_type, dev_vid, dev_pid, 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