diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2012-05-04 12:22:23 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2012-05-18 08:57:48 +1000 |
commit | db4a4c5ed31fde4c65473c48f24d3db5ac252983 (patch) | |
tree | c3d4e71d4d5474fc77497c72887b7f8df1be4187 | |
parent | 6f78863659fa6828aceec6323bf030306954661a (diff) | |
download | libwacom-db4a4c5ed31fde4c65473c48f24d3db5ac252983.tar.gz |
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 <peter.hutterer@who-t.net>
-rw-r--r-- | libwacom/libwacom.c | 15 |
1 files changed, 15 insertions, 0 deletions
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; |