diff options
| author | Henrik Rydberg <rydberg@euromail.se> | 2010-04-14 16:07:17 +0200 |
|---|---|---|
| committer | Henrik Rydberg <rydberg@euromail.se> | 2010-04-15 06:10:08 +0200 |
| commit | 2e51d27cf6e1380e7bf4744215bf16243af2829d (patch) | |
| tree | b4baa44ba1107fb694a4813cdc337fcc078ace13 /src | |
| parent | e5bff8354652f5798d1906004150790377abc775 (diff) | |
Define swipe gestures
Define three-finger vertical and horizontal scroll as vertical and
horizontal swipe gestures.
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'src')
| -rw-r--r-- | src/gestures.c | 16 | ||||
| -rw-r--r-- | src/gestures.h | 2 | ||||
| -rw-r--r-- | src/multitouch.c | 24 |
3 files changed, 32 insertions, 10 deletions
diff --git a/src/gestures.c b/src/gestures.c index fb81576..d075356 100644 --- a/src/gestures.c +++ b/src/gestures.c | |||
| @@ -90,10 +90,18 @@ static void extract_type(struct Gestures *gs, struct MTouch* mt) | |||
| 90 | if (gs->dx || gs->dy) { | 90 | if (gs->dx || gs->dy) { |
| 91 | if (mt->state.nfinger == 1) | 91 | if (mt->state.nfinger == 1) |
| 92 | SETBIT(gs->type, GS_MOVE); | 92 | SETBIT(gs->type, GS_MOVE); |
| 93 | if (mt->state.nfinger == 2) | 93 | if (mt->state.nfinger == 2) { |
| 94 | SETBIT(gs->type, GS_VSCROLL); | 94 | if (gs->dx) |
| 95 | if (mt->state.nfinger == 3) | 95 | SETBIT(gs->type, GS_HSCROLL); |
| 96 | SETBIT(gs->type, GS_HSCROLL); | 96 | if (gs->dy) |
| 97 | SETBIT(gs->type, GS_VSCROLL); | ||
| 98 | } | ||
| 99 | if (mt->state.nfinger == 3) { | ||
| 100 | if (gs->dx) | ||
| 101 | SETBIT(gs->type, GS_HSWIPE); | ||
| 102 | if (gs->dy) | ||
| 103 | SETBIT(gs->type, GS_VSWIPE); | ||
| 104 | } | ||
| 97 | } | 105 | } |
| 98 | } | 106 | } |
| 99 | 107 | ||
diff --git a/src/gestures.h b/src/gestures.h index 0428195..e99bc3d 100644 --- a/src/gestures.h +++ b/src/gestures.h | |||
| @@ -28,6 +28,8 @@ | |||
| 28 | #define GS_MOVE 1 | 28 | #define GS_MOVE 1 |
| 29 | #define GS_VSCROLL 2 | 29 | #define GS_VSCROLL 2 |
| 30 | #define GS_HSCROLL 3 | 30 | #define GS_HSCROLL 3 |
| 31 | #define GS_VSWIPE 4 | ||
| 32 | #define GS_HSWIPE 5 | ||
| 31 | 33 | ||
| 32 | struct Gestures { | 34 | struct Gestures { |
| 33 | unsigned type, btmask, btdata; | 35 | unsigned type, btmask, btdata; |
diff --git a/src/multitouch.c b/src/multitouch.c index f0e572d..cc57cad 100644 --- a/src/multitouch.c +++ b/src/multitouch.c | |||
| @@ -28,7 +28,9 @@ | |||
| 28 | 28 | ||
| 29 | /* these should be user-configurable at some point */ | 29 | /* these should be user-configurable at some point */ |
| 30 | static const float vscroll_fraction = 0.05; | 30 | static const float vscroll_fraction = 0.05; |
| 31 | static const float hscroll_fraction = 0.2; | 31 | static const float hscroll_fraction = 0.05; |
| 32 | static const float vswipe_fraction = 0.25; | ||
| 33 | static const float hswipe_fraction = 0.25; | ||
| 32 | 34 | ||
| 33 | /* flip these to enable event debugging */ | 35 | /* flip these to enable event debugging */ |
| 34 | #if 1 | 36 | #if 1 |
| @@ -207,9 +209,11 @@ static void handle_gestures(LocalDevicePtr local, | |||
| 207 | const struct Gestures *gs, | 209 | const struct Gestures *gs, |
| 208 | const struct Capabilities *caps) | 210 | const struct Capabilities *caps) |
| 209 | { | 211 | { |
| 210 | static int vscroll, hscroll; | 212 | static int vscroll, hscroll, vswipe, hswipe; |
| 211 | int vstep = 1 + vscroll_fraction * get_cap_ysize(caps); | 213 | int vscrollstep = 1 + vscroll_fraction * get_cap_ysize(caps); |
| 212 | int hstep = 1 + hscroll_fraction * get_cap_xsize(caps); | 214 | int hscrollstep = 1 + hscroll_fraction * get_cap_xsize(caps); |
| 215 | int vswipestep = 1 + vswipe_fraction * get_cap_ysize(caps); | ||
| 216 | int hswipestep = 1 + hswipe_fraction * get_cap_xsize(caps); | ||
| 213 | int i; | 217 | int i; |
| 214 | for (i = 0; i < DIM_BUTTON; i++) { | 218 | for (i = 0; i < DIM_BUTTON; i++) { |
| 215 | if (GETBIT(gs->btmask, i)) { | 219 | if (GETBIT(gs->btmask, i)) { |
| @@ -224,13 +228,21 @@ static void handle_gestures(LocalDevicePtr local, | |||
| 224 | TRACE2("motion: %d %d\n", gs->dx, gs->dy); | 228 | TRACE2("motion: %d %d\n", gs->dx, gs->dy); |
| 225 | } | 229 | } |
| 226 | if (GETBIT(gs->type, GS_VSCROLL)) { | 230 | if (GETBIT(gs->type, GS_VSCROLL)) { |
| 227 | button_scroll(local, 4, 5, &vscroll, vstep, gs->dy); | 231 | button_scroll(local, 4, 5, &vscroll, vscrollstep, gs->dy); |
| 228 | TRACE1("vscroll: %d\n", gs->dy); | 232 | TRACE1("vscroll: %d\n", gs->dy); |
| 229 | } | 233 | } |
| 230 | if (GETBIT(gs->type, GS_HSCROLL)) { | 234 | if (GETBIT(gs->type, GS_HSCROLL)) { |
| 231 | button_scroll(local, 6, 7, &hscroll, hstep, gs->dx); | 235 | button_scroll(local, 6, 7, &hscroll, hscrollstep, gs->dx); |
| 232 | TRACE1("hscroll: %d\n", gs->dx); | 236 | TRACE1("hscroll: %d\n", gs->dx); |
| 233 | } | 237 | } |
| 238 | if (GETBIT(gs->type, GS_VSWIPE)) { | ||
| 239 | button_scroll(local, 8, 9, &vswipe, vswipestep, gs->dy); | ||
| 240 | TRACE1("vswipe: %d\n", gs->dy); | ||
| 241 | } | ||
| 242 | if (GETBIT(gs->type, GS_HSWIPE)) { | ||
| 243 | button_scroll(local, 10, 11, &hswipe, hswipestep, gs->dx); | ||
| 244 | TRACE1("hswipe: %d\n", gs->dx); | ||
| 245 | } | ||
| 234 | } | 246 | } |
| 235 | 247 | ||
| 236 | /* called for each full received packet from the touchpad */ | 248 | /* called for each full received packet from the touchpad */ |
