This requires to expand the blacklisting to be a bit more specific so we don't initialize dwt config on devices that won't need it.
https://bugs.freedesktop.org/show_bug.cgi?id=99140 Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net> --- src/evdev-mt-touchpad.c | 13 +- src/libinput-util.h | 1 + test/Makefile.am | 2 + test/litest-device-acer-hawaii-keyboard.c | 208 ++++++++++++++++++++++++++++++ test/litest-device-acer-hawaii-touchpad.c | 113 ++++++++++++++++ test/litest.c | 4 + test/litest.h | 2 + test/touchpad.c | 43 ++++++ 8 files changed, 384 insertions(+), 2 deletions(-) create mode 100644 test/litest-device-acer-hawaii-keyboard.c create mode 100644 test/litest-device-acer-hawaii-touchpad.c diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index 26b65de..b1666ea 100644 --- a/src/evdev-mt-touchpad.c +++ b/src/evdev-mt-touchpad.c @@ -1427,12 +1427,14 @@ static bool tp_dwt_device_is_blacklisted(struct evdev_device *device) { unsigned int bus = libevdev_get_id_bustype(device->evdev); + unsigned int vendor_id = libevdev_get_id_vendor(device->evdev); /* evemu will set the right bus type */ - if (bus == BUS_VIRTUAL) + if (bus == BUS_VIRTUAL || bus == BUS_BLUETOOTH) return true; - if (device->tags & EVDEV_TAG_EXTERNAL_TOUCHPAD) + /* Wacom doesn't have devices that need dwt */ + if (vendor_id == VENDOR_ID_WACOM) return true; return false; @@ -1446,11 +1448,18 @@ tp_want_dwt(struct evdev_device *touchpad, bus_kbd = libevdev_get_id_bustype(keyboard->evdev); unsigned int vendor_tp = evdev_device_get_id_vendor(touchpad); unsigned int vendor_kbd = evdev_device_get_id_vendor(keyboard); + unsigned int product_tp = evdev_device_get_id_product(touchpad); + unsigned int product_kbd = evdev_device_get_id_product(keyboard); if (tp_dwt_device_is_blacklisted(touchpad) || tp_dwt_device_is_blacklisted(keyboard)) return false; + /* External touchpads with the same vid/pid as the keyboard are + considered a happy couple */ + if (touchpad->tags & EVDEV_TAG_EXTERNAL_TOUCHPAD) + return vendor_tp == vendor_kbd && product_tp == product_kbd; + /* If the touchpad is on serio, the keyboard is too, so ignore any other devices */ if (bus_tp == BUS_I8042 && bus_kbd != bus_tp) diff --git a/src/libinput-util.h b/src/libinput-util.h index 3fd3747..ba09ab6 100644 --- a/src/libinput-util.h +++ b/src/libinput-util.h @@ -42,6 +42,7 @@ #include "libinput.h" #define VENDOR_ID_APPLE 0x5ac +#define VENDOR_ID_CHICONY 0x4f2 #define VENDOR_ID_LOGITECH 0x46d #define VENDOR_ID_WACOM 0x56a #define VENDOR_ID_SYNAPTICS_SERIAL 0x002 diff --git a/test/Makefile.am b/test/Makefile.am index f43cf52..983264c 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -14,6 +14,8 @@ noinst_LTLIBRARIES = liblitest.la liblitest_la_SOURCES = \ litest.h \ litest-int.h \ + litest-device-acer-hawaii-keyboard.c \ + litest-device-acer-hawaii-touchpad.c \ litest-device-alps-semi-mt.c \ litest-device-alps-dualpoint.c \ litest-device-anker-mouse-kbd.c \ diff --git a/test/litest-device-acer-hawaii-keyboard.c b/test/litest-device-acer-hawaii-keyboard.c new file mode 100644 index 0000000..1691e9c --- /dev/null +++ b/test/litest-device-acer-hawaii-keyboard.c @@ -0,0 +1,208 @@ +/* + * Copyright © 2016 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include "config.h" + +#include "litest.h" +#include "litest-int.h" + +static void litest_keyboard_setup(void) +{ + struct litest_device *d = litest_create_device(LITEST_ACER_HAWAII_KEYBOARD); + litest_set_current_device(d); +} + +static struct input_id input_id = { + .bustype = 0x3, + .vendor = 0x4f2, + .product = 0x1558, +}; + +static int events[] = { + EV_KEY, KEY_ESC, + EV_KEY, KEY_1, + EV_KEY, KEY_2, + EV_KEY, KEY_3, + EV_KEY, KEY_4, + EV_KEY, KEY_5, + EV_KEY, KEY_6, + EV_KEY, KEY_7, + EV_KEY, KEY_8, + EV_KEY, KEY_9, + EV_KEY, KEY_0, + EV_KEY, KEY_MINUS, + EV_KEY, KEY_EQUAL, + EV_KEY, KEY_BACKSPACE, + EV_KEY, KEY_TAB, + EV_KEY, KEY_Q, + EV_KEY, KEY_W, + EV_KEY, KEY_E, + EV_KEY, KEY_R, + EV_KEY, KEY_T, + EV_KEY, KEY_Y, + EV_KEY, KEY_U, + EV_KEY, KEY_I, + EV_KEY, KEY_O, + EV_KEY, KEY_P, + EV_KEY, KEY_LEFTBRACE, + EV_KEY, KEY_RIGHTBRACE, + EV_KEY, KEY_ENTER, + EV_KEY, KEY_LEFTCTRL, + EV_KEY, KEY_A, + EV_KEY, KEY_S, + EV_KEY, KEY_D, + EV_KEY, KEY_F, + EV_KEY, KEY_G, + EV_KEY, KEY_H, + EV_KEY, KEY_J, + EV_KEY, KEY_K, + EV_KEY, KEY_L, + EV_KEY, KEY_SEMICOLON, + EV_KEY, KEY_APOSTROPHE, + EV_KEY, KEY_GRAVE, + EV_KEY, KEY_LEFTSHIFT, + EV_KEY, KEY_BACKSLASH, + EV_KEY, KEY_Z, + EV_KEY, KEY_X, + EV_KEY, KEY_C, + EV_KEY, KEY_V, + EV_KEY, KEY_B, + EV_KEY, KEY_N, + EV_KEY, KEY_M, + EV_KEY, KEY_COMMA, + EV_KEY, KEY_DOT, + EV_KEY, KEY_SLASH, + EV_KEY, KEY_RIGHTSHIFT, + EV_KEY, KEY_KPASTERISK, + EV_KEY, KEY_LEFTALT, + EV_KEY, KEY_SPACE, + EV_KEY, KEY_CAPSLOCK, + EV_KEY, KEY_F1, + EV_KEY, KEY_F2, + EV_KEY, KEY_F3, + EV_KEY, KEY_F4, + EV_KEY, KEY_F5, + EV_KEY, KEY_F6, + EV_KEY, KEY_F7, + EV_KEY, KEY_F8, + EV_KEY, KEY_F9, + EV_KEY, KEY_F10, + EV_KEY, KEY_NUMLOCK, + EV_KEY, KEY_SCROLLLOCK, + EV_KEY, KEY_KP7, + EV_KEY, KEY_KP8, + EV_KEY, KEY_KP9, + EV_KEY, KEY_KPMINUS, + EV_KEY, KEY_KP4, + EV_KEY, KEY_KP5, + EV_KEY, KEY_KP6, + EV_KEY, KEY_KPPLUS, + EV_KEY, KEY_KP1, + EV_KEY, KEY_KP2, + EV_KEY, KEY_KP3, + EV_KEY, KEY_KP0, + EV_KEY, KEY_KPDOT, + EV_KEY, KEY_ZENKAKUHANKAKU, + EV_KEY, KEY_102ND, + EV_KEY, KEY_F11, + EV_KEY, KEY_F12, + EV_KEY, KEY_RO, + EV_KEY, KEY_KATAKANA, + EV_KEY, KEY_HIRAGANA, + EV_KEY, KEY_HENKAN, + EV_KEY, KEY_KATAKANAHIRAGANA, + EV_KEY, KEY_MUHENKAN, + EV_KEY, KEY_KPJPCOMMA, + EV_KEY, KEY_KPENTER, + EV_KEY, KEY_RIGHTCTRL, + EV_KEY, KEY_KPSLASH, + EV_KEY, KEY_SYSRQ, + EV_KEY, KEY_RIGHTALT, + EV_KEY, KEY_LINEFEED, + EV_KEY, KEY_HOME, + EV_KEY, KEY_UP, + EV_KEY, KEY_PAGEUP, + EV_KEY, KEY_LEFT, + EV_KEY, KEY_RIGHT, + EV_KEY, KEY_END, + EV_KEY, KEY_DOWN, + EV_KEY, KEY_PAGEDOWN, + EV_KEY, KEY_INSERT, + EV_KEY, KEY_DELETE, + EV_KEY, KEY_MACRO, + EV_KEY, KEY_MUTE, + EV_KEY, KEY_VOLUMEDOWN, + EV_KEY, KEY_VOLUMEUP, + EV_KEY, KEY_POWER, + EV_KEY, KEY_KPEQUAL, + EV_KEY, KEY_KPPLUSMINUS, + EV_KEY, KEY_PAUSE, + /* EV_KEY, KEY_SCALE, */ + EV_KEY, KEY_KPCOMMA, + EV_KEY, KEY_HANGEUL, + EV_KEY, KEY_HANJA, + EV_KEY, KEY_YEN, + EV_KEY, KEY_LEFTMETA, + EV_KEY, KEY_RIGHTMETA, + EV_KEY, KEY_COMPOSE, + EV_KEY, KEY_STOP, + + EV_KEY, KEY_MENU, + EV_KEY, KEY_CALC, + EV_KEY, KEY_SETUP, + EV_KEY, KEY_SLEEP, + EV_KEY, KEY_WAKEUP, + EV_KEY, KEY_SCREENLOCK, + EV_KEY, KEY_DIRECTION, + EV_KEY, KEY_CYCLEWINDOWS, + EV_KEY, KEY_MAIL, + EV_KEY, KEY_BOOKMARKS, + EV_KEY, KEY_COMPUTER, + EV_KEY, KEY_BACK, + EV_KEY, KEY_FORWARD, + EV_KEY, KEY_NEXTSONG, + EV_KEY, KEY_PLAYPAUSE, + EV_KEY, KEY_PREVIOUSSONG, + EV_KEY, KEY_STOPCD, + EV_KEY, KEY_HOMEPAGE, + EV_KEY, KEY_REFRESH, + EV_KEY, KEY_F14, + EV_KEY, KEY_F15, + EV_KEY, KEY_SEARCH, + EV_KEY, KEY_MEDIA, + EV_KEY, KEY_FN, + -1, -1, +}; + +struct litest_test_device litest_acer_hawaii_keyboard_device = { + .type = LITEST_ACER_HAWAII_KEYBOARD, + .features = LITEST_KEYS, + .shortname = "hawaii-keyboard", + .setup = litest_keyboard_setup, + .interface = NULL, + + .name = "Chicony ACER Hawaii Keyboard", + .id = &input_id, + .events = events, + .absinfo = NULL, +}; diff --git a/test/litest-device-acer-hawaii-touchpad.c b/test/litest-device-acer-hawaii-touchpad.c new file mode 100644 index 0000000..1dcd4ce --- /dev/null +++ b/test/litest-device-acer-hawaii-touchpad.c @@ -0,0 +1,113 @@ +/* + * Copyright © 2016 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include "config.h" + +#include "litest.h" +#include "litest-int.h" + +static void +litest_touchpad_setup(void) +{ + struct litest_device *d = litest_create_device(LITEST_ACER_HAWAII_TOUCHPAD); + litest_set_current_device(d); +} + +static struct input_event down[] = { + { .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_MT_SLOT, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_MT_TRACKING_ID, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_MT_POSITION_X, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_MT_POSITION_Y, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_SYN, .code = SYN_REPORT, .value = 0 }, + { .type = -1, .code = -1 }, +}; + +static struct input_event move[] = { + { .type = EV_ABS, .code = ABS_MT_SLOT, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_MT_POSITION_X, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_MT_POSITION_Y, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_SYN, .code = SYN_REPORT, .value = 0 }, + { .type = -1, .code = -1 }, +}; + +static struct litest_device_interface interface = { + .touch_down_events = down, + .touch_move_events = move, +}; + +static struct input_id input_id = { + .bustype = 0x3, + .vendor = 0x4f2, + .product = 0x1558, +}; + +static int events[] = { + EV_KEY, BTN_LEFT, + EV_KEY, BTN_TOOL_FINGER, + EV_KEY, BTN_TOOL_QUINTTAP, + EV_KEY, BTN_TOUCH, + EV_KEY, BTN_TOOL_DOUBLETAP, + EV_KEY, BTN_TOOL_TRIPLETAP, + EV_KEY, BTN_TOOL_QUADTAP, + INPUT_PROP_MAX, INPUT_PROP_POINTER, + INPUT_PROP_MAX, INPUT_PROP_BUTTONPAD, + -1, -1, +}; + +static struct input_absinfo absinfo[] = { + { ABS_X, 0, 1151, 0, 0, 12 }, + { ABS_Y, 0, 738, 0, 0, 14 }, + { ABS_MT_SLOT, 0, 14, 0, 0, 0 }, + { ABS_MT_POSITION_X, 0, 1151, 0, 0, 12 }, + { ABS_MT_POSITION_Y, 0, 738, 0, 0, 14 }, + { ABS_MT_TRACKING_ID, 0, 65535, 0, 0, 0 }, + { .value = -1 } +}; + +static const char udev_rule[] = +"ACTION==\"remove\", GOTO=\"touchpad_end\"\n" +"KERNEL!=\"event*\", GOTO=\"touchpad_end\"\n" +"ENV{ID_INPUT_TOUCHPAD}==\"\", GOTO=\"touchpad_end\"\n" +"\n" +"ATTRS{name}==\"litest Chicony ACER Hawaii Keyboard Touchpad\"," +" ENV{ID_INPUT_TOUCHPAD_INTEGRATION}=\"external\"\n" +"\n" +"LABEL=\"touchpad_end\""; + +struct litest_test_device litest_acer_hawaii_touchpad_device = { + .type = LITEST_ACER_HAWAII_TOUCHPAD, + .features = LITEST_TOUCHPAD | LITEST_CLICKPAD | LITEST_BUTTON, + .shortname = "hawaii-touchpad", + .setup = litest_touchpad_setup, + .interface = &interface, + + .name = "Chicony ACER Hawaii Keyboard Touchpad", + .id = &input_id, + .events = events, + .absinfo = absinfo, + .udev_rule = udev_rule, +}; diff --git a/test/litest.c b/test/litest.c index 4f43d79..40029d6 100644 --- a/test/litest.c +++ b/test/litest.c @@ -404,6 +404,8 @@ extern struct litest_test_device litest_wacom_cintiq_13hdt_pad_device; extern struct litest_test_device litest_wacom_hid4800_tablet_device; extern struct litest_test_device litest_mouse_wheel_click_count_device; extern struct litest_test_device litest_calibrated_touchscreen_device; +extern struct litest_test_device litest_acer_hawaii_keyboard_device; +extern struct litest_test_device litest_acer_hawaii_touchpad_device; struct litest_test_device* devices[] = { &litest_synaptics_clickpad_device, @@ -462,6 +464,8 @@ struct litest_test_device* devices[] = { &litest_wacom_hid4800_tablet_device, &litest_mouse_wheel_click_count_device, &litest_calibrated_touchscreen_device, + &litest_acer_hawaii_keyboard_device, + &litest_acer_hawaii_touchpad_device, NULL, }; diff --git a/test/litest.h b/test/litest.h index ccae368..017a3d2 100644 --- a/test/litest.h +++ b/test/litest.h @@ -224,6 +224,8 @@ enum litest_device_type { LITEST_WACOM_HID4800_PEN, LITEST_MOUSE_WHEEL_CLICK_COUNT, LITEST_CALIBRATED_TOUCHSCREEN, + LITEST_ACER_HAWAII_KEYBOARD, + LITEST_ACER_HAWAII_TOUCHPAD, }; enum litest_device_feature { diff --git a/test/touchpad.c b/test/touchpad.c index 5b6f0a4..c3204a3 100644 --- a/test/touchpad.c +++ b/test/touchpad.c @@ -2501,6 +2501,9 @@ dwt_init_paired_keyboard(struct libinput *li, if (libevdev_get_id_vendor(touchpad->evdev) == VENDOR_ID_APPLE) which = LITEST_APPLE_KEYBOARD; + if (libevdev_get_id_vendor(touchpad->evdev) == VENDOR_ID_CHICONY) + which = LITEST_ACER_HAWAII_KEYBOARD; + return litest_add_device(li, which); } @@ -3774,6 +3777,45 @@ START_TEST(touchpad_dwt_apple) } END_TEST +START_TEST(touchpad_dwt_acer_hawaii) +{ + struct litest_device *touchpad = litest_current_device(); + struct litest_device *keyboard, *hawaii_keyboard; + struct libinput *li = touchpad->libinput; + + ck_assert(has_disable_while_typing(touchpad)); + + /* Only the hawaii keyboard can trigger DWT */ + keyboard = litest_add_device(li, LITEST_KEYBOARD); + litest_drain_events(li); + + litest_keyboard_key(keyboard, KEY_A, true); + litest_keyboard_key(keyboard, KEY_A, false); + litest_assert_only_typed_events(li, LIBINPUT_EVENT_KEYBOARD_KEY); + + litest_touch_down(touchpad, 0, 50, 50); + litest_touch_move_to(touchpad, 0, 50, 50, 70, 50, 10, 1); + litest_touch_up(touchpad, 0); + litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_MOTION); + + hawaii_keyboard = litest_add_device(li, LITEST_ACER_HAWAII_KEYBOARD); + litest_drain_events(li); + + litest_keyboard_key(hawaii_keyboard, KEY_A, true); + litest_keyboard_key(hawaii_keyboard, KEY_A, false); + litest_assert_only_typed_events(li, LIBINPUT_EVENT_KEYBOARD_KEY); + + litest_touch_down(touchpad, 0, 50, 50); + litest_touch_move_to(touchpad, 0, 50, 50, 70, 50, 10, 1); + litest_touch_up(touchpad, 0); + libinput_dispatch(li); + litest_assert_empty_queue(li); + + litest_delete_device(keyboard); + litest_delete_device(hawaii_keyboard); +} +END_TEST + static int has_thumb_detect(struct litest_device *dev) { @@ -4750,6 +4792,7 @@ litest_setup_tests_touchpad(void) litest_add("touchpad:dwt", touchpad_dwt_enable_before_touch, LITEST_TOUCHPAD, LITEST_ANY); litest_add("touchpad:dwt", touchpad_dwt_enable_during_tap, LITEST_TOUCHPAD, LITEST_ANY); litest_add_for_device("touchpad:dwt", touchpad_dwt_apple, LITEST_BCM5974); + litest_add_for_device("touchpad:dwt", touchpad_dwt_acer_hawaii, LITEST_ACER_HAWAII_TOUCHPAD); litest_add("touchpad:thumb", touchpad_thumb_begin_no_motion, LITEST_CLICKPAD, LITEST_ANY); litest_add("touchpad:thumb", touchpad_thumb_update_no_motion, LITEST_CLICKPAD, LITEST_ANY); -- 2.9.3 _______________________________________________ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel