• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2014-2015 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 #ifndef EVDEV_MT_TOUCHPAD_H
25 #define EVDEV_MT_TOUCHPAD_H
26 
27 #include <stdbool.h>
28 
29 #include "evdev.h"
30 #include "timer.h"
31 
32 #define TOUCHPAD_HISTORY_LENGTH 4
33 #define TOUCHPAD_MIN_SAMPLES 4
34 
35 /* Convert mm to a distance normalized to DEFAULT_MOUSE_DPI */
36 #define TP_MM_TO_DPI_NORMALIZED(mm) (DEFAULT_MOUSE_DPI/25.4 * mm)
37 
38 enum touchpad_event {
39 	TOUCHPAD_EVENT_NONE		= 0,
40 	TOUCHPAD_EVENT_MOTION		= bit(0),
41 	TOUCHPAD_EVENT_BUTTON_PRESS	= bit(1),
42 	TOUCHPAD_EVENT_BUTTON_RELEASE	= bit(2),
43 	TOUCHPAD_EVENT_OTHERAXIS	= bit(3),
44 	TOUCHPAD_EVENT_TIMESTAMP	= bit(4),
45 };
46 
47 enum touch_state {
48 	TOUCH_NONE = 0,
49 	TOUCH_HOVERING = 1,
50 	TOUCH_BEGIN = 2,
51 	TOUCH_UPDATE = 3,
52 	TOUCH_MAYBE_END = 4,
53 	TOUCH_END = 5,
54 };
55 
56 static inline const char *
touch_state_to_str(enum touch_state state)57 touch_state_to_str(enum touch_state state)
58 {
59 	switch(state) {
60 	CASE_RETURN_STRING(TOUCH_NONE);
61 	CASE_RETURN_STRING(TOUCH_HOVERING);
62 	CASE_RETURN_STRING(TOUCH_BEGIN);
63 	CASE_RETURN_STRING(TOUCH_UPDATE);
64 	CASE_RETURN_STRING(TOUCH_MAYBE_END);
65 	CASE_RETURN_STRING(TOUCH_END);
66 	}
67 	return NULL;
68 }
69 
70 enum touch_palm_state {
71 	PALM_NONE = 0,
72 	PALM_EDGE,
73 	PALM_TYPING,
74 	PALM_TRACKPOINT,
75 	PALM_TOOL_PALM,
76 	PALM_PRESSURE,
77 	PALM_TOUCH_SIZE,
78 	PALM_ARBITRATION,
79 };
80 
81 enum button_event {
82 	BUTTON_EVENT_IN_BOTTOM_R = 30,
83 	BUTTON_EVENT_IN_BOTTOM_M,
84 	BUTTON_EVENT_IN_BOTTOM_L,
85 	BUTTON_EVENT_IN_TOP_R,
86 	BUTTON_EVENT_IN_TOP_M,
87 	BUTTON_EVENT_IN_TOP_L,
88 	BUTTON_EVENT_IN_AREA,
89 	BUTTON_EVENT_UP,
90 	BUTTON_EVENT_PRESS,
91 	BUTTON_EVENT_RELEASE,
92 	BUTTON_EVENT_TIMEOUT,
93 };
94 
95 enum button_state {
96 	BUTTON_STATE_NONE,
97 	BUTTON_STATE_AREA,
98 	BUTTON_STATE_BOTTOM,
99 	BUTTON_STATE_TOP,
100 	BUTTON_STATE_TOP_NEW,
101 	BUTTON_STATE_TOP_TO_IGNORE,
102 	BUTTON_STATE_IGNORE,
103 };
104 
105 enum tp_tap_state {
106 	TAP_STATE_IDLE = 4,
107 	TAP_STATE_TOUCH,
108 	TAP_STATE_HOLD,
109 	TAP_STATE_1FGTAP_TAPPED,
110 	TAP_STATE_2FGTAP_TAPPED,
111 	TAP_STATE_3FGTAP_TAPPED,
112 	TAP_STATE_TOUCH_2,
113 	TAP_STATE_TOUCH_2_HOLD,
114 	TAP_STATE_TOUCH_2_RELEASE,
115 	TAP_STATE_TOUCH_3,
116 	TAP_STATE_TOUCH_3_HOLD,
117 	TAP_STATE_TOUCH_3_RELEASE,
118 	TAP_STATE_TOUCH_3_RELEASE_2,
119 	TAP_STATE_1FGTAP_DRAGGING_OR_DOUBLETAP,
120 	TAP_STATE_2FGTAP_DRAGGING_OR_DOUBLETAP,
121 	TAP_STATE_3FGTAP_DRAGGING_OR_DOUBLETAP,
122 	TAP_STATE_1FGTAP_DRAGGING_OR_TAP,
123 	TAP_STATE_2FGTAP_DRAGGING_OR_TAP,
124 	TAP_STATE_3FGTAP_DRAGGING_OR_TAP,
125 	TAP_STATE_1FGTAP_DRAGGING,
126 	TAP_STATE_2FGTAP_DRAGGING,
127 	TAP_STATE_3FGTAP_DRAGGING,
128 	TAP_STATE_1FGTAP_DRAGGING_WAIT,
129 	TAP_STATE_2FGTAP_DRAGGING_WAIT,
130 	TAP_STATE_3FGTAP_DRAGGING_WAIT,
131 	TAP_STATE_1FGTAP_DRAGGING_2,
132 	TAP_STATE_2FGTAP_DRAGGING_2,
133 	TAP_STATE_3FGTAP_DRAGGING_2,
134 	TAP_STATE_DEAD, /**< finger count exceeded */
135 };
136 
137 enum tp_tap_touch_state {
138 	TAP_TOUCH_STATE_IDLE = 16,	/**< not in touch */
139 	TAP_TOUCH_STATE_TOUCH,		/**< touching, may tap */
140 	TAP_TOUCH_STATE_DEAD,		/**< exceeded motion/timeout */
141 };
142 
143 /* For edge scrolling, so we only care about right and bottom */
144 enum tp_edge {
145 	EDGE_NONE	= 0,
146 	EDGE_RIGHT	= bit(0),
147 	EDGE_BOTTOM	= bit(1),
148 };
149 
150 enum tp_edge_scroll_touch_state {
151 	EDGE_SCROLL_TOUCH_STATE_NONE,
152 	EDGE_SCROLL_TOUCH_STATE_EDGE_NEW,
153 	EDGE_SCROLL_TOUCH_STATE_EDGE,
154 	EDGE_SCROLL_TOUCH_STATE_AREA,
155 };
156 
157 enum tp_gesture_state {
158 	GESTURE_STATE_NONE,
159 	GESTURE_STATE_UNKNOWN,
160 	GESTURE_STATE_HOLD,
161 	GESTURE_STATE_HOLD_AND_MOTION,
162 	GESTURE_STATE_POINTER_MOTION,
163 	GESTURE_STATE_SCROLL,
164 	GESTURE_STATE_PINCH,
165 	GESTURE_STATE_SWIPE,
166 };
167 
168 enum tp_thumb_state {
169 	THUMB_STATE_FINGER,
170 	THUMB_STATE_JAILED,
171 	THUMB_STATE_PINCH,
172 	THUMB_STATE_SUPPRESSED,
173 	THUMB_STATE_REVIVED,
174 	THUMB_STATE_REVIVED_JAILED,
175 	THUMB_STATE_DEAD,
176 };
177 
178 enum tp_jump_state {
179 	JUMP_STATE_IGNORE = 0,
180 	JUMP_STATE_EXPECT_FIRST,
181 	JUMP_STATE_EXPECT_DELAY,
182 };
183 
184 struct tp_touch {
185 	struct tp_dispatch *tp;
186 	unsigned int index;
187 	enum touch_state state;
188 	bool has_ended;				/* TRACKING_ID == -1 */
189 	bool dirty;
190 	struct device_coords point;
191 	uint64_t initial_time;
192 	int pressure;
193 	bool is_tool_palm; /* MT_TOOL_PALM */
194 	int major, minor;
195 
196 	bool was_down; /* if distance == 0, false for pure hovering
197 			  touches */
198 
199 	struct {
200 		/* A quirk mostly used on Synaptics touchpads. In a
201 		   transition to/from fake touches > num_slots, the current
202 		   event data is likely garbage and the subsequent event
203 		   is likely too. This marker tells us to reset the motion
204 		   history again -> this effectively swallows any motion */
205 		bool reset_motion_history;
206 	} quirks;
207 
208 	struct {
209 		struct tp_history_point {
210 			uint64_t time;
211 			struct device_coords point;
212 		} samples[TOUCHPAD_HISTORY_LENGTH];
213 		unsigned int index;
214 		unsigned int count;
215 	} history;
216 
217 	struct {
218 		double last_delta_mm;
219 	} jumps;
220 
221 	struct {
222 		struct device_coords center;
223 		uint8_t x_motion_history;
224 	} hysteresis;
225 
226 	/* A pinned touchpoint is the one that pressed the physical button
227 	 * on a clickpad. After the release, it won't move until the center
228 	 * moves more than a threshold away from the original coordinates
229 	 */
230 	struct {
231 		bool is_pinned;
232 		struct device_coords center;
233 	} pinned;
234 
235 	/* Software-button state and timeout if applicable */
236 	struct {
237 		enum button_state state;
238 		/* We use button_event here so we can use == on events */
239 		enum button_event current;
240 		struct libinput_timer timer;
241 		struct device_coords initial;
242 		bool has_moved; /* has moved more than threshold */
243 		uint64_t initial_time;
244 	} button;
245 
246 	struct {
247 		enum tp_tap_touch_state state;
248 		struct device_coords initial;
249 		bool is_thumb;
250 		bool is_palm;
251 	} tap;
252 
253 	struct {
254 		enum tp_edge_scroll_touch_state edge_state;
255 		uint32_t edge;
256 		int direction;
257 		struct libinput_timer timer;
258 		struct device_coords initial;
259 	} scroll;
260 
261 	struct {
262 		enum touch_palm_state state;
263 		struct device_coords first; /* first coordinates if is_palm == true */
264 		uint64_t time; /* first timestamp if is_palm == true */
265 	} palm;
266 
267 	struct {
268 		struct device_coords initial;
269 	} gesture;
270 
271 	struct {
272 		double last_speed; /* speed in mm/s at last sample */
273 		unsigned int exceeded_count;
274 	} speed;
275 };
276 
277 enum suspend_trigger {
278 	SUSPEND_NO_FLAG         = 0x0,
279 	SUSPEND_EXTERNAL_MOUSE  = 0x1,
280 	SUSPEND_SENDEVENTS      = 0x2,
281 	SUSPEND_LID             = 0x4,
282 	SUSPEND_TABLET_MODE     = 0x8,
283 };
284 
285 struct tp_dispatch {
286 	struct evdev_dispatch base;
287 	struct evdev_device *device;
288 	unsigned int nfingers_down;		/* number of fingers down */
289 	unsigned int old_nfingers_down;		/* previous no fingers down */
290 	unsigned int slot;			/* current slot */
291 	bool has_mt;
292 	bool semi_mt;
293 
294 	uint32_t suspend_reason;
295 
296 	/* pen/touch arbitration */
297 	struct {
298 		enum evdev_arbitration_state state;
299 		struct libinput_timer arbitration_timer;
300 	} arbitration;
301 
302 	unsigned int nactive_slots;		/* number of active slots */
303 	unsigned int num_slots;			/* number of slots */
304 	unsigned int ntouches;			/* no slots inc. fakes */
305 	struct tp_touch *touches;		/* len == ntouches */
306 	/* bit 0: BTN_TOUCH
307 	 * bit 1: BTN_TOOL_FINGER
308 	 * bit 2: BTN_TOOL_DOUBLETAP
309 	 * ...
310 	 */
311 	unsigned int fake_touches;
312 
313 	struct {
314 		bool detection_disabled;
315 		struct ratelimit warning;
316 	} jump;
317 
318 	/* if pressure goes above high -> touch down,
319 	   if pressure then goes below low -> touch up */
320 	struct {
321 		bool use_pressure;
322 		int high;
323 		int low;
324 	} pressure;
325 
326 	/* If touch size (either axis) goes above high -> touch down,
327 	   if touch size (either axis) goes below low -> touch up */
328 	struct  {
329 		bool use_touch_size;
330 		int high;
331 		int low;
332 
333 		/* convert device units to angle */
334 		double orientation_to_angle;
335 	} touch_size;
336 
337 	struct {
338 		bool enabled;
339 		struct device_coords margin;
340 		unsigned int other_event_count;
341 		uint64_t last_motion_time;
342 	} hysteresis;
343 
344 	struct {
345 		double x_scale_coeff;
346 		double y_scale_coeff;
347 		double xy_scale_coeff;
348 	} accel;
349 
350 	struct {
351 		struct libinput_device_config_gesture config;
352 		bool enabled;
353 		bool started;
354 		unsigned int finger_count;
355 		unsigned int finger_count_pending;
356 		struct libinput_timer finger_count_switch_timer;
357 		enum tp_gesture_state state;
358 		struct tp_touch *touches[2];
359 		uint64_t initial_time;
360 		double initial_distance;
361 		double prev_scale;
362 		double angle;
363 		struct device_float_coords center;
364 		struct libinput_timer hold_timer;
365 		bool hold_enabled;
366 	} gesture;
367 
368 	struct {
369 		bool is_clickpad;		/* true for clickpads */
370 		bool has_topbuttons;
371 		bool use_clickfinger;		/* number of fingers decides button number */
372 		bool click_pending;
373 		uint32_t state;
374 		uint32_t old_state;
375 		struct {
376 			double x_scale_coeff;
377 			double y_scale_coeff;
378 		} motion_dist;			/* for pinned touches */
379 		unsigned int active;		/* currently active button, for release event */
380 		bool active_is_topbutton;	/* is active a top button? */
381 
382 		/* Only used for clickpads. The software button areas are
383 		 * always 2 horizontal stripes across the touchpad.
384 		 * The buttons are split according to the edge settings.
385 		 */
386 		struct {
387 			int32_t top_edge;	/* in device coordinates */
388 			int32_t rightbutton_left_edge; /* in device coordinates */
389 			int32_t middlebutton_left_edge; /* in device coordinates */
390 		} bottom_area;
391 
392 		struct {
393 			int32_t bottom_edge;	/* in device coordinates */
394 			int32_t rightbutton_left_edge; /* in device coordinates */
395 			int32_t leftbutton_right_edge; /* in device coordinates */
396 		} top_area;
397 
398 		struct evdev_device *trackpoint;
399 
400 		enum libinput_config_click_method click_method;
401 		struct libinput_device_config_click_method config_method;
402 	} buttons;
403 
404 	struct {
405 		struct libinput_device_config_scroll_method config_method;
406 		enum libinput_config_scroll_method method;
407 		int32_t right_edge;		/* in device coordinates */
408 		int32_t bottom_edge;		/* in device coordinates */
409 		struct {
410 			bool h, v;
411 		} active;
412 		struct phys_coords vector;
413 		uint64_t time_prev;
414 		struct {
415 			uint64_t h, v;
416 		} duration;
417 	} scroll;
418 
419 	enum touchpad_event queued;
420 
421 	struct {
422 		struct libinput_device_config_tap config;
423 		bool enabled;
424 		bool suspended;
425 		struct libinput_timer timer;
426 		enum tp_tap_state state;
427 		uint32_t buttons_pressed;
428 		uint64_t saved_press_time,
429 			 saved_release_time;
430 
431 		enum libinput_config_tap_button_map map;
432 		enum libinput_config_tap_button_map want_map;
433 
434 		bool drag_enabled;
435 		bool drag_lock_enabled;
436 
437 		unsigned int nfingers_down;	/* number of fingers down for tapping (excl. thumb/palm) */
438 	} tap;
439 
440 	struct {
441 		int32_t right_edge;		/* in device coordinates */
442 		int32_t left_edge;		/* in device coordinates */
443 		int32_t upper_edge;		/* in device coordinates */
444 
445 		bool trackpoint_active;
446 		struct libinput_event_listener trackpoint_listener;
447 		struct libinput_timer trackpoint_timer;
448 		uint64_t trackpoint_last_event_time;
449 		uint32_t trackpoint_event_count;
450 		bool monitor_trackpoint;
451 
452 		bool use_mt_tool;
453 
454 		bool use_pressure;
455 		int pressure_threshold;
456 
457 		bool use_size;
458 		int size_threshold;
459 	} palm;
460 
461 	struct {
462 		struct libinput_device_config_send_events config;
463 		enum libinput_config_send_events_mode current_mode;
464 	} sendevents;
465 
466 	struct {
467 		struct libinput_device_config_dwt config;
468 		bool dwt_enabled;
469 
470 		/* We have to allow for more than one device node to be the
471 		 * internal dwt keyboard (Razer Blade). But they're the same
472 		 * physical device, so we don't care about per-keyboard
473 		 * key/modifier masks.
474 		 */
475 		struct list paired_keyboard_list;
476 
477 		unsigned long key_mask[NLONGS(KEY_CNT)];
478 		unsigned long mod_mask[NLONGS(KEY_CNT)];
479 		bool keyboard_active;
480 		struct libinput_timer keyboard_timer;
481 		uint64_t keyboard_last_press_time;
482 	} dwt;
483 
484 	struct {
485 		bool detect_thumbs;
486 		int upper_thumb_line;
487 		int lower_thumb_line;
488 
489 		bool use_pressure;
490 		int pressure_threshold;
491 
492 		bool use_size;
493 		int size_threshold;
494 
495 		enum tp_thumb_state state;
496 		unsigned int index;
497 		bool pinch_eligible;
498 	} thumb;
499 
500 	struct {
501 		/* A quirk used on the T450 series Synaptics hardware.
502 		 * Slowly moving the finger causes multiple events with only
503 		 * ABS_MT_PRESSURE but no x/y information. When the x/y
504 		 * event comes, it will be a jump of ~20 units. We use the
505 		 * below to count non-motion events to discard that first
506 		 * event with the jump.
507 		 */
508 		unsigned int nonmotion_event_count;
509 
510 		struct msc_timestamp {
511 			enum tp_jump_state state;
512 			uint32_t interval;
513 			uint32_t now;
514 		} msc_timestamp;
515 	} quirks;
516 
517 	struct {
518 		struct libinput_event_listener listener;
519 		struct evdev_device *lid_switch;
520 	} lid_switch;
521 
522 	struct {
523 		struct libinput_event_listener listener;
524 		struct evdev_device *tablet_mode_switch;
525 	} tablet_mode_switch;
526 
527 	struct {
528 		bool rotate;
529 		bool want_rotate;
530 
531 		bool must_rotate; /* true if we should rotate when applicable */
532 		struct evdev_device *tablet_device;
533 		bool tablet_left_handed_state;
534 	} left_handed;
535 };
536 
537 static inline struct tp_dispatch*
tp_dispatch(struct evdev_dispatch * dispatch)538 tp_dispatch(struct evdev_dispatch *dispatch)
539 {
540 	evdev_verify_dispatch_type(dispatch, DISPATCH_TOUCHPAD);
541 
542 	return container_of(dispatch, struct tp_dispatch, base);
543 }
544 
545 #define tp_for_each_touch(_tp, _t) \
546 	for (unsigned int _i = 0; _i < (_tp)->ntouches && (_t = &(_tp)->touches[_i]); _i++)
547 
548 static inline struct libinput*
tp_libinput_context(const struct tp_dispatch * tp)549 tp_libinput_context(const struct tp_dispatch *tp)
550 {
551 	return evdev_libinput_context(tp->device);
552 }
553 
554 static inline struct normalized_coords
tp_normalize_delta(const struct tp_dispatch * tp,struct device_float_coords delta)555 tp_normalize_delta(const struct tp_dispatch *tp,
556 		   struct device_float_coords delta)
557 {
558 	struct normalized_coords normalized;
559 
560 	normalized.x = delta.x * tp->accel.x_scale_coeff;
561 	normalized.y = delta.y * tp->accel.y_scale_coeff;
562 
563 	return normalized;
564 }
565 
566 static inline struct phys_coords
tp_phys_delta(const struct tp_dispatch * tp,struct device_float_coords delta)567 tp_phys_delta(const struct tp_dispatch *tp,
568 	      struct device_float_coords delta)
569 {
570 	struct phys_coords mm;
571 
572 	mm.x = delta.x / tp->device->abs.absinfo_x->resolution;
573 	mm.y = delta.y / tp->device->abs.absinfo_y->resolution;
574 
575 	return mm;
576 }
577 
578 /**
579  * Takes a set of device coordinates, returns that set of coordinates in the
580  * x-axis' resolution.
581  */
582 static inline struct device_float_coords
tp_scale_to_xaxis(const struct tp_dispatch * tp,struct device_float_coords delta)583 tp_scale_to_xaxis(const struct tp_dispatch *tp,
584 		  struct device_float_coords delta)
585 {
586 	struct device_float_coords raw;
587 
588 	raw.x = delta.x;
589 	raw.y = delta.y * tp->accel.xy_scale_coeff;
590 
591 	return raw;
592 }
593 
594 struct device_coords
595 tp_get_delta(struct tp_touch *t);
596 
597 struct normalized_coords
598 tp_filter_motion(struct tp_dispatch *tp,
599 		 const struct device_float_coords *unaccelerated,
600 		 uint64_t time);
601 
602 struct normalized_coords
603 tp_filter_motion_unaccelerated(struct tp_dispatch *tp,
604 			       const struct device_float_coords *unaccelerated,
605 			       uint64_t time);
606 
607 bool
608 tp_touch_active(const struct tp_dispatch *tp, const struct tp_touch *t);
609 
610 bool
611 tp_touch_active_for_gesture(const struct tp_dispatch *tp,
612 			    const struct tp_touch *t);
613 
614 int
615 tp_tap_handle_state(struct tp_dispatch *tp, uint64_t time);
616 
617 void
618 tp_tap_post_process_state(struct tp_dispatch *tp);
619 
620 void
621 tp_init_tap(struct tp_dispatch *tp);
622 
623 void
624 tp_remove_tap(struct tp_dispatch *tp);
625 
626 void
627 tp_init_buttons(struct tp_dispatch *tp, struct evdev_device *device);
628 
629 void
630 tp_init_top_softbuttons(struct tp_dispatch *tp,
631 			struct evdev_device *device,
632 			double topbutton_size_mult);
633 
634 void
635 tp_remove_buttons(struct tp_dispatch *tp);
636 
637 void
638 tp_process_button(struct tp_dispatch *tp,
639 		  const struct input_event *e,
640 		  uint64_t time);
641 
642 void
643 tp_release_all_buttons(struct tp_dispatch *tp,
644 		       uint64_t time);
645 
646 int
647 tp_post_button_events(struct tp_dispatch *tp, uint64_t time);
648 
649 void
650 tp_button_handle_state(struct tp_dispatch *tp, uint64_t time);
651 
652 bool
653 tp_button_touch_active(const struct tp_dispatch *tp,
654 		       const struct tp_touch *t);
655 
656 bool
657 tp_button_is_inside_softbutton_area(const struct tp_dispatch *tp,
658 				    const struct tp_touch *t);
659 
660 void
661 tp_release_all_taps(struct tp_dispatch *tp,
662 		    uint64_t now);
663 
664 void
665 tp_tap_suspend(struct tp_dispatch *tp, uint64_t time);
666 
667 void
668 tp_tap_resume(struct tp_dispatch *tp, uint64_t time);
669 
670 bool
671 tp_tap_dragging(const struct tp_dispatch *tp);
672 
673 bool
674 tp_tap_dragging_or_double_tapping(const struct tp_dispatch *tp);
675 
676 void
677 tp_edge_scroll_init(struct tp_dispatch *tp, struct evdev_device *device);
678 
679 void
680 tp_remove_edge_scroll(struct tp_dispatch *tp);
681 
682 void
683 tp_edge_scroll_handle_state(struct tp_dispatch *tp, uint64_t time);
684 
685 int
686 tp_edge_scroll_post_events(struct tp_dispatch *tp, uint64_t time);
687 
688 void
689 tp_edge_scroll_stop_events(struct tp_dispatch *tp, uint64_t time);
690 
691 int
692 tp_edge_scroll_touch_active(const struct tp_dispatch *tp,
693 			    const struct tp_touch *t);
694 
695 uint32_t
696 tp_touch_get_edge(const struct tp_dispatch *tp, const struct tp_touch *t);
697 
698 void
699 tp_init_gesture(struct tp_dispatch *tp);
700 
701 void
702 tp_remove_gesture(struct tp_dispatch *tp);
703 
704 void
705 tp_gesture_stop(struct tp_dispatch *tp, uint64_t time);
706 
707 void
708 tp_gesture_cancel(struct tp_dispatch *tp, uint64_t time);
709 
710 void
711 tp_gesture_cancel_motion_gestures(struct tp_dispatch *tp, uint64_t time);
712 
713 void
714 tp_gesture_handle_state(struct tp_dispatch *tp, uint64_t time);
715 
716 void
717 tp_gesture_post_events(struct tp_dispatch *tp, uint64_t time,
718 		       bool ignore_motion);
719 
720 void
721 tp_gesture_stop_twofinger_scroll(struct tp_dispatch *tp, uint64_t time);
722 
723 void
724 tp_gesture_tap_timeout(struct tp_dispatch *tp, uint64_t time);
725 
726 bool
727 tp_palm_tap_is_palm(const struct tp_dispatch *tp, const struct tp_touch *t);
728 
729 void
730 tp_clickpad_middlebutton_apply_config(struct evdev_device *device);
731 
732 bool
733 tp_thumb_ignored(const struct tp_dispatch *tp, const struct tp_touch *t);
734 
735 void
736 tp_thumb_reset(struct tp_dispatch *tp);
737 
738 bool
739 tp_thumb_ignored_for_gesture(const struct tp_dispatch *tp, const struct tp_touch *t);
740 
741 bool
742 tp_thumb_ignored_for_tap(const struct tp_dispatch *tp,
743 			 const struct tp_touch *t);
744 
745 void
746 tp_thumb_suppress(struct tp_dispatch *tp, struct tp_touch *t);
747 
748 void
749 tp_thumb_update_touch(struct tp_dispatch *tp,
750 		      struct tp_touch *t,
751 		      uint64_t time);
752 
753 void
754 tp_detect_thumb_while_moving(struct tp_dispatch *tp);
755 
756 void
757 tp_thumb_update_multifinger(struct tp_dispatch *tp);
758 
759 void
760 tp_init_thumb(struct tp_dispatch *tp);
761 
762 struct tp_touch*
763 tp_thumb_get_touch(struct tp_dispatch *tp);
764 
765 #endif
766