Skip to content

Commit

Permalink
HID: usbhid: Insert USB bus/device ID into HID name
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
6by9 committed Nov 27, 2024
1 parent d128c12 commit aeebabd
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions drivers/hid/usbhid/hid-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1388,17 +1388,21 @@ static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id *
else if (intf->cur_altsetting->desc.bInterfaceProtocol == 0)
hid->type = HID_TYPE_USBNONE;

if (dev->manufacturer)
strscpy(hid->name, dev->manufacturer, sizeof(hid->name));
snprintf(hid->name, sizeof(hid->name), "usb-%s ", dev_name(&dev->dev));

if (dev->manufacturer) {
strlcat(hid->name, dev->manufacturer, sizeof(hid->name));
}

if (dev->product) {
if (dev->manufacturer)
strlcat(hid->name, " ", sizeof(hid->name));
strlcat(hid->name, dev->product, sizeof(hid->name));
}

if (!strlen(hid->name))
snprintf(hid->name, sizeof(hid->name), "HID %04x:%04x",
if (strlen(hid->name) == strlen(dev_name(&dev->dev)))
snprintf(hid->name, sizeof(hid->name), "usb-%s HID %04x:%04x",
dev_name(&dev->dev),
le16_to_cpu(dev->descriptor.idVendor),
le16_to_cpu(dev->descriptor.idProduct));

Expand Down

0 comments on commit aeebabd

Please sign in to comment.