diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/gestures-drag.c | 41 | ||||
| -rw-r--r-- | src/gestures-pinch.c | 41 | ||||
| -rw-r--r-- | src/gestures-rotate.c | 41 | ||||
| -rw-r--r-- | src/grail-gestures.h | 20 | ||||
| -rw-r--r-- | src/grail-recognizer.c | 3 | ||||
| -rw-r--r-- | src/grail-recognizer.h | 3 |
6 files changed, 146 insertions, 3 deletions
diff --git a/src/gestures-drag.c b/src/gestures-drag.c index b894bda..253bc9d 100644 --- a/src/gestures-drag.c +++ b/src/gestures-drag.c | |||
| @@ -82,3 +82,44 @@ int gru_drag(struct grail *ge, | |||
| 82 | return 1; | 82 | return 1; |
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | int gru_windrag(struct grail *ge, | ||
| 86 | const struct touch_frame *frame) | ||
| 87 | { | ||
| 88 | struct gesture_recognizer *gru = ge->gru; | ||
| 89 | struct combo_model *state = &gru->windrag; | ||
| 90 | struct move_model *move = &gru->move; | ||
| 91 | int mask = state->active ? (move->active & fm_mask) : fm_mask; | ||
| 92 | if (!move->multi && !move->single) { | ||
| 93 | if (state->active && out_of_bounds(state, move)) { | ||
| 94 | gru_end(ge, state->gid, move, | ||
| 95 | state->prop, state->nprop); | ||
| 96 | state->active = 0; | ||
| 97 | } | ||
| 98 | return 0; | ||
| 99 | } | ||
| 100 | if (!(move->tickle & mask)) | ||
| 101 | return 0; | ||
| 102 | if (!state->active) { | ||
| 103 | if (move->ntouch == 4) { | ||
| 104 | state->gid = gin_gid_begin(ge, GRAIL_TYPE_MDRAG, | ||
| 105 | PRIO_META, frame); | ||
| 106 | state->mintouch = 1; | ||
| 107 | state->maxtouch = 4; | ||
| 108 | state->active = 1; | ||
| 109 | } else if (move->ntouch == 3) { | ||
| 110 | state->gid = gin_gid_begin(ge, GRAIL_TYPE_EDRAG, | ||
| 111 | PRIO_ENV, frame); | ||
| 112 | state->mintouch = 1; | ||
| 113 | state->maxtouch = 3; | ||
| 114 | state->active = 1; | ||
| 115 | } else { | ||
| 116 | return 0; | ||
| 117 | } | ||
| 118 | } | ||
| 119 | if (!move->single && !(move->active & fm_mask)) | ||
| 120 | return 0; | ||
| 121 | set_props(state, move); | ||
| 122 | gru_event(ge, state->gid, move, state->prop, state->nprop); | ||
| 123 | return 1; | ||
| 124 | } | ||
| 125 | |||
diff --git a/src/gestures-pinch.c b/src/gestures-pinch.c index 0ddffa4..91e6504 100644 --- a/src/gestures-pinch.c +++ b/src/gestures-pinch.c | |||
| @@ -100,3 +100,44 @@ int gru_pinch(struct grail *ge, | |||
| 100 | gru_event(ge, state->gid, move, state->prop, state->nprop); | 100 | gru_event(ge, state->gid, move, state->prop, state->nprop); |
| 101 | return 1; | 101 | return 1; |
| 102 | } | 102 | } |
| 103 | |||
| 104 | int gru_winpinch(struct grail *ge, | ||
| 105 | const struct touch_frame *frame) | ||
| 106 | { | ||
| 107 | struct gesture_recognizer *gru = ge->gru; | ||
| 108 | struct combo_model *state = &gru->winpinch; | ||
| 109 | struct move_model *move = &gru->move; | ||
| 110 | int mask = state->active ? (move->active & fm_mask) : fm_mask; | ||
| 111 | if (!move->multi) { | ||
| 112 | if (state->active && out_of_bounds(state, move)) { | ||
| 113 | gru_end(ge, state->gid, move, | ||
| 114 | state->prop, state->nprop); | ||
| 115 | state->active = 0; | ||
| 116 | } | ||
| 117 | return 0; | ||
| 118 | } | ||
| 119 | if (!(move->tickle & mask)) | ||
| 120 | return 0; | ||
| 121 | if (!state->active) { | ||
| 122 | if (move->ntouch == 4) { | ||
| 123 | state->gid = gin_gid_begin(ge, GRAIL_TYPE_MPINCH, | ||
| 124 | PRIO_META, frame); | ||
| 125 | state->mintouch = 2; | ||
| 126 | state->maxtouch = 4; | ||
| 127 | state->active = 1; | ||
| 128 | } else if (move->ntouch == 3) { | ||
| 129 | state->gid = gin_gid_begin(ge, GRAIL_TYPE_EPINCH, | ||
| 130 | PRIO_ENV, frame); | ||
| 131 | state->mintouch = 2; | ||
| 132 | state->maxtouch = 3; | ||
| 133 | state->active = 1; | ||
| 134 | } else { | ||
| 135 | return 0; | ||
| 136 | } | ||
| 137 | } | ||
| 138 | if (!(move->active & fm_mask)) | ||
| 139 | return 0; | ||
| 140 | set_props(state, move, frame); | ||
| 141 | gru_event(ge, state->gid, move, state->prop, state->nprop); | ||
| 142 | return 1; | ||
| 143 | } | ||
diff --git a/src/gestures-rotate.c b/src/gestures-rotate.c index 52b5004..5763294 100644 --- a/src/gestures-rotate.c +++ b/src/gestures-rotate.c | |||
| @@ -73,3 +73,44 @@ int gru_rotate(struct grail *ge, | |||
| 73 | gru_event(ge, state->gid, move, state->prop, state->nprop); | 73 | gru_event(ge, state->gid, move, state->prop, state->nprop); |
| 74 | return 1; | 74 | return 1; |
| 75 | } | 75 | } |
| 76 | |||
| 77 | int gru_winrotate(struct grail *ge, | ||
| 78 | const struct touch_frame *frame) | ||
| 79 | { | ||
| 80 | struct gesture_recognizer *gru = ge->gru; | ||
| 81 | struct combo_model *state = &gru->winrotate; | ||
| 82 | struct move_model *move = &gru->move; | ||
| 83 | int mask = state->active ? (move->active & fm_mask) : fm_mask; | ||
| 84 | if (!move->multi) { | ||
| 85 | if (state->active && out_of_bounds(state, move)) { | ||
| 86 | gru_end(ge, state->gid, move, | ||
| 87 | state->prop, state->nprop); | ||
| 88 | state->active = 0; | ||
| 89 | } | ||
| 90 | return 0; | ||
| 91 | } | ||
| 92 | if (!(move->tickle & mask)) | ||
| 93 | return 0; | ||
| 94 | if (!state->active) { | ||
| 95 | if (move->ntouch == 4) { | ||
| 96 | state->gid = gin_gid_begin(ge, GRAIL_TYPE_MROTATE, | ||
| 97 | PRIO_META, frame); | ||
| 98 | state->mintouch = 2; | ||
| 99 | state->maxtouch = 4; | ||
| 100 | state->active = 1; | ||
| 101 | } else if (move->ntouch == 3) { | ||
| 102 | state->gid = gin_gid_begin(ge, GRAIL_TYPE_EROTATE, | ||
| 103 | PRIO_ENV, frame); | ||
| 104 | state->mintouch = 2; | ||
| 105 | state->maxtouch = 3; | ||
| 106 | state->active = 1; | ||
| 107 | } else { | ||
| 108 | return 0; | ||
| 109 | } | ||
| 110 | } | ||
| 111 | if (!(move->active & fm_mask)) | ||
| 112 | return 0; | ||
| 113 | set_props(state, move); | ||
| 114 | gru_event(ge, state->gid, move, state->prop, state->nprop); | ||
| 115 | return 1; | ||
| 116 | } | ||
diff --git a/src/grail-gestures.h b/src/grail-gestures.h index 888a50b..e716757 100644 --- a/src/grail-gestures.h +++ b/src/grail-gestures.h | |||
| @@ -27,7 +27,9 @@ | |||
| 27 | 27 | ||
| 28 | #define PRIO_POINTER 1 | 28 | #define PRIO_POINTER 1 |
| 29 | #define PRIO_GESTURE 2 | 29 | #define PRIO_GESTURE 2 |
| 30 | #define PRIO_TAP 3 | 30 | #define PRIO_ENV 3 |
| 31 | #define PRIO_META 4 | ||
| 32 | #define PRIO_TAP 5 | ||
| 31 | 33 | ||
| 32 | #define DIM_FM 4 | 34 | #define DIM_FM 4 |
| 33 | 35 | ||
| @@ -69,6 +71,7 @@ void gru_end(struct grail *ge, int gid, | |||
| 69 | 71 | ||
| 70 | struct combo_model { | 72 | struct combo_model { |
| 71 | int active, gid; | 73 | int active, gid; |
| 74 | int mintouch, maxtouch; | ||
| 72 | int nprop; | 75 | int nprop; |
| 73 | grail_prop_t prop[DIM_GRAIL_PROP]; | 76 | grail_prop_t prop[DIM_GRAIL_PROP]; |
| 74 | }; | 77 | }; |
| @@ -79,8 +82,19 @@ int gru_pinch(struct grail *ge, | |||
| 79 | const struct touch_frame *frame); | 82 | const struct touch_frame *frame); |
| 80 | int gru_rotate(struct grail *ge, | 83 | int gru_rotate(struct grail *ge, |
| 81 | const struct touch_frame *frame); | 84 | const struct touch_frame *frame); |
| 82 | int gru_combo(struct grail *ge, | 85 | |
| 83 | const struct touch_frame *frame); | 86 | static inline int out_of_bounds(const struct combo_model *s, |
| 87 | const struct move_model *m) | ||
| 88 | { | ||
| 89 | return m->ntouch < s->mintouch || m->ntouch > s->maxtouch; | ||
| 90 | } | ||
| 91 | |||
| 92 | int gru_windrag(struct grail *ge, | ||
| 93 | const struct touch_frame *frame); | ||
| 94 | int gru_winpinch(struct grail *ge, | ||
| 95 | const struct touch_frame *frame); | ||
| 96 | int gru_winrotate(struct grail *ge, | ||
| 97 | const struct touch_frame *frame); | ||
| 84 | 98 | ||
| 85 | struct tapping_model { | 99 | struct tapping_model { |
| 86 | grail_time_t start; | 100 | grail_time_t start; |
diff --git a/src/grail-recognizer.c b/src/grail-recognizer.c index fffbf6e..932f28a 100644 --- a/src/grail-recognizer.c +++ b/src/grail-recognizer.c | |||
| @@ -50,6 +50,9 @@ void gru_recognize(struct grail *ge, const struct touch_frame *frame) | |||
| 50 | gru_drag(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_windrag(ge, frame); | ||
| 54 | gru_winpinch(ge, frame); | ||
| 55 | gru_winrotate(ge, frame); | ||
| 53 | gru_tapping(ge, frame); | 56 | gru_tapping(ge, frame); |
| 54 | ge->gru->frame = *frame; | 57 | ge->gru->frame = *frame; |
| 55 | } | 58 | } |
diff --git a/src/grail-recognizer.h b/src/grail-recognizer.h index b39eac3..1a9edd1 100644 --- a/src/grail-recognizer.h +++ b/src/grail-recognizer.h | |||
| @@ -31,6 +31,9 @@ struct gesture_recognizer { | |||
| 31 | struct combo_model drag; | 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 windrag; | ||
| 35 | struct combo_model winpinch; | ||
| 36 | struct combo_model winrotate; | ||
| 34 | struct tapping_model tapping; | 37 | struct tapping_model tapping; |
| 35 | }; | 38 | }; |
| 36 | 39 | ||
