Emulating devices is important for debugging when the hardware isn't
present. udev doesn't apply the same settings to emulated uinput devices as
it does to real devices, so we need to guess.

To allow some flexibility, use an UINPUT_ namespace and check that. Custom
udev rules may then set the UINPUT_SUBSYSTEM for an emulated device.

Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net>
---
 libwacom/libwacom.c |   32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/libwacom/libwacom.c b/libwacom/libwacom.c
index 103f942..93695cb 100644
--- a/libwacom/libwacom.c
+++ b/libwacom/libwacom.c
@@ -47,6 +47,34 @@ is_tablet_or_touchpad (GUdevDevice *device)
                g_udev_device_get_property_as_boolean (device, 
"ID_INPUT_TOUCHPAD");
 }
 
+/* Overriding SUBSYSTEM isn't allowed in udev (works sometimes, but not
+ * always). For evemu devices we need to set custom properties to make them
+ * detected by libwacom.
+ */
+static char *
+get_uinput_subsystem (GUdevDevice *device)
+{
+       const char *bus_str;
+       GUdevDevice *parent;
+
+
+       bus_str = NULL;
+       parent = g_object_ref (device);
+
+       while (parent && !g_udev_device_get_property_as_boolean (parent, 
"UINPUT_DEVICE")) {
+               GUdevDevice *old_parent = parent;
+               parent = g_udev_device_get_parent (old_parent);
+               g_object_unref (old_parent);
+       }
+
+       if (parent) {
+               bus_str = g_udev_device_get_property (parent, 
"UINPUT_SUBSYSTEM");
+               g_object_unref (parent);
+       }
+
+       return bus_str ? g_strdup (bus_str) : NULL;
+}
+
 static char *
 get_bus (GUdevDevice *device)
 {
@@ -54,6 +82,10 @@ get_bus (GUdevDevice *device)
        char *bus_str;
        GUdevDevice *parent;
 
+       bus_str = get_uinput_subsystem (device);
+       if (bus_str)
+               return bus_str;
+
        subsystem = g_udev_device_get_subsystem (device);
        parent = g_object_ref (device);
 
-- 
1.7.10.1


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

Reply via email to