[PATCH xf86-input-libinput] Use the new unaccelerated valuator ValuatorMask features

Peter Hutterer peter.hutterer at who-t.net
Mon May 4 22:22:08 PDT 2015


SDL Games like openarena rely on relative input that's handled by the DGA code
in the server. That code casts the driver's input data to int and sends it to
the client. libinput does pointer acceleration for us, so sending any deltas
of less than 1 (likely for slow movements) ends up being 0.

Use the new ValuatorMask accelerated/unaccelerated values to pass the
unaccelerated values along, the server can then decide what to do with it.

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

diff --git a/src/libinput.c b/src/libinput.c
index c7ab18c..110af78 100644
--- a/src/libinput.c
+++ b/src/libinput.c
@@ -47,6 +47,12 @@
 #define XI86_SERVER_FD 0x20
 #endif
 
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) * 1000 + GET_ABI_MINOR(ABI_XINPUT_VERSION) > 22000
+#define HAVE_VMASK_UNACCEL 1
+#else
+#undef HAVE_VMASK_UNACCEL
+#endif
+
 #define TOUCHPAD_NUM_AXES 4 /* x, y, hscroll, vscroll */
 #define TOUCH_MAX_SLOTS 15
 #define XORG_KEYCODE_OFFSET 8
@@ -84,6 +90,7 @@ struct xf86libinput {
 	} scale;
 
 	ValuatorMask *valuators;
+	ValuatorMask *valuators_unaccelerated;
 
 	struct options {
 		BOOL tapping;
@@ -693,9 +700,21 @@ xf86libinput_handle_motion(InputInfoPtr pInfo, struct libinput_event_pointer *ev
 	y = libinput_event_pointer_get_dy(event);
 
 	valuator_mask_zero(mask);
+
+#if HAVE_VMASK_UNACCEL
+	{
+		double ux, uy;
+
+		ux = libinput_event_pointer_get_dx_unaccelerated(event);
+		uy = libinput_event_pointer_get_dy_unaccelerated(event);
+
+		valuator_mask_set_accelerated(mask, 0, x, ux);
+		valuator_mask_set_accelerated(mask, 1, y, uy);
+	}
+#else
 	valuator_mask_set_double(mask, 0, x);
 	valuator_mask_set_double(mask, 1, y);
-
+#endif
 	xf86PostMotionEventM(dev, Relative, mask);
 }
 
@@ -1349,6 +1368,10 @@ xf86libinput_pre_init(InputDriverPtr drv,
 	if (!driver_data->valuators)
 		goto fail;
 
+	driver_data->valuators_unaccelerated = valuator_mask_new(2);
+	if (!driver_data->valuators_unaccelerated)
+		goto fail;
+
 	driver_data->scroll_vdist = 15;
 	driver_data->scroll_hdist = 15;
 
@@ -1420,6 +1443,8 @@ fail:
 		fd_pop(&driver_context, pInfo->fd);
 	if (driver_data->valuators)
 		valuator_mask_free(&driver_data->valuators);
+	if (driver_data->valuators_unaccelerated)
+		valuator_mask_free(&driver_data->valuators_unaccelerated);
 	free(path);
 	free(driver_data);
 	return BadValue;
-- 
2.3.5



More information about the xorg-devel mailing list