The device and its parent have "input", but the grandparent has the actual subsystem this device is connected through.
Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net> --- libwacom/libwacom.c | 47 ++++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/libwacom/libwacom.c b/libwacom/libwacom.c index accb941..e05dbc0 100644 --- a/libwacom/libwacom.c +++ b/libwacom/libwacom.c @@ -47,6 +47,33 @@ is_tablet_or_touchpad (GUdevDevice *device) g_udev_device_get_property_as_boolean (device, "ID_INPUT_TOUCHPAD"); } +static const char * +get_bus (GUdevDevice *device) +{ + const char *subsystem; + const char *bus_str; + GUdevDevice *parent; + + subsystem = g_udev_device_get_subsystem (device); + parent = g_object_ref (device); + + while (parent && (g_strcmp0 (subsystem, "input")) == 0) { + GUdevDevice *old_parent = parent; + parent = g_udev_device_get_parent (parent); + subsystem = g_udev_device_get_subsystem (parent); + g_object_unref (old_parent); + } + + if (parent) + g_object_unref (parent); + + bus_str = subsystem; + if (g_strcmp0 (bus_str, "tty") == 0 || g_strcmp0 (bus_str, "serio") == 0) + bus_str = "serial"; + + return bus_str; +} + static gboolean get_device_info (const char *path, int *vendor_id, @@ -88,25 +115,7 @@ get_device_info (const char *path, g_object_unref (parent); } - /* FIXME: ID_BUS on the device is usb even for bluetooth devices, - * but ID_BUS on the parent is NULL. - */ - bus_str = g_udev_device_get_property (device, "ID_BUS"); - /* Serial devices are weird */ - if (bus_str == NULL) { - if (g_strcmp0 (g_udev_device_get_subsystem (device), "tty") == 0) - bus_str = "serial"; - } - /* Poke the parent device for Bluetooth models */ - if (bus_str == NULL) { - GUdevDevice *parent; - - parent = g_udev_device_get_parent (device); - - g_object_unref (device); - device = parent; - bus_str = "bluetooth"; - } + bus_str = get_bus (device); /* Is the device builtin? */ devname = g_udev_device_get_name (device); -- 1.7.10 ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Linuxwacom-devel mailing list Linuxwacom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel