aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@euromail.se>2010-04-14 16:07:17 +0200
committerHenrik Rydberg <rydberg@euromail.se>2010-04-15 06:10:08 +0200
commit2e51d27cf6e1380e7bf4744215bf16243af2829d (patch)
treeb4baa44ba1107fb694a4813cdc337fcc078ace13
parente5bff8354652f5798d1906004150790377abc775 (diff)
downloadxorg-input-kobomultitouch-2e51d27cf6e1380e7bf4744215bf16243af2829d.tar.gz
xorg-input-kobomultitouch-2e51d27cf6e1380e7bf4744215bf16243af2829d.tar.bz2
xorg-input-kobomultitouch-2e51d27cf6e1380e7bf4744215bf16243af2829d.zip
Define swipe gestures
Define three-finger vertical and horizontal scroll as vertical and horizontal swipe gestures. Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
-rw-r--r--src/gestures.c16
-rw-r--r--src/gestures.h2
-rw-r--r--src/multitouch.c24
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)
if (gs->dx || gs->dy) {
if (mt->state.nfinger == 1)
SETBIT(gs->type, GS_MOVE);
- if (mt->state.nfinger == 2)
- SETBIT(gs->type, GS_VSCROLL);
- if (mt->state.nfinger == 3)
- SETBIT(gs->type, GS_HSCROLL);
+ if (mt->state.nfinger == 2) {
+ if (gs->dx)
+ SETBIT(gs->type, GS_HSCROLL);
+ if (gs->dy)
+ SETBIT(gs->type, GS_VSCROLL);
+ }
+ if (mt->state.nfinger == 3) {
+ if (gs->dx)
+ SETBIT(gs->type, GS_HSWIPE);
+ if (gs->dy)
+ SETBIT(gs->type, GS_VSWIPE);
+ }
}
}
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 @@
#define GS_MOVE 1
#define GS_VSCROLL 2
#define GS_HSCROLL 3
+#define GS_VSWIPE 4
+#define GS_HSWIPE 5
struct Gestures {
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 @@
/* these should be user-configurable at some point */
static const float vscroll_fraction = 0.05;
-static const float hscroll_fraction = 0.2;
+static const float hscroll_fraction = 0.05;
+static const float vswipe_fraction = 0.25;
+static const float hswipe_fraction = 0.25;
/* flip these to enable event debugging */
#if 1
@@ -207,9 +209,11 @@ static void handle_gestures(LocalDevicePtr local,
const struct Gestures *gs,
const struct Capabilities *caps)
{
- static int vscroll, hscroll;
- int vstep = 1 + vscroll_fraction * get_cap_ysize(caps);
- int hstep = 1 + hscroll_fraction * get_cap_xsize(caps);
+ static int vscroll, hscroll, vswipe, hswipe;
+ int vscrollstep = 1 + vscroll_fraction * get_cap_ysize(caps);
+ int hscrollstep = 1 + hscroll_fraction * get_cap_xsize(caps);
+ int vswipestep = 1 + vswipe_fraction * get_cap_ysize(caps);
+ int hswipestep = 1 + hswipe_fraction * get_cap_xsize(caps);
int i;
for (i = 0; i < DIM_BUTTON; i++) {
if (GETBIT(gs->btmask, i)) {
@@ -224,13 +228,21 @@ static void handle_gestures(LocalDevicePtr local,
TRACE2("motion: %d %d\n", gs->dx, gs->dy);
}
if (GETBIT(gs->type, GS_VSCROLL)) {
- button_scroll(local, 4, 5, &vscroll, vstep, gs->dy);
+ button_scroll(local, 4, 5, &vscroll, vscrollstep, gs->dy);
TRACE1("vscroll: %d\n", gs->dy);
}
if (GETBIT(gs->type, GS_HSCROLL)) {
- button_scroll(local, 6, 7, &hscroll, hstep, gs->dx);
+ button_scroll(local, 6, 7, &hscroll, hscrollstep, gs->dx);
TRACE1("hscroll: %d\n", gs->dx);
}
+ if (GETBIT(gs->type, GS_VSWIPE)) {
+ button_scroll(local, 8, 9, &vswipe, vswipestep, gs->dy);
+ TRACE1("vswipe: %d\n", gs->dy);
+ }
+ if (GETBIT(gs->type, GS_HSWIPE)) {
+ button_scroll(local, 10, 11, &hswipe, hswipestep, gs->dx);
+ TRACE1("hswipe: %d\n", gs->dx);
+ }
}
/* called for each full received packet from the touchpad */