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-rotate.c | 52 ++++++++++++++++++++++----------------------------- 1 file changed, 22 insertions(+), 30 deletions(-) (limited to 'src/gestures-rotate.c') diff --git a/src/gestures-rotate.c b/src/gestures-rotate.c index 6097347..011e9a0 100644 --- a/src/gestures-rotate.c +++ b/src/gestures-rotate.c @@ -26,46 +26,38 @@ #include #include -void gru_reset_rotate(struct grail *ge, - const struct touch_frame *frame) -{ - struct gesture_inserter *gin = ge->gin; - struct gesture_recognizer *gru = ge->gru; - struct rotate_model *state = &gru->rotate; - struct move_model *move = &gru->move; - gin_gesture_discard_type(gin, GRAIL_TYPE_ROTATE); - state->a = move->a; - state->active = 0; - state->rotating = 0; -} - int gru_rotate(struct grail *ge, const struct touch_frame *frame) { - struct gesture_inserter *gin = ge->gin; struct gesture_recognizer *gru = ge->gru; - struct rotate_model *state = &gru->rotate; + struct combo_model *state = &gru->rotate; struct move_model *move = &gru->move; grail_prop_t prop[DIM_GRAIL_PROP]; - float da; - int i; - da = move->a - state->a; - if (fabs(da) < 1) + if (!move->motion) { + if (state->active) { + gru_end(ge, state->gid, move); + state->active = 0; + } + return 0; + } + if (!move->a.tickle) return 0; if (!state->active) { - i = gin_gesture_begin(ge, - GRAIL_TYPE_ROTATE, 1, - frame->touches, sizeof(frame->touches)); - state->geslot = i; + switch(move->ntouch) { + case 2: + state->gid = gin_gid_begin(ge, GRAIL_TYPE_ROTATE, frame); + break; + case 3: + state->gid = gin_gid_begin(ge, GRAIL_TYPE_TURN, frame); + break; + default: + return 0; + } state->active = 1; } - if (!state->rotating && fabs(da) < move->abar) + if (!move->a.active) return 0; - state->rotating = 1; - prop[0] = da; - gin_gesture_event(gin, state->geslot, - move->x, move->y, move->ntouch, - prop, 1); - state->a = move->a; + prop[0] = move->a.delta; + gru_event(ge, state->gid, move, prop, 1); return 1; } -- cgit v1.2.3