summaryrefslogtreecommitdiff
path: root/src/gestures-pinch.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gestures-pinch.c')
-rw-r--r--src/gestures-pinch.c68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/gestures-pinch.c b/src/gestures-pinch.c
new file mode 100644
index 0000000..0721e02
--- /dev/null
+++ b/src/gestures-pinch.c
@@ -0,0 +1,68 @@
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_PINCH,
33 GRAIL_TYPE_SCALE,
34 GRAIL_TYPE_PICK,
35 GRAIL_TYPE_GRAB,
36};
37
38int gru_pinch(struct grail *ge,
39 const struct touch_frame *frame)
40{
41 struct gesture_recognizer *gru = ge->gru;
42 struct combo_model *state = &gru->pinch;
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->a.tickle)
53 return 0;
54 if (!move->r.tickle)
55 return 0;
56 if (!state->active) {
57 int type = getype[move->ntouch];
58 if (!type)
59 return 0;
60 state->gid = gin_gid_begin(ge, type, PRIO_GESTURE, frame);
61 state->active = 1;
62 }
63 if (!move->r.active)
64 return 0;
65 prop[0] = move->r.delta;
66 gru_event(ge, state->gid, move, prop, 1);
67 return 1;
68}