diff options
-rw-r--r-- | src/evdev-mt-touchpad-buttons.c | 15 | ||||
-rw-r--r-- | src/evdev-mt-touchpad.c | 6 | ||||
-rw-r--r-- | src/evdev.c | 1 | ||||
-rw-r--r-- | src/evdev.h | 1 | ||||
-rw-r--r-- | src/libinput-util.h | 1 | ||||
-rw-r--r-- | test/Makefile.am | 1 | ||||
-rw-r--r-- | test/litest-device-apple-appletouch.c | 115 | ||||
-rw-r--r-- | test/litest.c | 2 | ||||
-rw-r--r-- | test/litest.h | 1 | ||||
-rw-r--r-- | test/test-pointer.c | 4 | ||||
-rw-r--r-- | test/test-touchpad-buttons.c | 113 | ||||
-rw-r--r-- | test/test-touchpad.c | 30 | ||||
-rw-r--r-- | udev/90-libinput-model-quirks.hwdb | 3 |
13 files changed, 284 insertions, 9 deletions
diff --git a/src/evdev-mt-touchpad-buttons.c b/src/evdev-mt-touchpad-buttons.c index b53d2e4..44b81bf 100644 --- a/src/evdev-mt-touchpad-buttons.c +++ b/src/evdev-mt-touchpad-buttons.c @@ -637,6 +637,9 @@ tp_button_config_click_get_methods(struct libinput_device *device) methods |= LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER; } + if (evdev->model_flags & EVDEV_MODEL_APPLE_TOUCHPAD_ONEBUTTON) + methods |= LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER; + return methods; } @@ -695,16 +698,17 @@ tp_click_get_default_method(struct tp_dispatch *tp) EVDEV_MODEL_SYSTEM76_BONOBO | EVDEV_MODEL_SYSTEM76_GALAGO | EVDEV_MODEL_SYSTEM76_KUDU | - EVDEV_MODEL_CLEVO_W740SU; + EVDEV_MODEL_CLEVO_W740SU | + EVDEV_MODEL_APPLE_TOUCHPAD_ONEBUTTON; + + if (device->model_flags & clickfinger_models) + return LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER; if (!tp->buttons.is_clickpad) return LIBINPUT_CONFIG_CLICK_METHOD_NONE; else if (libevdev_get_id_vendor(tp->device->evdev) == VENDOR_ID_APPLE) return LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER; - if (device->model_flags & clickfinger_models) - return LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER; - return LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS; } @@ -1177,7 +1181,8 @@ tp_post_clickpadbutton_buttons(struct tp_dispatch *tp, uint64_t time) int tp_post_button_events(struct tp_dispatch *tp, uint64_t time) { - if (tp->buttons.is_clickpad) + if (tp->buttons.is_clickpad || + tp->device->model_flags & EVDEV_MODEL_APPLE_TOUCHPAD_ONEBUTTON) return tp_post_clickpadbutton_buttons(tp, time); else return tp_post_physical_buttons(tp, time); diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index e0500fe..c5eeeac 100644 --- a/src/evdev-mt-touchpad.c +++ b/src/evdev-mt-touchpad.c @@ -2544,6 +2544,7 @@ struct evdev_dispatch * evdev_mt_touchpad_create(struct evdev_device *device) { struct tp_dispatch *tp; + bool want_left_handed = true; evdev_tag_touchpad(device, device->udev_device); @@ -2564,7 +2565,10 @@ evdev_mt_touchpad_create(struct evdev_device *device) tp->sendevents.config.get_mode = tp_sendevents_get_mode; tp->sendevents.config.get_default_mode = tp_sendevents_get_default_mode; - evdev_init_left_handed(device, tp_change_to_left_handed); + if (device->model_flags & EVDEV_MODEL_APPLE_TOUCHPAD_ONEBUTTON) + want_left_handed = false; + if (want_left_handed) + evdev_init_left_handed(device, tp_change_to_left_handed); return &tp->base; } diff --git a/src/evdev.c b/src/evdev.c index afee590..246352a 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -2244,6 +2244,7 @@ evdev_read_model_flags(struct evdev_device *device) MODEL(HP6910_TOUCHPAD), MODEL(HP_ZBOOK_STUDIO_G3), MODEL(HP_PAVILION_DM4_TOUCHPAD), + MODEL(APPLE_TOUCHPAD_ONEBUTTON), #undef MODEL { "ID_INPUT_TRACKBALL", EVDEV_MODEL_TRACKBALL }, { NULL, EVDEV_MODEL_DEFAULT }, diff --git a/src/evdev.h b/src/evdev.h index 1a24d4b..967feaf 100644 --- a/src/evdev.h +++ b/src/evdev.h @@ -125,6 +125,7 @@ enum evdev_device_model { EVDEV_MODEL_HP6910_TOUCHPAD = (1 << 22), EVDEV_MODEL_HP_ZBOOK_STUDIO_G3 = (1 << 23), EVDEV_MODEL_HP_PAVILION_DM4_TOUCHPAD = (1 << 24), + EVDEV_MODEL_APPLE_TOUCHPAD_ONEBUTTON = (1 << 25), }; struct mt_slot { diff --git a/src/libinput-util.h b/src/libinput-util.h index 1d03ce1..1bad149 100644 --- a/src/libinput-util.h +++ b/src/libinput-util.h @@ -47,6 +47,7 @@ #define VENDOR_ID_WACOM 0x56a #define VENDOR_ID_SYNAPTICS_SERIAL 0x002 #define PRODUCT_ID_APPLE_KBD_TOUCHPAD 0x273 +#define PRODUCT_ID_APPLE_APPLETOUCH 0x21a #define PRODUCT_ID_SYNAPTICS_SERIAL 0x007 /* The HW DPI rate we normalize to before calculating pointer acceleration */ diff --git a/test/Makefile.am b/test/Makefile.am index 2e565de..1ff1406 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -19,6 +19,7 @@ liblitest_la_SOURCES = \ litest-device-alps-semi-mt.c \ litest-device-alps-dualpoint.c \ litest-device-anker-mouse-kbd.c \ + litest-device-apple-appletouch.c \ litest-device-apple-internal-keyboard.c \ litest-device-apple-magicmouse.c \ litest-device-asus-rog-gladius.c \ diff --git a/test/litest-device-apple-appletouch.c b/test/litest-device-apple-appletouch.c new file mode 100644 index 0000000..08c0768 --- /dev/null +++ b/test/litest-device-apple-appletouch.c @@ -0,0 +1,115 @@ +/* + * Copyright © 2017 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_appletouch_setup(void) +{ + struct litest_device *d = litest_create_device(LITEST_APPLETOUCH); + 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 = 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_X, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN }, + { .type = EV_SYN, .code = SYN_REPORT, .value = 0 }, + { .type = -1, .code = -1 }, +}; + +static int +get_axis_default(struct litest_device *d, unsigned int evcode, int32_t *value) +{ + switch (evcode) { + case ABS_PRESSURE: + case ABS_MT_PRESSURE: + *value = 70; + return 0; + } + return 1; +} + +static struct litest_device_interface interface = { + .touch_down_events = down, + .touch_move_events = move, + + .get_axis_default = get_axis_default, +}; + +static struct input_id input_id = { + .bustype = 0x03, + .vendor = 0x5ac, + .product = 0x21a, +}; + +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, + -1, -1, +}; + +static struct input_absinfo absinfo[] = { + { ABS_X, 0, 1215, 0, 0, 0 }, + { ABS_Y, 0, 588, 0, 0, 0 }, + { ABS_PRESSURE, 0, 300, 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 appletouch\"," +" ENV{LIBINPUT_MODEL_APPLE_TOUCHPAD_ONEBUTTON}=\"1\"\n" +"\n" +"LABEL=\"touchpad_end\""; + +struct litest_test_device litest_appletouch_device = { + .type = LITEST_APPLETOUCH, + .features = LITEST_TOUCHPAD | LITEST_BUTTON | LITEST_SINGLE_TOUCH, + .shortname = "appletouch", + .setup = litest_appletouch_setup, + .interface = &interface, + + .name = "appletouch", + .id = &input_id, + .events = events, + .absinfo = absinfo, + .udev_rule = udev_rule, +}; diff --git a/test/litest.c b/test/litest.c index 78ef5df..aa7b8a4 100644 --- a/test/litest.c +++ b/test/litest.c @@ -410,6 +410,7 @@ extern struct litest_test_device litest_synaptics_rmi4_device; extern struct litest_test_device litest_mouse_wheel_tilt_device; extern struct litest_test_device litest_lid_switch_device; extern struct litest_test_device litest_lid_switch_surface3_device; +extern struct litest_test_device litest_appletouch_device; struct litest_test_device* devices[] = { &litest_synaptics_clickpad_device, @@ -474,6 +475,7 @@ struct litest_test_device* devices[] = { &litest_mouse_wheel_tilt_device, &litest_lid_switch_device, &litest_lid_switch_surface3_device, + &litest_appletouch_device, NULL, }; diff --git a/test/litest.h b/test/litest.h index d6b0ef0..00180e7 100644 --- a/test/litest.h +++ b/test/litest.h @@ -231,6 +231,7 @@ enum litest_device_type { LITEST_MOUSE_WHEEL_TILT, LITEST_LID_SWITCH, LITEST_LID_SWITCH_SURFACE3, + LITEST_APPLETOUCH, }; enum litest_device_feature { diff --git a/test/test-pointer.c b/test/test-pointer.c index 2689e4e..aba5fd2 100644 --- a/test/test-pointer.c +++ b/test/test-pointer.c @@ -847,6 +847,10 @@ START_TEST(pointer_left_handed_defaults) struct libinput_device *d = dev->libinput_device; int rc; + if (libevdev_get_id_vendor(dev->evdev) == VENDOR_ID_APPLE && + libevdev_get_id_product(dev->evdev) == PRODUCT_ID_APPLE_APPLETOUCH) + return; + rc = libinput_device_config_left_handed_is_available(d); ck_assert_int_ne(rc, 0); diff --git a/test/test-touchpad-buttons.c b/test/test-touchpad-buttons.c index 2beb637..63d02f2 100644 --- a/test/test-touchpad-buttons.c +++ b/test/test-touchpad-buttons.c @@ -93,6 +93,10 @@ START_TEST(touchpad_click_defaults_none) uint32_t methods, method; enum libinput_config_status status; + if (libevdev_get_id_vendor(dev->evdev) == VENDOR_ID_APPLE && + libevdev_get_id_product(dev->evdev) == PRODUCT_ID_APPLE_APPLETOUCH) + return; + /* call this test for non-clickpads */ methods = libinput_device_config_click_get_methods(device); @@ -828,6 +832,110 @@ START_TEST(touchpad_clickfinger_4fg_tool_position) } END_TEST +START_TEST(touchpad_clickfinger_appletouch_config) +{ + struct litest_device *dev = litest_current_device(); + struct libinput_device *device = dev->libinput_device; + uint32_t methods, method; + enum libinput_config_status status; + + methods = libinput_device_config_click_get_methods(device); + ck_assert(!(methods & LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS)); + ck_assert(methods & LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER); + + method = libinput_device_config_click_get_method(device); + ck_assert_int_eq(method, LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER); + + status = libinput_device_config_click_set_method(device, + LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS); + ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_UNSUPPORTED); + status = libinput_device_config_click_set_method(device, + LIBINPUT_CONFIG_CLICK_METHOD_NONE); + ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS); +} +END_TEST + +START_TEST(touchpad_clickfinger_appletouch_1fg) +{ + struct litest_device *dev = litest_current_device(); + struct libinput *li = dev->libinput; + + litest_enable_clickfinger(dev); + + litest_drain_events(li); + + litest_touch_down(dev, 0, 50, 50); + litest_event(dev, EV_KEY, BTN_LEFT, 1); + litest_event(dev, EV_SYN, SYN_REPORT, 0); + litest_event(dev, EV_KEY, BTN_LEFT, 0); + litest_event(dev, EV_SYN, SYN_REPORT, 0); + litest_touch_up(dev, 0); + + libinput_dispatch(li); + + litest_assert_button_event(li, BTN_LEFT, + LIBINPUT_BUTTON_STATE_PRESSED); + litest_assert_button_event(li, BTN_LEFT, + LIBINPUT_BUTTON_STATE_RELEASED); +} +END_TEST + +START_TEST(touchpad_clickfinger_appletouch_2fg) +{ + struct litest_device *dev = litest_current_device(); + struct libinput *li = dev->libinput; + + litest_enable_clickfinger(dev); + + litest_drain_events(li); + + litest_touch_down(dev, 0, 50, 50); + litest_touch_down(dev, 1, 50, 50); + litest_event(dev, EV_KEY, BTN_LEFT, 1); + litest_event(dev, EV_SYN, SYN_REPORT, 0); + litest_event(dev, EV_KEY, BTN_LEFT, 0); + litest_event(dev, EV_SYN, SYN_REPORT, 0); + litest_touch_up(dev, 0); + litest_touch_up(dev, 1); + + libinput_dispatch(li); + + litest_assert_button_event(li, BTN_RIGHT, + LIBINPUT_BUTTON_STATE_PRESSED); + litest_assert_button_event(li, BTN_RIGHT, + LIBINPUT_BUTTON_STATE_RELEASED); +} +END_TEST + +START_TEST(touchpad_clickfinger_appletouch_3fg) +{ + struct litest_device *dev = litest_current_device(); + struct libinput *li = dev->libinput; + + litest_enable_clickfinger(dev); + + litest_drain_events(li); + + litest_touch_down(dev, 0, 50, 50); + litest_touch_down(dev, 1, 50, 50); + litest_touch_down(dev, 2, 50, 50); + litest_event(dev, EV_KEY, BTN_LEFT, 1); + litest_event(dev, EV_SYN, SYN_REPORT, 0); + litest_event(dev, EV_KEY, BTN_LEFT, 0); + litest_event(dev, EV_SYN, SYN_REPORT, 0); + litest_touch_up(dev, 0); + litest_touch_up(dev, 1); + litest_touch_up(dev, 2); + + libinput_dispatch(li); + + litest_assert_button_event(li, BTN_MIDDLE, + LIBINPUT_BUTTON_STATE_PRESSED); + litest_assert_button_event(li, BTN_MIDDLE, + LIBINPUT_BUTTON_STATE_RELEASED); +} +END_TEST + START_TEST(touchpad_btn_left) { struct litest_device *dev = litest_current_device(); @@ -1830,6 +1938,11 @@ litest_setup_tests_touchpad_buttons(void) litest_add_for_device("touchpad:clickfinger", touchpad_clickfinger_3fg_tool_position, LITEST_SYNAPTICS_TOPBUTTONPAD); litest_add_for_device("touchpad:clickfinger", touchpad_clickfinger_4fg_tool_position, LITEST_SYNAPTICS_TOPBUTTONPAD); + litest_add_for_device("touchpad:clickfinger", touchpad_clickfinger_appletouch_config, LITEST_APPLETOUCH); + litest_add_for_device("touchpad:clickfinger", touchpad_clickfinger_appletouch_1fg, LITEST_APPLETOUCH); + litest_add_for_device("touchpad:clickfinger", touchpad_clickfinger_appletouch_2fg, LITEST_APPLETOUCH); + litest_add_for_device("touchpad:clickfinger", touchpad_clickfinger_appletouch_3fg, LITEST_APPLETOUCH); + litest_add("touchpad:click", touchpad_click_defaults_clickfinger, LITEST_APPLE_CLICKPAD, LITEST_ANY); litest_add("touchpad:click", touchpad_click_defaults_btnarea, LITEST_CLICKPAD, LITEST_APPLE_CLICKPAD); litest_add("touchpad:click", touchpad_click_defaults_none, LITEST_TOUCHPAD, LITEST_CLICKPAD); diff --git a/test/test-touchpad.c b/test/test-touchpad.c index ec738e9..aca9f7b 100644 --- a/test/test-touchpad.c +++ b/test/test-touchpad.c @@ -556,15 +556,21 @@ START_TEST(touchpad_scroll_defaults) struct libevdev *evdev = dev->evdev; enum libinput_config_scroll_method method, expected; enum libinput_config_status status; + bool should_have_2fg = false; + + if (libevdev_get_num_slots(evdev) > 1 || + (libevdev_get_id_vendor(dev->evdev) == VENDOR_ID_APPLE && + libevdev_get_id_product(dev->evdev) == PRODUCT_ID_APPLE_APPLETOUCH)) + should_have_2fg = true; method = libinput_device_config_scroll_get_methods(device); ck_assert(method & LIBINPUT_CONFIG_SCROLL_EDGE); - if (libevdev_get_num_slots(evdev) > 1) + if (should_have_2fg) ck_assert(method & LIBINPUT_CONFIG_SCROLL_2FG); else ck_assert((method & LIBINPUT_CONFIG_SCROLL_2FG) == 0); - if (libevdev_get_num_slots(evdev) > 1) + if (should_have_2fg) expected = LIBINPUT_CONFIG_SCROLL_2FG; else expected = LIBINPUT_CONFIG_SCROLL_EDGE; @@ -580,7 +586,7 @@ START_TEST(touchpad_scroll_defaults) status = libinput_device_config_scroll_set_method(device, LIBINPUT_CONFIG_SCROLL_2FG); - if (libevdev_get_num_slots(evdev) > 1) + if (should_have_2fg) ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS); else ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_UNSUPPORTED); @@ -1290,6 +1296,10 @@ START_TEST(touchpad_left_handed) struct libinput *li = dev->libinput; enum libinput_config_status status; + if (libevdev_get_id_vendor(dev->evdev) == VENDOR_ID_APPLE && + libevdev_get_id_product(dev->evdev) == PRODUCT_ID_APPLE_APPLETOUCH) + return; + status = libinput_device_config_left_handed_set(d, 1); ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS); @@ -1328,6 +1338,19 @@ START_TEST(touchpad_left_handed) } END_TEST +START_TEST(touchpad_left_handed_appletouch) +{ + struct litest_device *dev = litest_current_device(); + struct libinput_device *d = dev->libinput_device; + enum libinput_config_status status; + + ck_assert_int_eq(libinput_device_config_left_handed_is_available(d), 0); + status = libinput_device_config_left_handed_set(d, 1); + ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_UNSUPPORTED); + ck_assert_int_eq(libinput_device_config_left_handed_get(d), 0); +} +END_TEST + START_TEST(touchpad_left_handed_clickpad) { struct litest_device *dev = litest_current_device(); @@ -4962,6 +4985,7 @@ litest_setup_tests_touchpad(void) litest_add("touchpad:palm", touchpad_palm_detect_both_edges, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH); litest_add("touchpad:left-handed", touchpad_left_handed, LITEST_TOUCHPAD|LITEST_BUTTON, LITEST_CLICKPAD); + litest_add_for_device("touchpad:left-handed", touchpad_left_handed_appletouch, LITEST_APPLETOUCH); litest_add("touchpad:left-handed", touchpad_left_handed_clickpad, LITEST_CLICKPAD, LITEST_APPLE_CLICKPAD); litest_add("touchpad:left-handed", touchpad_left_handed_clickfinger, LITEST_APPLE_CLICKPAD, LITEST_ANY); litest_add("touchpad:left-handed", touchpad_left_handed_tapping, LITEST_TOUCHPAD, LITEST_ANY); diff --git a/udev/90-libinput-model-quirks.hwdb b/udev/90-libinput-model-quirks.hwdb index 86eea0d..412d872 100644 --- a/udev/90-libinput-model-quirks.hwdb +++ b/udev/90-libinput-model-quirks.hwdb @@ -50,6 +50,9 @@ libinput:name:*Apple Inc. Apple Internal Keyboard*:dmi:* libinput:mouse:input:b0005v05ACp030D* LIBINPUT_MODEL_APPLE_MAGICMOUSE=1 +libinput:touchpad:input:b0003v05ACp021A* + LIBINPUT_MODEL_APPLE_TOUCHPAD_ONEBUTTON=1 + ########################################## # Asus ########################################## |