---
src/evdev-mt-touchpad.c | 48 ++++++++---
test/Makefile.am | 2 +
test/litest-device-synaptics-i2c.c | 102 ++++++++++++++++++++++
test/litest-device-yubikey.c | 169 +++++++++++++++++++++++++++++++++++++
test/litest.c | 4 +
test/litest.h | 2 +
test/touchpad.c | 103 ++++++++++++++++++++++
7 files changed, 416 insertions(+), 14 deletions(-)
create mode 100644 test/litest-device-synaptics-i2c.c
create mode 100644 test/litest-device-yubikey.c
diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
index d0d1ddd..2be9d40 100644
--- a/src/evdev-mt-touchpad.c
+++ b/src/evdev-mt-touchpad.c
@@ -1336,6 +1336,38 @@ tp_want_dwt(struct evdev_device *touchpad,
}
static void
+tp_dwt_pair_keyboard(struct evdev_device *touchpad,
+ struct evdev_device *keyboard)
+{
+ struct tp_dispatch *tp = (struct tp_dispatch*)touchpad->dispatch;
+ unsigned int bus_kbd = libevdev_get_id_bustype(keyboard->evdev);
+
+ if (!tp_want_dwt(touchpad, keyboard))
+ return;
+
+ /* If we already have a keyboard paired, override it if the new one
+ * is a serio device. Otherwise keep the current one */
+ if (tp->dwt.keyboard) {
+ if (bus_kbd != BUS_I8042)
+ return;
+
+ memset(tp->dwt.key_mask, 0, sizeof(tp->dwt.key_mask));
+
libinput_device_remove_event_listener(&tp->dwt.keyboard_listener);
+ }
+
+ libinput_device_add_event_listener(&keyboard->base,
+ &tp->dwt.keyboard_listener,
+ tp_keyboard_event, tp);
+ tp->dwt.keyboard = keyboard;
+ tp->dwt.keyboard_active = false;
+
+ log_debug(touchpad->base.seat->libinput,
+ "palm: dwt activated with %s<->%s\n",
+ touchpad->devname,
+ keyboard->devname);
+}
+
+static void
tp_interface_device_added(struct evdev_device *device,
struct evdev_device *added_device)
{
@@ -1359,20 +1391,8 @@ tp_interface_device_added(struct evdev_device *device,
tp_trackpoint_event, tp);
}
- if (added_device->tags & EVDEV_TAG_KEYBOARD &&
- tp->dwt.keyboard == NULL &&
- tp_want_dwt(device, added_device)) {
- log_debug(tp_libinput_context(tp),
- "palm: dwt activated with %s<->%s\n",
- device->devname,
- added_device->devname);
-
- libinput_device_add_event_listener(&added_device->base,
- &tp->dwt.keyboard_listener,
- tp_keyboard_event, tp);
- tp->dwt.keyboard = added_device;
- tp->dwt.keyboard_active = false;
- }
+ if (added_device->tags & EVDEV_TAG_KEYBOARD)
+ tp_dwt_pair_keyboard(device, added_device);
if (tp->sendevents.current_mode !=
LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE)
diff --git a/test/Makefile.am b/test/Makefile.am
index 27a2a36..c7e68ef 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -38,6 +38,7 @@ liblitest_la_SOURCES = \
litest-device-qemu-usb-tablet.c \
litest-device-synaptics.c \
litest-device-synaptics-hover.c \
+ litest-device-synaptics-i2c.c \
litest-device-synaptics-st.c \
litest-device-synaptics-t440.c \
litest-device-synaptics-x1-carbon-3rd.c \
@@ -53,6 +54,7 @@ liblitest_la_SOURCES = \
litest-device-wheel-only.c \
litest-device-xen-virtual-pointer.c \
litest-device-vmware-virtual-usb-mouse.c \
+ litest-device-yubikey.c \
litest.c
liblitest_la_LIBADD = $(top_builddir)/src/libinput-util.la
liblitest_la_CFLAGS = $(AM_CFLAGS) \
diff --git a/test/litest-device-synaptics-i2c.c
b/test/litest-device-synaptics-i2c.c
new file mode 100644
index 0000000..b6b632b
--- /dev/null
+++ b/test/litest-device-synaptics-i2c.c
@@ -0,0 +1,102 @@
+/*
+ * Copyright © 2015 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.
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "litest.h"
+#include "litest-int.h"
+
+static void
+litest_synaptics_i2c_setup(void)
+{
+ struct litest_device *d = litest_create_device(LITEST_SYNAPTICS_I2C);
+ 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 = 0x18,
+ .vendor = 0x6cb,
+ .product = 0x76ad,
+};
+
+static int events[] = {
+ EV_KEY, BTN_LEFT,
+ EV_KEY, BTN_TOOL_FINGER,
+ EV_KEY, BTN_TOUCH,
+ EV_KEY, BTN_TOOL_DOUBLETAP,
+ EV_KEY, BTN_TOOL_TRIPLETAP,
+ INPUT_PROP_MAX, INPUT_PROP_POINTER,
+ INPUT_PROP_MAX, INPUT_PROP_BUTTONPAD,
+ -1, -1,
+};
+
+static struct input_absinfo absinfo[] = {
+ { ABS_X, 0, 1216, 0, 0, 12 },
+ { ABS_Y, 0, 680, 0, 0, 12 },
+ { ABS_MT_SLOT, 0, 1, 0, 0, 0 },
+ { ABS_MT_POSITION_X, 0, 1216, 0, 0, 12 },
+ { ABS_MT_POSITION_Y, 0, 680, 0, 0, 12 },
+ { ABS_MT_TRACKING_ID, 0, 65535, 0, 0, 0 },
+ { .value = -1 }
+};
+
+struct litest_test_device litest_synaptics_i2c_device = {
+ .type = LITEST_SYNAPTICS_I2C,
+ .features = LITEST_TOUCHPAD | LITEST_CLICKPAD | LITEST_BUTTON,
+ .shortname = "synaptics-i2c",
+ .setup = litest_synaptics_i2c_setup,
+ .interface = &interface,
+
+ .name = "DLL0704:01 06CB:76AD Touchpad",
+ .id = &input_id,
+ .events = events,
+ .absinfo = absinfo,
+};
diff --git a/test/litest-device-yubikey.c b/test/litest-device-yubikey.c
new file mode 100644
index 0000000..d2c1d4c
--- /dev/null
+++ b/test/litest-device-yubikey.c
@@ -0,0 +1,169 @@
+/*
+ * Copyright © 2014 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.
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "litest.h"
+#include "litest-int.h"
+
+static void litest_yubikey_setup(void)
+{
+ struct litest_device *d = litest_create_device(LITEST_YUBIKEY);
+ litest_set_current_device(d);
+}
+
+static struct input_id input_id = {
+ .bustype = 0x3,
+ .vendor = 0x1050,
+ .product = 0x10,
+};
+
+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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,
+ 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_102ND,
+ EV_KEY, KEY_F11,
+ EV_KEY, KEY_F12,
+ EV_KEY, KEY_KPENTER,
+ EV_KEY, KEY_RIGHTCTRL,
+ EV_KEY, KEY_KPSLASH,
+ EV_KEY, KEY_SYSRQ,
+ EV_KEY, KEY_RIGHTALT,
+ 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_PAUSE,
+ EV_KEY, KEY_LEFTMETA,
+ EV_KEY, KEY_RIGHTMETA,
+ EV_KEY, KEY_COMPOSE,
+
+ EV_LED, LED_NUML,
+ EV_LED, LED_CAPSL,
+ EV_LED, LED_SCROLLL,
+ EV_LED, LED_COMPOSE,
+ EV_LED, LED_KANA,
+ -1, -1,
+};
+
+struct litest_test_device litest_yubikey_device = {
+ .type = LITEST_YUBIKEY,
+ .features = LITEST_KEYS,
+ .shortname = "yubikey",
+ .setup = litest_yubikey_setup,
+ .interface = NULL,
+
+ .name = "Yubico Yubico Yubikey II",
+ .id = &input_id,
+ .events = events,
+ .absinfo = NULL,
+};
diff --git a/test/litest.c b/test/litest.c
index 2d31c7b..0901e2d 100644
--- a/test/litest.c
+++ b/test/litest.c
@@ -376,6 +376,8 @@ extern struct litest_test_device
litest_anker_mouse_kbd_device;
extern struct litest_test_device litest_waltop_tablet_device;
extern struct litest_test_device litest_huion_tablet_device;
extern struct litest_test_device litest_cyborg_rat_device;
+extern struct litest_test_device litest_yubikey_device;
+extern struct litest_test_device litest_synaptics_i2c_device;
struct litest_test_device* devices[] = {
&litest_synaptics_clickpad_device,
@@ -418,6 +420,8 @@ struct litest_test_device* devices[] = {
&litest_waltop_tablet_device,
&litest_huion_tablet_device,
&litest_cyborg_rat_device,
+ &litest_yubikey_device,
+ &litest_synaptics_i2c_device,
NULL,
};
diff --git a/test/litest.h b/test/litest.h
index bd9b903..2976394 100644
--- a/test/litest.h
+++ b/test/litest.h
@@ -193,6 +193,8 @@ enum litest_device_type {
LITEST_WALTOP = -39,
LITEST_HUION_TABLET = -40,
LITEST_CYBORG_RAT = -41,
+ LITEST_YUBIKEY = -42,
+ LITEST_SYNAPTICS_I2C = -43,
};
enum litest_device_feature {
diff --git a/test/touchpad.c b/test/touchpad.c
index 0d3aa03..1c6cdf8 100644
--- a/test/touchpad.c
+++ b/test/touchpad.c
@@ -2336,6 +2336,107 @@ START_TEST(touchpad_dwt)
}
END_TEST
+START_TEST(touchpad_dwt_update_keyboard)
+{
+ struct litest_device *touchpad = litest_current_device();
+ struct litest_device *keyboard, *yubikey;
+ struct libinput *li = touchpad->libinput;
+
+ if (!has_disable_while_typing(touchpad))
+ return;
+
+ litest_disable_tap(touchpad->libinput_device);
+
+ /* Yubikey is initialized first */
+ yubikey = litest_add_device(li, LITEST_YUBIKEY);
+ litest_drain_events(li);
+
+ keyboard = dwt_init_paired_keyboard(li, touchpad);
+ litest_drain_events(li);
+
+ litest_keyboard_key(keyboard, KEY_A, true);
+ litest_keyboard_key(keyboard, KEY_A, false);
+ libinput_dispatch(li);
+ 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_KEYBOARD_KEY);
+
+ /* within timeout - no events */
+ 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_empty_queue(li);
+
+ litest_timeout_dwt_short();
+ libinput_dispatch(li);
+
+ /* after timeout - motion events*/
+ 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);
+
+ litest_delete_device(keyboard);
+ litest_delete_device(yubikey);
+}
+END_TEST
+
+START_TEST(touchpad_dwt_update_keyboard_with_state)
+{
+ struct litest_device *touchpad = litest_current_device();
+ struct litest_device *keyboard, *yubikey;
+ struct libinput *li = touchpad->libinput;
+
+ if (!has_disable_while_typing(touchpad))
+ return;
+
+ litest_disable_tap(touchpad->libinput_device);
+
+ /* Yubikey is initialized first */
+ yubikey = litest_add_device(li, LITEST_YUBIKEY);
+ litest_drain_events(li);
+
+ litest_keyboard_key(yubikey, KEY_A, true);
+ litest_keyboard_key(yubikey, KEY_A, false);
+ litest_keyboard_key(yubikey, KEY_A, true);
+ 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_empty_queue(li);
+
+ litest_keyboard_key(yubikey, KEY_A, false);
+ litest_keyboard_key(yubikey, KEY_A, true);
+ litest_drain_events(li);
+
+ /* yubikey still has A down */
+ keyboard = dwt_init_paired_keyboard(li, touchpad);
+ litest_drain_events(li);
+
+ /* expected repairing, dwt should be disabled */
+ 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);
+
+ /* release remaining key */
+ litest_keyboard_key(yubikey, 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);
+
+ litest_delete_device(keyboard);
+ litest_delete_device(yubikey);
+}
+END_TEST
+
START_TEST(touchpad_dwt_enable_touch)
{
struct litest_device *touchpad = litest_current_device();
@@ -3805,6 +3906,8 @@ litest_setup_tests(void)
litest_add_ranged("touchpad:state", touchpad_initial_state,
LITEST_TOUCHPAD, LITEST_ANY, &axis_range);
litest_add("touchpad:dwt", touchpad_dwt, LITEST_TOUCHPAD, LITEST_ANY);
+ litest_add_for_device("touchpad:dwt", touchpad_dwt_update_keyboard,
LITEST_SYNAPTICS_I2C);
+ litest_add_for_device("touchpad:dwt",
touchpad_dwt_update_keyboard_with_state, LITEST_SYNAPTICS_I2C);
litest_add("touchpad:dwt", touchpad_dwt_enable_touch, LITEST_TOUCHPAD,
LITEST_ANY);
litest_add("touchpad:dwt", touchpad_dwt_touch_hold, LITEST_TOUCHPAD,
LITEST_ANY);
litest_add("touchpad:dwt", touchpad_dwt_key_hold, LITEST_TOUCHPAD,
LITEST_ANY);