From 697b5b5c7d2b1c46387061fcbed24cbee51d98ce Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Wed, 4 Aug 2010 16:47:43 +0200 Subject: Introduce tapping Simplify some common parts of the recognizer code and add tapping to the gesture suite. Signed-off-by: Henrik Rydberg --- src/gestures-combo.c | 66 +++++++++++++++++++++------------------------------- 1 file changed, 26 insertions(+), 40 deletions(-) (limited to 'src/gestures-combo.c') diff --git a/src/gestures-combo.c b/src/gestures-combo.c index 4ecd1e4..82e7b42 100644 --- a/src/gestures-combo.c +++ b/src/gestures-combo.c @@ -26,57 +26,43 @@ #include #include -void gru_reset_combo(struct grail *ge, - const struct touch_frame *frame) -{ - struct gesture_inserter *gin = ge->gin; - struct gesture_recognizer *gru = ge->gru; - struct combo_model *state = &gru->combo; - struct move_model *move = &gru->move; - gin_gesture_discard_type(gin, GRAIL_TYPE_SZRCOMBO); - state->r = move->r; - state->active = 0; - state->running = 0; -} - int gru_combo(struct grail *ge, const struct touch_frame *frame) { - struct gesture_inserter *gin = ge->gin; struct gesture_recognizer *gru = ge->gru; struct combo_model *state = &gru->combo; struct move_model *move = &gru->move; grail_prop_t prop[DIM_GRAIL_PROP]; - float dx, dy, dr, da; - int i; - dx = move->x - state->x; - dy = move->y - state->y; - dr = move->r - state->r; - da = move->a - state->a; - if (fabs(dx) < 1 && fabs(dy) < 1 && fabs(da) < 1 && fabs(dr) < 1) + if (!move->motion) { + if (state->active) { + gru_end(ge, state->gid, move); + state->active = 0; + } + return 0; + } + if (!move->x.tickle && !move->y.tickle && + !move->r.tickle && !move->a.tickle) return 0; if (!state->active) { - i = gin_gesture_begin(ge, - GRAIL_TYPE_SZRCOMBO, 2, - frame->touches, sizeof(frame->touches)); - state->geslot = i; + switch(move->ntouch) { + case 2: + state->gid = gin_gid_begin(ge, GRAIL_TYPE_COMBO2, frame); + break; + case 3: + state->gid = gin_gid_begin(ge, GRAIL_TYPE_COMBO3, frame); + break; + default: + return 0; + } state->active = 1; } - if (!state->running && - fabs(dx) < move->xbar && fabs(dy) < move->ybar && - fabs(da) < move->abar && fabs(dr) < move->rbar) + if (!move->x.active && !move->y.active && + !move->r.active && !move->a.active) return 0; - state->running = 1; - prop[0] = dx; - prop[1] = dy; - prop[2] = dr; - prop[3] = da; - gin_gesture_event(gin, state->geslot, - move->x, move->y, move->ntouch, - prop, 4); - state->x = move->x; - state->y = move->y; - state->r = move->r; - state->a = move->a; + prop[0] = move->x.active ? move->x.delta : 0; + prop[1] = move->y.active ? move->y.delta : 0; + prop[2] = move->r.active ? move->r.delta : 0; + prop[3] = move->a.active ? move->a.delta : 0; + gru_event(ge, state->gid, move, prop, 4); return 1; } -- cgit v1.2.3