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

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