[PATCH libinput 3/3] tablet: ignore pad buttons
Peter Hutterer
peter.hutterer at who-t.net
Sun Jun 22 21:16:36 PDT 2014
We've got big plans for handling pad buttons, and the interface will likely
be different for those. Meanwhile, discard any pad button events so no-one can
get too used to them.
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
src/evdev-tablet.c | 14 ++++----------
src/evdev-tablet.h | 1 -
test/tablet.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 54 insertions(+), 11 deletions(-)
diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c
index 9f19565..7d03b17 100644
--- a/src/evdev-tablet.c
+++ b/src/evdev-tablet.c
@@ -179,8 +179,7 @@ tablet_update_button(struct tablet_dispatch *tablet,
/* XXX: This really depends on the expected buttons fitting in the mask */
if (evcode >= BTN_MISC && evcode <= BTN_TASK) {
- mask = &tablet->button_state.pad_buttons;
- button = evcode - BTN_MISC;
+ return;
} else if (evcode >= BTN_TOUCH && evcode <= BTN_STYLUS2) {
mask = &tablet->button_state.stylus_buttons;
button = evcode - BTN_TOUCH;
@@ -325,21 +324,16 @@ tablet_notify_buttons(struct tablet_dispatch *tablet,
uint32_t time,
enum libinput_button_state state)
{
- uint32_t pad_buttons, stylus_buttons;
+ uint32_t stylus_buttons;
- if (state == LIBINPUT_BUTTON_STATE_PRESSED) {
- pad_buttons = tablet_get_pressed_buttons(tablet, pad_buttons);
+ if (state == LIBINPUT_BUTTON_STATE_PRESSED)
stylus_buttons =
tablet_get_pressed_buttons(tablet, stylus_buttons);
- } else {
- pad_buttons = tablet_get_released_buttons(tablet, pad_buttons);
+ else
stylus_buttons =
tablet_get_released_buttons(tablet, stylus_buttons);
- }
tablet_notify_button_mask(tablet, device, time,
- pad_buttons, BTN_MISC, state);
- tablet_notify_button_mask(tablet, device, time,
stylus_buttons, BTN_TOUCH, state);
}
diff --git a/src/evdev-tablet.h b/src/evdev-tablet.h
index 9beba7b..504b093 100644
--- a/src/evdev-tablet.h
+++ b/src/evdev-tablet.h
@@ -38,7 +38,6 @@ enum tablet_status {
};
struct button_state {
- uint32_t pad_buttons; /* bitmask of evcode - BTN_MISC */
uint32_t stylus_buttons; /* bitmask of evcode - BTN_TOUCH */
};
diff --git a/test/tablet.c b/test/tablet.c
index 3bfbb6a..6fb4465 100644
--- a/test/tablet.c
+++ b/test/tablet.c
@@ -537,6 +537,55 @@ START_TEST(invalid_serials)
}
END_TEST
+START_TEST(pad_buttons_ignored)
+{
+ struct litest_device *dev = litest_current_device();
+ struct libinput *li = dev->libinput;
+ struct libinput_event *event;
+ struct axis_replacement axes[] = {
+ { ABS_DISTANCE, 10 },
+ { -1, -1 }
+ };
+ int button;
+
+ litest_drain_events(li);
+
+ for (button = BTN_0; button < BTN_MOUSE; button++) {
+ litest_event(dev, EV_KEY, button, 1);
+ litest_event(dev, EV_SYN, SYN_REPORT, 0);
+ litest_event(dev, EV_KEY, button, 0);
+ litest_event(dev, EV_SYN, SYN_REPORT, 0);
+ libinput_dispatch(li);
+ }
+
+ while ((event = libinput_get_event(li))) {
+ ck_assert_int_ne(libinput_event_get_type,
+ LIBINPUT_EVENT_TABLET_BUTTON);
+ libinput_event_destroy(event);
+ libinput_dispatch(li);
+ }
+
+ /* same thing while in prox */
+ litest_tablet_proximity_in(dev, 10, 10, axes);
+ for (button = BTN_0; button < BTN_MOUSE; button++) {
+ litest_event(dev, EV_KEY, button, 1);
+ litest_event(dev, EV_SYN, SYN_REPORT, 0);
+ litest_event(dev, EV_KEY, button, 0);
+ litest_event(dev, EV_SYN, SYN_REPORT, 0);
+ libinput_dispatch(li);
+ }
+ litest_tablet_proximity_out(dev);
+
+ libinput_dispatch(li);
+ while ((event = libinput_get_event(li))) {
+ ck_assert_int_ne(libinput_event_get_type,
+ LIBINPUT_EVENT_TABLET_BUTTON);
+ libinput_event_destroy(event);
+ libinput_dispatch(li);
+ }
+}
+END_TEST
+
int
main(int argc, char **argv)
{
@@ -548,6 +597,7 @@ main(int argc, char **argv)
litest_add("tablet:proximity", bad_distance_events, LITEST_TABLET | LITEST_DISTANCE, LITEST_ANY);
litest_add("tablet:motion", motion, LITEST_TABLET, LITEST_ANY);
litest_add("tablet:normalization", normalization, LITEST_TABLET, LITEST_ANY);
+ litest_add("tablet:pad", pad_buttons_ignored, LITEST_TABLET, LITEST_ANY);
return litest_run(argc, argv);
}
--
1.9.3
More information about the wayland-devel
mailing list