summaryrefslogtreecommitdiff
path: root/src/gestures-combo.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gestures-combo.c')
-rw-r--r--src/gestures-combo.c66
1 files changed, 26 insertions, 40 deletions
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 @@
26#include <math.h> 26#include <math.h>
27#include <stdio.h> 27#include <stdio.h>
28 28
29void gru_reset_combo(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 combo_model *state = &gru->combo;
35 struct move_model *move = &gru->move;
36 gin_gesture_discard_type(gin, GRAIL_TYPE_SZRCOMBO);
37 state->r = move->r;
38 state->active = 0;
39 state->running = 0;
40}
41
42int gru_combo(struct grail *ge, 29int gru_combo(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 combo_model *state = &gru->combo; 33 struct combo_model *state = &gru->combo;
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 dx, dy, dr, da; 36 if (!move->motion) {
51 int i; 37 if (state->active) {
52 dx = move->x - state->x; 38 gru_end(ge, state->gid, move);
53 dy = move->y - state->y; 39 state->active = 0;
54 dr = move->r - state->r; 40 }
55 da = move->a - state->a; 41 return 0;
56 if (fabs(dx) < 1 && fabs(dy) < 1 && fabs(da) < 1 && fabs(dr) < 1) 42 }
43 if (!move->x.tickle && !move->y.tickle &&
44 !move->r.tickle && !move->a.tickle)
57 return 0; 45 return 0;
58 if (!state->active) { 46 if (!state->active) {
59 i = gin_gesture_begin(ge, 47 switch(move->ntouch) {
60 GRAIL_TYPE_SZRCOMBO, 2, 48 case 2:
61 frame->touches, sizeof(frame->touches)); 49 state->gid = gin_gid_begin(ge, GRAIL_TYPE_COMBO2, frame);
62 state->geslot = i; 50 break;
51 case 3:
52 state->gid = gin_gid_begin(ge, GRAIL_TYPE_COMBO3, frame);
53 break;
54 default:
55 return 0;
56 }
63 state->active = 1; 57 state->active = 1;
64 } 58 }
65 if (!state->running && 59 if (!move->x.active && !move->y.active &&
66 fabs(dx) < move->xbar && fabs(dy) < move->ybar && 60 !move->r.active && !move->a.active)
67 fabs(da) < move->abar && fabs(dr) < move->rbar)
68 return 0; 61 return 0;
69 state->running = 1; 62 prop[0] = move->x.active ? move->x.delta : 0;
70 prop[0] = dx; 63 prop[1] = move->y.active ? move->y.delta : 0;
71 prop[1] = dy; 64 prop[2] = move->r.active ? move->r.delta : 0;
72 prop[2] = dr; 65 prop[3] = move->a.active ? move->a.delta : 0;
73 prop[3] = da; 66 gru_event(ge, state->gid, move, prop, 4);
74 gin_gesture_event(gin, state->geslot,
75 move->x, move->y, move->ntouch,
76 prop, 4);
77 state->x = move->x;
78 state->y = move->y;
79 state->r = move->r;
80 state->a = move->a;
81 return 1; 67 return 1;
82} 68}