[PATCH libinput 04/14] evdev: move axis dimension handling into a single helper function
Peter Hutterer
peter.hutterer at who-t.net
Thu Jul 21 00:31:52 UTC 2016
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
src/evdev.c | 42 ++++++++++++++++++++++--------------------
1 file changed, 22 insertions(+), 20 deletions(-)
diff --git a/src/evdev.c b/src/evdev.c
index 0687de0..a7b77c8 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -2116,14 +2116,30 @@ evdev_reject_device(struct evdev_device *device)
return false;
}
-static bool
-evdev_configure_mt_device(struct evdev_device *device)
+static void
+evdev_extract_abs_axes(struct evdev_device *device)
{
struct libevdev *evdev = device->evdev;
- if (!libevdev_has_event_code(evdev, EV_ABS, ABS_MT_POSITION_X) ||
+ if (!libevdev_has_event_code(evdev, EV_ABS, ABS_X) ||
+ !libevdev_has_event_code(evdev, EV_ABS, ABS_Y))
+ return;
+
+ if (evdev_fix_abs_resolution(device, ABS_X, ABS_Y))
+ device->abs.fake_resolution = 1;
+ device->abs.absinfo_x = libevdev_get_abs_info(evdev, ABS_X);
+ device->abs.absinfo_y = libevdev_get_abs_info(evdev, ABS_Y);
+ device->abs.point.x = device->abs.absinfo_x->value;
+ device->abs.point.y = device->abs.absinfo_y->value;
+ device->abs.dimensions.x = abs(device->abs.absinfo_x->maximum -
+ device->abs.absinfo_x->minimum);
+ device->abs.dimensions.y = abs(device->abs.absinfo_y->maximum -
+ device->abs.absinfo_y->minimum);
+
+ if (evdev_is_fake_mt_device(device) ||
+ !libevdev_has_event_code(evdev, EV_ABS, ABS_MT_POSITION_X) ||
!libevdev_has_event_code(evdev, EV_ABS, ABS_MT_POSITION_Y))
- return true;
+ return;
if (evdev_fix_abs_resolution(device,
ABS_MT_POSITION_X,
@@ -2137,8 +2153,6 @@ evdev_configure_mt_device(struct evdev_device *device)
device->abs.dimensions.y = abs(device->abs.absinfo_y->maximum -
device->abs.absinfo_y->minimum);
device->is_mt = 1;
-
- return true;
}
static struct evdev_dispatch *
@@ -2201,22 +2215,10 @@ evdev_configure_device(struct evdev_device *device)
evdev_fix_android_mt(device);
if (libevdev_has_event_code(evdev, EV_ABS, ABS_X)) {
- if (evdev_fix_abs_resolution(device, ABS_X, ABS_Y))
- device->abs.fake_resolution = 1;
- device->abs.absinfo_x = libevdev_get_abs_info(evdev, ABS_X);
- device->abs.absinfo_y = libevdev_get_abs_info(evdev, ABS_Y);
- device->abs.point.x = device->abs.absinfo_x->value;
- device->abs.point.y = device->abs.absinfo_y->value;
- device->abs.dimensions.x = abs(device->abs.absinfo_x->maximum -
- device->abs.absinfo_x->minimum);
- device->abs.dimensions.y = abs(device->abs.absinfo_y->maximum -
- device->abs.absinfo_y->minimum);
+ evdev_extract_abs_axes(device);
- if (evdev_is_fake_mt_device(device)) {
+ if (evdev_is_fake_mt_device(device))
udev_tags &= ~EVDEV_UDEV_TAG_TOUCHSCREEN;
- } else if (!evdev_configure_mt_device(device)) {
- return NULL;
- }
}
/* libwacom assigns touchpad (or touchscreen) _and_ tablet to the
--
2.7.4
More information about the wayland-devel
mailing list