From a23067b7066786ceaa0779324e9120f8b04a6372 Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Tue, 21 Sep 2010 10:27:17 +0200 Subject: Do not tap when leaving fingers on the pad The current code will treat a 3-down-2-up as a tap. This patch changes the logic so that taps are only emitted when the number of fingers returns to the baseline. Signed-off-by: Henrik Rydberg --- src/gestures-tapping.c | 23 +++++++++++++---------- src/grail-gestures.h | 2 +- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/gestures-tapping.c b/src/gestures-tapping.c index 5474731..cb30168 100644 --- a/src/gestures-tapping.c +++ b/src/gestures-tapping.c @@ -46,42 +46,45 @@ int gru_tapping(struct grail *ge, struct tapping_model *state = &gru->tapping; struct move_model *move = &gru->move; grail_time_t up = move->time - state->end; - if (move->ntouch && move->ntouch < state->ntouch) + if (move->ntouch && move->ntouch < state->mintouch) state->end = move->time; - if (move->ntouch > state->ntouch) { + if (move->ntouch > state->maxtouch) { if (state->active) { gin_gid_discard(ge, state->gid); state->active = 0; } state->start = move->time; - state->ntouch = move->ntouch; + state->maxtouch = move->ntouch; set_props(ge->gin, state, move, frame); - if (state->ntouch <= 5) { - int type = GRAIL_TYPE_TAP1 + state->ntouch - 1; + if (state->maxtouch <= 5) { + int type = GRAIL_TYPE_TAP1 + state->maxtouch - 1; state->gid = gin_gid_begin(ge, type, PRIO_TAP, frame); state->active = 1; } return 0; } if (!state->active) { - state->ntouch = move->ntouch; + state->mintouch = move->ntouch; + state->maxtouch = move->ntouch; return 0; } - if (move->ntouch < state->ntouch) { + if (move->ntouch <= state->mintouch) { int x = state->prop[GRAIL_PROP_TAP_X]; int y = state->prop[GRAIL_PROP_TAP_Y]; int t = move->time - state->start; if (t < TAP_MIN_GAP_MS || t > move->fm[FM_X].bar_ms || up < TAP_MIN_UP_MS) { gin_gid_discard(ge, state->gid); - state->ntouch = move->ntouch; + state->mintouch = move->ntouch; + state->maxtouch = move->ntouch; state->active = 0; return 0; } state->prop[GRAIL_PROP_TAP_DT] = t; - gin_gid_event(ge, state->gid, x, y, state->ntouch, + gin_gid_event(ge, state->gid, x, y, state->maxtouch, state->prop, state->nprop, 1); - state->ntouch = move->ntouch; + state->mintouch = move->ntouch; + state->maxtouch = move->ntouch; state->active = 0; return 1; } diff --git a/src/grail-gestures.h b/src/grail-gestures.h index 247acf9..36d8e78 100644 --- a/src/grail-gestures.h +++ b/src/grail-gestures.h @@ -98,7 +98,7 @@ int gru_winrotate(struct grail *ge, struct tapping_model { grail_time_t start, end; - int ntouch; + int mintouch, maxtouch; int active, gid; int nprop; grail_prop_t prop[DIM_GRAIL_PROP]; -- cgit v1.2.3