From 1c3de35abb5b5b085a9cbcf84419b8bf112b8a2f Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 10 Feb 2015 11:29:34 +1000 Subject: [PATCH] tablet: drop LIBINPUT_TABLET_AXIS_NONE from the API This constant isn't used in the public API, let's drop it. To make it easier to use it internally and avoid accidental boolean comparisions with axes, bump all real axes up to start at 1. Internally that means we drop the AXIS_CNT since it'd be misleading and instead use MAX or MAX + 1 everywhere. Signed-off-by: Peter Hutterer Reviewed-by: Benjamin Tissoires --- src/evdev-tablet.c | 8 +++++--- src/evdev-tablet.h | 8 +++++--- src/libinput-private.h | 4 ++-- src/libinput.c | 4 ++-- src/libinput.h | 13 ++++++------- 5 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c index acab5a15..4a0d4b24 100644 --- a/src/evdev-tablet.c +++ b/src/evdev-tablet.c @@ -75,7 +75,7 @@ tablet_mark_all_axes_changed(struct tablet_dispatch *tablet, { enum libinput_tablet_axis a; - for (a = 0; a < LIBINPUT_TABLET_AXIS_CNT; 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))) @@ -151,7 +151,7 @@ tablet_check_notify_axes(struct tablet_dispatch *tablet, bool axis_update_needed = false; int a; - for (a = 0; a < LIBINPUT_TABLET_AXIS_CNT; a++) { + for (a = LIBINPUT_TABLET_AXIS_X; a <= LIBINPUT_TABLET_AXIS_MAX; a++) { const struct input_absinfo *absinfo; if (!bit_is_set(tablet->changed_axes, a)) @@ -596,7 +596,9 @@ tablet_init(struct tablet_dispatch *tablet, tablet->current_tool_type = LIBINPUT_TOOL_NONE; list_init(&tablet->tool_list); - for (axis = 0; axis < LIBINPUT_TABLET_AXIS_CNT; axis++) { + 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))) diff --git a/src/evdev-tablet.h b/src/evdev-tablet.h index cb375771..4f354171 100644 --- a/src/evdev-tablet.h +++ b/src/evdev-tablet.h @@ -27,6 +27,8 @@ #include "evdev.h" +#define LIBINPUT_TABLET_AXIS_NONE 0 + enum tablet_status { TABLET_NONE = 0, TABLET_AXES_UPDATED = 1 << 0, @@ -46,9 +48,9 @@ struct tablet_dispatch { struct evdev_dispatch base; struct evdev_device *device; unsigned char status; - unsigned char changed_axes[NCHARS(LIBINPUT_TABLET_AXIS_CNT)]; - double axes[LIBINPUT_TABLET_AXIS_CNT]; - unsigned char axis_caps[NCHARS(LIBINPUT_TABLET_AXIS_CNT)]; + unsigned char changed_axes[NCHARS(LIBINPUT_TABLET_AXIS_MAX + 1)]; + double axes[LIBINPUT_TABLET_AXIS_MAX + 1]; + unsigned char axis_caps[NCHARS(LIBINPUT_TABLET_AXIS_MAX + 1)]; /* Only used for tablets that don't report serial numbers */ struct list tool_list; diff --git a/src/libinput-private.h b/src/libinput-private.h index 33ce2db7..bc1e0c10 100644 --- a/src/libinput-private.h +++ b/src/libinput-private.h @@ -30,7 +30,7 @@ #include "libinput.h" #include "libinput-util.h" -#define LIBINPUT_TABLET_AXIS_CNT LIBINPUT_TABLET_AXIS_TILT_Y + 1 +#define LIBINPUT_TABLET_AXIS_MAX LIBINPUT_TABLET_AXIS_TILT_Y struct libinput_source; @@ -188,7 +188,7 @@ struct libinput_tool { struct list link; uint32_t serial; enum libinput_tool_type type; - unsigned char axis_caps[NCHARS(LIBINPUT_TABLET_AXIS_CNT)]; + unsigned char axis_caps[NCHARS(LIBINPUT_TABLET_AXIS_MAX + 1)]; int refcount; void *user_data; }; diff --git a/src/libinput.c b/src/libinput.c index aac6183d..b300d74e 100644 --- a/src/libinput.c +++ b/src/libinput.c @@ -85,8 +85,8 @@ struct libinput_event_tablet { enum libinput_button_state state; uint32_t seat_button_count; uint32_t time; - double axes[LIBINPUT_TABLET_AXIS_CNT]; - unsigned char changed_axes[NCHARS(LIBINPUT_TABLET_AXIS_CNT)]; + double axes[LIBINPUT_TABLET_AXIS_MAX + 1]; + unsigned char changed_axes[NCHARS(LIBINPUT_TABLET_AXIS_MAX + 1)]; struct libinput_tool *tool; enum libinput_tool_proximity_state proximity_state; }; diff --git a/src/libinput.h b/src/libinput.h index 197c09e5..402877a9 100644 --- a/src/libinput.h +++ b/src/libinput.h @@ -137,13 +137,12 @@ enum libinput_pointer_axis_source { * LIBINPUT_DEVICE_CAP_TABLET capability. */ enum libinput_tablet_axis { - LIBINPUT_TABLET_AXIS_NONE = -1, - LIBINPUT_TABLET_AXIS_X = 0, - LIBINPUT_TABLET_AXIS_Y = 1, - LIBINPUT_TABLET_AXIS_DISTANCE = 2, - LIBINPUT_TABLET_AXIS_PRESSURE = 3, - LIBINPUT_TABLET_AXIS_TILT_X = 4, - LIBINPUT_TABLET_AXIS_TILT_Y = 5, + LIBINPUT_TABLET_AXIS_X = 1, + LIBINPUT_TABLET_AXIS_Y = 2, + LIBINPUT_TABLET_AXIS_DISTANCE = 3, + LIBINPUT_TABLET_AXIS_PRESSURE = 4, + LIBINPUT_TABLET_AXIS_TILT_X = 5, + LIBINPUT_TABLET_AXIS_TILT_Y = 6, }; /**