diff options
| author | Henrik Rydberg <rydberg@euromail.se> | 2010-09-21 09:49:26 +0200 |
|---|---|---|
| committer | Henrik Rydberg <rydberg@euromail.se> | 2010-09-21 12:56:17 +0200 |
| commit | d0f7b524153d1b54128b049841f880ee78c2c529 (patch) | |
| tree | d6a1fa1f3254f183c77b7222b17c4ac60df658f2 | |
| parent | 0e1bf39bd34062f07358dc605c0f03fa5df08356 (diff) | |
Simplify book-keeping of active gestures
The current frame computation returns the event types to filter,
which is less useful than knowing what gesture types are active
in the frame. Add the active gesture types to the frame struct
and simplify usage.
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
| -rw-r--r-- | src/grail-api.c | 9 | ||||
| -rw-r--r-- | src/grail-inserter.c | 14 | ||||
| -rw-r--r-- | src/grail-inserter.h | 4 |
3 files changed, 10 insertions, 17 deletions
diff --git a/src/grail-api.c b/src/grail-api.c index d0712b3..0673120 100644 --- a/src/grail-api.c +++ b/src/grail-api.c | |||
| @@ -106,13 +106,14 @@ static void tp_sync(struct touch_dev *dev, | |||
| 106 | struct input_event ev; | 106 | struct input_event ev; |
| 107 | struct grail *ge = dev->priv; | 107 | struct grail *ge = dev->priv; |
| 108 | struct grail_impl *impl = ge->impl; | 108 | struct grail_impl *impl = ge->impl; |
| 109 | struct gesture_inserter *gin = ge->gin; | ||
| 109 | struct touch_frame *frame = &dev->frame; | 110 | struct touch_frame *frame = &dev->frame; |
| 110 | grail_mask_t filtered[DIM_EV_TYPE_BYTES]; | 111 | int pointer, used_move, nevent = 0; |
| 111 | int pointer, nevent = 0; | ||
| 112 | gin_frame_begin(ge, frame); | 112 | gin_frame_begin(ge, frame); |
| 113 | gru_recognize(ge, frame); | 113 | gru_recognize(ge, frame); |
| 114 | gin_frame_end(ge, filtered, sizeof(filtered), frame); | 114 | gin_frame_end(ge, frame); |
| 115 | pointer = pointer_active(ge) && !grail_mask_get(filtered, EV_ABS); | 115 | used_move = grail_mask_count(gin->types, sizeof(gin->types)); |
| 116 | pointer = pointer_active(ge) && !used_move; | ||
| 116 | 117 | ||
| 117 | if (!ge->event) { | 118 | if (!ge->event) { |
| 118 | evbuf_clear(&impl->evbuf); | 119 | evbuf_clear(&impl->evbuf); |
diff --git a/src/grail-inserter.c b/src/grail-inserter.c index a54b73a..847995a 100644 --- a/src/grail-inserter.c +++ b/src/grail-inserter.c | |||
| @@ -103,20 +103,15 @@ void gin_destroy(struct grail *ge) | |||
| 103 | void gin_frame_begin(struct grail *ge, const struct touch_frame *frame) | 103 | void gin_frame_begin(struct grail *ge, const struct touch_frame *frame) |
| 104 | { | 104 | { |
| 105 | struct gesture_inserter *gin = ge->gin; | 105 | struct gesture_inserter *gin = ge->gin; |
| 106 | memset(gin->types, 0, sizeof(gin->types)); | ||
| 106 | gin->time = frame->time; | 107 | gin->time = frame->time; |
| 107 | } | 108 | } |
| 108 | 109 | ||
| 109 | void gin_frame_end(struct grail *ge, | 110 | void gin_frame_end(struct grail *ge, const struct touch_frame *frame) |
| 110 | grail_mask_t *filtered, int max_filtered, | ||
| 111 | const struct touch_frame *frame) | ||
| 112 | { | 111 | { |
| 113 | struct gesture_inserter *gin = ge->gin; | 112 | struct gesture_inserter *gin = ge->gin; |
| 114 | grail_mask_t span[DIM_INSTANCE_BYTES]; | ||
| 115 | int i, hold = 0, discard = 0; | 113 | int i, hold = 0, discard = 0; |
| 116 | 114 | ||
| 117 | memset(filtered, 0, max_filtered); | ||
| 118 | memset(span, 0, sizeof(span)); | ||
| 119 | |||
| 120 | setup_new_gestures(ge, frame); | 115 | setup_new_gestures(ge, frame); |
| 121 | 116 | ||
| 122 | grail_mask_foreach(i, gin->used, sizeof(gin->used)) { | 117 | grail_mask_foreach(i, gin->used, sizeof(gin->used)) { |
| @@ -140,7 +135,7 @@ void gin_frame_end(struct grail *ge, | |||
| 140 | grail_mask_foreach(i, gin->used, sizeof(gin->used)) { | 135 | grail_mask_foreach(i, gin->used, sizeof(gin->used)) { |
| 141 | struct slot_state *s = &gin->state[i]; | 136 | struct slot_state *s = &gin->state[i]; |
| 142 | struct gesture_event ev; | 137 | struct gesture_event ev; |
| 143 | grail_mask_set_mask(span, s->span, sizeof(span)); | 138 | grail_mask_set(gin->types, s->type); |
| 144 | if (s->priority < hold) | 139 | if (s->priority < hold) |
| 145 | continue; | 140 | continue; |
| 146 | while (!gebuf_empty(&s->buf)) { | 141 | while (!gebuf_empty(&s->buf)) { |
| @@ -154,9 +149,6 @@ void gin_frame_end(struct grail *ge, | |||
| 154 | if (s->status == GRAIL_STATUS_END) | 149 | if (s->status == GRAIL_STATUS_END) |
| 155 | gin_gid_discard(ge, s->id); | 150 | gin_gid_discard(ge, s->id); |
| 156 | } | 151 | } |
| 157 | |||
| 158 | if (grail_mask_count(span, sizeof(span))) | ||
| 159 | grail_mask_set(filtered, EV_ABS); | ||
| 160 | } | 152 | } |
| 161 | 153 | ||
| 162 | int gin_gid_begin_select(struct grail *ge, int type, int priority, | 154 | int gin_gid_begin_select(struct grail *ge, int type, int priority, |
diff --git a/src/grail-inserter.h b/src/grail-inserter.h index c5a865a..9baecb7 100644 --- a/src/grail-inserter.h +++ b/src/grail-inserter.h | |||
| @@ -48,6 +48,7 @@ struct slot_state { | |||
| 48 | 48 | ||
| 49 | struct gesture_inserter { | 49 | struct gesture_inserter { |
| 50 | struct slot_state state[DIM_INSTANCE]; | 50 | struct slot_state state[DIM_INSTANCE]; |
| 51 | grail_mask_t types[DIM_GRAIL_TYPE_BYTES]; | ||
| 51 | grail_mask_t unused[DIM_INSTANCE_BYTES]; | 52 | grail_mask_t unused[DIM_INSTANCE_BYTES]; |
| 52 | grail_mask_t fresh[DIM_INSTANCE_BYTES]; | 53 | grail_mask_t fresh[DIM_INSTANCE_BYTES]; |
| 53 | grail_mask_t used[DIM_INSTANCE_BYTES]; | 54 | grail_mask_t used[DIM_INSTANCE_BYTES]; |
| @@ -83,8 +84,7 @@ int gin_init(struct grail *ge); | |||
| 83 | void gin_destroy(struct grail *ge); | 84 | void gin_destroy(struct grail *ge); |
| 84 | 85 | ||
| 85 | void gin_frame_begin(struct grail *ge, const struct touch_frame *frame); | 86 | void gin_frame_begin(struct grail *ge, const struct touch_frame *frame); |
| 86 | void gin_frame_end(struct grail *ge, grail_mask_t *filtered, int max_filtered, | 87 | void gin_frame_end(struct grail *ge, const struct touch_frame *frame); |
| 87 | const struct touch_frame *frame); | ||
| 88 | 88 | ||
| 89 | int gin_gid_begin_select(struct grail *ge, int type, int priority, | 89 | int gin_gid_begin_select(struct grail *ge, int type, int priority, |
| 90 | const grail_mask_t *span, int nspan); | 90 | const grail_mask_t *span, int nspan); |
