From 76f51a7675801acfe8e58c6a21192668d23d3320 Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Thu, 19 Aug 2010 22:15:55 +0200 Subject: Add contact information to the property list Add the five first contacts to the property list, and unify the handling of all gesture types in this regard. To avoid duplication, move the scaling of properties closer to the gesture recognizer. Move all gesture event handling code to grail-event.c, simplifying the structure somewhat. Signed-off-by: Henrik Rydberg --- src/grail-inserter.c | 124 ++------------------------------------------------- 1 file changed, 3 insertions(+), 121 deletions(-) (limited to 'src/grail-inserter.c') 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 @@ static const int MAX_GESTURE_ID = 0xfff; -static const int grail_main_type[DIM_GRAIL_TYPE] = { - GRAIL_MAIN_DRAG, - GRAIL_MAIN_PINCH, - GRAIL_MAIN_ROTATE, - GRAIL_MAIN_DRAG, - GRAIL_MAIN_PINCH, - GRAIL_MAIN_ROTATE, - GRAIL_MAIN_DRAG, - GRAIL_MAIN_PINCH, - GRAIL_MAIN_ROTATE, - GRAIL_MAIN_DRAG, - GRAIL_MAIN_PINCH, - GRAIL_MAIN_ROTATE, - GRAIL_MAIN_DRAG, - GRAIL_MAIN_PINCH, - GRAIL_MAIN_ROTATE, - GRAIL_MAIN_TAP, - GRAIL_MAIN_TAP, - GRAIL_MAIN_TAP, - GRAIL_MAIN_TAP, - GRAIL_MAIN_TAP, - GRAIL_MAIN_DRAG, - GRAIL_MAIN_PINCH, - GRAIL_MAIN_ROTATE, - GRAIL_MAIN_DRAG, - GRAIL_MAIN_PINCH, - GRAIL_MAIN_ROTATE, -}; - -static void transform_pos(const struct gesture_inserter *gin, - struct grail_coord *pos) -{ - pos->x *= gin->scale_x; - pos->x += gin->trans_x; - pos->y *= gin->scale_y; - pos->y += gin->trans_y; -} - -static void transform_prop(const struct gesture_inserter *gin, int type, - grail_prop_t *prop, int nprop) -{ - switch (grail_main_type[type]) { - case GRAIL_MAIN_DRAG: - prop[GRAIL_PROP_DRAG_DX] *= gin->scale_x; - prop[GRAIL_PROP_DRAG_DY] *= gin->scale_y; - prop[GRAIL_PROP_DRAG_VX] *= gin->scale_x; - prop[GRAIL_PROP_DRAG_VY] *= gin->scale_y; - prop[GRAIL_PROP_DRAG_X] *= gin->scale_x; - prop[GRAIL_PROP_DRAG_X] += gin->trans_x; - prop[GRAIL_PROP_DRAG_Y] *= gin->scale_y; - prop[GRAIL_PROP_DRAG_Y] += gin->trans_y; - break; - case GRAIL_MAIN_PINCH: - prop[GRAIL_PROP_PINCH_DR] *= gin->scale_r; - prop[GRAIL_PROP_PINCH_VR] *= gin->scale_r; - prop[GRAIL_PROP_PINCH_R] *= gin->scale_r; - prop[GRAIL_PROP_PINCH_X1] *= gin->scale_x; - prop[GRAIL_PROP_PINCH_X1] += gin->trans_x; - prop[GRAIL_PROP_PINCH_Y1] *= gin->scale_y; - prop[GRAIL_PROP_PINCH_Y1] += gin->trans_y; - prop[GRAIL_PROP_PINCH_X2] *= gin->scale_x; - prop[GRAIL_PROP_PINCH_X2] += gin->trans_x; - prop[GRAIL_PROP_PINCH_Y2] *= gin->scale_y; - prop[GRAIL_PROP_PINCH_Y2] += gin->trans_y; - break; - case GRAIL_MAIN_ROTATE: - prop[GRAIL_PROP_ROTATE_X1] *= gin->scale_x; - prop[GRAIL_PROP_ROTATE_X1] += gin->trans_x; - prop[GRAIL_PROP_ROTATE_Y1] *= gin->scale_y; - prop[GRAIL_PROP_ROTATE_Y1] += gin->trans_y; - prop[GRAIL_PROP_ROTATE_X2] *= gin->scale_x; - prop[GRAIL_PROP_ROTATE_X2] += gin->trans_x; - prop[GRAIL_PROP_ROTATE_Y2] *= gin->scale_y; - prop[GRAIL_PROP_ROTATE_Y2] += gin->trans_y; - break; - case GRAIL_MAIN_TAP: - prop[GRAIL_PROP_TAP_X] *= gin->scale_x; - prop[GRAIL_PROP_TAP_X] += gin->trans_x; - prop[GRAIL_PROP_TAP_Y] *= gin->scale_y; - prop[GRAIL_PROP_TAP_Y] += gin->trans_y; - break; - }; -} - static int find_gslot(const struct gesture_inserter *gin, int gid) { int i; @@ -122,29 +38,6 @@ static int find_gslot(const struct gesture_inserter *gin, int gid) return -1; } -static void send_event(struct grail *ge, struct slot_state *s, - const struct gesture_event *ev) -{ - struct grail_event gev; - int i; - if (!ge->gesture) - return; - gev.type = s->type; - gev.id = s->id; - gev.status = ev->status; - gev.ntouch = ev->ntouch; - gev.nprop = ev->nprop; - gev.time = ev->time; - gev.pos = ev->pos; - transform_pos(ge->gin, &gev.pos); - memcpy(gev.prop, ev->prop, ev->nprop * sizeof(grail_prop_t)); - transform_prop(ge->gin, gev.type, gev.prop, gev.nprop); - for (i = 0; i < s->nclient; i++) { - gev.client_id = s->client_id[i]; - ge->gesture(ge, &gev); - } -} - // todo: spanning tree for multi-user case static void setup_new_gestures(struct grail *ge, const struct touch_frame *frame) @@ -167,19 +60,8 @@ static void setup_new_gestures(struct grail *ge, grail_mask_set_mask(span, s->span, sizeof(span)); } - if (ge->get_clients) { - struct grail_coord coord[DIM_CLIENT]; - int ncoord = 0; - grail_mask_foreach(i, span, sizeof(span)) { - const struct touch *t = &frame->touch[i]; - coord[ncoord].x = t->x; - coord[ncoord].y = t->y; - transform_pos(gin, &coord[ncoord]); - ncoord++; - } - nclient = ge->get_clients(ge, info, DIM_CLIENT, - coord, ncoord, types, sizeof(types)); - } + nclient = gin_get_clients(ge, info, DIM_CLIENT, types, sizeof(types), + span, sizeof(span), frame); grail_mask_foreach(i, gin->fresh, sizeof(gin->fresh)) { struct slot_state *s = &gin->state[i]; @@ -263,7 +145,7 @@ void gin_frame_end(struct grail *ge, continue; while (!gebuf_empty(&s->buf)) { gebuf_get(&s->buf, &ev); - send_event(ge, s, &ev); + gin_send_event(ge, s, &ev, frame); } } -- cgit v1.2.3