[PATCH libinput 07/15] tablet: factor out checking a device for axes
Peter Hutterer
peter.hutterer at who-t.net
Tue Feb 17 21:45:08 PST 2015
This gets more complicated for axes that aren't a 1:1 relationship with event
codes.
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
src/evdev-tablet.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c
index 9f55946..8b8573a 100644
--- a/src/evdev-tablet.c
+++ b/src/evdev-tablet.c
@@ -36,6 +36,18 @@
#define tablet_get_released_buttons(tablet_,field_) \
((tablet_)->prev_button_state.field_ & ~((tablet_)->button_state.field_))
+static int
+tablet_device_has_axis(struct tablet_dispatch *tablet,
+ enum libinput_tablet_axis axis)
+{
+ unsigned int code;
+
+ code = axis_to_evcode(axis);
+ return libevdev_has_event_code(tablet->device->evdev,
+ EV_ABS,
+ code);
+}
+
static void
tablet_process_absolute(struct tablet_dispatch *tablet,
struct evdev_device *device,
@@ -87,9 +99,7 @@ tablet_mark_all_axes_changed(struct tablet_dispatch *tablet,
enum libinput_tablet_axis a;
for (a = LIBINPUT_TABLET_AXIS_X; a <= LIBINPUT_TABLET_AXIS_MAX; a++) {
- if (libevdev_has_event_code(device->evdev,
- EV_ABS,
- axis_to_evcode(a)))
+ if (tablet_device_has_axis(tablet, a))
set_bit(tablet->changed_axes, a);
}
@@ -612,9 +622,7 @@ tablet_init(struct tablet_dispatch *tablet,
for (axis = LIBINPUT_TABLET_AXIS_X;
axis <= LIBINPUT_TABLET_AXIS_MAX;
axis++) {
- if (libevdev_has_event_code(device->evdev,
- EV_ABS,
- axis_to_evcode(axis)))
+ if (tablet_device_has_axis(tablet, axis))
set_bit(tablet->axis_caps, axis);
}
--
2.1.0
More information about the wayland-devel
mailing list