mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-05-09 07:08:01 +02:00
tablet: de-couple tool enum values from linux/input.h
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@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com> Reviewed-by: Stephen Chandler Paul <thatslyude@gmail.com>
This commit is contained in:
parent
585c30e01e
commit
5146bd00fd
2 changed files with 26 additions and 3 deletions
|
|
@ -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
|
static void
|
||||||
tablet_process_key(struct tablet_dispatch *tablet,
|
tablet_process_key(struct tablet_dispatch *tablet,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
|
|
@ -259,8 +280,10 @@ tablet_process_key(struct tablet_dispatch *tablet,
|
||||||
case BTN_TOOL_FINGER:
|
case BTN_TOOL_FINGER:
|
||||||
case BTN_TOOL_MOUSE:
|
case BTN_TOOL_MOUSE:
|
||||||
case BTN_TOOL_LENS:
|
case BTN_TOOL_LENS:
|
||||||
/* These codes have an equivalent libinput_tool value */
|
tablet_update_tool(tablet,
|
||||||
tablet_update_tool(tablet, device, e->code, e->value);
|
device,
|
||||||
|
tablet_evcode_to_tool(e->code),
|
||||||
|
e->value);
|
||||||
break;
|
break;
|
||||||
case BTN_TOUCH:
|
case BTN_TOUCH:
|
||||||
if (e->value)
|
if (e->value)
|
||||||
|
|
|
||||||
|
|
@ -159,7 +159,7 @@ struct libinput_tool;
|
||||||
* LIBINPUT_DEVICE_CAP_TABLET capability.
|
* LIBINPUT_DEVICE_CAP_TABLET capability.
|
||||||
*/
|
*/
|
||||||
enum libinput_tool_type {
|
enum libinput_tool_type {
|
||||||
LIBINPUT_TOOL_PEN = 0x140, /* Matches BTN_TOOL_PEN */
|
LIBINPUT_TOOL_PEN = 1,
|
||||||
LIBINPUT_TOOL_ERASER,
|
LIBINPUT_TOOL_ERASER,
|
||||||
LIBINPUT_TOOL_BRUSH,
|
LIBINPUT_TOOL_BRUSH,
|
||||||
LIBINPUT_TOOL_PENCIL,
|
LIBINPUT_TOOL_PENCIL,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue