diff options
-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) 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 */ |