summaryrefslogtreecommitdiff
path: root/src/gestures-rotate.c
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@bitmath.org>2010-08-04 16:47:43 +0200
committerHenrik Rydberg <rydberg@euromail.se>2010-08-05 22:48:38 +0200
commit697b5b5c7d2b1c46387061fcbed24cbee51d98ce (patch)
treeb8e8dbf02453f7c7dc31c691822a088123d21cd8 /src/gestures-rotate.c
parent642d7ee26f347152a106d48ddad37a8059d36fb1 (diff)
Introduce tapping
Simplify some common parts of the recognizer code and add tapping to the gesture suite. Signed-off-by: Henrik Rydberg <rydberg@bitmath.org>
Diffstat (limited to 'src/gestures-rotate.c')
-rw-r--r--src/gestures-rotate.c52
1 files changed, 22 insertions, 30 deletions
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 @@
26#include <math.h> 26#include <math.h>
27#include <stdio.h> 27#include <stdio.h>
28 28
29void gru_reset_rotate(struct grail *ge,
30 const struct touch_frame *frame)
31{
32 struct gesture_inserter *gin = ge->gin;
33 struct gesture_recognizer *gru = ge->gru;
34 struct rotate_model *state = &gru->rotate;
35 struct move_model *move = &gru->move;
36 gin_gesture_discard_type(gin, GRAIL_TYPE_ROTATE);
37 state->a = move->a;
38 state->active = 0;
39 state->rotating = 0;
40}
41
42int gru_rotate(struct grail *ge, 29int gru_rotate(struct grail *ge,
43 const struct touch_frame *frame) 30 const struct touch_frame *frame)
44{ 31{
45 struct gesture_inserter *gin = ge->gin;
46 struct gesture_recognizer *gru = ge->gru; 32 struct gesture_recognizer *gru = ge->gru;
47 struct rotate_model *state = &gru->rotate; 33 struct combo_model *state = &gru->rotate;
48 struct move_model *move = &gru->move; 34 struct move_model *move = &gru->move;
49 grail_prop_t prop[DIM_GRAIL_PROP]; 35 grail_prop_t prop[DIM_GRAIL_PROP];
50 float da; 36 if (!move->motion) {
51 int i; 37 if (state->active) {
52 da = move->a - state->a; 38 gru_end(ge, state->gid, move);
53 if (fabs(da) < 1) 39 state->active = 0;
40 }
41 return 0;
42 }
43 if (!move->a.tickle)
54 return 0; 44 return 0;
55 if (!state->active) { 45 if (!state->active) {
56 i = gin_gesture_begin(ge, 46 switch(move->ntouch) {
57 GRAIL_TYPE_ROTATE, 1, 47 case 2:
58 frame->touches, sizeof(frame->touches)); 48 state->gid = gin_gid_begin(ge, GRAIL_TYPE_ROTATE, frame);
59 state->geslot = i; 49 break;
50 case 3:
51 state->gid = gin_gid_begin(ge, GRAIL_TYPE_TURN, frame);
52 break;
53 default:
54 return 0;
55 }
60 state->active = 1; 56 state->active = 1;
61 } 57 }
62 if (!state->rotating && fabs(da) < move->abar) 58 if (!move->a.active)
63 return 0; 59 return 0;
64 state->rotating = 1; 60 prop[0] = move->a.delta;
65 prop[0] = da; 61 gru_event(ge, state->gid, move, prop, 1);
66 gin_gesture_event(gin, state->geslot,
67 move->x, move->y, move->ntouch,
68 prop, 1);
69 state->a = move->a;
70 return 1; 62 return 1;
71} 63}