summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/grail-types.h56
-rw-r--r--include/grail.h17
-rw-r--r--src/Makefile.am1
-rw-r--r--src/gestures-combo.c12
-rw-r--r--src/gestures-pan.c12
-rw-r--r--src/gestures-pinch.c14
-rw-r--r--src/gestures-rotate.c12
7 files changed, 100 insertions, 24 deletions
diff --git a/include/grail-types.h b/include/grail-types.h
new file mode 100644
index 0000000..7de3d9a
--- /dev/null
+++ b/include/grail-types.h
@@ -0,0 +1,56 @@
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#ifndef _GRAIL_TYPES_H
26#define _GRAIL_TYPES_H
27
28#define GRAIL_TYPE_POINTER 0 /* reserved */
29
30#define GRAIL_TYPE_PAN 1 /* two-finger pan/scroll */
31#define GRAIL_TYPE_PINCH 2 /* two-finger pinch-to-zoom */
32#define GRAIL_TYPE_ROTATE 3 /* two-finger rotation */
33#define GRAIL_TYPE_COMBO2 4 /* two-finger combo */
34
35#define GRAIL_TYPE_SWIPE 5 /* three-finger pan */
36#define GRAIL_TYPE_SCALE 6 /* three-finger pinch */
37#define GRAIL_TYPE_TURN 7 /* three-finger rotate */
38#define GRAIL_TYPE_COMBO3 8 /* three-finger combo */
39
40#define GRAIL_TYPE_BRUSH 9 /* four-finger pan */
41#define GRAIL_TYPE_PICK 10 /* four-finger pinch */
42#define GRAIL_TYPE_WHIRL 11 /* four-finger rotate */
43#define GRAIL_TYPE_COMBO4 12 /* four-finger combo */
44
45#define GRAIL_TYPE_HAND 13 /* five-finger pan */
46#define GRAIL_TYPE_GRAB 14 /* five-finger pinch */
47#define GRAIL_TYPE_REVOLVE 15 /* five-finger rotate */
48#define GRAIL_TYPE_COMBO5 16 /* five-finger combo */
49
50#define GRAIL_TYPE_TAP1 17 /* single one-finger tap */
51#define GRAIL_TYPE_TAP2 18 /* single two-finger tap */
52#define GRAIL_TYPE_TAP3 19 /* single three-finger tap */
53#define GRAIL_TYPE_TAP4 20 /* single four-finger tap */
54#define GRAIL_TYPE_TAP5 21 /* single five-finger tap */
55
56#endif
diff --git a/include/grail.h b/include/grail.h
index 1113188..a100b36 100644
--- a/include/grail.h
+++ b/include/grail.h
@@ -26,6 +26,7 @@
26#define _GRAIL_H 26#define _GRAIL_H
27 27
28#include <grail-bits.h> 28#include <grail-bits.h>
29#include <grail-types.h>
29#include <linux/input.h> 30#include <linux/input.h>
30 31
31#define DIM_GRAIL_TYPE 64 32#define DIM_GRAIL_TYPE 64
@@ -34,22 +35,6 @@
34#define DIM_GRAIL_PROP 16 35#define DIM_GRAIL_PROP 16
35#define DIM_GRAIL_PROP_BYTES ((DIM_GRAIL_PROP + 7) >> 3) 36#define DIM_GRAIL_PROP_BYTES ((DIM_GRAIL_PROP + 7) >> 3)
36 37
37#define GRAIL_TYPE_POINTER 0 /* reserved */
38#define GRAIL_TYPE_PAN 1 /* two-finger pan/scroll */
39#define GRAIL_TYPE_PINCH 2 /* two-finger pinch-to-zoom */
40#define GRAIL_TYPE_ROTATE 3 /* two-finger rotation */
41#define GRAIL_TYPE_COMBO2 4 /* two-finger combo */
42#define GRAIL_TYPE_SWIPE 5 /* three-finger pan */
43#define GRAIL_TYPE_SCALE 6 /* three-finger pinch */
44#define GRAIL_TYPE_TURN 7 /* three-finger rotate */
45#define GRAIL_TYPE_COMBO3 8 /* three-finger combo */
46
47#define GRAIL_TYPE_TAP1 9 /* single one-finger tap */
48#define GRAIL_TYPE_TAP2 10 /* single two-finger tap */
49#define GRAIL_TYPE_TAP3 11 /* single three-finger tap */
50#define GRAIL_TYPE_TAP4 12 /* single four-finger tap */
51#define GRAIL_TYPE_TAP5 13 /* single five-finger tap */
52
53#define GRAIL_STATUS_BEGIN 0 38#define GRAIL_STATUS_BEGIN 0
54#define GRAIL_STATUS_UPDATE 1 39#define GRAIL_STATUS_UPDATE 1
55#define GRAIL_STATUS_END 2 40#define GRAIL_STATUS_END 2
diff --git a/src/Makefile.am b/src/Makefile.am
index 53b4300..4556610 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -25,5 +25,6 @@ INCLUDES = -I$(top_srcdir)/include/
25libgrailincludedir = $(includedir) 25libgrailincludedir = $(includedir)
26libgrailinclude_HEADERS = \ 26libgrailinclude_HEADERS = \
27 $(top_srcdir)/include/grail-bits.h \ 27 $(top_srcdir)/include/grail-bits.h \
28 $(top_srcdir)/include/grail-types.h \
28 $(top_srcdir)/include/grail-touch.h \ 29 $(top_srcdir)/include/grail-touch.h \
29 $(top_srcdir)/include/grail.h 30 $(top_srcdir)/include/grail.h
diff --git a/src/gestures-combo.c b/src/gestures-combo.c
index 8b4ad8c..7b8dbd5 100644
--- a/src/gestures-combo.c
+++ b/src/gestures-combo.c
@@ -26,6 +26,15 @@
26#include <math.h> 26#include <math.h>
27#include <stdio.h> 27#include <stdio.h>
28 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
29int gru_combo(struct grail *ge, 38int gru_combo(struct grail *ge,
30 const struct touch_frame *frame) 39 const struct touch_frame *frame)
31{ 40{
@@ -44,8 +53,7 @@ int gru_combo(struct grail *ge,
44 !move->r.tickle && !move->a.tickle) 53 !move->r.tickle && !move->a.tickle)
45 return 0; 54 return 0;
46 if (!state->active) { 55 if (!state->active) {
47 int type = move->ntouch == 2 ? GRAIL_TYPE_COMBO2 : 56 int type = getype[move->ntouch];
48 move->ntouch == 3 ? GRAIL_TYPE_COMBO3 : 0;
49 if (!type) 57 if (!type)
50 return 0; 58 return 0;
51 state->gid = gin_gid_begin(ge, type, PRIO_GESTURE, frame); 59 state->gid = gin_gid_begin(ge, type, PRIO_GESTURE, frame);
diff --git a/src/gestures-pan.c b/src/gestures-pan.c
index 6c34e5d..3094007 100644
--- a/src/gestures-pan.c
+++ b/src/gestures-pan.c
@@ -26,6 +26,15 @@
26#include <math.h> 26#include <math.h>
27#include <stdio.h> 27#include <stdio.h>
28 28
29static const int getype[DIM_TOUCH + 1] = {
30 0,
31 0,
32 GRAIL_TYPE_PAN,
33 GRAIL_TYPE_SWIPE,
34 GRAIL_TYPE_BRUSH,
35 GRAIL_TYPE_HAND,
36};
37
29int gru_pan(struct grail *ge, 38int gru_pan(struct grail *ge,
30 const struct touch_frame *frame) 39 const struct touch_frame *frame)
31{ 40{
@@ -43,8 +52,7 @@ int gru_pan(struct grail *ge,
43 if (!move->x.tickle && !move->y.tickle) 52 if (!move->x.tickle && !move->y.tickle)
44 return 0; 53 return 0;
45 if (!state->active) { 54 if (!state->active) {
46 int type = move->ntouch == 2 ? GRAIL_TYPE_PAN : 55 int type = getype[move->ntouch];
47 move->ntouch == 3 ? GRAIL_TYPE_SWIPE : 0;
48 if (!type) 56 if (!type)
49 return 0; 57 return 0;
50 state->gid = gin_gid_begin(ge, type, PRIO_GESTURE, frame); 58 state->gid = gin_gid_begin(ge, type, PRIO_GESTURE, frame);
diff --git a/src/gestures-pinch.c b/src/gestures-pinch.c
index 6c5392d..0721e02 100644
--- a/src/gestures-pinch.c
+++ b/src/gestures-pinch.c
@@ -26,6 +26,15 @@
26#include <math.h> 26#include <math.h>
27#include <stdio.h> 27#include <stdio.h>
28 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
29int gru_pinch(struct grail *ge, 38int gru_pinch(struct grail *ge,
30 const struct touch_frame *frame) 39 const struct touch_frame *frame)
31{ 40{
@@ -40,11 +49,12 @@ int gru_pinch(struct grail *ge,
40 } 49 }
41 return 0; 50 return 0;
42 } 51 }
52 if (!move->a.tickle)
53 return 0;
43 if (!move->r.tickle) 54 if (!move->r.tickle)
44 return 0; 55 return 0;
45 if (!state->active) { 56 if (!state->active) {
46 int type = move->ntouch == 2 ? GRAIL_TYPE_PINCH : 57 int type = getype[move->ntouch];
47 move->ntouch == 3 ? GRAIL_TYPE_SCALE : 0;
48 if (!type) 58 if (!type)
49 return 0; 59 return 0;
50 state->gid = gin_gid_begin(ge, type, PRIO_GESTURE, frame); 60 state->gid = gin_gid_begin(ge, type, PRIO_GESTURE, frame);
diff --git a/src/gestures-rotate.c b/src/gestures-rotate.c
index 90f9bdf..6c496d2 100644
--- a/src/gestures-rotate.c
+++ b/src/gestures-rotate.c
@@ -26,6 +26,15 @@
26#include <math.h> 26#include <math.h>
27#include <stdio.h> 27#include <stdio.h>
28 28
29static const int getype[DIM_TOUCH + 1] = {
30 0,
31 0,
32 GRAIL_TYPE_ROTATE,
33 GRAIL_TYPE_TURN,
34 GRAIL_TYPE_WHIRL,
35 GRAIL_TYPE_REVOLVE,
36};
37
29int gru_rotate(struct grail *ge, 38int gru_rotate(struct grail *ge,
30 const struct touch_frame *frame) 39 const struct touch_frame *frame)
31{ 40{
@@ -43,8 +52,7 @@ int gru_rotate(struct grail *ge,
43 if (!move->a.tickle) 52 if (!move->a.tickle)
44 return 0; 53 return 0;
45 if (!state->active) { 54 if (!state->active) {
46 int type = move->ntouch == 2 ? GRAIL_TYPE_ROTATE : 55 int type = getype[move->ntouch];
47 move->ntouch == 3 ? GRAIL_TYPE_TURN : 0;
48 if (!type) 56 if (!type)
49 return 0; 57 return 0;
50 state->gid = gin_gid_begin(ge, type, PRIO_GESTURE, frame); 58 state->gid = gin_gid_begin(ge, type, PRIO_GESTURE, frame);