diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2019-01-17 11:08:27 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2019-12-04 15:38:39 +1000 |
commit | 2d1bcf982ab6b26180c4a45e04f244592f4a7832 (patch) | |
tree | e2dfed37cba242d9845caa844e7e58f78c88ce4e /src/evdev-tablet-pad.c | |
parent | 27fda918d8a3aeb46e3884bffcf8b406ce496f07 (diff) | |
download | libinput-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>
Diffstat (limited to 'src/evdev-tablet-pad.c')
-rw-r--r-- | src/evdev-tablet-pad.c | 34 |
1 files changed, 34 insertions, 0 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; |