chiark / gitweb /
Offsets: In button zone code, cope with negative "pos" values
[xf86-input-mtrack.git] / include / gestures.h
1 /***************************************************************************
2  *
3  * Multitouch X driver
4  * Copyright (C) 2008 Henrik Rydberg <rydberg@euromail.se>
5  * Copyright (C) 2011 Ryan Bourgeois <bluedragonx@gmail.com>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20  *
21  **************************************************************************/
22
23 #ifndef GESTURES_H
24 #define GESTURES_H
25
26 #include "common.h"
27 #include "mconfig.h"
28 #include "hwstate.h"
29 #include "mtstate.h"
30
31 struct MTouch;
32
33 #define GS_TAP 0
34 #define GS_BUTTON 1
35
36 #define GS_NONE 0
37 #define GS_MOVE 1
38 #define GS_SCROLL 2
39 #define GS_SWIPE 3
40 #define GS_SCALE 4
41 #define GS_ROTATE 5
42 #define GS_DRAG_READY 6
43 #define GS_DRAG_WAIT 7
44 #define GS_DRAG_ACTIVE 8
45
46 struct Gestures {
47         /* Taps, physical buttons, and gestures will trigger
48          * button events. If a bit is set, the button is down.
49          * If a bit is not set, the button is up.
50          * Bit 0 is button 1.
51          */
52         bitmask_t buttons;
53
54         /* Pointer movement is tracked here.
55          */
56         int move_dx, move_dy;
57
58         /* Current time and time delta. Updated after each event and after sleeping.
59          */
60         struct timeval time;
61         struct timeval dt;
62
63         /* Internal state tracking. Not for direct access.
64          */
65         int button_emulate;
66         int button_delayed;
67         struct timeval button_delayed_time;
68         struct timeval button_delayed_delta;
69
70         int tap_touching;
71         int tap_released;
72         struct timeval tap_time_down;
73
74         int move_type;
75         int move_dist;
76         int move_dir;
77         int move_drag;
78         int move_drag_dx;
79         int move_drag_dy;
80         double move_speed;
81         struct timeval move_wait;
82         struct timeval move_drag_wait;
83         struct timeval move_drag_expire;
84 };
85
86
87 void gestures_init(struct MTouch* mt);
88 void gestures_extract(struct MTouch* mt);
89 int gestures_delayed(struct MTouch* mt);
90
91 #endif
92