2 * Copyright © 2014 Red Hat, Inc.
4 * Permission to use, copy, modify, distribute, and sell this software and
5 * its documentation for any purpose is hereby granted without fee, provided
6 * that the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of the copyright holders not be used in
9 * advertising or publicity pertaining to distribution of the software
10 * without specific, written prior permission. The copyright holders make
11 * no representations about the suitability of this software for any
12 * purpose. It is provided "as is" without express or implied warranty.
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
15 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
17 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
18 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
19 * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
20 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
24 #ifndef EVDEV_MT_TOUCHPAD_H
25 #define EVDEV_MT_TOUCHPAD_H
33 #define TOUCHPAD_HISTORY_LENGTH 4
34 #define TOUCHPAD_MIN_SAMPLES 4
37 TOUCHPAD_EVENT_NONE = 0,
38 TOUCHPAD_EVENT_MOTION = (1 << 0),
39 TOUCHPAD_EVENT_BUTTON_PRESS = (1 << 1),
40 TOUCHPAD_EVENT_BUTTON_RELEASE = (1 << 2),
51 BUTTON_EVENT_IN_BOTTOM_R = 30,
52 BUTTON_EVENT_IN_BOTTOM_L,
53 BUTTON_EVENT_IN_TOP_R,
54 BUTTON_EVENT_IN_TOP_M,
55 BUTTON_EVENT_IN_TOP_L,
69 BUTTON_STATE_TOP_TO_IGNORE,
79 TAP_STATE_TOUCH_2_HOLD,
81 TAP_STATE_TOUCH_3_HOLD,
82 TAP_STATE_DRAGGING_OR_DOUBLETAP,
84 TAP_STATE_DRAGGING_WAIT,
86 TAP_STATE_DEAD, /**< finger count exceeded */
89 enum tp_tap_touch_state {
90 TAP_TOUCH_STATE_IDLE = 16, /**< not in touch */
91 TAP_TOUCH_STATE_TOUCH, /**< touching, may tap */
92 TAP_TOUCH_STATE_DEAD, /**< exceeded motion/timeout */
101 struct tp_dispatch *tp;
102 enum touch_state state;
104 bool fake; /* a fake touch */
105 bool is_pointer; /* the pointer-controlling touch */
111 struct tp_motion samples[TOUCHPAD_HISTORY_LENGTH];
121 /* A pinned touchpoint is the one that pressed the physical button
122 * on a clickpad. After the release, it won't move until the center
123 * moves more than a threshold away from the original coordinates
131 /* Software-button state and timeout if applicable */
133 enum button_state state;
134 /* We use button_event here so we can use == on events */
135 enum button_event curr;
136 struct libinput_timer timer;
140 enum tp_tap_touch_state state;
145 struct evdev_dispatch base;
146 struct evdev_device *device;
147 unsigned int nfingers_down; /* number of fingers down */
148 unsigned int slot; /* current slot */
151 unsigned int ntouches; /* number of slots */
152 struct tp_touch *touches; /* len == ntouches */
153 unsigned int fake_touches; /* fake touch mask */
160 struct motion_filter *filter;
163 double x_scale_coeff;
164 double y_scale_coeff;
168 bool is_clickpad; /* true for clickpads */
170 bool use_clickfinger; /* number of fingers decides button number */
174 uint32_t motion_dist; /* for pinned touches */
175 unsigned int active; /* currently active button, for release event */
177 /* Only used for clickpads. The software button areas are
178 * always 2 horizontal stripes across the touchpad.
179 * The buttons are split according to the edge settings.
183 int32_t rightbutton_left_edge;
188 int32_t rightbutton_left_edge;
189 int32_t leftbutton_right_edge;
191 } buttons; /* physical buttons */
194 enum libinput_pointer_axis direction;
197 enum touchpad_event queued;
200 struct libinput_device_config_tap config;
202 struct libinput_timer timer;
203 enum tp_tap_state state;
207 #define tp_for_each_touch(_tp, _t) \
208 for (unsigned int _i = 0; _i < (_tp)->ntouches && (_t = &(_tp)->touches[_i]); _i++)
211 tp_get_delta(struct tp_touch *t, double *dx, double *dy);
214 tp_set_pointer(struct tp_dispatch *tp, struct tp_touch *t);
217 tp_tap_handle_state(struct tp_dispatch *tp, uint64_t time);
220 tp_init_tap(struct tp_dispatch *tp);
223 tp_destroy_tap(struct tp_dispatch *tp);
226 tp_init_buttons(struct tp_dispatch *tp, struct evdev_device *device);
229 tp_destroy_buttons(struct tp_dispatch *tp);
232 tp_process_button(struct tp_dispatch *tp,
233 const struct input_event *e,
237 tp_post_button_events(struct tp_dispatch *tp, uint64_t time);
240 tp_button_handle_state(struct tp_dispatch *tp, uint64_t time);
243 tp_button_touch_active(struct tp_dispatch *tp, struct tp_touch *t);