• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2014 Red Hat, Inc.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21  * DEALINGS IN THE SOFTWARE.
22  */
23 
24 #include <config.h>
25 
26 #include <check.h>
27 #include <errno.h>
28 #include <fcntl.h>
29 #include <libinput.h>
30 #include <unistd.h>
31 
32 #include "libinput-util.h"
33 #include "litest.h"
34 
START_TEST(touchpad_button)35 START_TEST(touchpad_button)
36 {
37 	struct litest_device *dev = litest_current_device();
38 	struct libinput *li = dev->libinput;
39 
40 	if (!libevdev_has_event_code(dev->evdev, EV_KEY, BTN_LEFT))
41 		return;
42 
43 	litest_drain_events(li);
44 
45 	litest_button_click(dev, BTN_LEFT, true);
46 	libinput_dispatch(li);
47 	litest_assert_button_event(li,
48 				   BTN_LEFT,
49 				   LIBINPUT_BUTTON_STATE_PRESSED);
50 	litest_button_click(dev, BTN_LEFT, false);
51 	libinput_dispatch(li);
52 	litest_assert_button_event(li,
53 				   BTN_LEFT,
54 				   LIBINPUT_BUTTON_STATE_RELEASED);
55 }
56 END_TEST
57 
START_TEST(touchpad_click_defaults_clickfinger)58 START_TEST(touchpad_click_defaults_clickfinger)
59 {
60 	struct litest_device *dev = litest_current_device();
61 	struct libinput_device *device = dev->libinput_device;
62 	uint32_t methods, method;
63 	enum libinput_config_status status;
64 
65 	/* call this test for apple touchpads */
66 
67 	methods = libinput_device_config_click_get_methods(device);
68 	ck_assert(methods & LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS);
69 	ck_assert(methods & LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER);
70 
71 	method = libinput_device_config_click_get_method(device);
72 	ck_assert_int_eq(method, LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER);
73 	method = libinput_device_config_click_get_default_method(device);
74 	ck_assert_int_eq(method, LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER);
75 
76 	status = libinput_device_config_click_set_method(device,
77 							 LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS);
78 	ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
79 	status = libinput_device_config_click_set_method(device,
80 							 LIBINPUT_CONFIG_CLICK_METHOD_NONE);
81 	ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
82 }
83 END_TEST
84 
START_TEST(touchpad_click_defaults_btnarea)85 START_TEST(touchpad_click_defaults_btnarea)
86 {
87 	struct litest_device *dev = litest_current_device();
88 	struct libinput_device *device = dev->libinput_device;
89 	uint32_t methods, method;
90 	enum libinput_config_status status;
91 
92 	/* call this test for non-apple clickpads */
93 
94 	methods = libinput_device_config_click_get_methods(device);
95 	ck_assert(methods & LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER);
96 	ck_assert(methods & LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS);
97 
98 	method = libinput_device_config_click_get_method(device);
99 	ck_assert_int_eq(method,  LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS);
100 	method = libinput_device_config_click_get_default_method(device);
101 	ck_assert_int_eq(method,  LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS);
102 
103 	status = libinput_device_config_click_set_method(device,
104 							 LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER);
105 	ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
106 	status = libinput_device_config_click_set_method(device,
107 							 LIBINPUT_CONFIG_CLICK_METHOD_NONE);
108 	ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
109 }
110 END_TEST
111 
START_TEST(touchpad_click_defaults_none)112 START_TEST(touchpad_click_defaults_none)
113 {
114 	struct litest_device *dev = litest_current_device();
115 	struct libinput_device *device = dev->libinput_device;
116 	uint32_t methods, method;
117 	enum libinput_config_status status;
118 
119 	if (libevdev_get_id_vendor(dev->evdev) == VENDOR_ID_APPLE &&
120 	    libevdev_get_id_product(dev->evdev) == PRODUCT_ID_APPLE_APPLETOUCH)
121 		return;
122 
123 	/* call this test for non-clickpads and non-touchpads */
124 
125 	methods = libinput_device_config_click_get_methods(device);
126 	ck_assert_int_eq(methods, 0);
127 
128 	method = libinput_device_config_click_get_method(device);
129 	ck_assert_int_eq(method, LIBINPUT_CONFIG_CLICK_METHOD_NONE);
130 	method = libinput_device_config_click_get_default_method(device);
131 	ck_assert_int_eq(method, LIBINPUT_CONFIG_CLICK_METHOD_NONE);
132 
133 	status = libinput_device_config_click_set_method(device,
134 							 LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER);
135 	ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_UNSUPPORTED);
136 	status = libinput_device_config_click_set_method(device,
137 							 LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS);
138 	ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_UNSUPPORTED);
139 }
140 END_TEST
141 
START_TEST(touchpad_1fg_clickfinger)142 START_TEST(touchpad_1fg_clickfinger)
143 {
144 	struct litest_device *dev = litest_current_device();
145 	struct libinput *li = dev->libinput;
146 
147 	litest_enable_clickfinger(dev);
148 
149 	litest_drain_events(li);
150 
151 	litest_touch_down(dev, 0, 50, 50);
152 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
153 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
154 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
155 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
156 	litest_touch_up(dev, 0);
157 
158 	libinput_dispatch(li);
159 
160 	litest_assert_button_event(li, BTN_LEFT,
161 				   LIBINPUT_BUTTON_STATE_PRESSED);
162 	litest_assert_button_event(li, BTN_LEFT,
163 				   LIBINPUT_BUTTON_STATE_RELEASED);
164 }
165 END_TEST
166 
START_TEST(touchpad_1fg_clickfinger_no_touch)167 START_TEST(touchpad_1fg_clickfinger_no_touch)
168 {
169 	struct litest_device *dev = litest_current_device();
170 	struct libinput *li = dev->libinput;
171 
172 	litest_enable_clickfinger(dev);
173 
174 	litest_drain_events(li);
175 
176 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
177 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
178 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
179 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
180 
181 	libinput_dispatch(li);
182 
183 	litest_assert_button_event(li, BTN_LEFT,
184 				   LIBINPUT_BUTTON_STATE_PRESSED);
185 	litest_assert_button_event(li, BTN_LEFT,
186 				   LIBINPUT_BUTTON_STATE_RELEASED);
187 }
188 END_TEST
189 
START_TEST(touchpad_2fg_clickfinger)190 START_TEST(touchpad_2fg_clickfinger)
191 {
192 	struct litest_device *dev = litest_current_device();
193 	struct libinput *li = dev->libinput;
194 
195 	litest_enable_clickfinger(dev);
196 
197 	litest_drain_events(li);
198 
199 	litest_touch_down(dev, 0, 50, 50);
200 	litest_touch_down(dev, 1, 70, 70);
201 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
202 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
203 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
204 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
205 	litest_touch_up(dev, 0);
206 	litest_touch_up(dev, 1);
207 
208 	libinput_dispatch(li);
209 
210 	litest_assert_button_event(li, BTN_RIGHT,
211 				   LIBINPUT_BUTTON_STATE_PRESSED);
212 	litest_assert_button_event(li, BTN_RIGHT,
213 				   LIBINPUT_BUTTON_STATE_RELEASED);
214 }
215 END_TEST
216 
START_TEST(touchpad_3fg_clickfinger)217 START_TEST(touchpad_3fg_clickfinger)
218 {
219 	struct litest_device *dev = litest_current_device();
220 	struct libinput *li = dev->libinput;
221 
222 	if (litest_slot_count(dev) < 3)
223 		return;
224 
225 	litest_enable_clickfinger(dev);
226 
227 	litest_drain_events(li);
228 
229 	litest_touch_down(dev, 0, 50, 50);
230 	litest_touch_down(dev, 1, 60, 70);
231 	litest_touch_down(dev, 2, 70, 70);
232 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
233 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
234 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
235 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
236 	litest_touch_up(dev, 0);
237 	litest_touch_up(dev, 1);
238 	litest_touch_up(dev, 2);
239 
240 	libinput_dispatch(li);
241 
242 	litest_assert_button_event(li,
243 				   BTN_MIDDLE,
244 				   LIBINPUT_BUTTON_STATE_PRESSED);
245 	litest_assert_button_event(li,
246 				   BTN_MIDDLE,
247 				   LIBINPUT_BUTTON_STATE_RELEASED);
248 }
249 END_TEST
250 
START_TEST(touchpad_3fg_clickfinger_btntool)251 START_TEST(touchpad_3fg_clickfinger_btntool)
252 {
253 	struct litest_device *dev = litest_current_device();
254 	struct libinput *li = dev->libinput;
255 
256 	if (litest_slot_count(dev) >= 3 ||
257 	    !libevdev_has_event_code(dev->evdev, EV_KEY, BTN_TOOL_TRIPLETAP))
258 		return;
259 
260 	litest_enable_clickfinger(dev);
261 
262 	litest_drain_events(li);
263 
264 	litest_touch_down(dev, 0, 50, 50);
265 	litest_touch_down(dev, 1, 60, 70);
266 	litest_event(dev, EV_KEY, BTN_TOOL_DOUBLETAP, 0);
267 	litest_event(dev, EV_KEY, BTN_TOOL_TRIPLETAP, 1);
268 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
269 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
270 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
271 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
272 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
273 	litest_event(dev, EV_KEY, BTN_TOOL_DOUBLETAP, 1);
274 	litest_event(dev, EV_KEY, BTN_TOOL_TRIPLETAP, 0);
275 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
276 	litest_touch_up(dev, 0);
277 	litest_touch_up(dev, 1);
278 
279 	libinput_dispatch(li);
280 
281 	litest_assert_button_event(li,
282 				   BTN_MIDDLE,
283 				   LIBINPUT_BUTTON_STATE_PRESSED);
284 	litest_assert_button_event(li,
285 				   BTN_MIDDLE,
286 				   LIBINPUT_BUTTON_STATE_RELEASED);
287 }
288 END_TEST
289 
START_TEST(touchpad_4fg_clickfinger)290 START_TEST(touchpad_4fg_clickfinger)
291 {
292 	struct litest_device *dev = litest_current_device();
293 	struct libinput *li = dev->libinput;
294 	struct libinput_event *event;
295 
296 	if (litest_slot_count(dev) < 4)
297 		return;
298 
299 	litest_enable_clickfinger(dev);
300 
301 	litest_drain_events(li);
302 
303 	litest_touch_down(dev, 0, 50, 50);
304 	litest_touch_down(dev, 1, 60, 70);
305 	litest_touch_down(dev, 2, 70, 70);
306 	litest_touch_down(dev, 3, 80, 70);
307 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
308 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
309 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
310 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
311 	litest_touch_up(dev, 0);
312 	litest_touch_up(dev, 1);
313 	litest_touch_up(dev, 2);
314 	litest_touch_up(dev, 3);
315 
316 	libinput_dispatch(li);
317 
318 	litest_wait_for_event(li);
319 	event = libinput_get_event(li);
320 	litest_is_button_event(event,
321 			       BTN_MIDDLE,
322 			       LIBINPUT_BUTTON_STATE_PRESSED);
323 	libinput_event_destroy(event);
324 	event = libinput_get_event(li);
325 	litest_is_button_event(event,
326 			       BTN_MIDDLE,
327 			       LIBINPUT_BUTTON_STATE_RELEASED);
328 	libinput_event_destroy(event);
329 
330 	litest_assert_empty_queue(li);
331 }
332 END_TEST
333 
START_TEST(touchpad_4fg_clickfinger_btntool_2slots)334 START_TEST(touchpad_4fg_clickfinger_btntool_2slots)
335 {
336 	struct litest_device *dev = litest_current_device();
337 	struct libinput *li = dev->libinput;
338 	struct libinput_event *event;
339 
340 	if (litest_slot_count(dev) >= 3 ||
341 	    !libevdev_has_event_code(dev->evdev, EV_KEY, BTN_TOOL_QUADTAP))
342 		return;
343 
344 	litest_enable_clickfinger(dev);
345 
346 	litest_drain_events(li);
347 
348 	litest_touch_down(dev, 0, 50, 50);
349 	litest_touch_down(dev, 1, 60, 70);
350 	litest_event(dev, EV_KEY, BTN_TOOL_DOUBLETAP, 0);
351 	litest_event(dev, EV_KEY, BTN_TOOL_QUADTAP, 1);
352 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
353 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
354 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
355 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
356 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
357 	litest_event(dev, EV_KEY, BTN_TOOL_DOUBLETAP, 1);
358 	litest_event(dev, EV_KEY, BTN_TOOL_QUADTAP, 0);
359 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
360 	litest_touch_up(dev, 0);
361 	litest_touch_up(dev, 1);
362 
363 	litest_wait_for_event(li);
364 	event = libinput_get_event(li);
365 	litest_is_button_event(event,
366 			       BTN_MIDDLE,
367 			       LIBINPUT_BUTTON_STATE_PRESSED);
368 	libinput_event_destroy(event);
369 	event = libinput_get_event(li);
370 	litest_is_button_event(event,
371 			       BTN_MIDDLE,
372 			       LIBINPUT_BUTTON_STATE_RELEASED);
373 	libinput_event_destroy(event);
374 
375 	litest_assert_empty_queue(li);
376 }
377 END_TEST
378 
START_TEST(touchpad_4fg_clickfinger_btntool_3slots)379 START_TEST(touchpad_4fg_clickfinger_btntool_3slots)
380 {
381 	struct litest_device *dev = litest_current_device();
382 	struct libinput *li = dev->libinput;
383 	struct libinput_event *event;
384 
385 	if (litest_slot_count(dev) != 3 ||
386 	    !libevdev_has_event_code(dev->evdev, EV_KEY, BTN_TOOL_TRIPLETAP))
387 		return;
388 
389 	litest_enable_clickfinger(dev);
390 
391 	litest_drain_events(li);
392 
393 	litest_touch_down(dev, 0, 50, 50);
394 	litest_touch_down(dev, 1, 60, 70);
395 	litest_touch_down(dev, 2, 70, 70);
396 	litest_event(dev, EV_KEY, BTN_TOOL_TRIPLETAP, 0);
397 	litest_event(dev, EV_KEY, BTN_TOOL_QUADTAP, 1);
398 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
399 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
400 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
401 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
402 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
403 	litest_event(dev, EV_KEY, BTN_TOOL_TRIPLETAP, 1);
404 	litest_event(dev, EV_KEY, BTN_TOOL_QUADTAP, 0);
405 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
406 	litest_touch_up(dev, 0);
407 	litest_touch_up(dev, 1);
408 	litest_touch_up(dev, 2);
409 
410 	libinput_dispatch(li);
411 
412 	litest_wait_for_event(li);
413 	event = libinput_get_event(li);
414 	litest_is_button_event(event,
415 			       BTN_MIDDLE,
416 			       LIBINPUT_BUTTON_STATE_PRESSED);
417 	libinput_event_destroy(event);
418 	event = libinput_get_event(li);
419 	litest_is_button_event(event,
420 			       BTN_MIDDLE,
421 			       LIBINPUT_BUTTON_STATE_RELEASED);
422 	libinput_event_destroy(event);
423 
424 	litest_assert_empty_queue(li);
425 }
426 END_TEST
427 
START_TEST(touchpad_2fg_clickfinger_distance)428 START_TEST(touchpad_2fg_clickfinger_distance)
429 {
430 	struct litest_device *dev = litest_current_device();
431 	struct libinput *li = dev->libinput;
432 	double w, h;
433 	bool small_touchpad = false;
434 	unsigned int expected_button;
435 
436 	if (libinput_device_get_size(dev->libinput_device, &w, &h) == 0 &&
437 	    h < 50.0)
438 		small_touchpad = true;
439 
440 	litest_enable_clickfinger(dev);
441 
442 	litest_drain_events(li);
443 
444 	litest_touch_down(dev, 0, 90, 50);
445 	litest_touch_down(dev, 1, 10, 50);
446 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
447 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
448 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
449 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
450 	litest_touch_up(dev, 0);
451 	litest_touch_up(dev, 1);
452 
453 	litest_assert_button_event(li,
454 				   BTN_LEFT,
455 				   LIBINPUT_BUTTON_STATE_PRESSED);
456 	litest_assert_button_event(li,
457 				   BTN_LEFT,
458 				   LIBINPUT_BUTTON_STATE_RELEASED);
459 
460 	litest_assert_empty_queue(li);
461 
462 	litest_touch_down(dev, 0, 50, 5);
463 	litest_touch_down(dev, 1, 50, 95);
464 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
465 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
466 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
467 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
468 	litest_touch_up(dev, 0);
469 	litest_touch_up(dev, 1);
470 
471 	/* if the touchpad is small enough, we expect all fingers to count
472 	 * for clickfinger */
473 	if (small_touchpad)
474 		expected_button = BTN_RIGHT;
475 	else
476 		expected_button = BTN_LEFT;
477 
478 	litest_assert_button_event(li,
479 				   expected_button,
480 				   LIBINPUT_BUTTON_STATE_PRESSED);
481 	litest_assert_button_event(li,
482 				   expected_button,
483 				   LIBINPUT_BUTTON_STATE_RELEASED);
484 }
485 END_TEST
486 
START_TEST(touchpad_3fg_clickfinger_distance)487 START_TEST(touchpad_3fg_clickfinger_distance)
488 {
489 	struct litest_device *dev = litest_current_device();
490 	struct libinput *li = dev->libinput;
491 
492 	if (litest_slot_count(dev) < 3)
493 		return;
494 
495 	litest_enable_clickfinger(dev);
496 
497 	litest_drain_events(li);
498 
499 	litest_touch_down(dev, 0, 90, 20);
500 	litest_touch_down(dev, 1, 10, 15);
501 	litest_touch_down(dev, 2, 10, 15);
502 
503 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
504 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
505 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
506 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
507 	litest_touch_up(dev, 0);
508 	litest_touch_up(dev, 1);
509 	litest_touch_up(dev, 2);
510 
511 	litest_assert_button_event(li,
512 				   BTN_MIDDLE,
513 				   LIBINPUT_BUTTON_STATE_PRESSED);
514 	litest_assert_button_event(li,
515 				   BTN_MIDDLE,
516 				   LIBINPUT_BUTTON_STATE_RELEASED);
517 }
518 END_TEST
519 
START_TEST(touchpad_3fg_clickfinger_distance_btntool)520 START_TEST(touchpad_3fg_clickfinger_distance_btntool)
521 {
522 	struct litest_device *dev = litest_current_device();
523 	struct libinput *li = dev->libinput;
524 
525 	if (litest_slot_count(dev) > 2)
526 		return;
527 
528 	litest_enable_clickfinger(dev);
529 
530 	litest_drain_events(li);
531 
532 	litest_touch_down(dev, 0, 90, 15);
533 	litest_touch_down(dev, 1, 10, 15);
534 	libinput_dispatch(li);
535 	litest_event(dev, EV_KEY, BTN_TOOL_DOUBLETAP, 0);
536 	litest_event(dev, EV_KEY, BTN_TOOL_TRIPLETAP, 1);
537 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
538 	libinput_dispatch(li);
539 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
540 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
541 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
542 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
543 	litest_event(dev, EV_KEY, BTN_TOOL_DOUBLETAP, 1);
544 	litest_event(dev, EV_KEY, BTN_TOOL_TRIPLETAP, 0);
545 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
546 	litest_touch_up(dev, 0);
547 	litest_touch_up(dev, 1);
548 
549 	litest_assert_button_event(li,
550 				   BTN_MIDDLE,
551 				   LIBINPUT_BUTTON_STATE_PRESSED);
552 	litest_assert_button_event(li,
553 				   BTN_MIDDLE,
554 				   LIBINPUT_BUTTON_STATE_RELEASED);
555 }
556 END_TEST
557 
START_TEST(touchpad_2fg_clickfinger_bottom)558 START_TEST(touchpad_2fg_clickfinger_bottom)
559 {
560 	struct litest_device *dev = litest_current_device();
561 	struct libinput *li = dev->libinput;
562 
563 	/* this test is run for the T440s touchpad only, makes getting the
564 	 * mm correct easier */
565 
566 	libinput_device_config_click_set_method(dev->libinput_device,
567 						LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER);
568 	litest_drain_events(li);
569 
570 	/* one above, one below the magic line, vert spread ca 27mm */
571 	litest_touch_down(dev, 0, 40, 60);
572 	litest_touch_down(dev, 1, 60, 100);
573 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
574 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
575 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
576 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
577 	litest_touch_up(dev, 0);
578 	litest_touch_up(dev, 1);
579 
580 	litest_assert_button_event(li,
581 				   BTN_LEFT,
582 				   LIBINPUT_BUTTON_STATE_PRESSED);
583 	litest_assert_button_event(li,
584 				   BTN_LEFT,
585 				   LIBINPUT_BUTTON_STATE_RELEASED);
586 
587 	litest_assert_empty_queue(li);
588 
589 	/* both below the magic line */
590 	litest_touch_down(dev, 0, 40, 100);
591 	litest_touch_down(dev, 1, 60, 95);
592 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
593 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
594 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
595 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
596 	litest_touch_up(dev, 0);
597 	litest_touch_up(dev, 1);
598 
599 	litest_assert_button_event(li,
600 				   BTN_RIGHT,
601 				   LIBINPUT_BUTTON_STATE_PRESSED);
602 	litest_assert_button_event(li,
603 				   BTN_RIGHT,
604 				   LIBINPUT_BUTTON_STATE_RELEASED);
605 
606 	/* one above, one below the magic line, vert spread 17mm */
607 	litest_touch_down(dev, 0, 50, 75);
608 	litest_touch_down(dev, 1, 55, 100);
609 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
610 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
611 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
612 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
613 	litest_touch_up(dev, 0);
614 	litest_touch_up(dev, 1);
615 
616 	litest_assert_button_event(li,
617 				   BTN_RIGHT,
618 				   LIBINPUT_BUTTON_STATE_PRESSED);
619 	litest_assert_button_event(li,
620 				   BTN_RIGHT,
621 				   LIBINPUT_BUTTON_STATE_RELEASED);
622 }
623 END_TEST
624 
START_TEST(touchpad_clickfinger_to_area_method)625 START_TEST(touchpad_clickfinger_to_area_method)
626 {
627 	struct litest_device *dev = litest_current_device();
628 	struct libinput *li = dev->libinput;
629 
630 	litest_drain_events(li);
631 
632 	litest_enable_buttonareas(dev);
633 
634 	litest_touch_down(dev, 0, 95, 95);
635 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
636 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
637 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
638 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
639 	litest_touch_up(dev, 0);
640 	libinput_dispatch(li);
641 
642 	litest_assert_button_event(li, BTN_RIGHT,
643 				   LIBINPUT_BUTTON_STATE_PRESSED);
644 	litest_assert_button_event(li, BTN_RIGHT,
645 				   LIBINPUT_BUTTON_STATE_RELEASED);
646 
647 	litest_enable_clickfinger(dev);
648 
649 	litest_drain_events(li);
650 
651 	/* use bottom right corner to catch accidental softbutton right */
652 	litest_touch_down(dev, 0, 95, 95);
653 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
654 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
655 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
656 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
657 	litest_touch_up(dev, 0);
658 	libinput_dispatch(li);
659 
660 	litest_assert_button_event(li, BTN_LEFT,
661 				   LIBINPUT_BUTTON_STATE_PRESSED);
662 	litest_assert_button_event(li, BTN_LEFT,
663 				   LIBINPUT_BUTTON_STATE_RELEASED);
664 
665 }
666 END_TEST
667 
START_TEST(touchpad_clickfinger_to_area_method_while_down)668 START_TEST(touchpad_clickfinger_to_area_method_while_down)
669 {
670 	struct litest_device *dev = litest_current_device();
671 	struct libinput *li = dev->libinput;
672 
673 	litest_drain_events(li);
674 
675 	litest_enable_buttonareas(dev);
676 
677 	litest_touch_down(dev, 0, 95, 95);
678 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
679 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
680 	libinput_dispatch(li);
681 	litest_assert_button_event(li, BTN_RIGHT,
682 				   LIBINPUT_BUTTON_STATE_PRESSED);
683 
684 	litest_enable_clickfinger(dev);
685 
686 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
687 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
688 	litest_touch_up(dev, 0);
689 	libinput_dispatch(li);
690 
691 	litest_assert_button_event(li, BTN_RIGHT,
692 				   LIBINPUT_BUTTON_STATE_RELEASED);
693 
694 	litest_drain_events(li);
695 
696 	/* use bottom right corner to catch accidental softbutton right */
697 	litest_touch_down(dev, 0, 95, 95);
698 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
699 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
700 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
701 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
702 	litest_touch_up(dev, 0);
703 	libinput_dispatch(li);
704 
705 	litest_assert_button_event(li, BTN_LEFT,
706 				   LIBINPUT_BUTTON_STATE_PRESSED);
707 	litest_assert_button_event(li, BTN_LEFT,
708 				   LIBINPUT_BUTTON_STATE_RELEASED);
709 
710 }
711 END_TEST
712 
START_TEST(touchpad_area_to_clickfinger_method)713 START_TEST(touchpad_area_to_clickfinger_method)
714 {
715 	struct litest_device *dev = litest_current_device();
716 	struct libinput *li = dev->libinput;
717 
718 	litest_enable_clickfinger(dev);
719 
720 	litest_drain_events(li);
721 
722 	/* use bottom right corner to catch accidental softbutton right */
723 	litest_touch_down(dev, 0, 95, 95);
724 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
725 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
726 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
727 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
728 	litest_touch_up(dev, 0);
729 	libinput_dispatch(li);
730 
731 	litest_assert_button_event(li, BTN_LEFT,
732 				   LIBINPUT_BUTTON_STATE_PRESSED);
733 	litest_assert_button_event(li, BTN_LEFT,
734 				   LIBINPUT_BUTTON_STATE_RELEASED);
735 
736 	litest_enable_buttonareas(dev);
737 
738 	litest_touch_down(dev, 0, 95, 95);
739 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
740 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
741 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
742 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
743 	litest_touch_up(dev, 0);
744 	libinput_dispatch(li);
745 
746 	litest_assert_button_event(li, BTN_RIGHT,
747 				   LIBINPUT_BUTTON_STATE_PRESSED);
748 	litest_assert_button_event(li, BTN_RIGHT,
749 				   LIBINPUT_BUTTON_STATE_RELEASED);
750 
751 }
752 END_TEST
753 
START_TEST(touchpad_area_to_clickfinger_method_while_down)754 START_TEST(touchpad_area_to_clickfinger_method_while_down)
755 {
756 	struct litest_device *dev = litest_current_device();
757 	struct libinput *li = dev->libinput;
758 
759 	litest_enable_clickfinger(dev);
760 
761 	litest_drain_events(li);
762 
763 	/* use bottom right corner to catch accidental softbutton right */
764 	litest_touch_down(dev, 0, 95, 95);
765 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
766 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
767 	litest_assert_button_event(li, BTN_LEFT,
768 				   LIBINPUT_BUTTON_STATE_PRESSED);
769 
770 	litest_enable_buttonareas(dev);
771 
772 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
773 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
774 	litest_touch_up(dev, 0);
775 	libinput_dispatch(li);
776 
777 	litest_assert_button_event(li, BTN_LEFT,
778 				   LIBINPUT_BUTTON_STATE_RELEASED);
779 
780 	litest_touch_down(dev, 0, 95, 95);
781 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
782 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
783 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
784 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
785 	litest_touch_up(dev, 0);
786 	libinput_dispatch(li);
787 
788 	litest_assert_button_event(li, BTN_RIGHT,
789 				   LIBINPUT_BUTTON_STATE_PRESSED);
790 	litest_assert_button_event(li, BTN_RIGHT,
791 				   LIBINPUT_BUTTON_STATE_RELEASED);
792 
793 }
794 END_TEST
795 
START_TEST(touchpad_clickfinger_3fg_tool_position)796 START_TEST(touchpad_clickfinger_3fg_tool_position)
797 {
798 	struct litest_device *dev = litest_current_device();
799 	struct libinput *li = dev->libinput;
800 
801 	litest_enable_clickfinger(dev);
802 	litest_drain_events(li);
803 
804 	/* one in thumb area, one in normal area + TRIPLETAP. spread is wide
805 	 * but any non-palm 3fg touch+click counts as middle */
806 	litest_touch_down(dev, 0, 20, 99);
807 	litest_touch_down(dev, 1, 90, 15);
808 	litest_event(dev, EV_KEY, BTN_TOOL_DOUBLETAP, 0);
809 	litest_event(dev, EV_KEY, BTN_TOOL_TRIPLETAP, 1);
810 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
811 	libinput_dispatch(li);
812 
813 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
814 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
815 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
816 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
817 	libinput_dispatch(li);
818 
819 	litest_assert_button_event(li, BTN_RIGHT,
820 				   LIBINPUT_BUTTON_STATE_PRESSED);
821 	litest_assert_button_event(li, BTN_RIGHT,
822 				   LIBINPUT_BUTTON_STATE_RELEASED);
823 }
824 END_TEST
825 
START_TEST(touchpad_clickfinger_4fg_tool_position)826 START_TEST(touchpad_clickfinger_4fg_tool_position)
827 {
828 	struct litest_device *dev = litest_current_device();
829 	struct libinput *li = dev->libinput;
830 
831 	litest_enable_clickfinger(dev);
832 	litest_drain_events(li);
833 
834 	litest_touch_down(dev, 0, 5, 99);
835 	litest_touch_down(dev, 1, 90, 15);
836 	litest_event(dev, EV_KEY, BTN_TOOL_DOUBLETAP, 0);
837 	litest_event(dev, EV_KEY, BTN_TOOL_QUADTAP, 1);
838 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
839 	libinput_dispatch(li);
840 
841 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
842 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
843 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
844 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
845 	libinput_dispatch(li);
846 
847 	litest_assert_button_event(li,
848 				   BTN_MIDDLE,
849 				   LIBINPUT_BUTTON_STATE_PRESSED);
850 	litest_assert_button_event(li,
851 				   BTN_MIDDLE,
852 				   LIBINPUT_BUTTON_STATE_RELEASED);
853 }
854 END_TEST
855 
START_TEST(touchpad_clickfinger_appletouch_config)856 START_TEST(touchpad_clickfinger_appletouch_config)
857 {
858 	struct litest_device *dev = litest_current_device();
859 	struct libinput_device *device = dev->libinput_device;
860 	uint32_t methods, method;
861 	enum libinput_config_status status;
862 
863 	methods = libinput_device_config_click_get_methods(device);
864 	ck_assert(!(methods & LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS));
865 	ck_assert(methods & LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER);
866 
867 	method = libinput_device_config_click_get_method(device);
868 	ck_assert_int_eq(method, LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER);
869 
870 	status = libinput_device_config_click_set_method(device,
871 							 LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS);
872 	ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_UNSUPPORTED);
873 	status = libinput_device_config_click_set_method(device,
874 							 LIBINPUT_CONFIG_CLICK_METHOD_NONE);
875 	ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
876 }
877 END_TEST
878 
START_TEST(touchpad_clickfinger_appletouch_1fg)879 START_TEST(touchpad_clickfinger_appletouch_1fg)
880 {
881 	struct litest_device *dev = litest_current_device();
882 	struct libinput *li = dev->libinput;
883 
884 	litest_enable_clickfinger(dev);
885 
886 	litest_drain_events(li);
887 
888 	litest_touch_down(dev, 0, 50, 50);
889 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
890 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
891 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
892 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
893 	litest_touch_up(dev, 0);
894 
895 	libinput_dispatch(li);
896 
897 	litest_assert_button_event(li, BTN_LEFT,
898 				   LIBINPUT_BUTTON_STATE_PRESSED);
899 	litest_assert_button_event(li, BTN_LEFT,
900 				   LIBINPUT_BUTTON_STATE_RELEASED);
901 }
902 END_TEST
903 
START_TEST(touchpad_clickfinger_appletouch_2fg)904 START_TEST(touchpad_clickfinger_appletouch_2fg)
905 {
906 	struct litest_device *dev = litest_current_device();
907 	struct libinput *li = dev->libinput;
908 
909 	litest_enable_clickfinger(dev);
910 
911 	litest_drain_events(li);
912 
913 	litest_touch_down(dev, 0, 50, 50);
914 	litest_touch_down(dev, 1, 50, 50);
915 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
916 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
917 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
918 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
919 	litest_touch_up(dev, 0);
920 	litest_touch_up(dev, 1);
921 
922 	libinput_dispatch(li);
923 
924 	litest_assert_button_event(li, BTN_RIGHT,
925 				   LIBINPUT_BUTTON_STATE_PRESSED);
926 	litest_assert_button_event(li, BTN_RIGHT,
927 				   LIBINPUT_BUTTON_STATE_RELEASED);
928 }
929 END_TEST
930 
START_TEST(touchpad_clickfinger_appletouch_3fg)931 START_TEST(touchpad_clickfinger_appletouch_3fg)
932 {
933 	struct litest_device *dev = litest_current_device();
934 	struct libinput *li = dev->libinput;
935 
936 	litest_enable_clickfinger(dev);
937 
938 	litest_drain_events(li);
939 
940 	litest_touch_down(dev, 0, 50, 50);
941 	litest_touch_down(dev, 1, 50, 50);
942 	litest_touch_down(dev, 2, 50, 50);
943 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
944 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
945 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
946 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
947 	litest_touch_up(dev, 0);
948 	litest_touch_up(dev, 1);
949 	litest_touch_up(dev, 2);
950 
951 	libinput_dispatch(li);
952 
953 	litest_assert_button_event(li, BTN_MIDDLE,
954 				   LIBINPUT_BUTTON_STATE_PRESSED);
955 	litest_assert_button_event(li, BTN_MIDDLE,
956 				   LIBINPUT_BUTTON_STATE_RELEASED);
957 }
958 END_TEST
959 
START_TEST(touchpad_clickfinger_click_drag)960 START_TEST(touchpad_clickfinger_click_drag)
961 {
962 	struct litest_device *dev = litest_current_device();
963 	struct libinput *li = dev->libinput;
964 	int nfingers = _i; /* ranged test */
965 	unsigned int button;
966 	int nslots = litest_slot_count(dev);
967 
968 	litest_enable_clickfinger(dev);
969 	litest_drain_events(li);
970 
971 	litest_touch_down(dev, 0, 40, 50);
972 	button = BTN_LEFT;
973 
974 	if (nfingers > 1) {
975 		if (nslots > 1) {
976 			litest_touch_down(dev, 1, 50, 50);
977 		} else {
978 			litest_event(dev, EV_KEY, BTN_TOOL_DOUBLETAP, 1);
979 		}
980 		button = BTN_RIGHT;
981 	}
982 
983 	if (nfingers > 2) {
984 		if (nslots > 2) {
985 			litest_touch_down(dev, 2, 60, 50);
986 		} else {
987 			litest_event(dev, EV_KEY, BTN_TOOL_DOUBLETAP, 0);
988 			litest_event(dev, EV_KEY, BTN_TOOL_TRIPLETAP, 1);
989 		}
990 		button = BTN_MIDDLE;
991 	}
992 
993 	litest_button_click(dev, BTN_LEFT, true);
994 
995 	libinput_dispatch(li);
996 	litest_assert_button_event(li, button,
997 				   LIBINPUT_BUTTON_STATE_PRESSED);
998 
999 	for (int i = 0; i < 20; i++) {
1000 		litest_push_event_frame(dev);
1001 		switch (nfingers) {
1002 		case 3:
1003 			if (nslots >= nfingers)
1004 				litest_touch_move(dev, 2, 60, 50 + i);
1005 			/* fallthrough */
1006 		case 2:
1007 			if (nslots >= nfingers)
1008 				litest_touch_move(dev, 1, 50, 50 + i);
1009 			/* fallthrough */
1010 		case 1:
1011 			litest_touch_move(dev, 0, 40, 50 + i);
1012 			break;
1013 		}
1014 		litest_pop_event_frame(dev);
1015 		libinput_dispatch(li);
1016 	}
1017 
1018 	litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_MOTION);
1019 
1020 	litest_button_click(dev, BTN_LEFT, false);
1021 	litest_assert_button_event(li, button,
1022 				   LIBINPUT_BUTTON_STATE_RELEASED);
1023 
1024 	if (nfingers > 3) {
1025 		if (nslots > 3) {
1026 			litest_touch_up(dev, 2);
1027 		} else {
1028 			litest_event(dev, EV_KEY, BTN_TOOL_DOUBLETAP, 1);
1029 			litest_event(dev, EV_KEY, BTN_TOOL_TRIPLETAP, 0);
1030 		}
1031 	}
1032 
1033 	if (nfingers > 2) {
1034 		if (nslots > 2) {
1035 			litest_touch_up(dev, 1);
1036 		} else {
1037 			litest_event(dev, EV_KEY, BTN_TOOL_DOUBLETAP, 0);
1038 		}
1039 	}
1040 
1041 	litest_touch_up(dev, 0);
1042 
1043 
1044 	libinput_dispatch(li);
1045 	litest_assert_empty_queue(li);
1046 }
1047 END_TEST
1048 
START_TEST(touchpad_btn_left)1049 START_TEST(touchpad_btn_left)
1050 {
1051 	struct litest_device *dev = litest_current_device();
1052 	struct libinput *li = dev->libinput;
1053 
1054 	litest_drain_events(li);
1055 
1056 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
1057 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
1058 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
1059 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
1060 
1061 	libinput_dispatch(li);
1062 
1063 	litest_assert_button_event(li, BTN_LEFT,
1064 				   LIBINPUT_BUTTON_STATE_PRESSED);
1065 	litest_assert_button_event(li, BTN_LEFT,
1066 				   LIBINPUT_BUTTON_STATE_RELEASED);
1067 }
1068 END_TEST
1069 
START_TEST(clickpad_btn_left)1070 START_TEST(clickpad_btn_left)
1071 {
1072 	struct litest_device *dev = litest_current_device();
1073 	struct libinput *li = dev->libinput;
1074 
1075 	litest_enable_buttonareas(dev);
1076 
1077 	litest_drain_events(li);
1078 
1079 	/* A clickpad always needs a finger down to tell where the
1080 	   click happens */
1081 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
1082 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
1083 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
1084 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
1085 
1086 	libinput_dispatch(li);
1087 	ck_assert_int_eq(libinput_next_event_type(li), LIBINPUT_EVENT_NONE);
1088 }
1089 END_TEST
1090 
START_TEST(clickpad_click_n_drag)1091 START_TEST(clickpad_click_n_drag)
1092 {
1093 	struct litest_device *dev = litest_current_device();
1094 	struct libinput *li = dev->libinput;
1095 
1096 	litest_drain_events(li);
1097 
1098 	litest_touch_down(dev, 0, 50, 50);
1099 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
1100 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
1101 
1102 	libinput_dispatch(li);
1103 	litest_assert_button_event(li, BTN_LEFT,
1104 				   LIBINPUT_BUTTON_STATE_PRESSED);
1105 
1106 	libinput_dispatch(li);
1107 	ck_assert_int_eq(libinput_next_event_type(li), LIBINPUT_EVENT_NONE);
1108 
1109 	/* now put a second finger down */
1110 	litest_touch_down(dev, 1, 70, 70);
1111 	litest_touch_move_to(dev, 1, 70, 70, 80, 50, 5);
1112 	litest_touch_up(dev, 1);
1113 
1114 	litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_MOTION);
1115 
1116 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
1117 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
1118 	litest_touch_up(dev, 0);
1119 
1120 	litest_assert_button_event(li, BTN_LEFT,
1121 				   LIBINPUT_BUTTON_STATE_RELEASED);
1122 }
1123 END_TEST
1124 
START_TEST(clickpad_finger_pin)1125 START_TEST(clickpad_finger_pin)
1126 {
1127 	struct litest_device *dev = litest_current_device();
1128 	struct libinput *li = dev->libinput;
1129 	struct libevdev *evdev = dev->evdev;
1130 	const struct input_absinfo *abs;
1131 	double w, h;
1132 	double dist;
1133 
1134 	abs = libevdev_get_abs_info(evdev, ABS_MT_POSITION_X);
1135 	ck_assert_notnull(abs);
1136 	if (abs->resolution == 0)
1137 		return;
1138 
1139 	if (libinput_device_get_size(dev->libinput_device, &w, &h) != 0)
1140 		return;
1141 
1142 	dist = 100.0/max(w, h);
1143 
1144 	litest_drain_events(li);
1145 
1146 	/* make sure the movement generates pointer events when
1147 	   not pinned */
1148 	litest_touch_down(dev, 0, 50, 50);
1149 	litest_touch_move_to(dev, 0, 50, 50, 52, 52, 10);
1150 	litest_touch_move_to(dev, 0, 52, 52, 48, 48, 10);
1151 	litest_touch_move_to(dev, 0, 48, 48, 50, 50, 10);
1152 	litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_MOTION);
1153 
1154 	litest_button_click(dev, BTN_LEFT, true);
1155 	litest_drain_events(li);
1156 
1157 	litest_touch_move_to(dev, 0, 50, 50, 50 + dist, 50 + dist, 10);
1158 	litest_touch_move_to(dev, 0, 50 + dist, 50 + dist, 50, 50, 10);
1159 	litest_touch_move_to(dev, 0, 50, 50, 50 - dist, 50 - dist, 10);
1160 
1161 	litest_assert_empty_queue(li);
1162 
1163 	litest_button_click(dev, BTN_LEFT, false);
1164 	litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_BUTTON);
1165 
1166 	/* still pinned after release */
1167 	litest_touch_move_to(dev, 0, 50, 50, 50 + dist, 50 + dist, 10);
1168 	litest_touch_move_to(dev, 0, 50 + dist, 50 + dist, 50, 50, 10);
1169 	litest_touch_move_to(dev, 0, 50, 50, 50 - dist, 50 - dist, 10);
1170 
1171 	litest_assert_empty_queue(li);
1172 
1173 	/* move to unpin */
1174 	litest_touch_move_to(dev, 0, 50, 50, 70, 70, 10);
1175 	litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_MOTION);
1176 }
1177 END_TEST
1178 
START_TEST(clickpad_softbutton_left)1179 START_TEST(clickpad_softbutton_left)
1180 {
1181 	struct litest_device *dev = litest_current_device();
1182 	struct libinput *li = dev->libinput;
1183 
1184 	litest_drain_events(li);
1185 
1186 	litest_touch_down(dev, 0, 10, 90);
1187 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
1188 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
1189 
1190 	litest_assert_button_event(li,
1191 				   BTN_LEFT,
1192 				   LIBINPUT_BUTTON_STATE_PRESSED);
1193 
1194 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
1195 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
1196 	litest_touch_up(dev, 0);
1197 
1198 	litest_assert_button_event(li,
1199 				   BTN_LEFT,
1200 				   LIBINPUT_BUTTON_STATE_RELEASED);
1201 
1202 	libinput_dispatch(li);
1203 
1204 	litest_assert_empty_queue(li);
1205 }
1206 END_TEST
1207 
START_TEST(clickpad_softbutton_middle)1208 START_TEST(clickpad_softbutton_middle)
1209 {
1210 	struct litest_device *dev = litest_current_device();
1211 	struct libinput *li = dev->libinput;
1212 
1213 	litest_drain_events(li);
1214 
1215 	litest_touch_down(dev, 0, 50, 90);
1216 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
1217 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
1218 
1219 	litest_assert_button_event(li,
1220 				   BTN_MIDDLE,
1221 				   LIBINPUT_BUTTON_STATE_PRESSED);
1222 
1223 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
1224 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
1225 	litest_touch_up(dev, 0);
1226 
1227 	litest_assert_button_event(li,
1228 				   BTN_MIDDLE,
1229 				   LIBINPUT_BUTTON_STATE_RELEASED);
1230 
1231 	libinput_dispatch(li);
1232 
1233 	litest_assert_empty_queue(li);
1234 }
1235 END_TEST
1236 
START_TEST(clickpad_softbutton_right)1237 START_TEST(clickpad_softbutton_right)
1238 {
1239 	struct litest_device *dev = litest_current_device();
1240 	struct libinput *li = dev->libinput;
1241 
1242 	litest_drain_events(li);
1243 
1244 	litest_touch_down(dev, 0, 90, 90);
1245 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
1246 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
1247 
1248 	litest_assert_button_event(li,
1249 				   BTN_RIGHT,
1250 			    LIBINPUT_BUTTON_STATE_PRESSED);
1251 
1252 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
1253 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
1254 	litest_touch_up(dev, 0);
1255 
1256 	litest_assert_button_event(li,
1257 				   BTN_RIGHT,
1258 			    LIBINPUT_BUTTON_STATE_RELEASED);
1259 
1260 	libinput_dispatch(li);
1261 
1262 	litest_assert_empty_queue(li);
1263 }
1264 END_TEST
1265 
START_TEST(clickpad_softbutton_left_tap_n_drag)1266 START_TEST(clickpad_softbutton_left_tap_n_drag)
1267 {
1268 	struct litest_device *dev = litest_current_device();
1269 	struct libinput *li = dev->libinput;
1270 
1271 	litest_enable_tap(dev->libinput_device);
1272 
1273 	litest_drain_events(li);
1274 
1275 	/* Tap in left button area, then finger down, button click
1276 		-> expect left button press/release and left button press
1277 	   Release button, finger up
1278 		-> expect right button release
1279 	 */
1280 	litest_touch_down(dev, 0, 20, 90);
1281 	litest_touch_up(dev, 0);
1282 	litest_touch_down(dev, 0, 20, 90);
1283 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
1284 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
1285 
1286 	litest_assert_button_event(li,
1287 				   BTN_LEFT,
1288 			    LIBINPUT_BUTTON_STATE_PRESSED);
1289 	litest_assert_button_event(li,
1290 				   BTN_LEFT,
1291 			    LIBINPUT_BUTTON_STATE_RELEASED);
1292 	litest_assert_button_event(li,
1293 				   BTN_LEFT,
1294 			    LIBINPUT_BUTTON_STATE_PRESSED);
1295 	litest_assert_empty_queue(li);
1296 
1297 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
1298 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
1299 	litest_touch_up(dev, 0);
1300 
1301 	litest_assert_button_event(li,
1302 				   BTN_LEFT,
1303 			    LIBINPUT_BUTTON_STATE_RELEASED);
1304 	litest_assert_empty_queue(li);
1305 }
1306 END_TEST
1307 
START_TEST(clickpad_softbutton_right_tap_n_drag)1308 START_TEST(clickpad_softbutton_right_tap_n_drag)
1309 {
1310 	struct litest_device *dev = litest_current_device();
1311 	struct libinput *li = dev->libinput;
1312 
1313 	litest_enable_tap(dev->libinput_device);
1314 
1315 	litest_drain_events(li);
1316 
1317 	/* Tap in right button area, then finger down, button click
1318 		-> expect left button press/release and right button press
1319 	   Release button, finger up
1320 		-> expect right button release
1321 	 */
1322 	litest_touch_down(dev, 0, 90, 90);
1323 	litest_touch_up(dev, 0);
1324 	litest_touch_down(dev, 0, 90, 90);
1325 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
1326 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
1327 
1328 	litest_assert_button_event(li,
1329 				   BTN_LEFT,
1330 				   LIBINPUT_BUTTON_STATE_PRESSED);
1331 	litest_assert_button_event(li,
1332 				   BTN_LEFT,
1333 				   LIBINPUT_BUTTON_STATE_RELEASED);
1334 	litest_assert_button_event(li,
1335 				   BTN_RIGHT,
1336 				   LIBINPUT_BUTTON_STATE_PRESSED);
1337 	litest_assert_empty_queue(li);
1338 
1339 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
1340 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
1341 	litest_touch_up(dev, 0);
1342 
1343 	litest_assert_button_event(li,
1344 				   BTN_RIGHT,
1345 				   LIBINPUT_BUTTON_STATE_RELEASED);
1346 	litest_assert_empty_queue(li);
1347 }
1348 END_TEST
1349 
START_TEST(clickpad_softbutton_left_1st_fg_move)1350 START_TEST(clickpad_softbutton_left_1st_fg_move)
1351 {
1352 	struct litest_device *dev = litest_current_device();
1353 	struct libinput *li = dev->libinput;
1354 	struct libinput_event *event;
1355 	double x = 0, y = 0;
1356 	int nevents = 0;
1357 
1358 	litest_drain_events(li);
1359 
1360 	/* One finger down in the left button area, button press
1361 		-> expect a button event
1362 	   Move finger up out of the area, wait for timeout
1363 	   Move finger around diagonally down left
1364 		-> expect motion events down left
1365 	   Release finger
1366 		-> expect a button event */
1367 
1368 	/* finger down, press in left button */
1369 	litest_touch_down(dev, 0, 20, 90);
1370 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
1371 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
1372 
1373 	litest_assert_button_event(li,
1374 				   BTN_LEFT,
1375 				   LIBINPUT_BUTTON_STATE_PRESSED);
1376 	litest_assert_empty_queue(li);
1377 
1378 	/* move out of the area, then wait for softbutton timer */
1379 	litest_touch_move_to(dev, 0, 20, 90, 50, 50, 20);
1380 	libinput_dispatch(li);
1381 	litest_timeout_softbuttons();
1382 	libinput_dispatch(li);
1383 	litest_drain_events(li);
1384 
1385 	/* move down left, expect motion */
1386 	litest_touch_move_to(dev, 0, 50, 50, 20, 90, 20);
1387 
1388 	libinput_dispatch(li);
1389 	event = libinput_get_event(li);
1390 	ck_assert_notnull(event);
1391 	while (event) {
1392 		struct libinput_event_pointer *p;
1393 
1394 		ck_assert_int_eq(libinput_event_get_type(event),
1395 				 LIBINPUT_EVENT_POINTER_MOTION);
1396 		p = libinput_event_get_pointer_event(event);
1397 
1398 		/* we moved up/right, now down/left so the pointer accel
1399 		   code may lag behind with the dx/dy vectors. Hence, add up
1400 		   the x/y movements and expect that on average we moved
1401 		   left and down */
1402 		x += libinput_event_pointer_get_dx(p);
1403 		y += libinput_event_pointer_get_dy(p);
1404 		nevents++;
1405 
1406 		libinput_event_destroy(event);
1407 		libinput_dispatch(li);
1408 		event = libinput_get_event(li);
1409 	}
1410 
1411 	ck_assert(x/nevents < 0);
1412 	ck_assert(y/nevents > 0);
1413 
1414 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
1415 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
1416 	litest_touch_up(dev, 0);
1417 
1418 	litest_assert_button_event(li,
1419 				   BTN_LEFT,
1420 				   LIBINPUT_BUTTON_STATE_RELEASED);
1421 
1422 	litest_assert_empty_queue(li);
1423 }
1424 END_TEST
1425 
START_TEST(clickpad_softbutton_left_2nd_fg_move)1426 START_TEST(clickpad_softbutton_left_2nd_fg_move)
1427 {
1428 	struct litest_device *dev = litest_current_device();
1429 	struct libinput *li = dev->libinput;
1430 	struct libinput_event *event;
1431 
1432 	litest_drain_events(li);
1433 
1434 	/* One finger down in the left button area, button press
1435 		-> expect a button event
1436 	   Put a second finger down in the area, move it right, release
1437 		-> expect motion events right
1438 	   Put a second finger down in the area, move it down, release
1439 		-> expect motion events down
1440 	   Release second finger, release first finger
1441 		-> expect a button event */
1442 	litest_touch_down(dev, 0, 20, 90);
1443 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
1444 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
1445 
1446 	litest_assert_button_event(li,
1447 				   BTN_LEFT,
1448 				   LIBINPUT_BUTTON_STATE_PRESSED);
1449 	litest_assert_empty_queue(li);
1450 
1451 	litest_touch_down(dev, 1, 20, 20);
1452 	litest_touch_move_to(dev, 1, 20, 20, 80, 20, 10);
1453 
1454 	libinput_dispatch(li);
1455 	event = libinput_get_event(li);
1456 	ck_assert_notnull(event);
1457 	while (event) {
1458 		struct libinput_event_pointer *p;
1459 		double x, y;
1460 
1461 		ck_assert_int_eq(libinput_event_get_type(event),
1462 				 LIBINPUT_EVENT_POINTER_MOTION);
1463 		p = libinput_event_get_pointer_event(event);
1464 
1465 		x = libinput_event_pointer_get_dx(p);
1466 		y = libinput_event_pointer_get_dy(p);
1467 
1468 		/* Ignore events only containing an unaccelerated motion
1469 		 * vector. */
1470 		if (x != 0 || y != 0) {
1471 			ck_assert(x > 0);
1472 			ck_assert(y == 0);
1473 		}
1474 
1475 		libinput_event_destroy(event);
1476 		libinput_dispatch(li);
1477 		event = libinput_get_event(li);
1478 	}
1479 	litest_touch_up(dev, 1);
1480 
1481 	/* second finger down */
1482 	litest_touch_down(dev, 1, 20, 20);
1483 	litest_touch_move_to(dev, 1, 20, 20, 20, 80, 10);
1484 
1485 	libinput_dispatch(li);
1486 	event = libinput_get_event(li);
1487 	ck_assert_notnull(event);
1488 	while (event) {
1489 		struct libinput_event_pointer *p;
1490 		double x, y;
1491 
1492 		ck_assert_int_eq(libinput_event_get_type(event),
1493 				 LIBINPUT_EVENT_POINTER_MOTION);
1494 		p = libinput_event_get_pointer_event(event);
1495 
1496 		x = libinput_event_pointer_get_dx(p);
1497 		y = libinput_event_pointer_get_dy(p);
1498 
1499 		ck_assert(x == 0);
1500 		ck_assert(y > 0);
1501 
1502 		libinput_event_destroy(event);
1503 		libinput_dispatch(li);
1504 		event = libinput_get_event(li);
1505 	}
1506 
1507 	litest_touch_up(dev, 1);
1508 
1509 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
1510 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
1511 	litest_touch_up(dev, 0);
1512 
1513 	litest_assert_button_event(li,
1514 				   BTN_LEFT,
1515 				   LIBINPUT_BUTTON_STATE_RELEASED);
1516 
1517 	litest_assert_empty_queue(li);
1518 }
1519 END_TEST
1520 
START_TEST(clickpad_softbutton_left_to_right)1521 START_TEST(clickpad_softbutton_left_to_right)
1522 {
1523 	struct litest_device *dev = litest_current_device();
1524 	struct libinput *li = dev->libinput;
1525 
1526 	litest_drain_events(li);
1527 
1528 	/* One finger down in left software button area,
1529 	   move to right button area immediately, click
1530 		-> expect right button event
1531 	*/
1532 
1533 	litest_touch_down(dev, 0, 30, 90);
1534 	litest_touch_move_to(dev, 0, 30, 90, 90, 90, 10);
1535 	litest_drain_events(li);
1536 
1537 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
1538 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
1539 
1540 	litest_assert_button_event(li,
1541 				   BTN_RIGHT,
1542 				   LIBINPUT_BUTTON_STATE_PRESSED);
1543 	litest_assert_empty_queue(li);
1544 
1545 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
1546 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
1547 	litest_touch_up(dev, 0);
1548 
1549 	litest_assert_button_event(li,
1550 				   BTN_RIGHT,
1551 				   LIBINPUT_BUTTON_STATE_RELEASED);
1552 
1553 	litest_assert_empty_queue(li);
1554 }
1555 END_TEST
1556 
START_TEST(clickpad_softbutton_right_to_left)1557 START_TEST(clickpad_softbutton_right_to_left)
1558 {
1559 	struct litest_device *dev = litest_current_device();
1560 	struct libinput *li = dev->libinput;
1561 
1562 	litest_drain_events(li);
1563 
1564 	/* One finger down in right software button area,
1565 	   move to left button area immediately, click
1566 		-> expect left button event
1567 	*/
1568 
1569 	litest_touch_down(dev, 0, 80, 90);
1570 	litest_touch_move_to(dev, 0, 80, 90, 30, 90, 10);
1571 	litest_drain_events(li);
1572 
1573 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
1574 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
1575 
1576 	litest_assert_button_event(li,
1577 				   BTN_LEFT,
1578 				   LIBINPUT_BUTTON_STATE_PRESSED);
1579 	litest_assert_empty_queue(li);
1580 
1581 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
1582 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
1583 	litest_touch_up(dev, 0);
1584 
1585 	litest_assert_button_event(li,
1586 				   BTN_LEFT,
1587 				   LIBINPUT_BUTTON_STATE_RELEASED);
1588 
1589 	litest_assert_empty_queue(li);
1590 }
1591 END_TEST
1592 
START_TEST(clickpad_softbutton_hover_into_buttons)1593 START_TEST(clickpad_softbutton_hover_into_buttons)
1594 {
1595 	struct litest_device *dev = litest_current_device();
1596 	struct libinput *li = dev->libinput;
1597 
1598 	litest_drain_events(li);
1599 
1600 	litest_hover_start(dev, 0, 50, 50);
1601 	libinput_dispatch(li);
1602 	litest_hover_move_to(dev, 0, 50, 50, 90, 90, 10);
1603 	libinput_dispatch(li);
1604 
1605 	litest_touch_move_to(dev, 0, 90, 90, 91, 91, 1);
1606 
1607 	litest_button_click(dev, BTN_LEFT, true);
1608 	libinput_dispatch(li);
1609 
1610 	litest_assert_button_event(li,
1611 				   BTN_RIGHT,
1612 				   LIBINPUT_BUTTON_STATE_PRESSED);
1613 	litest_assert_empty_queue(li);
1614 
1615 	litest_button_click(dev, BTN_LEFT, false);
1616 	litest_touch_up(dev, 0);
1617 
1618 	litest_assert_button_event(li,
1619 				   BTN_RIGHT,
1620 				   LIBINPUT_BUTTON_STATE_RELEASED);
1621 }
1622 END_TEST
1623 
START_TEST(clickpad_topsoftbuttons_left)1624 START_TEST(clickpad_topsoftbuttons_left)
1625 {
1626 	struct litest_device *dev = litest_current_device();
1627 	struct libinput *li = dev->libinput;
1628 
1629 	litest_drain_events(li);
1630 
1631 	litest_touch_down(dev, 0, 10, 5);
1632 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
1633 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
1634 
1635 	litest_assert_button_event(li,
1636 				   BTN_LEFT,
1637 				   LIBINPUT_BUTTON_STATE_PRESSED);
1638 	litest_assert_empty_queue(li);
1639 
1640 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
1641 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
1642 	litest_touch_up(dev, 0);
1643 
1644 	litest_assert_button_event(li,
1645 				   BTN_LEFT,
1646 				   LIBINPUT_BUTTON_STATE_RELEASED);
1647 
1648 	litest_assert_empty_queue(li);
1649 }
1650 END_TEST
1651 
START_TEST(clickpad_topsoftbuttons_right)1652 START_TEST(clickpad_topsoftbuttons_right)
1653 {
1654 	struct litest_device *dev = litest_current_device();
1655 	struct libinput *li = dev->libinput;
1656 
1657 	litest_drain_events(li);
1658 
1659 	litest_touch_down(dev, 0, 90, 5);
1660 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
1661 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
1662 
1663 	litest_assert_button_event(li,
1664 				   BTN_RIGHT,
1665 				   LIBINPUT_BUTTON_STATE_PRESSED);
1666 	litest_assert_empty_queue(li);
1667 
1668 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
1669 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
1670 	litest_touch_up(dev, 0);
1671 
1672 	litest_assert_button_event(li,
1673 				   BTN_RIGHT,
1674 				   LIBINPUT_BUTTON_STATE_RELEASED);
1675 
1676 	litest_assert_empty_queue(li);
1677 }
1678 END_TEST
1679 
START_TEST(clickpad_topsoftbuttons_middle)1680 START_TEST(clickpad_topsoftbuttons_middle)
1681 {
1682 	struct litest_device *dev = litest_current_device();
1683 	struct libinput *li = dev->libinput;
1684 
1685 	litest_drain_events(li);
1686 
1687 	litest_touch_down(dev, 0, 50, 5);
1688 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
1689 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
1690 
1691 	litest_assert_button_event(li,
1692 				   BTN_MIDDLE,
1693 				   LIBINPUT_BUTTON_STATE_PRESSED);
1694 	litest_assert_empty_queue(li);
1695 
1696 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
1697 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
1698 	litest_touch_up(dev, 0);
1699 
1700 	litest_assert_button_event(li,
1701 				   BTN_MIDDLE,
1702 				   LIBINPUT_BUTTON_STATE_RELEASED);
1703 
1704 	litest_assert_empty_queue(li);
1705 }
1706 END_TEST
1707 
START_TEST(clickpad_topsoftbuttons_move_out_leftclick_before_timeout)1708 START_TEST(clickpad_topsoftbuttons_move_out_leftclick_before_timeout)
1709 {
1710 	struct litest_device *dev = litest_current_device();
1711 	struct libinput *li = dev->libinput;
1712 
1713 	/* Finger down in top right button area, wait past enter timeout
1714 	   Move into main area, wait past leave timeout
1715 	   Click
1716 	     -> expect left click
1717 	 */
1718 
1719 	litest_drain_events(li);
1720 
1721 	litest_touch_down(dev, 0, 80, 5);
1722 	libinput_dispatch(li);
1723 	litest_timeout_softbuttons();
1724 	libinput_dispatch(li);
1725 	litest_assert_empty_queue(li);
1726 
1727 	litest_touch_move_to(dev, 0, 80, 5, 80, 90, 20);
1728 	libinput_dispatch(li);
1729 
1730 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
1731 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
1732 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
1733 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
1734 
1735 	litest_touch_up(dev, 0);
1736 
1737 	litest_assert_button_event(li, BTN_RIGHT, LIBINPUT_BUTTON_STATE_PRESSED);
1738 	litest_assert_button_event(li, BTN_RIGHT, LIBINPUT_BUTTON_STATE_RELEASED);
1739 }
1740 END_TEST
1741 
START_TEST(clickpad_topsoftbuttons_move_out_leftclick)1742 START_TEST(clickpad_topsoftbuttons_move_out_leftclick)
1743 {
1744 	struct litest_device *dev = litest_current_device();
1745 	struct libinput *li = dev->libinput;
1746 
1747 	/* Finger down in top right button area, wait past enter timeout
1748 	   Move into main area, wait past leave timeout
1749 	   Click
1750 	     -> expect left click
1751 	 */
1752 
1753 	litest_drain_events(li);
1754 
1755 	litest_touch_down(dev, 0, 80, 5);
1756 	libinput_dispatch(li);
1757 	litest_timeout_softbuttons();
1758 	libinput_dispatch(li);
1759 	litest_assert_empty_queue(li);
1760 
1761 	litest_touch_move_to(dev, 0, 80, 5, 80, 90, 20);
1762 	libinput_dispatch(li);
1763 	litest_timeout_softbuttons();
1764 	libinput_dispatch(li);
1765 
1766 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
1767 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
1768 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
1769 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
1770 
1771 	litest_touch_up(dev, 0);
1772 
1773 	litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_PRESSED);
1774 	litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_RELEASED);
1775 }
1776 END_TEST
1777 
START_TEST(clickpad_topsoftbuttons_clickfinger)1778 START_TEST(clickpad_topsoftbuttons_clickfinger)
1779 {
1780 	struct litest_device *dev = litest_current_device();
1781 	struct libinput *li = dev->libinput;
1782 
1783 	litest_enable_clickfinger(dev);
1784 
1785 	litest_drain_events(li);
1786 
1787 	litest_touch_down(dev, 0, 90, 5);
1788 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
1789 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
1790 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
1791 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
1792 	litest_touch_up(dev, 0);
1793 
1794 	litest_assert_button_event(li,
1795 				   BTN_LEFT,
1796 				   LIBINPUT_BUTTON_STATE_PRESSED);
1797 	litest_assert_button_event(li,
1798 				   BTN_LEFT,
1799 				   LIBINPUT_BUTTON_STATE_RELEASED);
1800 
1801 	litest_assert_empty_queue(li);
1802 
1803 	litest_touch_down(dev, 0, 90, 5);
1804 	litest_touch_down(dev, 1, 80, 5);
1805 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
1806 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
1807 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
1808 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
1809 	litest_touch_up(dev, 0);
1810 	litest_touch_up(dev, 1);
1811 
1812 	litest_assert_button_event(li,
1813 				   BTN_RIGHT,
1814 				   LIBINPUT_BUTTON_STATE_PRESSED);
1815 	litest_assert_button_event(li,
1816 				   BTN_RIGHT,
1817 				   LIBINPUT_BUTTON_STATE_RELEASED);
1818 }
1819 END_TEST
1820 
START_TEST(clickpad_topsoftbuttons_clickfinger_dev_disabled)1821 START_TEST(clickpad_topsoftbuttons_clickfinger_dev_disabled)
1822 {
1823 	struct litest_device *dev = litest_current_device();
1824 	struct libinput *li = dev->libinput;
1825 	struct litest_device *trackpoint = litest_add_device(li,
1826 							     LITEST_TRACKPOINT);
1827 
1828 	libinput_device_config_send_events_set_mode(dev->libinput_device,
1829 						    LIBINPUT_CONFIG_SEND_EVENTS_DISABLED);
1830 	litest_enable_clickfinger(dev);
1831 	litest_drain_events(li);
1832 
1833 	litest_touch_down(dev, 0, 90, 5);
1834 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
1835 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
1836 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
1837 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
1838 	litest_touch_up(dev, 0);
1839 
1840 	litest_assert_button_event(li,
1841 				   BTN_RIGHT,
1842 				   LIBINPUT_BUTTON_STATE_PRESSED);
1843 	litest_assert_button_event(li,
1844 				   BTN_RIGHT,
1845 				   LIBINPUT_BUTTON_STATE_RELEASED);
1846 
1847 	litest_assert_empty_queue(li);
1848 
1849 	litest_touch_down(dev, 0, 90, 5);
1850 	litest_touch_down(dev, 1, 10, 5);
1851 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
1852 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
1853 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
1854 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
1855 	litest_touch_up(dev, 0);
1856 	litest_touch_up(dev, 1);
1857 
1858 	litest_assert_button_event(li,
1859 				   BTN_MIDDLE,
1860 				   LIBINPUT_BUTTON_STATE_PRESSED);
1861 	litest_assert_button_event(li,
1862 				   BTN_MIDDLE,
1863 				   LIBINPUT_BUTTON_STATE_RELEASED);
1864 
1865 	litest_delete_device(trackpoint);
1866 }
1867 END_TEST
1868 
START_TEST(clickpad_middleemulation_config_delayed)1869 START_TEST(clickpad_middleemulation_config_delayed)
1870 {
1871 	struct litest_device *dev = litest_current_device();
1872 	struct libinput_device *device = dev->libinput_device;
1873 	struct libinput *li = dev->libinput;
1874 	enum libinput_config_status status;
1875 	int enabled;
1876 
1877 	enabled = libinput_device_config_middle_emulation_get_enabled(device);
1878 	ck_assert(!enabled);
1879 
1880 	litest_touch_down(dev, 0, 30, 95);
1881 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
1882 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
1883 	libinput_dispatch(li);
1884 
1885 	/* actual config is delayed, but status is immediate */
1886 	status = libinput_device_config_middle_emulation_set_enabled(device,
1887 				LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED);
1888 	ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
1889 
1890 	enabled = libinput_device_config_middle_emulation_get_enabled(device);
1891 	ck_assert(enabled);
1892 
1893 	status = libinput_device_config_middle_emulation_set_enabled(device,
1894 				LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED);
1895 	ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
1896 	enabled = libinput_device_config_middle_emulation_get_enabled(device);
1897 	ck_assert(!enabled);
1898 }
1899 END_TEST
1900 
START_TEST(clickpad_middleemulation_click)1901 START_TEST(clickpad_middleemulation_click)
1902 {
1903 	struct litest_device *dev = litest_current_device();
1904 	struct libinput *li = dev->libinput;
1905 
1906 	litest_enable_buttonareas(dev);
1907 	litest_enable_middleemu(dev);
1908 	litest_drain_events(li);
1909 
1910 	litest_touch_down(dev, 0, 30, 95);
1911 	litest_touch_down(dev, 1, 80, 95);
1912 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
1913 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
1914 
1915 	litest_assert_button_event(li,
1916 				   BTN_MIDDLE,
1917 				   LIBINPUT_BUTTON_STATE_PRESSED);
1918 
1919 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
1920 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
1921 	litest_touch_up(dev, 0);
1922 	litest_touch_up(dev, 1);
1923 
1924 	litest_assert_button_event(li,
1925 				   BTN_MIDDLE,
1926 				   LIBINPUT_BUTTON_STATE_RELEASED);
1927 
1928 	libinput_dispatch(li);
1929 
1930 	litest_assert_empty_queue(li);
1931 }
1932 END_TEST
1933 
START_TEST(clickpad_middleemulation_click_middle_left)1934 START_TEST(clickpad_middleemulation_click_middle_left)
1935 {
1936 	struct litest_device *dev = litest_current_device();
1937 	struct libinput *li = dev->libinput;
1938 
1939 	litest_enable_buttonareas(dev);
1940 	litest_enable_middleemu(dev);
1941 	litest_drain_events(li);
1942 
1943 	litest_touch_down(dev, 0, 49, 95);
1944 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
1945 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
1946 
1947 	litest_assert_button_event(li,
1948 				   BTN_LEFT,
1949 				   LIBINPUT_BUTTON_STATE_PRESSED);
1950 
1951 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
1952 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
1953 	litest_touch_up(dev, 0);
1954 
1955 	litest_assert_button_event(li,
1956 				   BTN_LEFT,
1957 				   LIBINPUT_BUTTON_STATE_RELEASED);
1958 
1959 	libinput_dispatch(li);
1960 
1961 	litest_assert_empty_queue(li);
1962 }
1963 END_TEST
1964 
START_TEST(clickpad_middleemulation_click_middle_right)1965 START_TEST(clickpad_middleemulation_click_middle_right)
1966 {
1967 	struct litest_device *dev = litest_current_device();
1968 	struct libinput *li = dev->libinput;
1969 
1970 	litest_enable_buttonareas(dev);
1971 	litest_enable_middleemu(dev);
1972 	litest_drain_events(li);
1973 
1974 	litest_touch_down(dev, 0, 51, 95);
1975 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
1976 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
1977 
1978 	litest_assert_button_event(li,
1979 				   BTN_RIGHT,
1980 				   LIBINPUT_BUTTON_STATE_PRESSED);
1981 
1982 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
1983 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
1984 	litest_touch_up(dev, 0);
1985 
1986 	litest_assert_button_event(li,
1987 				   BTN_RIGHT,
1988 				   LIBINPUT_BUTTON_STATE_RELEASED);
1989 
1990 	libinput_dispatch(li);
1991 
1992 	litest_assert_empty_queue(li);
1993 }
1994 END_TEST
1995 
START_TEST(clickpad_middleemulation_click_enable_while_down)1996 START_TEST(clickpad_middleemulation_click_enable_while_down)
1997 {
1998 	struct litest_device *dev = litest_current_device();
1999 	struct libinput *li = dev->libinput;
2000 
2001 	litest_enable_buttonareas(dev);
2002 	litest_drain_events(li);
2003 
2004 	litest_touch_down(dev, 0, 49, 95);
2005 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
2006 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
2007 
2008 	litest_assert_button_event(li,
2009 				   BTN_MIDDLE,
2010 				   LIBINPUT_BUTTON_STATE_PRESSED);
2011 
2012 	litest_enable_middleemu(dev);
2013 
2014 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
2015 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
2016 	litest_touch_up(dev, 0);
2017 
2018 	litest_assert_button_event(li,
2019 				   BTN_MIDDLE,
2020 				   LIBINPUT_BUTTON_STATE_RELEASED);
2021 
2022 	libinput_dispatch(li);
2023 
2024 	litest_assert_empty_queue(li);
2025 
2026 	litest_touch_down(dev, 0, 49, 95);
2027 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
2028 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
2029 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
2030 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
2031 	litest_touch_up(dev, 0);
2032 
2033 	litest_assert_button_event(li,
2034 				   BTN_LEFT,
2035 				   LIBINPUT_BUTTON_STATE_PRESSED);
2036 	litest_assert_button_event(li,
2037 				   BTN_LEFT,
2038 				   LIBINPUT_BUTTON_STATE_RELEASED);
2039 
2040 	libinput_dispatch(li);
2041 }
2042 END_TEST
2043 
START_TEST(clickpad_middleemulation_click_disable_while_down)2044 START_TEST(clickpad_middleemulation_click_disable_while_down)
2045 {
2046 	struct litest_device *dev = litest_current_device();
2047 	struct libinput *li = dev->libinput;
2048 
2049 	litest_enable_buttonareas(dev);
2050 	litest_enable_middleemu(dev);
2051 
2052 	litest_drain_events(li);
2053 
2054 	litest_touch_down(dev, 0, 30, 95);
2055 	litest_touch_down(dev, 1, 70, 95);
2056 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
2057 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
2058 
2059 	litest_assert_button_event(li,
2060 				   BTN_MIDDLE,
2061 				   LIBINPUT_BUTTON_STATE_PRESSED);
2062 
2063 	litest_disable_middleemu(dev);
2064 
2065 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
2066 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
2067 	litest_touch_up(dev, 0);
2068 	litest_touch_up(dev, 1);
2069 
2070 	litest_assert_button_event(li,
2071 				   BTN_MIDDLE,
2072 				   LIBINPUT_BUTTON_STATE_RELEASED);
2073 	libinput_dispatch(li);
2074 
2075 	litest_assert_empty_queue(li);
2076 
2077 	litest_touch_down(dev, 0, 49, 95);
2078 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
2079 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
2080 	litest_event(dev, EV_KEY, BTN_LEFT, 0);
2081 	litest_event(dev, EV_SYN, SYN_REPORT, 0);
2082 	litest_touch_up(dev, 0);
2083 
2084 	litest_assert_button_event(li,
2085 				   BTN_MIDDLE,
2086 				   LIBINPUT_BUTTON_STATE_PRESSED);
2087 	litest_assert_button_event(li,
2088 				   BTN_MIDDLE,
2089 				   LIBINPUT_BUTTON_STATE_RELEASED);
2090 
2091 	libinput_dispatch(li);
2092 }
2093 END_TEST
2094 
TEST_COLLECTION(touchpad_buttons)2095 TEST_COLLECTION(touchpad_buttons)
2096 {
2097 	struct range finger_count = {1, 4};
2098 
2099 	litest_add("touchpad:button", touchpad_button, LITEST_TOUCHPAD, LITEST_CLICKPAD);
2100 
2101 	litest_add("touchpad:clickfinger", touchpad_1fg_clickfinger, LITEST_CLICKPAD, LITEST_ANY);
2102 	litest_add("touchpad:clickfinger", touchpad_1fg_clickfinger_no_touch, LITEST_CLICKPAD, LITEST_ANY);
2103 	litest_add("touchpad:clickfinger", touchpad_2fg_clickfinger, LITEST_CLICKPAD, LITEST_ANY);
2104 	litest_add("touchpad:clickfinger", touchpad_3fg_clickfinger, LITEST_CLICKPAD, LITEST_ANY);
2105 	litest_add("touchpad:clickfinger", touchpad_3fg_clickfinger_btntool, LITEST_CLICKPAD, LITEST_ANY);
2106 	litest_add("touchpad:clickfinger", touchpad_4fg_clickfinger, LITEST_CLICKPAD, LITEST_ANY);
2107 	litest_add("touchpad:clickfinger", touchpad_4fg_clickfinger_btntool_2slots, LITEST_CLICKPAD, LITEST_ANY);
2108 	litest_add("touchpad:clickfinger", touchpad_4fg_clickfinger_btntool_3slots, LITEST_CLICKPAD, LITEST_ANY);
2109 	litest_add("touchpad:clickfinger", touchpad_2fg_clickfinger_distance, LITEST_CLICKPAD, LITEST_ANY);
2110 	litest_add("touchpad:clickfinger", touchpad_3fg_clickfinger_distance, LITEST_CLICKPAD, LITEST_ANY);
2111 	litest_add("touchpad:clickfinger", touchpad_3fg_clickfinger_distance_btntool, LITEST_CLICKPAD, LITEST_ANY);
2112 	litest_add_for_device("touchpad:clickfinger", touchpad_2fg_clickfinger_bottom, LITEST_SYNAPTICS_TOPBUTTONPAD);
2113 	litest_add("touchpad:clickfinger", touchpad_clickfinger_to_area_method, LITEST_CLICKPAD, LITEST_ANY);
2114 	litest_add("touchpad:clickfinger",
2115 		   touchpad_clickfinger_to_area_method_while_down, LITEST_CLICKPAD, LITEST_ANY);
2116 	litest_add("touchpad:clickfinger", touchpad_area_to_clickfinger_method, LITEST_CLICKPAD, LITEST_ANY);
2117 	litest_add("touchpad:clickfinger",
2118 		   touchpad_area_to_clickfinger_method_while_down, LITEST_CLICKPAD, LITEST_ANY);
2119 	/* run those two for the T440 one only so we don't have to worry
2120 	 * about small touchpads messing with thumb detection expectations */
2121 	litest_add_for_device("touchpad:clickfinger", touchpad_clickfinger_3fg_tool_position, LITEST_SYNAPTICS_TOPBUTTONPAD);
2122 	litest_add_for_device("touchpad:clickfinger", touchpad_clickfinger_4fg_tool_position, LITEST_SYNAPTICS_TOPBUTTONPAD);
2123 
2124 	litest_add_for_device("touchpad:clickfinger", touchpad_clickfinger_appletouch_config, LITEST_APPLETOUCH);
2125 	litest_add_for_device("touchpad:clickfinger", touchpad_clickfinger_appletouch_1fg, LITEST_APPLETOUCH);
2126 	litest_add_for_device("touchpad:clickfinger", touchpad_clickfinger_appletouch_2fg, LITEST_APPLETOUCH);
2127 	litest_add_for_device("touchpad:clickfinger", touchpad_clickfinger_appletouch_3fg, LITEST_APPLETOUCH);
2128 
2129 	litest_add_ranged("touchpad:clickfinger", touchpad_clickfinger_click_drag, LITEST_CLICKPAD, LITEST_ANY, &finger_count);
2130 
2131 	litest_add("touchpad:click", touchpad_click_defaults_clickfinger, LITEST_APPLE_CLICKPAD, LITEST_ANY);
2132 	litest_add("touchpad:click", touchpad_click_defaults_btnarea, LITEST_CLICKPAD, LITEST_APPLE_CLICKPAD);
2133 	litest_add("touchpad:click", touchpad_click_defaults_none, LITEST_TOUCHPAD, LITEST_CLICKPAD);
2134 	litest_add("touchpad:click", touchpad_click_defaults_none, LITEST_ANY, LITEST_TOUCHPAD);
2135 
2136 	litest_add("touchpad:click", touchpad_btn_left, LITEST_TOUCHPAD|LITEST_BUTTON, LITEST_CLICKPAD);
2137 	litest_add("touchpad:click", clickpad_btn_left, LITEST_CLICKPAD, LITEST_ANY);
2138 	litest_add("touchpad:click", clickpad_click_n_drag, LITEST_CLICKPAD, LITEST_SINGLE_TOUCH);
2139 	litest_add("touchpad:click", clickpad_finger_pin, LITEST_CLICKPAD, LITEST_ANY);
2140 
2141 	litest_add("touchpad:softbutton", clickpad_softbutton_left, LITEST_CLICKPAD, LITEST_APPLE_CLICKPAD);
2142 	litest_add("touchpad:softbutton", clickpad_softbutton_middle, LITEST_CLICKPAD, LITEST_APPLE_CLICKPAD);
2143 	litest_add("touchpad:softbutton", clickpad_softbutton_right, LITEST_CLICKPAD, LITEST_APPLE_CLICKPAD);
2144 	litest_add("touchpad:softbutton", clickpad_softbutton_left_tap_n_drag, LITEST_CLICKPAD, LITEST_APPLE_CLICKPAD);
2145 	litest_add("touchpad:softbutton", clickpad_softbutton_right_tap_n_drag, LITEST_CLICKPAD, LITEST_APPLE_CLICKPAD);
2146 	litest_add("touchpad:softbutton", clickpad_softbutton_left_1st_fg_move, LITEST_CLICKPAD, LITEST_APPLE_CLICKPAD);
2147 	litest_add("touchpad:softbutton", clickpad_softbutton_left_2nd_fg_move, LITEST_CLICKPAD, LITEST_APPLE_CLICKPAD);
2148 	litest_add("touchpad:softbutton", clickpad_softbutton_left_to_right, LITEST_CLICKPAD, LITEST_APPLE_CLICKPAD);
2149 	litest_add("touchpad:softbutton", clickpad_softbutton_right_to_left, LITEST_CLICKPAD, LITEST_APPLE_CLICKPAD);
2150 	litest_add("touchpad:softbutton", clickpad_softbutton_hover_into_buttons, LITEST_CLICKPAD|LITEST_HOVER, LITEST_APPLE_CLICKPAD);
2151 
2152 	litest_add("touchpad:topsoftbuttons", clickpad_topsoftbuttons_left, LITEST_TOPBUTTONPAD, LITEST_ANY);
2153 	litest_add("touchpad:topsoftbuttons", clickpad_topsoftbuttons_right, LITEST_TOPBUTTONPAD, LITEST_ANY);
2154 	litest_add("touchpad:topsoftbuttons", clickpad_topsoftbuttons_middle, LITEST_TOPBUTTONPAD, LITEST_ANY);
2155 	litest_add("touchpad:topsoftbuttons", clickpad_topsoftbuttons_move_out_leftclick, LITEST_TOPBUTTONPAD, LITEST_ANY);
2156 	litest_add("touchpad:topsoftbuttons", clickpad_topsoftbuttons_move_out_leftclick_before_timeout, LITEST_TOPBUTTONPAD, LITEST_ANY);
2157 	litest_add("touchpad:topsoftbuttons", clickpad_topsoftbuttons_clickfinger, LITEST_TOPBUTTONPAD, LITEST_ANY);
2158 	litest_add("touchpad:topsoftbuttons", clickpad_topsoftbuttons_clickfinger_dev_disabled, LITEST_TOPBUTTONPAD, LITEST_ANY);
2159 
2160 	litest_add("touchpad:middleemulation", clickpad_middleemulation_config_delayed, LITEST_CLICKPAD, LITEST_ANY);
2161 	litest_add("touchpad:middleemulation", clickpad_middleemulation_click, LITEST_CLICKPAD, LITEST_ANY);
2162 	litest_add("touchpad:middleemulation", clickpad_middleemulation_click_middle_left, LITEST_CLICKPAD, LITEST_ANY);
2163 	litest_add("touchpad:middleemulation", clickpad_middleemulation_click_middle_right, LITEST_CLICKPAD, LITEST_ANY);
2164 	litest_add("touchpad:middleemulation", clickpad_middleemulation_click_enable_while_down, LITEST_CLICKPAD, LITEST_ANY);
2165 	litest_add("touchpad:middleemulation", clickpad_middleemulation_click_disable_while_down, LITEST_CLICKPAD, LITEST_ANY);
2166 }
2167