1 From 19c91044e44dd31deaeb638a919c64e9a9182448 Mon Sep 17 00:00:00 2001
2 From: Peter Hutterer <peter.hutterer@who-t.net>
3 Date: Tue, 5 May 2015 14:17:10 +1000
4 Subject: [PATCH xf86-input-libinput] Use the new unaccelerated valuator
7 SDL Games like openarena rely on relative input that's handled by the DGA code
8 in the server. That code casts the driver's input data to int and sends it to
9 the client. libinput does pointer acceleration for us, so sending any deltas
10 of less than 1 (likely for slow movements) ends up being 0.
12 Use the new ValuatorMask accelerated/unaccelerated values to pass the
13 unaccelerated values along, the server can then decide what to do with it.
15 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
16 Reviewed-by: Hans de Goede <hdegoede@redhat.com>
18 src/libinput.c | 27 ++++++++++++++++++++++++++-
19 1 file changed, 26 insertions(+), 1 deletion(-)
21 diff --git a/src/libinput.c b/src/libinput.c
22 index c8669fc..3cc4426 100644
26 #define XI86_SERVER_FD 0x20
29 +#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) * 1000 + GET_ABI_MINOR(ABI_XINPUT_VERSION) > 21000
30 +#define HAVE_VMASK_UNACCEL 1
32 +#undef HAVE_VMASK_UNACCEL
35 #define TOUCHPAD_NUM_AXES 4 /* x, y, hscroll, vscroll */
36 #define TOUCH_MAX_SLOTS 15
37 #define XORG_KEYCODE_OFFSET 8
38 @@ -88,6 +94,7 @@ struct xf86libinput {
41 ValuatorMask *valuators;
42 + ValuatorMask *valuators_unaccelerated;
46 @@ -700,9 +707,21 @@ xf86libinput_handle_motion(InputInfoPtr pInfo, struct libinput_event_pointer *ev
47 y = libinput_event_pointer_get_dy(event);
49 valuator_mask_zero(mask);
51 +#if HAVE_VMASK_UNACCEL
55 + ux = libinput_event_pointer_get_dx_unaccelerated(event);
56 + uy = libinput_event_pointer_get_dy_unaccelerated(event);
58 + valuator_mask_set_unaccelerated(mask, 0, x, ux);
59 + valuator_mask_set_unaccelerated(mask, 1, y, uy);
62 valuator_mask_set_double(mask, 0, x);
63 valuator_mask_set_double(mask, 1, y);
66 xf86PostMotionEventM(dev, Relative, mask);
69 @@ -1363,6 +1382,10 @@ xf86libinput_pre_init(InputDriverPtr drv,
70 if (!driver_data->valuators)
73 + driver_data->valuators_unaccelerated = valuator_mask_new(2);
74 + if (!driver_data->valuators_unaccelerated)
77 driver_data->scroll.vdist = 15;
78 driver_data->scroll.hdist = 15;
80 @@ -1434,6 +1457,8 @@ fail:
81 fd_pop(&driver_context, pInfo->fd);
82 if (driver_data->valuators)
83 valuator_mask_free(&driver_data->valuators);
84 + if (driver_data->valuators_unaccelerated)
85 + valuator_mask_free(&driver_data->valuators_unaccelerated);