[PATCH xf86-input-libinput 3/4] Support the mouse/lens tool

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


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

diff --git a/src/xf86libinput.c b/src/xf86libinput.c
index 477ec5c..d41826a 100644
--- a/src/xf86libinput.c
+++ b/src/xf86libinput.c
@@ -849,6 +849,39 @@ xf86libinput_init_tablet_airbrush(InputInfoPtr pInfo,
 }
 
 static void
+xf86libinput_init_tablet_mouse(InputInfoPtr pInfo,
+			       struct libinput_tablet_tool *tool)
+{
+	DeviceIntPtr dev = pInfo->dev;
+	int min, max, res;
+	int axis;
+
+	if (!libinput_tablet_tool_has_rotation(tool)) {
+		xf86IDrvMsg(pInfo, X_ERROR, "Mouse tool is missing the rotation axis\n");
+		return;
+	}
+
+	min = 0;
+	max = TABLET_AXIS_MAX;
+	res = 0;
+
+	/* The mouse/lens tool don't have pressure, but for backwards-compat
+	   with the xorg wacom driver we initialize the the axis anyway */
+	axis = 2;
+	xf86InitValuatorAxisStruct(dev, axis,
+				   XIGetKnownProperty(AXIS_LABEL_PROP_ABS_PRESSURE),
+				   min, max, res * 1000, 0, res * 1000, Absolute);
+
+	axis = 3;
+	min = -TABLET_AXIS_MAX;
+	max = TABLET_AXIS_MAX;
+	xf86InitValuatorAxisStruct(dev, axis,
+				   XIGetKnownProperty(AXIS_LABEL_PROP_ABS_RZ),
+				   min, max, res * 1000, 0, res * 1000, Absolute);
+	return;
+}
+
+static void
 xf86libinput_init_tablet(InputInfoPtr pInfo)
 {
 	DeviceIntPtr dev = pInfo->dev;
@@ -873,6 +906,8 @@ xf86libinput_init_tablet(InputInfoPtr pInfo)
 		naxes += 2;
 	if (libinput_tablet_tool_has_slider(tool))
 		naxes++;
+	if (libinput_tablet_tool_has_rotation(tool))
+		naxes++;
 
 	InitPointerDeviceStruct((DevicePtr)dev,
 				driver_data->options.btnmap,
@@ -901,6 +936,10 @@ xf86libinput_init_tablet(InputInfoPtr pInfo)
 	case LIBINPUT_TABLET_TOOL_TYPE_AIRBRUSH:
 		xf86libinput_init_tablet_airbrush(pInfo, tool);
 		break;
+	case LIBINPUT_TABLET_TOOL_TYPE_MOUSE:
+	case LIBINPUT_TABLET_TOOL_TYPE_LENS:
+		xf86libinput_init_tablet_mouse(pInfo, tool);
+		break;
 	default:
 		xf86IDrvMsg(pInfo, X_ERROR, "Tool type not supported yet\n");
 		break;
@@ -1318,6 +1357,12 @@ xf86libinput_handle_tablet_axis(InputInfoPtr pInfo,
 		valuator_mask_set_double(mask, 5, value);
 	}
 
+	if (libinput_tablet_tool_has_rotation(tool)) {
+		value = libinput_event_tablet_tool_get_rotation(event);
+		value *= TABLET_AXIS_MAX;
+		valuator_mask_set_double(mask, 3, value);
+	}
+
 	xf86PostMotionEventM(dev, Absolute, mask);
 }
 
-- 
2.5.0



More information about the xorg-devel mailing list