From db4a4c5ed31fde4c65473c48f24d3db5ac252983 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 4 May 2012 12:22:23 +1000 Subject: lib: if we can't get vendor/product, try again on the parent This happens with uinput custom-labelled devices. Signed-off-by: Peter Hutterer --- libwacom/libwacom.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/libwacom/libwacom.c b/libwacom/libwacom.c index 123c045..482baa5 100644 --- a/libwacom/libwacom.c +++ b/libwacom/libwacom.c @@ -185,12 +185,27 @@ get_device_info (const char *path, *bus = bus_from_str (bus_str); if (*bus == WBUSTYPE_USB) { const char *vendor_str, *product_str; + GUdevDevice *parent; vendor_str = g_udev_device_get_property (device, "ID_VENDOR_ID"); product_str = g_udev_device_get_property (device, "ID_MODEL_ID"); + parent = NULL; + /* uinput devices have the props set on the parent, there is + * nothing a a udev rule can match on on the child */ + if (!vendor_str || !product_str) { + parent = g_udev_device_get_parent (device); + if (parent) { + vendor_str = g_udev_device_get_property (parent, "ID_VENDOR_ID"); + product_str = g_udev_device_get_property (parent, "ID_MODEL_ID"); + } + } + *vendor_id = strtol (vendor_str, NULL, 16); *product_id = strtol (product_str, NULL, 16); + + if (parent) + g_object_unref (parent); } else if (*bus == WBUSTYPE_BLUETOOTH || *bus == WBUSTYPE_SERIAL) { GUdevDevice *parent; const char *product_str; -- cgit v1.2.1