Peter Hutterer 0af31b5
From d26b08b93f05eba58d46ad6811e71e9da0e74201 Mon Sep 17 00:00:00 2001
Peter Hutterer 0af31b5
From: Peter Hutterer <peter.hutterer@who-t.net>
Peter Hutterer 0af31b5
Date: Mon, 5 Feb 2018 09:11:42 +1000
Peter Hutterer 0af31b5
Subject: [PATCH libinput] tablet: don't set rotation on a tool if we don't
Peter Hutterer 0af31b5
 have ABS_Z
Peter Hutterer 0af31b5
Peter Hutterer 0af31b5
Rotation on a tool can either ABS_Z or in the case of the mouse/lens tools a
Peter Hutterer 0af31b5
combination of ABS_TILT_X/Y. The code assumes that if the rotation on a stylus
Peter Hutterer 0af31b5
(not mouse/lense) changes, we need to fetch it from ABS_Z. This happens on the
Peter Hutterer 0af31b5
very first event from the tablet, proximity in invalidates all axes so we can
Peter Hutterer 0af31b5
send the current state to the caller.
Peter Hutterer 0af31b5
Peter Hutterer 0af31b5
On libwacom-recognized tablets we never set the rotation bit on the stylus, so
Peter Hutterer 0af31b5
that's all fine. On tablets without libwacom support, the stylus may have a
Peter Hutterer 0af31b5
rotation bit copied because we have it set thanks to mouse+tilt on the tablet.
Peter Hutterer 0af31b5
When that first event is handled, we try to access ABS_Z. On tablets without
Peter Hutterer 0af31b5
ABS_Z like Aipteks, we go boom.
Peter Hutterer 0af31b5
Peter Hutterer 0af31b5
Fix this by checking for ABS_Z during tablet init, if we don't have that axis
Peter Hutterer 0af31b5
then never set the rotation bit on the tool. That's the only axis where we
Peter Hutterer 0af31b5
need this, all other axes have a single cause only and thus the tablet bits
Peter Hutterer 0af31b5
are accurate anyway.
Peter Hutterer 0af31b5
Peter Hutterer 0af31b5
https://bugs.freedesktop.org/show_bug.cgi?id=104939
Peter Hutterer 0af31b5
Peter Hutterer 0af31b5
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Peter Hutterer 0af31b5
---
Peter Hutterer 0af31b5
 src/evdev-tablet.c | 12 +++++++++++-
Peter Hutterer 0af31b5
 1 file changed, 11 insertions(+), 1 deletion(-)
Peter Hutterer 0af31b5
Peter Hutterer 0af31b5
diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c
Peter Hutterer 0af31b5
index 2f6b64da..771e7775 100644
Peter Hutterer 0af31b5
--- a/src/evdev-tablet.c
Peter Hutterer 0af31b5
+++ b/src/evdev-tablet.c
Peter Hutterer 0af31b5
@@ -933,7 +933,17 @@ tool_set_bits(const struct tablet_dispatch *tablet,
Peter Hutterer 0af31b5
 		copy_axis_cap(tablet, tool, LIBINPUT_TABLET_TOOL_AXIS_TILT_X);
Peter Hutterer 0af31b5
 		copy_axis_cap(tablet, tool, LIBINPUT_TABLET_TOOL_AXIS_TILT_Y);
Peter Hutterer 0af31b5
 		copy_axis_cap(tablet, tool, LIBINPUT_TABLET_TOOL_AXIS_SLIDER);
Peter Hutterer 0af31b5
-		copy_axis_cap(tablet, tool, LIBINPUT_TABLET_TOOL_AXIS_ROTATION_Z);
Peter Hutterer 0af31b5
+
Peter Hutterer 0af31b5
+		/* Rotation is special, it can be either ABS_Z or
Peter Hutterer 0af31b5
+		 * BTN_TOOL_MOUSE+ABS_TILT_X/Y. Aiptek tablets have
Peter Hutterer 0af31b5
+		 * mouse+tilt (and thus rotation), but they do not have
Peter Hutterer 0af31b5
+		 * ABS_Z. So let's not copy the axis bit if we don't have
Peter Hutterer 0af31b5
+		 * ABS_Z, otherwise we try to get the value from it later on
Peter Hutterer 0af31b5
+		 * proximity in and go boom because the absinfo isn't there.
Peter Hutterer 0af31b5
+		 */
Peter Hutterer 0af31b5
+		if (libevdev_has_event_code(tablet->device->evdev, EV_ABS,
Peter Hutterer 0af31b5
+					    ABS_Z))
Peter Hutterer 0af31b5
+			copy_axis_cap(tablet, tool, LIBINPUT_TABLET_TOOL_AXIS_ROTATION_Z);
Peter Hutterer 0af31b5
 		break;
Peter Hutterer 0af31b5
 	case LIBINPUT_TABLET_TOOL_TYPE_MOUSE:
Peter Hutterer 0af31b5
 	case LIBINPUT_TABLET_TOOL_TYPE_LENS:
Peter Hutterer 0af31b5
-- 
Peter Hutterer 0af31b5
2.14.3
Peter Hutterer 0af31b5