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.c71
1 files changed, 71 insertions, 0 deletions
diff --git a/src/gestures-combo.c b/src/gestures-combo.c
new file mode 100644
index 0000000..7b8dbd5
--- /dev/null
+++ b/src/gestures-combo.c
@@ -0,0 +1,71 @@
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 <math.h>
27#include <stdio.h>
28
29static const int getype[DIM_TOUCH + 1] = {
30 0,
31 0,
32 GRAIL_TYPE_COMBO2,
33 GRAIL_TYPE_COMBO3,
34 GRAIL_TYPE_COMBO4,
35 GRAIL_TYPE_COMBO5,
36};
37
38int gru_combo(struct grail *ge,
39 const struct touch_frame *frame)
40{
41 struct gesture_recognizer *gru = ge->gru;
42 struct combo_model *state = &gru->combo;
43 struct move_model *move = &gru->move;
44 grail_prop_t prop[DIM_GRAIL_PROP];
45 if (!move->multi) {
46 if (state->active) {
47 gru_end(ge, state->gid, move);
48 state->active = 0;
49 }
50 return 0;
51 }
52 if (!move->x.tickle && !move->y.tickle &&
53 !move->r.tickle && !move->a.tickle)
54 return 0;
55 if (!state->active) {
56 int type = getype[move->ntouch];
57 if (!type)
58 return 0;
59 state->gid = gin_gid_begin(ge, type, PRIO_GESTURE, frame);
60 state->active = 1;
61 }
62 if (!move->x.active && !move->y.active &&
63 !move->r.active && !move->a.active)
64 return 0;
65 prop[0] = move->x.active ? move->x.delta : 0;
66 prop[1] = move->y.active ? move->y.delta : 0;
67 prop[2] = move->r.active ? move->r.delta : 0;
68 prop[3] = move->a.active ? move->a.delta : 0;
69 gru_event(ge, state->gid, move, prop, 4);
70 return 1;
71}