summaryrefslogtreecommitdiff
path: root/src/grail-recognizer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/grail-recognizer.c')
-rw-r--r--src/grail-recognizer.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/grail-recognizer.c b/src/grail-recognizer.c
new file mode 100644
index 0000000..587a12a
--- /dev/null
+++ b/src/grail-recognizer.c
@@ -0,0 +1,58 @@
1/*****************************************************************************
2 *
3 * grail - Gesture Recognition And Instantiation Library
4 *
5 * Copyright (C) 2010 Canonical Ltd.
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * Authors:
21 * Henrik Rydberg <rydberg@bitmath.org>
22 *
23 ****************************************************************************/
24
25#include "grail-recognizer.h"
26#include <string.h>
27#include <malloc.h>
28#include <errno.h>
29
30int gru_init(struct grail *ge)
31{
32 struct gesture_recognizer *gru;
33 gru = calloc(1, sizeof(struct gesture_recognizer));
34 if (!gru)
35 return -ENOMEM;
36 ge->gru = gru;
37 gru_init_motion(ge);
38 return 0;
39}
40
41void gru_destroy(struct grail *ge)
42{
43 free(ge->gru);
44 ge->gru = NULL;
45}
46
47void gru_recognize(struct grail *ge, const struct touch_frame *frame)
48{
49 if (!ge->gin || !ge->gru)
50 return;
51 gru_motion(ge, frame);
52 gru_pan(ge, frame);
53 gru_pinch(ge, frame);
54 gru_rotate(ge, frame);
55 gru_combo(ge, frame);
56 gru_tapping(ge, frame);
57 ge->gru->frame = *frame;
58}