[PATCH xf86-input-libinput 4/4] Support art pen rotation

Peter Hutterer peter.hutterer at who-t.net
Mon Feb 8 05:13:09 UTC 2016


The art pen is a normal pen, but it does provide a rotation axis.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/xf86libinput.c | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/src/xf86libinput.c b/src/xf86libinput.c
index d41826a..2f5e758 100644
--- a/src/xf86libinput.c
+++ b/src/xf86libinput.c
@@ -816,6 +816,12 @@ xf86libinput_init_tablet_pen_or_eraser(InputInfoPtr pInfo,
 					   min, max, res * 1000, 0, res * 1000, Absolute);
 	}
 
+	min = -TABLET_AXIS_MAX;
+	max = TABLET_AXIS_MAX;
+	if (libinput_tablet_tool_has_rotation(tool))
+		xf86InitValuatorAxisStruct(dev, axis++,
+					   XIGetKnownProperty(AXIS_LABEL_PROP_ABS_RZ),
+					   min, max, res * 1000, 0, res * 1000, Absolute);
 	return axis;
 }
 
@@ -1358,9 +1364,27 @@ xf86libinput_handle_tablet_axis(InputInfoPtr pInfo,
 	}
 
 	if (libinput_tablet_tool_has_rotation(tool)) {
+		int valuator;
+
 		value = libinput_event_tablet_tool_get_rotation(event);
 		value *= TABLET_AXIS_MAX;
-		valuator_mask_set_double(mask, 3, value);
+
+		switch (libinput_tablet_tool_get_type(tool)) {
+		case LIBINPUT_TABLET_TOOL_TYPE_PEN:
+		case LIBINPUT_TABLET_TOOL_TYPE_ERASER:
+			valuator = 5;
+			break;
+		case LIBINPUT_TABLET_TOOL_TYPE_MOUSE:
+		case LIBINPUT_TABLET_TOOL_TYPE_LENS:
+			valuator = 3;
+			break;
+		default:
+			xf86IDrvMsg(pInfo, X_ERROR,
+				    "Invalid rotation axis on tool\n");
+			break;
+		}
+
+		valuator_mask_set_double(mask, valuator, value);
 	}
 
 	xf86PostMotionEventM(dev, Absolute, mask);
-- 
2.5.0



More information about the xorg-devel mailing list