diff options
Diffstat (limited to 'src/grail-inserter.c')
| -rw-r--r-- | src/grail-inserter.c | 124 |
1 files changed, 3 insertions, 121 deletions
diff --git a/src/grail-inserter.c b/src/grail-inserter.c index 2e5e7af..d77da79 100644 --- a/src/grail-inserter.c +++ b/src/grail-inserter.c | |||
| @@ -29,90 +29,6 @@ | |||
| 29 | 29 | ||
| 30 | static const int MAX_GESTURE_ID = 0xfff; | 30 | static const int MAX_GESTURE_ID = 0xfff; |
| 31 | 31 | ||
| 32 | static const int grail_main_type[DIM_GRAIL_TYPE] = { | ||
| 33 | GRAIL_MAIN_DRAG, | ||
| 34 | GRAIL_MAIN_PINCH, | ||
| 35 | GRAIL_MAIN_ROTATE, | ||
| 36 | GRAIL_MAIN_DRAG, | ||
| 37 | GRAIL_MAIN_PINCH, | ||
| 38 | GRAIL_MAIN_ROTATE, | ||
| 39 | GRAIL_MAIN_DRAG, | ||
| 40 | GRAIL_MAIN_PINCH, | ||
| 41 | GRAIL_MAIN_ROTATE, | ||
| 42 | GRAIL_MAIN_DRAG, | ||
| 43 | GRAIL_MAIN_PINCH, | ||
| 44 | GRAIL_MAIN_ROTATE, | ||
| 45 | GRAIL_MAIN_DRAG, | ||
| 46 | GRAIL_MAIN_PINCH, | ||
| 47 | GRAIL_MAIN_ROTATE, | ||
| 48 | GRAIL_MAIN_TAP, | ||
| 49 | GRAIL_MAIN_TAP, | ||
| 50 | GRAIL_MAIN_TAP, | ||
| 51 | GRAIL_MAIN_TAP, | ||
| 52 | GRAIL_MAIN_TAP, | ||
| 53 | GRAIL_MAIN_DRAG, | ||
| 54 | GRAIL_MAIN_PINCH, | ||
| 55 | GRAIL_MAIN_ROTATE, | ||
| 56 | GRAIL_MAIN_DRAG, | ||
| 57 | GRAIL_MAIN_PINCH, | ||
| 58 | GRAIL_MAIN_ROTATE, | ||
| 59 | }; | ||
| 60 | |||
| 61 | static void transform_pos(const struct gesture_inserter *gin, | ||
| 62 | struct grail_coord *pos) | ||
| 63 | { | ||
| 64 | pos->x *= gin->scale_x; | ||
| 65 | pos->x += gin->trans_x; | ||
| 66 | pos->y *= gin->scale_y; | ||
| 67 | pos->y += gin->trans_y; | ||
| 68 | } | ||
| 69 | |||
| 70 | static void transform_prop(const struct gesture_inserter *gin, int type, | ||
| 71 | grail_prop_t *prop, int nprop) | ||
| 72 | { | ||
| 73 | switch (grail_main_type[type]) { | ||
| 74 | case GRAIL_MAIN_DRAG: | ||
| 75 | prop[GRAIL_PROP_DRAG_DX] *= gin->scale_x; | ||
| 76 | prop[GRAIL_PROP_DRAG_DY] *= gin->scale_y; | ||
| 77 | prop[GRAIL_PROP_DRAG_VX] *= gin->scale_x; | ||
| 78 | prop[GRAIL_PROP_DRAG_VY] *= gin->scale_y; | ||
| 79 | prop[GRAIL_PROP_DRAG_X] *= gin->scale_x; | ||
| 80 | prop[GRAIL_PROP_DRAG_X] += gin->trans_x; | ||
| 81 | prop[GRAIL_PROP_DRAG_Y] *= gin->scale_y; | ||
| 82 | prop[GRAIL_PROP_DRAG_Y] += gin->trans_y; | ||
| 83 | break; | ||
| 84 | case GRAIL_MAIN_PINCH: | ||
| 85 | prop[GRAIL_PROP_PINCH_DR] *= gin->scale_r; | ||
| 86 | prop[GRAIL_PROP_PINCH_VR] *= gin->scale_r; | ||
| 87 | prop[GRAIL_PROP_PINCH_R] *= gin->scale_r; | ||
| 88 | prop[GRAIL_PROP_PINCH_X1] *= gin->scale_x; | ||
| 89 | prop[GRAIL_PROP_PINCH_X1] += gin->trans_x; | ||
| 90 | prop[GRAIL_PROP_PINCH_Y1] *= gin->scale_y; | ||
| 91 | prop[GRAIL_PROP_PINCH_Y1] += gin->trans_y; | ||
| 92 | prop[GRAIL_PROP_PINCH_X2] *= gin->scale_x; | ||
| 93 | prop[GRAIL_PROP_PINCH_X2] += gin->trans_x; | ||
| 94 | prop[GRAIL_PROP_PINCH_Y2] *= gin->scale_y; | ||
| 95 | prop[GRAIL_PROP_PINCH_Y2] += gin->trans_y; | ||
| 96 | break; | ||
| 97 | case GRAIL_MAIN_ROTATE: | ||
| 98 | prop[GRAIL_PROP_ROTATE_X1] *= gin->scale_x; | ||
| 99 | prop[GRAIL_PROP_ROTATE_X1] += gin->trans_x; | ||
| 100 | prop[GRAIL_PROP_ROTATE_Y1] *= gin->scale_y; | ||
| 101 | prop[GRAIL_PROP_ROTATE_Y1] += gin->trans_y; | ||
| 102 | prop[GRAIL_PROP_ROTATE_X2] *= gin->scale_x; | ||
| 103 | prop[GRAIL_PROP_ROTATE_X2] += gin->trans_x; | ||
| 104 | prop[GRAIL_PROP_ROTATE_Y2] *= gin->scale_y; | ||
| 105 | prop[GRAIL_PROP_ROTATE_Y2] += gin->trans_y; | ||
| 106 | break; | ||
| 107 | case GRAIL_MAIN_TAP: | ||
| 108 | prop[GRAIL_PROP_TAP_X] *= gin->scale_x; | ||
| 109 | prop[GRAIL_PROP_TAP_X] += gin->trans_x; | ||
| 110 | prop[GRAIL_PROP_TAP_Y] *= gin->scale_y; | ||
| 111 | prop[GRAIL_PROP_TAP_Y] += gin->trans_y; | ||
| 112 | break; | ||
| 113 | }; | ||
| 114 | } | ||
| 115 | |||
| 116 | static int find_gslot(const struct gesture_inserter *gin, int gid) | 32 | static int find_gslot(const struct gesture_inserter *gin, int gid) |
| 117 | { | 33 | { |
| 118 | int i; | 34 | int i; |
| @@ -122,29 +38,6 @@ static int find_gslot(const struct gesture_inserter *gin, int gid) | |||
| 122 | return -1; | 38 | return -1; |
| 123 | } | 39 | } |
| 124 | 40 | ||
| 125 | static void send_event(struct grail *ge, struct slot_state *s, | ||
| 126 | const struct gesture_event *ev) | ||
| 127 | { | ||
| 128 | struct grail_event gev; | ||
| 129 | int i; | ||
| 130 | if (!ge->gesture) | ||
| 131 | return; | ||
| 132 | gev.type = s->type; | ||
| 133 | gev.id = s->id; | ||
| 134 | gev.status = ev->status; | ||
| 135 | gev.ntouch = ev->ntouch; | ||
| 136 | gev.nprop = ev->nprop; | ||
| 137 | gev.time = ev->time; | ||
| 138 | gev.pos = ev->pos; | ||
| 139 | transform_pos(ge->gin, &gev.pos); | ||
| 140 | memcpy(gev.prop, ev->prop, ev->nprop * sizeof(grail_prop_t)); | ||
| 141 | transform_prop(ge->gin, gev.type, gev.prop, gev.nprop); | ||
| 142 | for (i = 0; i < s->nclient; i++) { | ||
| 143 | gev.client_id = s->client_id[i]; | ||
| 144 | ge->gesture(ge, &gev); | ||
| 145 | } | ||
| 146 | } | ||
| 147 | |||
| 148 | // todo: spanning tree for multi-user case | 41 | // todo: spanning tree for multi-user case |
| 149 | static void setup_new_gestures(struct grail *ge, | 42 | static void setup_new_gestures(struct grail *ge, |
| 150 | const struct touch_frame *frame) | 43 | const struct touch_frame *frame) |
| @@ -167,19 +60,8 @@ static void setup_new_gestures(struct grail *ge, | |||
| 167 | grail_mask_set_mask(span, s->span, sizeof(span)); | 60 | grail_mask_set_mask(span, s->span, sizeof(span)); |
| 168 | } | 61 | } |
| 169 | 62 | ||
| 170 | if (ge->get_clients) { | 63 | nclient = gin_get_clients(ge, info, DIM_CLIENT, types, sizeof(types), |
| 171 | struct grail_coord coord[DIM_CLIENT]; | 64 | span, sizeof(span), frame); |
| 172 | int ncoord = 0; | ||
| 173 | grail_mask_foreach(i, span, sizeof(span)) { | ||
| 174 | const struct touch *t = &frame->touch[i]; | ||
| 175 | coord[ncoord].x = t->x; | ||
| 176 | coord[ncoord].y = t->y; | ||
| 177 | transform_pos(gin, &coord[ncoord]); | ||
| 178 | ncoord++; | ||
| 179 | } | ||
| 180 | nclient = ge->get_clients(ge, info, DIM_CLIENT, | ||
| 181 | coord, ncoord, types, sizeof(types)); | ||
| 182 | } | ||
| 183 | 65 | ||
| 184 | grail_mask_foreach(i, gin->fresh, sizeof(gin->fresh)) { | 66 | grail_mask_foreach(i, gin->fresh, sizeof(gin->fresh)) { |
| 185 | struct slot_state *s = &gin->state[i]; | 67 | struct slot_state *s = &gin->state[i]; |
| @@ -263,7 +145,7 @@ void gin_frame_end(struct grail *ge, | |||
| 263 | continue; | 145 | continue; |
| 264 | while (!gebuf_empty(&s->buf)) { | 146 | while (!gebuf_empty(&s->buf)) { |
| 265 | gebuf_get(&s->buf, &ev); | 147 | gebuf_get(&s->buf, &ev); |
| 266 | send_event(ge, s, &ev); | 148 | gin_send_event(ge, s, &ev, frame); |
| 267 | } | 149 | } |
| 268 | } | 150 | } |
| 269 | 151 | ||
