mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-03-22 09:10:40 +01:00
tablet: ignore pad buttons
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@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
parent
6fd00f74d4
commit
52cc0ef25a
3 changed files with 54 additions and 11 deletions
|
|
@ -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,20 +324,15 @@ 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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue