diff options
| author | Henrik Rydberg <rydberg@euromail.se> | 2010-08-06 21:11:17 +0200 |
|---|---|---|
| committer | Henrik Rydberg <rydberg@euromail.se> | 2010-08-06 21:11:17 +0200 |
| commit | 7db9d8d76ff61c4802ac15559dcea6fa54ff567a (patch) | |
| tree | b67e040c0abeb0ab1fca72754a767dc9ab851461 /src/gestures-rotate.c | |
initial bzr repo at rev 27
Diffstat (limited to 'src/gestures-rotate.c')
| -rw-r--r-- | src/gestures-rotate.c | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/gestures-rotate.c b/src/gestures-rotate.c new file mode 100644 index 0000000..6c496d2 --- /dev/null +++ b/src/gestures-rotate.c | |||
| @@ -0,0 +1,66 @@ | |||
| 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 | |||
| 29 | static 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 | |||
| 38 | int gru_rotate(struct grail *ge, | ||
| 39 | const struct touch_frame *frame) | ||
| 40 | { | ||
| 41 | struct gesture_recognizer *gru = ge->gru; | ||
| 42 | struct combo_model *state = &gru->rotate; | ||
| 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 (!state->active) { | ||
| 55 | int type = getype[move->ntouch]; | ||
| 56 | if (!type) | ||
| 57 | return 0; | ||
| 58 | state->gid = gin_gid_begin(ge, type, PRIO_GESTURE, frame); | ||
| 59 | state->active = 1; | ||
| 60 | } | ||
| 61 | if (!move->a.active) | ||
| 62 | return 0; | ||
| 63 | prop[0] = move->a.delta; | ||
| 64 | gru_event(ge, state->gid, move, prop, 1); | ||
| 65 | return 1; | ||
| 66 | } | ||
