[PATCH libinput 07/26] tablet: de-couple tool enum values from linux/input.h
Peter Hutterer
peter.hutterer at who-t.net
Mon Feb 23 22:21:10 PST 2015
There's no real reason to keep them in sync but it has drawbacks when we start
introducing tools that the kernel doesn't have (and can't easily add due to
range constraints).
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
src/evdev-tablet.c | 27 +++++++++++++++++++++++++--
src/libinput.h | 2 +-
2 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c
index e994de4..013038b 100644
--- a/src/evdev-tablet.c
+++ b/src/evdev-tablet.c
@@ -244,6 +244,27 @@ tablet_update_button(struct tablet_dispatch *tablet,
}
}
+static inline enum libinput_tool_type
+tablet_evcode_to_tool(int code)
+{
+ enum libinput_tool_type type;
+
+ switch (code) {
+ case BTN_TOOL_PEN: type = LIBINPUT_TOOL_PEN; break;
+ case BTN_TOOL_RUBBER: type = LIBINPUT_TOOL_ERASER; break;
+ case BTN_TOOL_BRUSH: type = LIBINPUT_TOOL_BRUSH; break;
+ case BTN_TOOL_PENCIL: type = LIBINPUT_TOOL_PENCIL; break;
+ case BTN_TOOL_AIRBRUSH: type = LIBINPUT_TOOL_AIRBRUSH; break;
+ case BTN_TOOL_FINGER: type = LIBINPUT_TOOL_FINGER; break;
+ case BTN_TOOL_MOUSE: type = LIBINPUT_TOOL_MOUSE; break;
+ case BTN_TOOL_LENS: type = LIBINPUT_TOOL_LENS; break;
+ default:
+ abort();
+ }
+
+ return type;
+}
+
static void
tablet_process_key(struct tablet_dispatch *tablet,
struct evdev_device *device,
@@ -259,8 +280,10 @@ tablet_process_key(struct tablet_dispatch *tablet,
case BTN_TOOL_FINGER:
case BTN_TOOL_MOUSE:
case BTN_TOOL_LENS:
- /* These codes have an equivalent libinput_tool value */
- tablet_update_tool(tablet, device, e->code, e->value);
+ tablet_update_tool(tablet,
+ device,
+ tablet_evcode_to_tool(e->code),
+ e->value);
break;
case BTN_TOUCH:
if (e->value)
diff --git a/src/libinput.h b/src/libinput.h
index 41ecb83..f5c4e9f 100644
--- a/src/libinput.h
+++ b/src/libinput.h
@@ -159,7 +159,7 @@ struct libinput_tool;
* LIBINPUT_DEVICE_CAP_TABLET capability.
*/
enum libinput_tool_type {
- LIBINPUT_TOOL_PEN = 0x140, /* Matches BTN_TOOL_PEN */
+ LIBINPUT_TOOL_PEN = 1,
LIBINPUT_TOOL_ERASER,
LIBINPUT_TOOL_BRUSH,
LIBINPUT_TOOL_PENCIL,
--
2.1.0
More information about the wayland-devel
mailing list