linux: up-enumerator-udev: Find the correct parent id for input devices

The parent id for the devices under "/sys/devices/virtual/misc/uhid/*"
points to /sys/devices/virtual/misc/uhid. It will cause the device
information to be updated incorrectly. For example, the type for a mouse is
updated to "keyboard". This patch makes sure the correct parent id for
each input device.

Resolves: #268 #286
This commit is contained in:
Kate Hsuan 2024-06-18 15:04:29 +08:00
parent 9ee76826bd
commit 7d7bb84fde

View file

@ -66,8 +66,17 @@ device_parent_id (GUdevDevice *dev)
return NULL;
/* Continue walk if the parent is a "hid" device */
if (g_strcmp0 (subsystem, "hid") == 0)
if (g_strcmp0 (subsystem, "hid") == 0) {
/* if the parent is under /sys/devices/virtual/misc/uhid, the device should be input devices
* and return the path immediately to make sure they belongs to the correct parent.
* for example:
* root@fedora:/sys/devices/virtual/misc/uhid# ls
* 0005:046D:B01A.0005 0005:05AC:0250.000B dev power subsystem uevent */
if (g_strrstr (g_udev_device_get_sysfs_path (parent), "/sys/devices/virtual/misc/uhid"))
return g_strdup (g_udev_device_get_sysfs_path (parent));
return device_parent_id (parent);
}
/* Also skip over USB interfaces, we care about full devices */
if (g_strcmp0 (subsystem, "usb") == 0 &&