From 594bbb01afaaac9986414e0902f6681c573851a9 Mon Sep 17 00:00:00 2001 From: Marek Chalupa Date: Wed, 21 Jan 2015 12:11:22 +0100 Subject: [PATCH 1/9] Remove libinput_event_pointer_get_axis from symbols This function was removed in 1baf109b40 Signed-off-by: Marek Chalupa Signed-off-by: Peter Hutterer --- src/libinput.sym | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libinput.sym b/src/libinput.sym index cfbeabd8..77fccb84 100644 --- a/src/libinput.sym +++ b/src/libinput.sym @@ -70,7 +70,6 @@ global: libinput_event_pointer_get_absolute_x_transformed; libinput_event_pointer_get_absolute_y; libinput_event_pointer_get_absolute_y_transformed; - libinput_event_pointer_get_axis; libinput_event_pointer_get_axis_source; libinput_event_pointer_get_axis_value; libinput_event_pointer_get_axis_value_discrete; From 0afd0b792fb9c244442ac4532ceeaa9565dd1928 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Wed, 21 Jan 2015 12:04:48 +0100 Subject: [PATCH 2/9] evdev: Be more careful about what we consider a joystick After switching my main workstation over to using xf86-input-libinput, I noticed that the multi-media keys like play/pause on my keyboard no longer worked. It turns out that the second hid interface on my keyboard which has the multimedia-keys, also declares having: BTN_BASE6 and BTN_MODE which both fell into the range we were using to test for something being a joystick. The commit makes our joystick test mode strict, restoring functionality of the multi-media keys on the keyboard in question. Signed-off-by: Hans de Goede Reviewed-by: Peter Hutterer Signed-off-by: Peter Hutterer --- src/evdev.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/evdev.c b/src/evdev.c index 6edacba6..24d30e0a 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -1324,7 +1324,7 @@ evdev_configure_device(struct evdev_device *device) struct libevdev *evdev = device->evdev; const struct input_absinfo *absinfo; int has_abs, has_rel, has_mt; - int has_button, has_keyboard, has_touch; + int has_button, has_keyboard, has_touch, has_joystick_button; struct mt_slot *slots; int num_slots; int active_slot; @@ -1336,17 +1336,24 @@ evdev_configure_device(struct evdev_device *device) has_abs = 0; has_mt = 0; has_button = 0; + has_joystick_button = 0; has_keyboard = 0; has_touch = 0; - for (i = BTN_JOYSTICK; i < BTN_DIGI; i++) { - if (libevdev_has_event_code(evdev, EV_KEY, i)) { - log_info(libinput, - "input device '%s', %s is a joystick, ignoring\n", - device->devname, devnode); - return -1; - } - } + for (i = BTN_JOYSTICK; i <= BTN_PINKIE; i++) + if (libevdev_has_event_code(evdev, EV_KEY, i)) + has_joystick_button = 1; + + for (i = BTN_GAMEPAD; i <= BTN_TR2; i++) + if (libevdev_has_event_code(evdev, EV_KEY, i)) + has_joystick_button = 1; + + if (has_joystick_button) { + log_info(libinput, + "input device '%s', %s is a joystick, ignoring\n", + device->devname, devnode); + return -1; + } if (libevdev_has_event_type(evdev, EV_ABS)) { From 4a90910895e627153ce9215285e1a443cf118d0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedrich=20Sch=C3=B6ller?= Date: Fri, 23 Jan 2015 22:31:04 +0100 Subject: [PATCH 3/9] tools: Use correct event axis in debugging GUI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Vertical axis values were used for the horizontal axis as well. Introduced 1baf109b40e5d610cb46d313d7c412419af8c9e0 Signed-off-by: Friedrich Schöller Signed-off-by: Peter Hutterer --- tools/event-gui.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/event-gui.c b/tools/event-gui.c index 4f9d7e67..e574bf7f 100644 --- a/tools/event-gui.c +++ b/tools/event-gui.c @@ -370,7 +370,7 @@ handle_event_axis(struct libinput_event *ev, struct window *w) w->vy = clip(w->vy, 0, w->height); } if (h != 0.0) { - w->hx += (int)v; + w->hx += (int)h; w->hx = clip(w->hx, 0, w->width); } } From 529ce8e4ac74e3238768922f552d83e4de622721 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedrich=20Sch=C3=B6ller?= Date: Fri, 23 Jan 2015 22:31:05 +0100 Subject: [PATCH 4/9] tools: Check if axis value is available in debugging GUI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit libinput complained with lots of "client bug" messages because the GUI tool did not check which axis values were available. Signed-off-by: Friedrich Schöller Signed-off-by: Peter Hutterer --- tools/event-gui.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/tools/event-gui.c b/tools/event-gui.c index e574bf7f..70dd8541 100644 --- a/tools/event-gui.c +++ b/tools/event-gui.c @@ -358,19 +358,21 @@ static void handle_event_axis(struct libinput_event *ev, struct window *w) { struct libinput_event_pointer *p = libinput_event_get_pointer_event(ev); - double v, h; + double value; - v = libinput_event_pointer_get_axis_value(p, - LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL); - h = libinput_event_pointer_get_axis_value(p, - LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL); - - if (v != 0.0) { - w->vy += (int)v; + if (libinput_event_pointer_has_axis(p, + LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL)) { + value = libinput_event_pointer_get_axis_value(p, + LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL); + w->vy += (int)value; w->vy = clip(w->vy, 0, w->height); } - if (h != 0.0) { - w->hx += (int)h; + + if (libinput_event_pointer_has_axis(p, + LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL)) { + value = libinput_event_pointer_get_axis_value(p, + LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL); + w->hx += (int)value; w->hx = clip(w->hx, 0, w->width); } } From c411de1078bcde95f6a1362f8878c64a5bff70f4 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 28 Jan 2015 15:59:03 +1000 Subject: [PATCH 5/9] test: set the input_id->version as well in litest devices Signed-off-by: Peter Hutterer Reviewed-by: Hans de Goede --- test/litest.c | 1 + 1 file changed, 1 insertion(+) diff --git a/test/litest.c b/test/litest.c index 7d482784..b5ce0a8f 100644 --- a/test/litest.c +++ b/test/litest.c @@ -1048,6 +1048,7 @@ litest_create_uinput_device_from_description(const char *name, libevdev_set_id_bustype(dev, id->bustype); libevdev_set_id_vendor(dev, id->vendor); libevdev_set_id_product(dev, id->product); + libevdev_set_id_version(dev, id->version); } abs = abs_info; From 82bb5841a2303b9bef2d6d390323aec5eb5dea45 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 28 Jan 2015 15:37:21 +1000 Subject: [PATCH 6/9] test: add a test device for the Lenovo X1 Carbon 3rd Notable: sends BTN_0/1/2 instead of the trackpoint This device currently has the INPUT_PROP_TOPBUTTONPAD property set, kernel patches [1] and [2] are pending to remove this. This test device already lacks the property. [1] https://patchwork.kernel.org/patch/5730371/ [2] https://patchwork.kernel.org/patch/5730451/ Signed-off-by: Peter Hutterer Reviewed-by: Hans de Goede --- test/Makefile.am | 1 + test/litest-synaptics-x1-carbon-3rd.c | 110 ++++++++++++++++++++++++++ test/litest.c | 2 + test/litest.h | 1 + 4 files changed, 114 insertions(+) create mode 100644 test/litest-synaptics-x1-carbon-3rd.c diff --git a/test/Makefile.am b/test/Makefile.am index 1b7ba870..5b9c7ab6 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -24,6 +24,7 @@ liblitest_la_SOURCES = \ litest-synaptics-hover.c \ litest-synaptics-st.c \ litest-synaptics-t440.c \ + litest-synaptics-x1-carbon-3rd.c \ litest-trackpoint.c \ litest-wacom-touch.c \ litest-xen-virtual-pointer.c \ diff --git a/test/litest-synaptics-x1-carbon-3rd.c b/test/litest-synaptics-x1-carbon-3rd.c new file mode 100644 index 00000000..7d9a57b3 --- /dev/null +++ b/test/litest-synaptics-x1-carbon-3rd.c @@ -0,0 +1,110 @@ +/* + * Copyright © 2015 Red Hat, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include "litest.h" +#include "litest-int.h" + +static void +litest_synaptics_carbon3rd_setup(void) +{ + struct litest_device *d = litest_create_device(LITEST_SYNAPTICS_TRACKPOINT_BUTTONS); + 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_PRESSURE, .value = 30 }, + { .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 = 0x11, + .vendor = 0x2, + .product = 0x7, +}; + +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, + EV_KEY, BTN_0, + EV_KEY, BTN_1, + EV_KEY, BTN_2, + INPUT_PROP_MAX, INPUT_PROP_POINTER, + INPUT_PROP_MAX, INPUT_PROP_BUTTONPAD, + -1, -1, +}; + +static struct input_absinfo absinfo[] = { + { ABS_X, 1266, 5676, 0, 0, 45 }, + { ABS_Y, 1096, 4758, 0, 0, 68 }, + { ABS_PRESSURE, 0, 255, 0, 0, 0 }, + { ABS_TOOL_WIDTH, 0, 15, 0, 0, 0 }, + { ABS_MT_SLOT, 0, 1, 0, 0, 0 }, + { ABS_MT_POSITION_X, 1266, 5676, 0, 0, 45 }, + { ABS_MT_POSITION_Y, 1096, 4758, 0, 0, 68 }, + { ABS_MT_TRACKING_ID, 0, 65535, 0, 0, 0 }, + { ABS_MT_PRESSURE, 0, 255, 0, 0, 0 }, + { .value = -1 } +}; + +struct litest_test_device litest_synaptics_carbon3rd_device = { + .type = LITEST_SYNAPTICS_TRACKPOINT_BUTTONS, + .features = LITEST_TOUCHPAD | LITEST_CLICKPAD | LITEST_BUTTON, + .shortname = "synaptics carbon3rd", + .setup = litest_synaptics_carbon3rd_setup, + .interface = &interface, + + .name = "SynPS/2 Synaptics TouchPad", + .id = &input_id, + .events = events, + .absinfo = absinfo, +}; diff --git a/test/litest.c b/test/litest.c index b5ce0a8f..2a336e9a 100644 --- a/test/litest.c +++ b/test/litest.c @@ -91,6 +91,7 @@ extern struct litest_test_device litest_qemu_tablet_device; extern struct litest_test_device litest_xen_virtual_pointer_device; extern struct litest_test_device litest_vmware_virtmouse_device; extern struct litest_test_device litest_synaptics_hover_device; +extern struct litest_test_device litest_synaptics_carbon3rd_device; struct litest_test_device* devices[] = { &litest_synaptics_clickpad_device, @@ -107,6 +108,7 @@ struct litest_test_device* devices[] = { &litest_xen_virtual_pointer_device, &litest_vmware_virtmouse_device, &litest_synaptics_hover_device, + &litest_synaptics_carbon3rd_device, NULL, }; diff --git a/test/litest.h b/test/litest.h index 2d4b4d8b..0625a71e 100644 --- a/test/litest.h +++ b/test/litest.h @@ -50,6 +50,7 @@ enum litest_device_type { LITEST_XEN_VIRTUAL_POINTER = -14, LITEST_VMWARE_VIRTMOUSE = -15, LITEST_SYNAPTICS_HOVER_SEMI_MT = -16, + LITEST_SYNAPTICS_TRACKPOINT_BUTTONS = -17, }; enum litest_device_feature { From 428614bb242a85a0b46f1a60bc822dbb47327b31 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 28 Jan 2015 15:38:00 +1000 Subject: [PATCH 7/9] touchpad: re-route trackpoint buttons on the *50 Lenovo series The laptops on this series have the physical trackpoint buttons back but wired them up to the touchpad instead of the trackpoint device and they appear as BTN_0, BTN_1 and BTN_2 for left, right, middle. The udev hwdb marks these for us with the TOUCHPAD_HAS_TRACKPOINT_BUTTONS tag [1]. Use that tag to identify them and re-route the events through the trackstick device after mangling the event codes to represent the actual buttons. [1] http://cgit.freedesktop.org/systemd/systemd/tree/hwdb/70-touchpad.hwdb Signed-off-by: Peter Hutterer Reviewed-by: Hans de Goede --- src/evdev-mt-touchpad.c | 44 +++++++++++++++++++++++++++++++++++++++++ src/evdev.h | 1 + 2 files changed, 45 insertions(+) diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index 5221be60..ae37ab17 100644 --- a/src/evdev-mt-touchpad.c +++ b/src/evdev-mt-touchpad.c @@ -349,6 +349,41 @@ tp_process_fake_touch(struct tp_dispatch *tp, } } +static void +tp_process_trackpoint_button(struct tp_dispatch *tp, + const struct input_event *e, + uint64_t time) +{ + struct evdev_dispatch *dispatch; + struct input_event event; + + if (!tp->buttons.trackpoint || + (tp->device->tags & EVDEV_TAG_TOUCHPAD_TRACKPOINT) == 0) + return; + + dispatch = tp->buttons.trackpoint->dispatch; + + event = *e; + + switch (event.code) { + case BTN_0: + event.code = BTN_LEFT; + break; + case BTN_1: + event.code = BTN_RIGHT; + break; + case BTN_2: + event.code = BTN_MIDDLE; + break; + default: + return; + } + + dispatch->interface->process(dispatch, + tp->buttons.trackpoint, + &event, time); +} + static void tp_process_key(struct tp_dispatch *tp, const struct input_event *e, @@ -367,6 +402,11 @@ tp_process_key(struct tp_dispatch *tp, case BTN_TOOL_QUADTAP: tp_process_fake_touch(tp, e, time); break; + case BTN_0: + case BTN_1: + case BTN_2: + tp_process_trackpoint_button(tp, e, time); + break; } } @@ -1063,6 +1103,10 @@ tp_tag_device(struct evdev_device *device, device->tags |= EVDEV_TAG_INTERNAL_TOUCHPAD; } else if (bustype != BUS_BLUETOOTH) device->tags |= EVDEV_TAG_INTERNAL_TOUCHPAD; + + if (udev_device_get_property_value(udev_device, + "TOUCHPAD_HAS_TRACKPOINT_BUTTONS")) + device->tags |= EVDEV_TAG_TOUCHPAD_TRACKPOINT; } static struct evdev_dispatch_interface tp_interface = { diff --git a/src/evdev.h b/src/evdev.h index 0f2c5acc..fc70a287 100644 --- a/src/evdev.h +++ b/src/evdev.h @@ -54,6 +54,7 @@ enum evdev_device_tags { EVDEV_TAG_EXTERNAL_MOUSE = (1 << 0), EVDEV_TAG_INTERNAL_TOUCHPAD = (1 << 1), EVDEV_TAG_TRACKPOINT = (1 << 2), + EVDEV_TAG_TOUCHPAD_TRACKPOINT = (1 << 3), }; struct mt_slot { From 149f711fcc54e37e10c11f22335623998401db01 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 28 Jan 2015 15:46:31 +1000 Subject: [PATCH 8/9] test: add tests for new lenovo touchpads Signed-off-by: Peter Hutterer Reviewed-by: Hans de Goede --- src/evdev-mt-touchpad.c | 6 + test/litest-synaptics-x1-carbon-3rd.c | 1 + test/touchpad.c | 291 ++++++++++++++++++++++++++ 3 files changed, 298 insertions(+) diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index ae37ab17..94cbc136 100644 --- a/src/evdev-mt-touchpad.c +++ b/src/evdev-mt-touchpad.c @@ -1107,6 +1107,12 @@ tp_tag_device(struct evdev_device *device, if (udev_device_get_property_value(udev_device, "TOUCHPAD_HAS_TRACKPOINT_BUTTONS")) device->tags |= EVDEV_TAG_TOUCHPAD_TRACKPOINT; + + /* Magic version tag: used by the litest device. Should never be set + * in real life but allows us to test for these features without + * requiring custom udev rules during make check */ + if (libevdev_get_id_version(device->evdev) == 0xfffa) + device->tags |= EVDEV_TAG_TOUCHPAD_TRACKPOINT; } static struct evdev_dispatch_interface tp_interface = { diff --git a/test/litest-synaptics-x1-carbon-3rd.c b/test/litest-synaptics-x1-carbon-3rd.c index 7d9a57b3..8be29e03 100644 --- a/test/litest-synaptics-x1-carbon-3rd.c +++ b/test/litest-synaptics-x1-carbon-3rd.c @@ -65,6 +65,7 @@ static struct input_id input_id = { .bustype = 0x11, .vendor = 0x2, .product = 0x7, + .version = 0xfffa, /* Magic value, used to detect this test device */ }; static int events[] = { diff --git a/test/touchpad.c b/test/touchpad.c index ab9a12e0..9c34b506 100644 --- a/test/touchpad.c +++ b/test/touchpad.c @@ -2959,6 +2959,290 @@ START_TEST(touchpad_hover_2fg_1fg_down) } END_TEST +static void +assert_btnevent_from_device(struct litest_device *device, + unsigned int button, + enum libinput_button_state state) +{ + struct libinput *li = device->libinput; + struct libinput_event *e; + struct libinput_event_pointer *pev; + + libinput_dispatch(li); + e = libinput_get_event(li); + ck_assert_notnull(e); + ck_assert_int_eq(libinput_event_get_type(e), + LIBINPUT_EVENT_POINTER_BUTTON); + pev = libinput_event_get_pointer_event(e); + + ck_assert_ptr_eq(libinput_event_get_device(e), device->libinput_device); + ck_assert_int_eq(libinput_event_pointer_get_button(pev), + button); + ck_assert_int_eq(libinput_event_pointer_get_button_state(pev), + state); + libinput_event_destroy(e); +} + + +START_TEST(touchpad_trackpoint_buttons) +{ + struct litest_device *touchpad = litest_current_device(); + struct litest_device *trackpoint; + struct libinput *li = touchpad->libinput; + + const struct buttons { + unsigned int device_value; + unsigned int real_value; + } buttons[] = { + { BTN_0, BTN_LEFT }, + { BTN_1, BTN_RIGHT }, + { BTN_2, BTN_MIDDLE }, + }; + const struct buttons *b; + + trackpoint = litest_add_device(li, + LITEST_TRACKPOINT); + libinput_device_config_scroll_set_method(trackpoint->libinput_device, + LIBINPUT_CONFIG_SCROLL_NO_SCROLL); + + litest_drain_events(li); + + ARRAY_FOR_EACH(buttons, b) { + litest_button_click(touchpad, b->device_value, true); + assert_btnevent_from_device(trackpoint, + b->real_value, + LIBINPUT_BUTTON_STATE_PRESSED); + + litest_button_click(touchpad, b->device_value, false); + + assert_btnevent_from_device(trackpoint, + b->real_value, + LIBINPUT_BUTTON_STATE_RELEASED); + } + + litest_delete_device(trackpoint); +} +END_TEST + +START_TEST(touchpad_trackpoint_mb_scroll) +{ + struct litest_device *touchpad = litest_current_device(); + struct litest_device *trackpoint; + struct libinput *li = touchpad->libinput; + + trackpoint = litest_add_device(li, + LITEST_TRACKPOINT); + + litest_drain_events(li); + litest_button_click(touchpad, BTN_2, true); /* middle */ + libinput_dispatch(li); + litest_timeout_buttonscroll(); + libinput_dispatch(li); + litest_event(trackpoint, EV_REL, REL_Y, -2); + litest_event(trackpoint, EV_SYN, SYN_REPORT, 0); + litest_event(trackpoint, EV_REL, REL_Y, -2); + litest_event(trackpoint, EV_SYN, SYN_REPORT, 0); + litest_event(trackpoint, EV_REL, REL_Y, -2); + litest_event(trackpoint, EV_SYN, SYN_REPORT, 0); + litest_event(trackpoint, EV_REL, REL_Y, -2); + litest_event(trackpoint, EV_SYN, SYN_REPORT, 0); + litest_button_click(touchpad, BTN_2, false); + + litest_assert_only_typed_events(li, + LIBINPUT_EVENT_POINTER_AXIS); + + litest_delete_device(trackpoint); +} +END_TEST + +START_TEST(touchpad_trackpoint_mb_click) +{ + struct litest_device *touchpad = litest_current_device(); + struct litest_device *trackpoint; + struct libinput *li = touchpad->libinput; + enum libinput_config_status status; + + trackpoint = litest_add_device(li, + LITEST_TRACKPOINT); + status = libinput_device_config_scroll_set_method( + trackpoint->libinput_device, + LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN); + ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS); + + litest_drain_events(li); + litest_button_click(touchpad, BTN_2, true); /* middle */ + litest_button_click(touchpad, BTN_2, false); + + assert_btnevent_from_device(trackpoint, + BTN_MIDDLE, + LIBINPUT_BUTTON_STATE_PRESSED); + assert_btnevent_from_device(trackpoint, + BTN_MIDDLE, + LIBINPUT_BUTTON_STATE_RELEASED); + litest_delete_device(trackpoint); +} +END_TEST + +START_TEST(touchpad_trackpoint_buttons_softbuttons) +{ + struct litest_device *touchpad = litest_current_device(); + struct litest_device *trackpoint; + struct libinput *li = touchpad->libinput; + + trackpoint = litest_add_device(li, + LITEST_TRACKPOINT); + + litest_drain_events(li); + + litest_touch_down(touchpad, 0, 95, 90); + litest_button_click(touchpad, BTN_LEFT, true); + litest_button_click(touchpad, BTN_1, true); + litest_button_click(touchpad, BTN_LEFT, false); + litest_touch_up(touchpad, 0); + litest_button_click(touchpad, BTN_1, false); + + assert_btnevent_from_device(touchpad, + BTN_RIGHT, + LIBINPUT_BUTTON_STATE_PRESSED); + assert_btnevent_from_device(trackpoint, + BTN_RIGHT, + LIBINPUT_BUTTON_STATE_PRESSED); + assert_btnevent_from_device(touchpad, + BTN_RIGHT, + LIBINPUT_BUTTON_STATE_RELEASED); + assert_btnevent_from_device(trackpoint, + BTN_RIGHT, + LIBINPUT_BUTTON_STATE_RELEASED); + + litest_touch_down(touchpad, 0, 95, 90); + litest_button_click(touchpad, BTN_LEFT, true); + litest_button_click(touchpad, BTN_1, true); + litest_button_click(touchpad, BTN_1, false); + litest_button_click(touchpad, BTN_LEFT, false); + litest_touch_up(touchpad, 0); + + assert_btnevent_from_device(touchpad, + BTN_RIGHT, + LIBINPUT_BUTTON_STATE_PRESSED); + assert_btnevent_from_device(trackpoint, + BTN_RIGHT, + LIBINPUT_BUTTON_STATE_PRESSED); + assert_btnevent_from_device(trackpoint, + BTN_RIGHT, + LIBINPUT_BUTTON_STATE_RELEASED); + assert_btnevent_from_device(touchpad, + BTN_RIGHT, + LIBINPUT_BUTTON_STATE_RELEASED); + + litest_delete_device(trackpoint); +} +END_TEST + +START_TEST(touchpad_trackpoint_buttons_2fg_scroll) +{ + struct litest_device *touchpad = litest_current_device(); + struct litest_device *trackpoint; + struct libinput *li = touchpad->libinput; + struct libinput_event *e; + struct libinput_event_pointer *pev; + double val; + + trackpoint = litest_add_device(li, + LITEST_TRACKPOINT); + + litest_drain_events(li); + + litest_touch_down(touchpad, 0, 40, 70); + litest_touch_down(touchpad, 1, 60, 70); + litest_touch_move_to(touchpad, 0, 40, 70, 40, 30, 10, 0); + litest_touch_move_to(touchpad, 1, 60, 70, 60, 30, 10, 0); + + libinput_dispatch(li); + litest_wait_for_event(li); + + /* Make sure we get scroll events but _not_ the scroll release */ + while ((e = libinput_get_event(li))) { + ck_assert_int_eq(libinput_event_get_type(e), + LIBINPUT_EVENT_POINTER_AXIS); + pev = libinput_event_get_pointer_event(e); + val = libinput_event_pointer_get_axis_value(pev, + LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL); + ck_assert(val != 0.0); + libinput_event_destroy(e); + } + + litest_button_click(touchpad, BTN_1, true); + assert_btnevent_from_device(trackpoint, + BTN_RIGHT, + LIBINPUT_BUTTON_STATE_PRESSED); + + litest_touch_move_to(touchpad, 0, 40, 30, 40, 70, 10, 0); + litest_touch_move_to(touchpad, 1, 60, 30, 60, 70, 10, 0); + + litest_assert_only_typed_events(li, + LIBINPUT_EVENT_POINTER_AXIS); + + while ((e = libinput_get_event(li))) { + ck_assert_int_eq(libinput_event_get_type(e), + LIBINPUT_EVENT_POINTER_AXIS); + pev = libinput_event_get_pointer_event(e); + val = libinput_event_pointer_get_axis_value(pev, + LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL); + ck_assert(val != 0.0); + libinput_event_destroy(e); + } + + litest_button_click(touchpad, BTN_1, false); + assert_btnevent_from_device(trackpoint, + BTN_RIGHT, + LIBINPUT_BUTTON_STATE_RELEASED); + + /* the movement lags behind the touch movement, so the first couple + events can be downwards even though we started scrolling up. do a + short scroll up, drain those events, then we can use + litest_assert_scroll() which tests for the trailing 0/0 scroll + for us. + */ + litest_touch_move_to(touchpad, 0, 40, 70, 40, 60, 10, 0); + litest_touch_move_to(touchpad, 1, 60, 70, 60, 60, 10, 0); + litest_assert_only_typed_events(li, + LIBINPUT_EVENT_POINTER_AXIS); + litest_touch_move_to(touchpad, 0, 40, 60, 40, 30, 10, 0); + litest_touch_move_to(touchpad, 1, 60, 60, 60, 30, 10, 0); + + litest_touch_up(touchpad, 0); + litest_touch_up(touchpad, 1); + + libinput_dispatch(li); + + litest_assert_scroll(li, + LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL, + -1); + + litest_delete_device(trackpoint); +} +END_TEST + +START_TEST(touchpad_trackpoint_no_trackpoint) +{ + struct litest_device *touchpad = litest_current_device(); + struct libinput *li = touchpad->libinput; + + litest_drain_events(li); + litest_button_click(touchpad, BTN_0, true); /* left */ + litest_button_click(touchpad, BTN_0, false); + litest_assert_empty_queue(li); + + litest_button_click(touchpad, BTN_1, true); /* right */ + litest_button_click(touchpad, BTN_1, false); + litest_assert_empty_queue(li); + + litest_button_click(touchpad, BTN_2, true); /* middle */ + litest_button_click(touchpad, BTN_2, false); + litest_assert_empty_queue(li); +} +END_TEST + int main(int argc, char **argv) { litest_add("touchpad:motion", touchpad_1fg_motion, LITEST_TOUCHPAD, LITEST_ANY); @@ -3067,5 +3351,12 @@ int main(int argc, char **argv) { litest_add_for_device("touchpad:hover", touchpad_hover_2fg_noevent, LITEST_SYNAPTICS_HOVER_SEMI_MT); litest_add_for_device("touchpad:hover", touchpad_hover_2fg_1fg_down, LITEST_SYNAPTICS_HOVER_SEMI_MT); + litest_add_for_device("touchpad:trackpoint", touchpad_trackpoint_buttons, LITEST_SYNAPTICS_TRACKPOINT_BUTTONS); + litest_add_for_device("touchpad:trackpoint", touchpad_trackpoint_mb_scroll, LITEST_SYNAPTICS_TRACKPOINT_BUTTONS); + litest_add_for_device("touchpad:trackpoint", touchpad_trackpoint_mb_click, LITEST_SYNAPTICS_TRACKPOINT_BUTTONS); + litest_add_for_device("touchpad:trackpoint", touchpad_trackpoint_buttons_softbuttons, LITEST_SYNAPTICS_TRACKPOINT_BUTTONS); + litest_add_for_device("touchpad:trackpoint", touchpad_trackpoint_buttons_2fg_scroll, LITEST_SYNAPTICS_TRACKPOINT_BUTTONS); + litest_add_for_device("touchpad:trackpoint", touchpad_trackpoint_no_trackpoint, LITEST_SYNAPTICS_TRACKPOINT_BUTTONS); + return litest_run(argc, argv); } From fd8a29fb692404ace405631012d0b708362b1fa0 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 30 Jan 2015 14:05:01 +1000 Subject: [PATCH 9/9] configure.ac: libinput 0.9.0 Signed-off-by: Peter Hutterer --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 1532e819..39e42d0f 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ AC_PREREQ([2.64]) m4_define([libinput_major_version], [0]) -m4_define([libinput_minor_version], [8]) +m4_define([libinput_minor_version], [9]) m4_define([libinput_micro_version], [0]) m4_define([libinput_version], [libinput_major_version.libinput_minor_version.libinput_micro_version]) @@ -30,7 +30,7 @@ AM_INIT_AUTOMAKE([1.11 foreign no-dist-gzip dist-xz]) # - If binary compatibility has been broken (eg removed or changed interfaces) # change to C+1:0:0 # - If the interface is the same as the previous version, change to C:R+1:A -LIBINPUT_LT_VERSION=7:0:0 +LIBINPUT_LT_VERSION=8:0:1 AC_SUBST(LIBINPUT_LT_VERSION) AM_SILENT_RULES([yes])