Skip to content

Commit bf30f12

Browse files
committed
HID: usbhid: Insert USB bus/device ID into HID name
libinput/wlroots/Wayfire/labwc match input device by the device name only. If you add 2 identical USB connected touch devices, you can't select between them. Add the usb bus&device name to the start of the name so that the names end up being unique, Signed-off-by: Dave Stevenson <[email protected]>
1 parent 7a3d1c2 commit bf30f12

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

drivers/hid/usbhid/hid-core.c

+8-4
Original file line numberDiff line numberDiff line change
@@ -1388,17 +1388,21 @@ static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id *
13881388
else if (intf->cur_altsetting->desc.bInterfaceProtocol == 0)
13891389
hid->type = HID_TYPE_USBNONE;
13901390

1391-
if (dev->manufacturer)
1392-
strscpy(hid->name, dev->manufacturer, sizeof(hid->name));
1391+
snprintf(hid->name, sizeof(hid->name), "usb-%s ", dev_name(&dev->dev));
1392+
1393+
if (dev->manufacturer) {
1394+
strlcat(hid->name, dev->manufacturer, sizeof(hid->name));
1395+
}
13931396

13941397
if (dev->product) {
13951398
if (dev->manufacturer)
13961399
strlcat(hid->name, " ", sizeof(hid->name));
13971400
strlcat(hid->name, dev->product, sizeof(hid->name));
13981401
}
13991402

1400-
if (!strlen(hid->name))
1401-
snprintf(hid->name, sizeof(hid->name), "HID %04x:%04x",
1403+
if (strlen(hid->name) == strlen(dev_name(&dev->dev)))
1404+
snprintf(hid->name, sizeof(hid->name), "usb-%s HID %04x:%04x",
1405+
dev_name(&dev->dev),
14021406
le16_to_cpu(dev->descriptor.idVendor),
14031407
le16_to_cpu(dev->descriptor.idProduct));
14041408

0 commit comments

Comments
 (0)