From 060d4470d0a4f6c0c18170fc2c961082eb79c34b Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 9 Apr 2015 16:08:14 +1000 Subject: [PATCH libinput] udev: prepend the libinput group with the product string Multiple tablets plugged into the same USB hub have the same PHYS path and are assigned to the same group. Specifically on the Cintiq 24HDT, the tablet is on its own USB hub and all devices plugged into the external ports are on that hub too. Prepend the content of the PRODUCT env to the phys path, this at least ensures that different devices are never grouped together. A real solution to differ between identical devices on the same physical path is likely more complicated but since this is a niche case anyway the best solution is likely to write custom udev rules for such a setup. https://bugs.freedesktop.org/show_bug.cgi?id=89802 Signed-off-by: Peter Hutterer --- udev/libinput-device-group.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/udev/libinput-device-group.c b/udev/libinput-device-group.c index 50bfbe0..adbd6b7 100644 --- a/udev/libinput-device-group.c +++ b/udev/libinput-device-group.c @@ -10,8 +10,9 @@ int main(int argc, char **argv) struct udev_device *device = NULL; const char *syspath, *phys = NULL; - char *group, - *str; + const char *product; + char group[1024]; + char *str; if (argc != 2) return 1; @@ -45,9 +46,12 @@ int main(int argc, char **argv) if (!phys) goto out; - group = strdup(phys); - if (!group) - goto out; + /* udev sets PRODUCT on the same device we find PHYS on, let's rely + on that*/ + product = udev_device_get_property_value(device, "PRODUCT"); + if (!product) + product = ""; + snprintf(group, sizeof(group), "%s:%s", product, phys); str = strstr(group, "/input"); if (str) @@ -64,7 +68,6 @@ int main(int argc, char **argv) *str = '\0'; printf("%s\n", group); - free(group); rc = 0; out: -- 2.3.4