summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am3
-rw-r--r--src/gestures-combo.c70
-rw-r--r--src/gestures-drag.c (renamed from src/gestures-pan.c)14
-rw-r--r--src/gestures-pinch.c8
-rw-r--r--src/gestures-rotate.c8
-rw-r--r--src/grail-gestures.h4
-rw-r--r--src/grail-recognizer.c3
-rw-r--r--src/grail-recognizer.h3
8 files changed, 20 insertions, 93 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 7dc3ac2..96ac7ed 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -15,10 +15,9 @@ libgrail_la_SOURCES = \
15 grail-inserter.h \ 15 grail-inserter.h \
16 grail-gestures.c \ 16 grail-gestures.c \
17 grail-gestures.h \ 17 grail-gestures.h \
18 gestures-pan.c \ 18 gestures-drag.c \
19 gestures-pinch.c \ 19 gestures-pinch.c \
20 gestures-rotate.c \ 20 gestures-rotate.c \
21 gestures-combo.c \
22 gestures-tapping.c \ 21 gestures-tapping.c \
23 grail-recognizer.c \ 22 grail-recognizer.c \
24 grail-recognizer.h \ 23 grail-recognizer.h \
diff --git a/src/gestures-combo.c b/src/gestures-combo.c
deleted file mode 100644
index 5b6de5b..0000000
--- a/src/gestures-combo.c
+++ /dev/null
@@ -1,70 +0,0 @@
1/*****************************************************************************
2 *
3 * grail - Gesture Recognition And Instantiation Library
4 *
5 * Copyright (C) 2010 Canonical Ltd.
6 * Copyright (C) 2010 Henrik Rydberg <rydberg@bitmath.org>
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program. If not, see <http://www.gnu.org/licenses/>.
20 *
21 ****************************************************************************/
22
23#include "grail-recognizer.h"
24#include <math.h>
25#include <stdio.h>
26
27static const int getype[DIM_TOUCH + 1] = {
28 0,
29 0,
30 GRAIL_TYPE_COMBO2,
31 GRAIL_TYPE_COMBO3,
32 GRAIL_TYPE_COMBO4,
33 GRAIL_TYPE_COMBO5,
34};
35
36static const int fm_mask = 0x0f;
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 int mask = state->active ? (move->active & fm_mask) : fm_mask;
46 if (!move->multi) {
47 if (state->active) {
48 gru_end(ge, state->gid, move);
49 state->active = 0;
50 }
51 return 0;
52 }
53 if (!(move->tickle & mask))
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->active & fm_mask))
63 return 0;
64 prop[0] = move->fm[FM_X].action_delta;
65 prop[1] = move->fm[FM_Y].action_delta;
66 prop[2] = move->fm[FM_R].action_delta;
67 prop[3] = move->fm[FM_A].action_delta;
68 gru_event(ge, state->gid, move, prop, 4);
69 return 1;
70}
diff --git a/src/gestures-pan.c b/src/gestures-drag.c
index c951b78..3f21041 100644
--- a/src/gestures-pan.c
+++ b/src/gestures-drag.c
@@ -26,20 +26,20 @@
26 26
27static const int getype[DIM_TOUCH + 1] = { 27static const int getype[DIM_TOUCH + 1] = {
28 -1, 28 -1,
29 GRAIL_TYPE_POINTER, 29 GRAIL_TYPE_DRAG1,
30 GRAIL_TYPE_PAN, 30 GRAIL_TYPE_DRAG2,
31 GRAIL_TYPE_SWIPE, 31 GRAIL_TYPE_DRAG3,
32 GRAIL_TYPE_BRUSH, 32 GRAIL_TYPE_DRAG4,
33 GRAIL_TYPE_HAND, 33 GRAIL_TYPE_DRAG5,
34}; 34};
35 35
36static const int fm_mask = 0x03; 36static const int fm_mask = 0x03;
37 37
38int gru_pan(struct grail *ge, 38int gru_drag(struct grail *ge,
39 const struct touch_frame *frame) 39 const struct touch_frame *frame)
40{ 40{
41 struct gesture_recognizer *gru = ge->gru; 41 struct gesture_recognizer *gru = ge->gru;
42 struct combo_model *state = &gru->pan; 42 struct combo_model *state = &gru->drag;
43 struct move_model *move = &gru->move; 43 struct move_model *move = &gru->move;
44 grail_prop_t prop[DIM_GRAIL_PROP]; 44 grail_prop_t prop[DIM_GRAIL_PROP];
45 int mask = state->active ? (move->active & fm_mask) : fm_mask; 45 int mask = state->active ? (move->active & fm_mask) : fm_mask;
diff --git a/src/gestures-pinch.c b/src/gestures-pinch.c
index 62f6601..3b94a66 100644
--- a/src/gestures-pinch.c
+++ b/src/gestures-pinch.c
@@ -27,10 +27,10 @@
27static const int getype[DIM_TOUCH + 1] = { 27static const int getype[DIM_TOUCH + 1] = {
28 0, 28 0,
29 0, 29 0,
30 GRAIL_TYPE_PINCH, 30 GRAIL_TYPE_PINCH2,
31 GRAIL_TYPE_SCALE, 31 GRAIL_TYPE_PINCH3,
32 GRAIL_TYPE_PICK, 32 GRAIL_TYPE_PINCH4,
33 GRAIL_TYPE_GRAB, 33 GRAIL_TYPE_PINCH5,
34}; 34};
35 35
36static const int fm_mask = 0x04; 36static const int fm_mask = 0x04;
diff --git a/src/gestures-rotate.c b/src/gestures-rotate.c
index fa0db22..ebab6d3 100644
--- a/src/gestures-rotate.c
+++ b/src/gestures-rotate.c
@@ -27,10 +27,10 @@
27static const int getype[DIM_TOUCH + 1] = { 27static const int getype[DIM_TOUCH + 1] = {
28 0, 28 0,
29 0, 29 0,
30 GRAIL_TYPE_ROTATE, 30 GRAIL_TYPE_ROTATE2,
31 GRAIL_TYPE_TURN, 31 GRAIL_TYPE_ROTATE3,
32 GRAIL_TYPE_WHIRL, 32 GRAIL_TYPE_ROTATE4,
33 GRAIL_TYPE_REVOLVE, 33 GRAIL_TYPE_ROTATE5,
34}; 34};
35 35
36static const int fm_mask = 0x08; 36static const int fm_mask = 0x08;
diff --git a/src/grail-gestures.h b/src/grail-gestures.h
index 2acbb6d..6846ed0 100644
--- a/src/grail-gestures.h
+++ b/src/grail-gestures.h
@@ -63,8 +63,8 @@ struct combo_model {
63 int active, gid; 63 int active, gid;
64}; 64};
65 65
66int gru_pan(struct grail *ge, 66int gru_drag(struct grail *ge,
67 const struct touch_frame *frame); 67 const struct touch_frame *frame);
68int gru_pinch(struct grail *ge, 68int gru_pinch(struct grail *ge,
69 const struct touch_frame *frame); 69 const struct touch_frame *frame);
70int gru_rotate(struct grail *ge, 70int gru_rotate(struct grail *ge,
diff --git a/src/grail-recognizer.c b/src/grail-recognizer.c
index bcfbc2c..5f4bee0 100644
--- a/src/grail-recognizer.c
+++ b/src/grail-recognizer.c
@@ -47,10 +47,9 @@ void gru_recognize(struct grail *ge, const struct touch_frame *frame)
47 if (!ge->gin || !ge->gru) 47 if (!ge->gin || !ge->gru)
48 return; 48 return;
49 gru_motion(ge, frame); 49 gru_motion(ge, frame);
50 gru_pan(ge, frame); 50 gru_drag(ge, frame);
51 gru_pinch(ge, frame); 51 gru_pinch(ge, frame);
52 gru_rotate(ge, frame); 52 gru_rotate(ge, frame);
53 gru_combo(ge, frame);
54 gru_tapping(ge, frame); 53 gru_tapping(ge, frame);
55 ge->gru->frame = *frame; 54 ge->gru->frame = *frame;
56} 55}
diff --git a/src/grail-recognizer.h b/src/grail-recognizer.h
index 11b44ce..1c36819 100644
--- a/src/grail-recognizer.h
+++ b/src/grail-recognizer.h
@@ -28,10 +28,9 @@
28struct gesture_recognizer { 28struct gesture_recognizer {
29 struct touch_frame frame; 29 struct touch_frame frame;
30 struct move_model move; 30 struct move_model move;
31 struct combo_model pan; 31 struct combo_model drag;
32 struct combo_model pinch; 32 struct combo_model pinch;
33 struct combo_model rotate; 33 struct combo_model rotate;
34 struct combo_model combo;
35 struct tapping_model tapping; 34 struct tapping_model tapping;
36 int pointer_gesture; 35 int pointer_gesture;
37}; 36};