summaryrefslogtreecommitdiff
path: root/src/grail-recognizer.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/grail-recognizer.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/grail-recognizer.c')
-rw-r--r--src/grail-recognizer.c29
1 files changed, 5 insertions, 24 deletions
diff --git a/src/grail-recognizer.c b/src/grail-recognizer.c
index 1e7a8bf..bed704e 100644
--- a/src/grail-recognizer.c
+++ b/src/grail-recognizer.c
@@ -27,8 +27,6 @@
27#include <malloc.h> 27#include <malloc.h>
28#include <errno.h> 28#include <errno.h>
29 29
30static const touch_time_t DROP_TIMEOUT_MS = 100;
31
32int gru_init(struct grail *ge, const struct touch_dev_caps *caps) 30int gru_init(struct grail *ge, const struct touch_dev_caps *caps)
33{ 31{
34 struct gesture_recognizer *gru; 32 struct gesture_recognizer *gru;
@@ -46,32 +44,15 @@ void gru_destroy(struct grail *ge)
46 ge->gru = NULL; 44 ge->gru = NULL;
47} 45}
48 46
49static void reset_gru_state(struct grail *ge, const struct touch_frame *frame)
50{
51 gru_reset_combo(ge, frame);
52 gru_reset_rotate(ge, frame);
53 gru_reset_zoom(ge, frame);
54 gru_reset_scroll(ge, frame);
55 gru_reset_motion(ge, frame);
56}
57
58void gru_recognize(struct grail *ge, const struct touch_frame *frame) 47void gru_recognize(struct grail *ge, const struct touch_frame *frame)
59{ 48{
60 struct gesture_recognizer *gru = ge->gru;
61 struct move_model *move = &gru->move;
62 if (!ge->gin || !ge->gru) 49 if (!ge->gin || !ge->gru)
63 return; 50 return;
64 if (frame->nactive < move->ntouch && 51 gru_motion(ge, frame);
65 frame->time < gru->frame.time + DROP_TIMEOUT_MS) 52 gru_pan(ge, frame);
66 return; 53 gru_pinch(ge, frame);
67 if (frame->nactive < 2 || frame->ncreate || frame->ndestroy) {
68 reset_gru_state(ge, frame);
69 return;
70 }
71 gru_compute_motion(ge, frame);
72 gru_scroll(ge, frame);
73 gru_zoom(ge, frame);
74 gru_rotate(ge, frame); 54 gru_rotate(ge, frame);
75 gru_combo(ge, frame); 55 gru_combo(ge, frame);
76 gru->frame = *frame; 56 gru_tapping(ge, frame);
57 ge->gru->frame = *frame;
77} 58}