summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2019-01-17 11:08:27 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2019-12-04 15:38:39 +1000
commit2d1bcf982ab6b26180c4a45e04f244592f4a7832 (patch)
treee2dfed37cba242d9845caa844e7e58f78c88ce4e
parent27fda918d8a3aeb46e3884bffcf8b406ce496f07 (diff)
downloadlibinput-2d1bcf982ab6b26180c4a45e04f244592f4a7832.tar.gz
pad: add LIBINPUT_EVENT_TABLET_PAD_KEY for pad keys
The Wacom Cintiq 24HD and later tablets send specific key events for hardware/soft buttons. KEY_PROG1..KEY_PROG3 on earlier tablets, KEY_CONTROLPANEL, KEY_ONSCREEN_DISPLAY, and KEY_BUTTONCONFIG on later tablets. We ignore KEY_PROG1-3 because starting with kernel 5.4 older tablets will too use the better-named #defines. These differ from pad buttons as the key code in itself carries semantic information, so we should pass them on as-is instead of mapping them to meaningless 0-indexed buttons like we do on the other buttons. So let's add a new event, LIBINPUT_EVENT_TABLET_PAD_KEY and the associated functions to handle that case. Pad keys have a fixed hw-defined semantic meaning and are thus not part of a tablet mode group. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--src/evdev-tablet-pad.c34
-rw-r--r--src/evdev.h4
-rw-r--r--src/libinput-private.h5
-rw-r--r--src/libinput.c72
-rw-r--r--src/libinput.h81
-rw-r--r--src/libinput.sym3
-rw-r--r--test/litest.c39
-rw-r--r--test/litest.h8
-rw-r--r--test/test-pad.c68
-rw-r--r--tools/libinput-debug-events.c32
-rw-r--r--tools/libinput-debug-gui.c2
11 files changed, 343 insertions, 5 deletions
diff --git a/src/evdev-tablet-pad.c b/src/evdev-tablet-pad.c
index 431972ae..97fc9717 100644
--- a/src/evdev-tablet-pad.c
+++ b/src/evdev-tablet-pad.c
@@ -392,6 +392,10 @@ pad_notify_button_mask(struct pad_dispatch *pad,
button,
state,
group);
+ } else if (map_is_key(map)) {
+ uint32_t key = map_value(map);
+
+ tablet_pad_notify_key(base, time, key, state);
} else {
abort();
}
@@ -612,6 +616,26 @@ pad_init_buttons_from_kernel(struct pad_dispatch *pad,
}
static void
+pad_init_keys(struct pad_dispatch *pad, struct evdev_device *device)
+{
+ unsigned int codes[] = {
+ KEY_BUTTONCONFIG,
+ KEY_ONSCREEN_KEYBOARD,
+ KEY_CONTROLPANEL,
+ };
+ unsigned int *code;
+
+ /* Wacom's keys are the only ones we know anything about */
+ if (libevdev_get_id_vendor(device->evdev) != VENDOR_ID_WACOM)
+ return;
+
+ ARRAY_FOR_EACH(codes, code) {
+ if (libevdev_has_event_code(device->evdev, EV_KEY, *code))
+ map_set_key_map(pad->button_map[*code], *code);
+ }
+}
+
+static void
pad_init_buttons(struct pad_dispatch *pad,
struct evdev_device *device)
{
@@ -623,6 +647,7 @@ pad_init_buttons(struct pad_dispatch *pad,
if (!pad_init_buttons_from_libwacom(pad, device))
pad_init_buttons_from_kernel(pad, device);
+ pad_init_keys(pad, device);
}
static void
@@ -719,6 +744,15 @@ evdev_tablet_pad_create(struct evdev_device *device)
}
int
+evdev_device_tablet_pad_has_key(struct evdev_device *device, uint32_t code)
+{
+ if (!(device->seat_caps & EVDEV_DEVICE_TABLET_PAD))
+ return -1;
+
+ return libevdev_has_event_code(device->evdev, EV_KEY, code);
+}
+
+int
evdev_device_tablet_pad_get_num_buttons(struct evdev_device *device)
{
struct pad_dispatch *pad = (struct pad_dispatch*)device->dispatch;
diff --git a/src/evdev.h b/src/evdev.h
index 0af0ba36..e95f7e60 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -511,6 +511,10 @@ evdev_device_has_switch(struct evdev_device *device,
enum libinput_switch sw);
int
+evdev_device_tablet_pad_has_key(struct evdev_device *device,
+ uint32_t code);
+
+int
evdev_device_tablet_pad_get_num_buttons(struct evdev_device *device);
int
diff --git a/src/libinput-private.h b/src/libinput-private.h
index 1a7900fd..cb3a4017 100644
--- a/src/libinput-private.h
+++ b/src/libinput-private.h
@@ -683,6 +683,11 @@ tablet_pad_notify_strip(struct libinput_device *device,
enum libinput_tablet_pad_strip_axis_source source,
struct libinput_tablet_pad_mode_group *group);
void
+tablet_pad_notify_key(struct libinput_device *device,
+ uint64_t time,
+ int32_t key,
+ enum libinput_key_state state);
+void
switch_notify_toggle(struct libinput_device *device,
uint64_t time,
enum libinput_switch sw,
diff --git a/src/libinput.c b/src/libinput.c
index 9570dc68..e764375b 100644
--- a/src/libinput.c
+++ b/src/libinput.c
@@ -130,6 +130,7 @@ event_type_to_str(enum libinput_event_type type)
CASE_RETURN_STRING(LIBINPUT_EVENT_TABLET_PAD_BUTTON);
CASE_RETURN_STRING(LIBINPUT_EVENT_TABLET_PAD_RING);
CASE_RETURN_STRING(LIBINPUT_EVENT_TABLET_PAD_STRIP);
+ CASE_RETURN_STRING(LIBINPUT_EVENT_TABLET_PAD_KEY);
CASE_RETURN_STRING(LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN);
CASE_RETURN_STRING(LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE);
CASE_RETURN_STRING(LIBINPUT_EVENT_GESTURE_SWIPE_END);
@@ -219,6 +220,10 @@ struct libinput_event_tablet_pad {
enum libinput_button_state state;
} button;
struct {
+ uint32_t code;
+ enum libinput_key_state state;
+ } key;
+ struct {
enum libinput_tablet_pad_ring_axis_source source;
double position;
int number;
@@ -425,7 +430,8 @@ libinput_event_get_tablet_pad_event(struct libinput_event *event)
NULL,
LIBINPUT_EVENT_TABLET_PAD_RING,
LIBINPUT_EVENT_TABLET_PAD_STRIP,
- LIBINPUT_EVENT_TABLET_PAD_BUTTON);
+ LIBINPUT_EVENT_TABLET_PAD_BUTTON,
+ LIBINPUT_EVENT_TABLET_PAD_KEY);
return (struct libinput_event_tablet_pad *) event;
}
@@ -1914,7 +1920,8 @@ libinput_event_tablet_tool_destroy(struct libinput_event_tablet_tool *event)
static void
libinput_event_tablet_pad_destroy(struct libinput_event_tablet_pad *event)
{
- libinput_tablet_pad_mode_group_unref(event->mode_group);
+ if (event->base.type != LIBINPUT_EVENT_TABLET_PAD_KEY)
+ libinput_tablet_pad_mode_group_unref(event->mode_group);
}
LIBINPUT_EXPORT void
@@ -1934,6 +1941,7 @@ libinput_event_destroy(struct libinput_event *event)
case LIBINPUT_EVENT_TABLET_PAD_RING:
case LIBINPUT_EVENT_TABLET_PAD_STRIP:
case LIBINPUT_EVENT_TABLET_PAD_BUTTON:
+ case LIBINPUT_EVENT_TABLET_PAD_KEY:
libinput_event_tablet_pad_destroy(
libinput_event_get_tablet_pad_event(event));
break;
@@ -2767,6 +2775,28 @@ tablet_pad_notify_strip(struct libinput_device *device,
&strip_event->base);
}
+void
+tablet_pad_notify_key(struct libinput_device *device,
+ uint64_t time,
+ int32_t key,
+ enum libinput_key_state state)
+{
+ struct libinput_event_tablet_pad *key_event;
+
+ key_event = zalloc(sizeof *key_event);
+
+ *key_event = (struct libinput_event_tablet_pad) {
+ .time = time,
+ .key.code = key,
+ .key.state = state,
+ };
+
+ post_device_event(device,
+ time,
+ LIBINPUT_EVENT_TABLET_PAD_KEY,
+ &key_event->base);
+}
+
static void
gesture_notify(struct libinput_device *device,
uint64_t time,
@@ -3116,6 +3146,13 @@ libinput_device_switch_has_switch(struct libinput_device *device,
}
LIBINPUT_EXPORT int
+libinput_device_tablet_pad_has_key(struct libinput_device *device, uint32_t code)
+{
+ return evdev_device_tablet_pad_has_key((struct evdev_device *)device,
+ code);
+}
+
+LIBINPUT_EXPORT int
libinput_device_tablet_pad_get_num_buttons(struct libinput_device *device)
{
return evdev_device_tablet_pad_get_num_buttons((struct evdev_device *)device);
@@ -3418,6 +3455,28 @@ libinput_event_tablet_pad_get_button_state(struct libinput_event_tablet_pad *eve
return event->button.state;
}
+LIBINPUT_EXPORT uint32_t
+libinput_event_tablet_pad_get_key(struct libinput_event_tablet_pad *event)
+{
+ require_event_type(libinput_event_get_context(&event->base),
+ event->base.type,
+ 0,
+ LIBINPUT_EVENT_TABLET_PAD_KEY);
+
+ return event->key.code;
+}
+
+LIBINPUT_EXPORT enum libinput_key_state
+libinput_event_tablet_pad_get_key_state(struct libinput_event_tablet_pad *event)
+{
+ require_event_type(libinput_event_get_context(&event->base),
+ event->base.type,
+ LIBINPUT_KEY_STATE_RELEASED,
+ LIBINPUT_EVENT_TABLET_PAD_KEY);
+
+ return event->key.state;
+}
+
LIBINPUT_EXPORT unsigned int
libinput_event_tablet_pad_get_mode(struct libinput_event_tablet_pad *event)
{
@@ -3452,7 +3511,8 @@ libinput_event_tablet_pad_get_time(struct libinput_event_tablet_pad *event)
0,
LIBINPUT_EVENT_TABLET_PAD_RING,
LIBINPUT_EVENT_TABLET_PAD_STRIP,
- LIBINPUT_EVENT_TABLET_PAD_BUTTON);
+ LIBINPUT_EVENT_TABLET_PAD_BUTTON,
+ LIBINPUT_EVENT_TABLET_PAD_KEY);
return us2ms(event->time);
}
@@ -3465,7 +3525,8 @@ libinput_event_tablet_pad_get_time_usec(struct libinput_event_tablet_pad *event)
0,
LIBINPUT_EVENT_TABLET_PAD_RING,
LIBINPUT_EVENT_TABLET_PAD_STRIP,
- LIBINPUT_EVENT_TABLET_PAD_BUTTON);
+ LIBINPUT_EVENT_TABLET_PAD_BUTTON,
+ LIBINPUT_EVENT_TABLET_PAD_KEY);
return event->time;
}
@@ -3478,7 +3539,8 @@ libinput_event_tablet_pad_get_base_event(struct libinput_event_tablet_pad *event
NULL,
LIBINPUT_EVENT_TABLET_PAD_RING,
LIBINPUT_EVENT_TABLET_PAD_STRIP,
- LIBINPUT_EVENT_TABLET_PAD_BUTTON);
+ LIBINPUT_EVENT_TABLET_PAD_BUTTON,
+ LIBINPUT_EVENT_TABLET_PAD_KEY);
return &event->base;
}
diff --git a/src/libinput.h b/src/libinput.h
index 54d40de6..5a19f79d 100644
--- a/src/libinput.h
+++ b/src/libinput.h
@@ -845,6 +845,12 @@ enum libinput_event_type {
* A button pressed on a device with the @ref
* LIBINPUT_DEVICE_CAP_TABLET_PAD capability.
*
+ * A button differs from @ref LIBINPUT_EVENT_TABLET_PAD_KEY in that
+ * buttons are sequentially indexed from 0 and do not carry any
+ * other information. Keys have a specific functionality assigned
+ * to them. The key code thus carries a semantic meaning, a button
+ * number does not.
+ *
* This event is not to be confused with the button events emitted
* by tools on a tablet (@ref LIBINPUT_EVENT_TABLET_TOOL_BUTTON).
*
@@ -867,6 +873,19 @@ enum libinput_event_type {
*/
LIBINPUT_EVENT_TABLET_PAD_STRIP,
+ /**
+ * A key pressed on a device with the @ref
+ * LIBINPUT_DEVICE_CAP_TABLET_PAD capability.
+ *
+ * A key differs from @ref LIBINPUT_EVENT_TABLET_PAD_BUTTON in that
+ * keys have a specific functionality assigned to them (buttons are
+ * sequentially ordered). The key code thus carries a semantic
+ * meaning, a button number does not.
+ *
+ * @since 1.15
+ */
+ LIBINPUT_EVENT_TABLET_PAD_KEY,
+
LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN = 800,
LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE,
LIBINPUT_EVENT_GESTURE_SWIPE_END,
@@ -3065,6 +3084,44 @@ libinput_event_tablet_pad_get_button_state(struct libinput_event_tablet_pad *eve
/**
* @ingroup event_tablet_pad
*
+ * Return the key code that triggered this event, e.g. KEY_CONTROLPANEL. The
+ * list of key codes is defined in linux/input-event-codes.h.
+ *
+ * For events that are not of type @ref LIBINPUT_EVENT_TABLET_PAD_KEY,
+ * this function returns 0.
+ *
+ * @note It is an application bug to call this function for events other than
+ * @ref LIBINPUT_EVENT_TABLET_PAD_KEY. For other events, this function
+ * returns 0.
+ *
+ * @param event The libinput tablet pad event
+ * @return the key code triggering this event
+ *
+ * @since 1.15
+ */
+uint32_t
+libinput_event_tablet_pad_get_key(struct libinput_event_tablet_pad *event);
+
+/**
+ * @ingroup event_tablet_pad
+ *
+ * Return the key state of the event.
+ *
+ * @note It is an application bug to call this function for events other than
+ * @ref LIBINPUT_EVENT_TABLET_PAD_KEY. For other events, this function
+ * returns 0.
+ *
+ * @param event The libinput tablet pad event
+ * @return the key state triggering this event
+ *
+ * @since 1.15
+ */
+enum libinput_key_state
+libinput_event_tablet_pad_get_key_state(struct libinput_event_tablet_pad *event);
+
+/**
+ * @ingroup event_tablet_pad
+ *
* Returns the mode the button, ring, or strip that triggered this event is
* in, at the time of the event.
*
@@ -3072,6 +3129,9 @@ libinput_event_tablet_pad_get_button_state(struct libinput_event_tablet_pad *eve
* visual feedback like LEDs on the pad. Mode indices start at 0, a device
* that does not support modes always returns 0.
*
+ * @note Pad keys are not part of a mode group. It is an application bug to
+ * call this function for @ref LIBINPUT_EVENT_TABLET_PAD_KEY.
+ *
* Mode switching is controlled by libinput and more than one mode may exist
* on the tablet. This function returns the mode that this event's button,
* ring or strip is logically in. If the button is a mode toggle button
@@ -3102,6 +3162,9 @@ libinput_event_tablet_pad_get_mode(struct libinput_event_tablet_pad *event);
* functionality, usually based on some visual feedback like LEDs on the
* pad.
*
+ * @note Pad keys are not part of a mode group. It is an application bug to
+ * call this function for @ref LIBINPUT_EVENT_TABLET_PAD_KEY.
+ *
* The returned mode group is not refcounted and may become invalid after
* the next call to libinput. Use libinput_tablet_pad_mode_group_ref() and
* libinput_tablet_pad_mode_group_unref() to continue using the handle
@@ -4156,6 +4219,24 @@ libinput_device_tablet_pad_get_num_strips(struct libinput_device *device);
/**
* @ingroup device
*
+ * Check if a @ref LIBINPUT_DEVICE_CAP_TABLET_PAD device has a key with the
+ * given code (see linux/input-event-codes.h).
+ *
+ * @param device A current input device
+ * @param code Key code to check for, e.g. <i>KEY_ESC</i>
+ *
+ * @return 1 if the device supports this key code, 0 if it does not, -1
+ * on error.
+ *
+ * @since 1.15
+ */
+int
+libinput_device_tablet_pad_has_key(struct libinput_device *device,
+ uint32_t code);
+
+/**
+ * @ingroup device
+ *
* Increase the refcount of the device group. A device group will be freed
* whenever the refcount reaches 0. This may happen during
* libinput_dispatch() if all devices of this group were removed from the
diff --git a/src/libinput.sym b/src/libinput.sym
index 1698a066..b45838e0 100644
--- a/src/libinput.sym
+++ b/src/libinput.sym
@@ -310,4 +310,7 @@ LIBINPUT_1.15 {
libinput_device_config_scroll_set_button_lock;
libinput_device_config_scroll_get_button_lock;
libinput_device_config_scroll_get_default_button_lock;
+ libinput_device_tablet_pad_has_key;
+ libinput_event_tablet_pad_get_key;
+ libinput_event_tablet_pad_get_key_state;
} LIBINPUT_1.14;
diff --git a/test/litest.c b/test/litest.c
index 8c4e52ee..5325720a 100644
--- a/test/litest.c
+++ b/test/litest.c
@@ -2975,6 +2975,9 @@ litest_event_type_str(enum libinput_event_type type)
case LIBINPUT_EVENT_TABLET_PAD_STRIP:
str = "TABLET PAD STRIP";
break;
+ case LIBINPUT_EVENT_TABLET_PAD_KEY:
+ str = "TABLET PAD KEY";
+ break;
case LIBINPUT_EVENT_SWITCH_TOGGLE:
str = "SWITCH TOGGLE";
break;
@@ -3600,6 +3603,27 @@ litest_is_pad_strip_event(struct libinput_event *event,
return p;
}
+struct libinput_event_tablet_pad *
+litest_is_pad_key_event(struct libinput_event *event,
+ unsigned int key,
+ enum libinput_key_state state)
+{
+ struct libinput_event_tablet_pad *p;
+ enum libinput_event_type type = LIBINPUT_EVENT_TABLET_PAD_KEY;
+
+ litest_assert(event != NULL);
+ litest_assert_event_type(event, type);
+
+ p = libinput_event_get_tablet_pad_event(event);
+ litest_assert(p != NULL);
+
+ litest_assert_int_eq(libinput_event_tablet_pad_get_key(p), key);
+ litest_assert_int_eq(libinput_event_tablet_pad_get_key_state(p),
+ state);
+
+ return p;
+}
+
struct libinput_event_switch *
litest_is_switch_event(struct libinput_event *event,
enum libinput_switch sw,
@@ -3635,6 +3659,21 @@ litest_assert_pad_button_event(struct libinput *li,
}
void
+litest_assert_pad_key_event(struct libinput *li,
+ unsigned int key,
+ enum libinput_key_state state)
+{
+ struct libinput_event *event;
+ struct libinput_event_tablet_pad *pev;
+
+ litest_wait_for_event(li);
+ event = libinput_get_event(li);
+
+ pev = litest_is_pad_key_event(event, key, state);
+ libinput_event_destroy(libinput_event_tablet_pad_get_base_event(pev));
+}
+
+void
litest_assert_scroll(struct libinput *li,
enum libinput_pointer_axis axis,
int minimum_movement)
diff --git a/test/litest.h b/test/litest.h
index 06072c10..5d0114e8 100644
--- a/test/litest.h
+++ b/test/litest.h
@@ -751,6 +751,10 @@ struct libinput_event_tablet_pad *
litest_is_pad_strip_event(struct libinput_event *event,
unsigned int number,
enum libinput_tablet_pad_strip_axis_source source);
+struct libinput_event_tablet_pad *
+litest_is_pad_key_event(struct libinput_event *event,
+ unsigned int key,
+ enum libinput_key_state state);
struct libinput_event_switch *
litest_is_switch_event(struct libinput_event *event,
@@ -796,6 +800,10 @@ void
litest_assert_pad_button_event(struct libinput *li,
unsigned int button,
enum libinput_button_state state);
+void
+litest_assert_pad_key_event(struct libinput *li,
+ unsigned int key,
+ enum libinput_key_state state);
struct libevdev_uinput *
litest_create_uinput_device(const char *name,
struct input_id *id,
diff --git a/test/test-pad.c b/test/test-pad.c
index 6ba8925c..9eba7182 100644
--- a/test/test-pad.c
+++ b/test/test-pad.c
@@ -916,6 +916,72 @@ START_TEST(pad_mode_group_has_no_toggle)
}
END_TEST
+static bool
+pad_has_keys(struct litest_device *dev)
+{
+ struct libevdev *evdev = dev->evdev;
+
+ return (libevdev_has_event_code(evdev, EV_KEY, KEY_BUTTONCONFIG) ||
+ libevdev_has_event_code(evdev, EV_KEY, KEY_ONSCREEN_KEYBOARD) ||
+ libevdev_has_event_code(evdev, EV_KEY, KEY_CONTROLPANEL));
+}
+
+static void
+pad_key_down(struct litest_device *dev, unsigned int which)
+{
+ litest_event(dev, EV_ABS, ABS_MISC, 15);
+ litest_event(dev, EV_KEY, which, 1);
+ litest_event(dev, EV_SYN, SYN_REPORT, 0);
+}
+
+static void
+pad_key_up(struct litest_device *dev, unsigned int which)
+{
+ litest_event(dev, EV_ABS, ABS_MISC, 0);
+ litest_event(dev, EV_KEY, which, 0);
+ litest_event(dev, EV_SYN, SYN_REPORT, 0);
+}
+
+START_TEST(pad_keys)
+{
+ struct litest_device *dev = litest_current_device();
+ struct libinput *li = dev->libinput;
+ unsigned int key;
+
+ if (!pad_has_keys(dev))
+ return;
+
+ litest_drain_events(li);
+
+ key = KEY_BUTTONCONFIG;
+ pad_key_down(dev, key);
+ libinput_dispatch(li);
+ litest_assert_pad_key_event(li, key, LIBINPUT_KEY_STATE_PRESSED);
+
+ pad_key_up(dev, key);
+ libinput_dispatch(li);
+ litest_assert_pad_key_event(li, key, LIBINPUT_KEY_STATE_RELEASED);
+
+ key = KEY_ONSCREEN_KEYBOARD;
+ pad_key_down(dev, key);
+ libinput_dispatch(li);
+ litest_assert_pad_key_event(li, key, LIBINPUT_KEY_STATE_PRESSED);
+
+ pad_key_up(dev, key);
+ libinput_dispatch(li);
+ litest_assert_pad_key_event(li, key, LIBINPUT_KEY_STATE_RELEASED);
+
+ key = KEY_CONTROLPANEL;
+ pad_key_down(dev, key);
+ libinput_dispatch(li);
+ litest_assert_pad_key_event(li, key, LIBINPUT_KEY_STATE_PRESSED);
+
+ pad_key_up(dev, key);
+ libinput_dispatch(li);
+ litest_assert_pad_key_event(li, key, LIBINPUT_KEY_STATE_RELEASED);
+}
+END_TEST
+
TEST_COLLECTION(tablet_pad)
{
litest_add("pad:cap", pad_cap, LITEST_TABLET_PAD, LITEST_ANY);
@@ -950,4 +1016,6 @@ TEST_COLLECTION(tablet_pad)
litest_add("pad:modes", pad_mode_group_has, LITEST_TABLET_PAD, LITEST_ANY);
litest_add("pad:modes", pad_mode_group_has_invalid, LITEST_TABLET_PAD, LITEST_ANY);
litest_add("pad:modes", pad_mode_group_has_no_toggle, LITEST_TABLET_PAD, LITEST_ANY);
+
+ litest_add("pad:keys", pad_keys, LITEST_TABLET_PAD, LITEST_ANY);
}
diff --git a/tools/libinput-debug-events.c b/tools/libinput-debug-events.c
index 079aa7c8..48704ee1 100644
--- a/tools/libinput-debug-events.c
+++ b/tools/libinput-debug-events.c
@@ -140,6 +140,9 @@ print_event_header(struct libinput_event *ev)
case LIBINPUT_EVENT_TABLET_PAD_STRIP:
type = "TABLET_PAD_STRIP";
break;
+ case LIBINPUT_EVENT_TABLET_PAD_KEY:
+ type = "TABLET_PAD_KEY";
+ break;
case LIBINPUT_EVENT_SWITCH_TOGGLE:
type = "SWITCH_TOGGLE";
break;
@@ -765,6 +768,32 @@ print_tablet_pad_strip_event(struct libinput_event *ev)
}
static void
+print_tablet_pad_key_event(struct libinput_event *ev)
+{
+ struct libinput_event_tablet_pad *p = libinput_event_get_tablet_pad_event(ev);
+ enum libinput_key_state state;
+ uint32_t key;
+ const char *keyname;
+
+ print_event_time(libinput_event_tablet_pad_get_time(p));
+
+ key = libinput_event_tablet_pad_get_key(p);
+ if (!show_keycodes && (key >= KEY_ESC && key < KEY_ZENKAKUHANKAKU)) {
+ keyname = "***";
+ key = -1;
+ } else {
+ keyname = libevdev_event_code_get_name(EV_KEY, key);
+ keyname = keyname ? keyname : "???";
+ }
+ state = libinput_event_tablet_pad_get_key_state(p);
+ printq("%s (%d) %s\n",
+ keyname,
+ key,
+ state == LIBINPUT_KEY_STATE_PRESSED ? "pressed" : "released");
+}
+
+
+static void
print_switch_event(struct libinput_event *ev)
{
struct libinput_event_switch *sw = libinput_event_get_switch_event(ev);
@@ -879,6 +908,9 @@ handle_and_print_events(struct libinput *li)
case LIBINPUT_EVENT_TABLET_PAD_STRIP:
print_tablet_pad_strip_event(ev);
break;
+ case LIBINPUT_EVENT_TABLET_PAD_KEY:
+ print_tablet_pad_key_event(ev);
+ break;
case LIBINPUT_EVENT_SWITCH_TOGGLE:
print_switch_event(ev);
break;
diff --git a/tools/libinput-debug-gui.c b/tools/libinput-debug-gui.c
index 72fef04b..d68f1ea1 100644
--- a/tools/libinput-debug-gui.c
+++ b/tools/libinput-debug-gui.c
@@ -1478,6 +1478,8 @@ handle_event_libinput(GIOChannel *source, GIOCondition condition, gpointer data)
case LIBINPUT_EVENT_TABLET_PAD_STRIP:
handle_event_tablet_pad(ev, w);
break;
+ case LIBINPUT_EVENT_TABLET_PAD_KEY:
+ break;
case LIBINPUT_EVENT_SWITCH_TOGGLE:
break;
}