From d8e8d112aa907f8021ae99e6d7cd7856f1d90b70 Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Thu, 5 Aug 2010 12:40:49 +0200 Subject: Add four-finger and five-finger gestures Add four-finger and five-finger gestures, and move all gesture types out to a separate file. Signed-off-by: Henrik Rydberg --- src/Makefile.am | 1 + src/gestures-combo.c | 12 ++++++++++-- src/gestures-pan.c | 12 ++++++++++-- src/gestures-pinch.c | 14 ++++++++++++-- src/gestures-rotate.c | 12 ++++++++++-- 5 files changed, 43 insertions(+), 8 deletions(-) (limited to 'src') 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/ libgrailincludedir = $(includedir) libgrailinclude_HEADERS = \ $(top_srcdir)/include/grail-bits.h \ + $(top_srcdir)/include/grail-types.h \ $(top_srcdir)/include/grail-touch.h \ $(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 @@ #include #include +static const int getype[DIM_TOUCH + 1] = { + 0, + 0, + GRAIL_TYPE_COMBO2, + GRAIL_TYPE_COMBO3, + GRAIL_TYPE_COMBO4, + GRAIL_TYPE_COMBO5, +}; + int gru_combo(struct grail *ge, const struct touch_frame *frame) { @@ -44,8 +53,7 @@ int gru_combo(struct grail *ge, !move->r.tickle && !move->a.tickle) return 0; if (!state->active) { - int type = move->ntouch == 2 ? GRAIL_TYPE_COMBO2 : - move->ntouch == 3 ? GRAIL_TYPE_COMBO3 : 0; + int type = getype[move->ntouch]; if (!type) return 0; 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 @@ #include #include +static const int getype[DIM_TOUCH + 1] = { + 0, + 0, + GRAIL_TYPE_PAN, + GRAIL_TYPE_SWIPE, + GRAIL_TYPE_BRUSH, + GRAIL_TYPE_HAND, +}; + int gru_pan(struct grail *ge, const struct touch_frame *frame) { @@ -43,8 +52,7 @@ int gru_pan(struct grail *ge, if (!move->x.tickle && !move->y.tickle) return 0; if (!state->active) { - int type = move->ntouch == 2 ? GRAIL_TYPE_PAN : - move->ntouch == 3 ? GRAIL_TYPE_SWIPE : 0; + int type = getype[move->ntouch]; if (!type) return 0; 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 @@ #include #include +static const int getype[DIM_TOUCH + 1] = { + 0, + 0, + GRAIL_TYPE_PINCH, + GRAIL_TYPE_SCALE, + GRAIL_TYPE_PICK, + GRAIL_TYPE_GRAB, +}; + int gru_pinch(struct grail *ge, const struct touch_frame *frame) { @@ -40,11 +49,12 @@ int gru_pinch(struct grail *ge, } return 0; } + if (!move->a.tickle) + return 0; if (!move->r.tickle) return 0; if (!state->active) { - int type = move->ntouch == 2 ? GRAIL_TYPE_PINCH : - move->ntouch == 3 ? GRAIL_TYPE_SCALE : 0; + int type = getype[move->ntouch]; if (!type) return 0; 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 @@ #include #include +static const int getype[DIM_TOUCH + 1] = { + 0, + 0, + GRAIL_TYPE_ROTATE, + GRAIL_TYPE_TURN, + GRAIL_TYPE_WHIRL, + GRAIL_TYPE_REVOLVE, +}; + int gru_rotate(struct grail *ge, const struct touch_frame *frame) { @@ -43,8 +52,7 @@ int gru_rotate(struct grail *ge, if (!move->a.tickle) return 0; if (!state->active) { - int type = move->ntouch == 2 ? GRAIL_TYPE_ROTATE : - move->ntouch == 3 ? GRAIL_TYPE_TURN : 0; + int type = getype[move->ntouch]; if (!type) return 0; state->gid = gin_gid_begin(ge, type, PRIO_GESTURE, frame); -- cgit v1.2.3