diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2019-06-13 09:48:28 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2019-06-13 11:02:42 +1000 |
commit | e439d740f0de43d72a90ca134bf9f3f83b74d50c (patch) | |
tree | f4a6d715e7bb8359816b2884231b38d7afbdb451 /tools/libinput-debug-gui.c | |
parent | 3a6d8c582ecf9aa473087fd94a317afe8a8684d7 (diff) | |
download | libinput-e439d740f0de43d72a90ca134bf9f3f83b74d50c.tar.gz |
tools: display tablet and tablet pad buttons when pressed
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'tools/libinput-debug-gui.c')
-rw-r--r-- | tools/libinput-debug-gui.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tools/libinput-debug-gui.c b/tools/libinput-debug-gui.c index 3a1c99f7..1fb90fc6 100644 --- a/tools/libinput-debug-gui.c +++ b/tools/libinput-debug-gui.c @@ -1189,6 +1189,8 @@ handle_event_tablet(struct libinput_event *ev, struct window *w) struct point point; int idx; const int mask = ARRAY_LENGTH(w->tool.deltas); + bool is_press; + unsigned int button; x = libinput_event_tablet_tool_get_x_transformed(t, w->width); y = libinput_event_tablet_tool_get_y_transformed(t, w->height); @@ -1248,6 +1250,38 @@ handle_event_tablet(struct libinput_event *ev, struct window *w) w->tool.ndeltas++; break; case LIBINPUT_EVENT_TABLET_TOOL_BUTTON: + is_press = libinput_event_tablet_tool_get_button_state(t) == LIBINPUT_BUTTON_STATE_PRESSED; + button = libinput_event_tablet_tool_get_button(t); + + w->buttons.other = is_press; + w->buttons.other_name = libevdev_event_code_get_name(EV_KEY, + button); + break; + default: + abort(); + } +} + +static void +handle_event_tablet_pad(struct libinput_event *ev, struct window *w) +{ + struct libinput_event_tablet_pad *p = libinput_event_get_tablet_pad_event(ev); + bool is_press; + unsigned int button; + static const char *pad_buttons[] = { + "Pad 0", "Pad 1", "Pad 2", "Pad 3", "Pad 4", "Pad 5", + "Pad 6", "Pad 7", "Pad 8", "Pad 9", "Pad >= 10" + }; + + switch (libinput_event_get_type(ev)) { + case LIBINPUT_EVENT_TABLET_PAD_BUTTON: + is_press = libinput_event_tablet_pad_get_button_state(p) == LIBINPUT_BUTTON_STATE_PRESSED; + button = libinput_event_tablet_pad_get_button_number(p); + w->buttons.other = is_press; + w->buttons.other_name = pad_buttons[min(button, 10)]; + break; + case LIBINPUT_EVENT_TABLET_PAD_RING: + case LIBINPUT_EVENT_TABLET_PAD_STRIP: break; default: abort(); @@ -1317,6 +1351,7 @@ handle_event_libinput(GIOChannel *source, GIOCondition condition, gpointer data) case LIBINPUT_EVENT_TABLET_PAD_BUTTON: case LIBINPUT_EVENT_TABLET_PAD_RING: case LIBINPUT_EVENT_TABLET_PAD_STRIP: + handle_event_tablet_pad(ev, w); break; case LIBINPUT_EVENT_SWITCH_TOGGLE: break; |