summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@euromail.se>2009-05-16 20:11:08 +0200
committerHenrik Rydberg <rydberg@euromail.se>2009-05-16 20:11:08 +0200
commitca85f84aedb3b4cfd78dfe1874239421de8807d6 (patch)
tree282b54229e03183afcc7ea80f4cacbb19c132c16
parentba20f03d7d2794b3d794e839ba1db45ba327bb62 (diff)
Add multi-finger button and scroll from experimental
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
-rw-r--r--src/gestures.c10
-rw-r--r--src/gestures.h6
-rw-r--r--src/multitouch.c51
-rw-r--r--src/state.c4
4 files changed, 61 insertions, 10 deletions
diff --git a/src/gestures.c b/src/gestures.c
index 8dfb939..9a1281c 100644
--- a/src/gestures.c
+++ b/src/gestures.c
@@ -25,6 +25,16 @@ void extract_gestures(struct Gestures *gs, struct MTouch* mt)
25 gs->dy /= dn; 25 gs->dy /= dn;
26 if (nsf == 1) 26 if (nsf == 1)
27 SETBIT(gs->type, GS_MOVE); 27 SETBIT(gs->type, GS_MOVE);
28 if (nsf == 2)
29 SETBIT(gs->type, GS_VSCROLL);
30 if (nsf == 3)
31 SETBIT(gs->type, GS_HSCROLL);
32 }
33 if (mt->ns.button == (1U << MT_BUTTON_LEFT)) {
34 if (nsf == 2)
35 mt->ns.button = (1U << MT_BUTTON_RIGHT);
36 if (nsf == 3)
37 mt->ns.button = (1U << MT_BUTTON_MIDDLE);
28 } 38 }
29 for (i = 0; i < DIM_BUTTON; i++) { 39 for (i = 0; i < DIM_BUTTON; i++) {
30 if (GETBIT(mt->ns.button, i) != GETBIT(mt->os.button, i)) { 40 if (GETBIT(mt->ns.button, i) != GETBIT(mt->os.button, i)) {
diff --git a/src/gestures.h b/src/gestures.h
index 18ac920..de029b7 100644
--- a/src/gestures.h
+++ b/src/gestures.h
@@ -5,8 +5,10 @@
5 5
6//////////////////////////////////////////////////////// 6////////////////////////////////////////////////////////
7 7
8#define GS_MOVE 0 8#define GS_BUTTON 0
9#define GS_BUTTON 1 9#define GS_MOVE 1
10#define GS_VSCROLL 2
11#define GS_HSCROLL 3
10 12
11//////////////////////////////////////////////////////// 13////////////////////////////////////////////////////////
12 14
diff --git a/src/multitouch.c b/src/multitouch.c
index 99807b9..11f1e19 100644
--- a/src/multitouch.c
+++ b/src/multitouch.c
@@ -120,20 +120,59 @@ static int device_close(LocalDevicePtr local)
120 120
121//////////////////////////////////////////////////////////////////////////// 121////////////////////////////////////////////////////////////////////////////
122 122
123static void tickle_button(LocalDevicePtr local, int id)
124{
125 xf86PostButtonEvent(local->dev, FALSE, id, 1, 0, 0);
126 xf86PostButtonEvent(local->dev, FALSE, id, 0, 0, 0);
127}
128
129////////////////////////////////////////////////////////////////////////////
130
123static void handle_gestures(LocalDevicePtr local, 131static void handle_gestures(LocalDevicePtr local,
124 const struct Gestures *gs) 132 const struct Gestures *gs,
133 const struct Capabilities *caps)
125{ 134{
135 static int vscroll, hscroll;
126 int i; 136 int i;
127 if (GETBIT(gs->type, GS_MOVE)) {
128 xf86PostMotionEvent(local->dev, 0, 0, 2, gs->dx, gs->dy);
129 //xf86Msg(X_INFO, "motion: %d %d\n", gs->dx, gs->dy);
130 }
131 for (i = 0; i < gs->nbt; i++) { 137 for (i = 0; i < gs->nbt; i++) {
132 xf86PostButtonEvent(local->dev, FALSE, 138 xf86PostButtonEvent(local->dev, FALSE,
133 gs->btix[i], gs->btval[i], 139 gs->btix[i], gs->btval[i],
134 0, 0); 140 0, 0);
135 xf86Msg(X_INFO, "button: %d %d\n", gs->btix[i], gs->btval[i]); 141 xf86Msg(X_INFO, "button: %d %d\n", gs->btix[i], gs->btval[i]);
136 } 142 }
143 if (GETBIT(gs->type, GS_MOVE)) {
144 xf86PostMotionEvent(local->dev, 0, 0, 2,
145 gs->dx, gs->dy);
146 xf86Msg(X_INFO, "motion: %d %d\n", gs->dx, gs->dy);
147 }
148 if (GETBIT(gs->type, GS_VSCROLL)) {
149 int vstep = 0.03 * (caps->abs_position_y.maximum -
150 caps->abs_position_y.minimum);
151 vscroll += gs->dy;
152 while (vscroll > vstep) {
153 tickle_button(local, 5);
154 vscroll -= vstep;
155 }
156 while (vscroll < -vstep) {
157 tickle_button(local, 4);
158 vscroll += vstep;
159 }
160 xf86Msg(X_INFO, "vscroll: %d\n", gs->dy);
161 }
162 if (GETBIT(gs->type, GS_HSCROLL)) {
163 int hstep = 0.1 * (caps->abs_position_x.maximum -
164 caps->abs_position_x.minimum);
165 hscroll += gs->dx;
166 while (hscroll > hstep) {
167 tickle_button(local, 6);
168 hscroll -= hstep;
169 }
170 while (hscroll < -hstep) {
171 tickle_button(local, 7);
172 hscroll += hstep;
173 }
174 xf86Msg(X_INFO, "hscroll: %d\n", gs->dx);
175 }
137} 176}
138 177
139//////////////////////////////////////////////////////////////////////////// 178////////////////////////////////////////////////////////////////////////////
@@ -146,7 +185,7 @@ static void read_input(LocalDevicePtr local)
146 while (read_synchronized_event(mt, local->fd)) { 185 while (read_synchronized_event(mt, local->fd)) {
147 parse_event(mt); 186 parse_event(mt);
148 extract_gestures(&gs, mt); 187 extract_gestures(&gs, mt);
149 handle_gestures(local, &gs); 188 handle_gestures(local, &gs, &mt->caps);
150 } 189 }
151} 190}
152 191
diff --git a/src/state.c b/src/state.c
index 290ec95..9bac532 100644
--- a/src/state.c
+++ b/src/state.c
@@ -2,8 +2,8 @@
2#include <stdlib.h> 2#include <stdlib.h>
3#include <limits.h> 3#include <limits.h>
4 4
5const double FTW = 0.1; 5const double FTW = 0.05;
6const double FTS = 0.1; 6const double FTS = 0.05;
7 7
8/******************************************************/ 8/******************************************************/
9 9