[gnome-control-center] wacom: Map wacom-driver-specific generic IDs to 0



commit d925ea3c6c260423a70412863cb6ee806e3cf815
Author: Peter Hutterer <peter hutterer who-t net>
Date:   Thu Dec 13 14:32:33 2018 +1000

    wacom: Map wacom-driver-specific generic IDs to 0
    
    The xf86-input-wacom driver doesn't use 0 for tools that do not have an id or
    serials. Serials default to 1, and the tool id is either 0x2 for stylus or 0xa
    for eraser, see xf86WacomDefs.h, the defines for STYLUS_DEVICE_ID and
    ERASER_DEVICE_ID.
    
    libwacom uses 0xfffff and 0xffffe for the generic pens and all the lookup code
    we have in the panel is designed for a serial/tool id of 0. So let's just map
    the wacom driver IDs to 0 at the only transition point between Gdk and our
    panel.
    
    No devices with serials 0 or hw ids 2/10 exist, so this shouldn't have side
    effects. This only affects X + xf86-input-wacom.

 panels/wacom/cc-wacom-panel.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
---
diff --git a/panels/wacom/cc-wacom-panel.c b/panels/wacom/cc-wacom-panel.c
index 0cb2f424e..51662c4dc 100644
--- a/panels/wacom/cc-wacom-panel.c
+++ b/panels/wacom/cc-wacom-panel.c
@@ -363,6 +363,14 @@ update_current_tool (CcWacomPanel  *panel,
 
        /* Check whether we already know this tool, nothing to do then */
        serial = gdk_device_tool_get_serial (tool);
+
+       /* The wacom driver sends serial-less tools with a serial of
+        * 1, libinput uses 0. No device exists with serial 1, let's reset
+        * it here so everything else works as expected.
+        */
+       if (serial == 1)
+               serial = 0;
+
        stylus = cc_tablet_tool_map_lookup_tool (panel->tablet_tool_map,
                                                 wacom_device, serial);
 
@@ -370,6 +378,15 @@ update_current_tool (CcWacomPanel  *panel,
                gboolean added;
 
                id = gdk_device_tool_get_hardware_id (tool);
+
+               /* The wacom driver sends a hw id of 0x2 for stylus and 0xa
+                * for eraser for devices that don't have a true HW id.
+                * Reset those to 0 so we can use the same code-paths
+                * libinput uses.
+                */
+               if (id == 0x2 || id == 0xa)
+                       id = 0;
+
                stylus = cc_wacom_tool_new (serial, id, wacom_device);
                if (!stylus)
                        return;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]