Blame SOURCES/backport-wacom-tool-id-fixes.patch

9b746a
From 6d01e7277f8589a1f0076acbf9e08b45a5a96d0d Mon Sep 17 00:00:00 2001
9b746a
From: Peter Hutterer <peter.hutterer@who-t.net>
9b746a
Date: Thu, 13 Dec 2018 14:32:33 +1000
9b746a
Subject: [PATCH 1/2] wacom: Map wacom-driver-specific generic IDs to 0
9b746a
9b746a
The xf86-input-wacom driver doesn't use 0 for tools that do not have an id or
9b746a
serials. Serials default to 1, and the tool id is either 0x2 for stylus or 0xa
9b746a
for eraser, see xf86WacomDefs.h, the defines for STYLUS_DEVICE_ID and
9b746a
ERASER_DEVICE_ID.
9b746a
9b746a
libwacom uses 0xfffff and 0xffffe for the generic pens and all the lookup code
9b746a
we have in the panel is designed for a serial/tool id of 0. So let's just map
9b746a
the wacom driver IDs to 0 at the only transition point between Gdk and our
9b746a
panel.
9b746a
9b746a
No devices with serials 0 or hw ids 2/10 exist, so this shouldn't have side
9b746a
effects. This only affects X + xf86-input-wacom.
9b746a
---
9b746a
 panels/wacom/cc-wacom-panel.c | 17 +++++++++++++++++
9b746a
 1 file changed, 17 insertions(+)
9b746a
9b746a
diff --git a/panels/wacom/cc-wacom-panel.c b/panels/wacom/cc-wacom-panel.c
9b746a
index e4f3ca7..8748876 100644
9b746a
--- a/panels/wacom/cc-wacom-panel.c
9b746a
+++ b/panels/wacom/cc-wacom-panel.c
9b746a
@@ -354,6 +354,14 @@ update_current_tool (CcWacomPanel  *panel,
9b746a
 
9b746a
 	/* Check whether we already know this tool, nothing to do then */
9b746a
 	serial = gdk_device_tool_get_serial (tool);
9b746a
+
9b746a
+	/* The wacom driver sends serial-less tools with a serial of
9b746a
+	 * 1, libinput uses 0. No device exists with serial 1, let's reset
9b746a
+	 * it here so everything else works as expected.
9b746a
+	 */
9b746a
+	if (serial == 1)
9b746a
+		serial = 0;
9b746a
+
9b746a
 	stylus = cc_tablet_tool_map_lookup_tool (priv->tablet_tool_map,
9b746a
 						 wacom_device, serial);
9b746a
 
9b746a
@@ -361,6 +369,15 @@ update_current_tool (CcWacomPanel  *panel,
9b746a
 		gboolean added;
9b746a
 
9b746a
 		id = gdk_device_tool_get_hardware_id (tool);
9b746a
+
9b746a
+		/* The wacom driver sends a hw id of 0x2 for stylus and 0xa
9b746a
+		 * for eraser for devices that don't have a true HW id.
9b746a
+		 * Reset those to 0 so we can use the same code-paths
9b746a
+		 * libinput uses.
9b746a
+		 */
9b746a
+		if (id == 0x2 || id == 0xa)
9b746a
+			id = 0;
9b746a
+
9b746a
 		stylus = cc_wacom_tool_new (serial, id, wacom_device);
9b746a
 		if (!stylus)
9b746a
 			return;
9b746a
-- 
9b746a
2.24.1
9b746a
9b746a
9b746a
From 6974aaeb20a5146f95de9c40cd0b3b5967b317a6 Mon Sep 17 00:00:00 2001
9b746a
From: Peter Hutterer <peter.hutterer@who-t.net>
9b746a
Date: Fri, 14 Dec 2018 16:14:30 +1000
9b746a
Subject: [PATCH 2/2] wacom: ignore the wacom driver's touch tool type
9b746a
9b746a
When the wacom driver handles the touch device, we get a tool id of 0x3. Let's
9b746a
ignore that because we don't need a tool for the touch node.
9b746a
9b746a
Ideally we should be able to rely on the GDK tool type but that one is always
9b746a
GDK_DEVICE_TOOL_TYPE_UNKNOWN see
9b746a
https://gitlab.gnome.org/GNOME/gtk/merge_requests/453
9b746a
9b746a
A GTK bug (also fixed in that MR) prevents the tool id from updating.
9b746a
Until that GTK bug is fixed the pen will only be detected if it is the first
9b746a
event from this physical device. If the touch node sends an event before the
9b746a
pen, the pen won't be detected.
9b746a
---
9b746a
 panels/wacom/cc-wacom-panel.c | 5 +++++
9b746a
 1 file changed, 5 insertions(+)
9b746a
9b746a
diff --git a/panels/wacom/cc-wacom-panel.c b/panels/wacom/cc-wacom-panel.c
9b746a
index 8748876..985ddf5 100644
9b746a
--- a/panels/wacom/cc-wacom-panel.c
9b746a
+++ b/panels/wacom/cc-wacom-panel.c
9b746a
@@ -374,9 +374,14 @@ update_current_tool (CcWacomPanel  *panel,
9b746a
 		 * for eraser for devices that don't have a true HW id.
9b746a
 		 * Reset those to 0 so we can use the same code-paths
9b746a
 		 * libinput uses.
9b746a
+		 * The touch ID is 0x3, let's ignore that because we don't
9b746a
+		 * have a touch tool and it only happens when the wacom
9b746a
+		 * driver handles the touch device.
9b746a
 		 */
9b746a
 		if (id == 0x2 || id == 0xa)
9b746a
 			id = 0;
9b746a
+		else if (id == 0x3)
9b746a
+			return;
9b746a
 
9b746a
 		stylus = cc_wacom_tool_new (serial, id, wacom_device);
9b746a
 		if (!stylus)
9b746a
-- 
9b746a
2.24.1
9b746a