summaryrefslogtreecommitdiff
path: root/src/gestures-pan.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-pan.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-pan.c')
-rw-r--r--src/gestures-pan.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/gestures-pan.c b/src/gestures-pan.c
new file mode 100644
index 0000000..541c502
--- /dev/null
+++ b/src/gestures-pan.c
@@ -0,0 +1,65 @@
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
29int gru_pan(struct grail *ge,
30 const struct touch_frame *frame)
31{
32 struct gesture_recognizer *gru = ge->gru;
33 struct combo_model *state = &gru->pan;
34 struct move_model *move = &gru->move;
35 grail_prop_t prop[DIM_GRAIL_PROP];
36 if (!move->motion) {
37 if (state->active) {
38 gru_end(ge, state->gid, move);
39 state->active = 0;
40 }
41 return 0;
42 }
43 if (!move->x.tickle && !move->y.tickle)
44 return 0;
45 if (!state->active) {
46 switch(move->ntouch) {
47 case 2:
48 state->gid = gin_gid_begin(ge, GRAIL_TYPE_PAN, frame);
49 break;
50 case 3:
51 state->gid = gin_gid_begin(ge, GRAIL_TYPE_SWIPE, frame);
52 break;
53 default:
54 return 0;
55 }
56 state->active = 1;
57 }
58 if (!move->x.active && !move->y.active)
59 return 0;
60 prop[0] = move->x.active ? move->x.delta : 0;
61 prop[1] = move->y.active ? move->y.delta : 0;
62 gru_event(ge, state->gid, move, prop, 2);
63 return 1;
64}
65