udev: prepend the libinput group with the product string

Multiple devices plugged into the same USB hub have the same
PHYS path and are assigned to the same group.

Prepend the content of the PRODUCT env to the phys path, this at least ensures
that different devices are never grouped together.

https://bugs.freedesktop.org/show_bug.cgi?id=89802

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
Peter Hutterer 2015-04-09 16:08:14 +10:00
parent f3d6fdae84
commit b1fc392268

View file

@ -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: