mirror of
https://github.com/libratbag/libratbag.git
synced 2026-11-07 23:23:52 +01:00
hidraw: make sure we're comparing products of the same int type
hidraw_devinfo.product is 16-bit signed, input_id.product is 16 bit unsigned. Move the hidraw info over to a input_id, then compare. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
@@ -41,6 +41,7 @@ ratbag_open_hidraw(struct ratbag_device *ratbag)
|
||||
struct hidraw_devinfo info;
|
||||
int fd, res;
|
||||
const char *devnode;
|
||||
struct input_id hid_id;
|
||||
|
||||
if (!ratbag->udev_hidraw)
|
||||
return -EINVAL;
|
||||
@@ -58,19 +59,23 @@ ratbag_open_hidraw(struct ratbag_device *ratbag)
|
||||
goto err;
|
||||
}
|
||||
|
||||
hid_id.bustype = info.bustype;
|
||||
hid_id.vendor = info.vendor;
|
||||
hid_id.product = info.product;
|
||||
|
||||
/* Check if the device actually matches the input node */
|
||||
if (info.bustype != ratbag->ids.bustype ||
|
||||
info.vendor != ratbag->ids.vendor) {
|
||||
if (hid_id.bustype != ratbag->ids.bustype ||
|
||||
hid_id.vendor != ratbag->ids.vendor) {
|
||||
errno -EINVAL;
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* On the Logitech receiver, the hid device has the pid of the
|
||||
* receiver, not of the actual device */
|
||||
if (info.product != ratbag->ids.product &&
|
||||
(info.vendor == USB_VENDOR_ID_LOGITECH &&
|
||||
info.product != (int16_t)USB_DEVICE_ID_UNIFYING_RECEIVER &&
|
||||
info.product != (int16_t)USB_DEVICE_ID_UNIFYING_RECEIVER2)) {
|
||||
if (hid_id.product != ratbag->ids.product &&
|
||||
(hid_id.vendor == USB_VENDOR_ID_LOGITECH &&
|
||||
hid_id.product != USB_DEVICE_ID_UNIFYING_RECEIVER &&
|
||||
hid_id.product != USB_DEVICE_ID_UNIFYING_RECEIVER2)) {
|
||||
errno = -EINVAL;
|
||||
goto err;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user