From 1fb331ca738e92e5815fe8b7ce503c187f52fecc Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Mon, 14 Mar 2011 15:17:01 +0100 Subject: Convert to utouch-frame mapping Remove the grail-internal mapping code and rely directly on utouch-frame instead. Passes the unit test designed for this change. Signed-off-by: Henrik Rydberg --- src/gestures-drag.c | 20 ++++++++------------ src/gestures-pinch.c | 6 +++--- src/gestures-tapping.c | 4 ++-- src/grail-event.c | 32 ++++++++++++++++---------------- src/grail-gestures.c | 4 ++-- src/grail-inserter.c | 26 ++++++++------------------ src/grail-inserter.h | 12 ------------ 7 files changed, 39 insertions(+), 65 deletions(-) diff --git a/src/gestures-drag.c b/src/gestures-drag.c index 41ded2c..a2819f2 100644 --- a/src/gestures-drag.c +++ b/src/gestures-drag.c @@ -38,20 +38,16 @@ static void set_props(const struct gesture_inserter *gin, const struct utouch_frame *frame) { if (m->single) { - s->prop[GRAIL_PROP_DRAG_DX] = - gin->scale_x * m->fm[FM_X].raw_delta; - s->prop[GRAIL_PROP_DRAG_DY] = - gin->scale_y * m->fm[FM_Y].raw_delta; + s->prop[GRAIL_PROP_DRAG_DX] = m->fm[FM_X].raw_delta; + s->prop[GRAIL_PROP_DRAG_DY] = m->fm[FM_Y].raw_delta; } else { - s->prop[GRAIL_PROP_DRAG_DX] = - gin->scale_x * m->fm[FM_X].action_delta; - s->prop[GRAIL_PROP_DRAG_DY] = - gin->scale_y * m->fm[FM_Y].action_delta; + s->prop[GRAIL_PROP_DRAG_DX] = m->fm[FM_X].action_delta; + s->prop[GRAIL_PROP_DRAG_DY] = m->fm[FM_Y].action_delta; } - s->prop[GRAIL_PROP_DRAG_VX] = gin->scale_x * m->fm[FM_X].velocity; - s->prop[GRAIL_PROP_DRAG_VY] = gin->scale_y * m->fm[FM_Y].velocity; - s->prop[GRAIL_PROP_DRAG_X] = gin_prop_x(gin, m->fm[FM_X].value); - s->prop[GRAIL_PROP_DRAG_Y] = gin_prop_y(gin, m->fm[FM_Y].value); + s->prop[GRAIL_PROP_DRAG_VX] = m->fm[FM_X].velocity; + s->prop[GRAIL_PROP_DRAG_VY] = m->fm[FM_Y].velocity; + s->prop[GRAIL_PROP_DRAG_X] = m->fm[FM_X].value; + s->prop[GRAIL_PROP_DRAG_Y] = m->fm[FM_Y].value; s->nprop = 6; s->nprop += gin_add_contact_props(gin, s->prop + s->nprop, frame); } diff --git a/src/gestures-pinch.c b/src/gestures-pinch.c index bc5db1f..facb952 100644 --- a/src/gestures-pinch.c +++ b/src/gestures-pinch.c @@ -40,9 +40,9 @@ static void set_props(const struct gesture_inserter *gin, const struct move_model *m, const struct utouch_frame *frame) { - s->prop[GRAIL_PROP_PINCH_DR] = gin->scale_r * m->fm[FM_R].action_delta; - s->prop[GRAIL_PROP_PINCH_VR] = gin->scale_r * m->fm[FM_R].velocity; - s->prop[GRAIL_PROP_PINCH_R] = gin->scale_r * m->fm[FM_R].value; + s->prop[GRAIL_PROP_PINCH_DR] = m->fm[FM_R].action_delta; + s->prop[GRAIL_PROP_PINCH_VR] = m->fm[FM_R].velocity; + s->prop[GRAIL_PROP_PINCH_R] = m->fm[FM_R].value; s->nprop = 3; s->nprop += gin_add_contact_props(gin, s->prop + s->nprop, frame); } diff --git a/src/gestures-tapping.c b/src/gestures-tapping.c index 656d6e9..6d9837d 100644 --- a/src/gestures-tapping.c +++ b/src/gestures-tapping.c @@ -30,8 +30,8 @@ static void set_props(const struct gesture_inserter *gin, const struct utouch_frame *frame) { s->prop[GRAIL_PROP_TAP_DT] = m->time - s->start; - s->prop[GRAIL_PROP_TAP_X] = gin_prop_x(gin, m->fm[FM_X].value); - s->prop[GRAIL_PROP_TAP_Y] = gin_prop_y(gin, m->fm[FM_Y].value); + s->prop[GRAIL_PROP_TAP_X] = m->fm[FM_X].value; + s->prop[GRAIL_PROP_TAP_Y] = m->fm[FM_Y].value; s->nprop = 3; s->nprop += gin_add_contact_props(gin, s->prop + s->nprop, frame); } diff --git a/src/grail-event.c b/src/grail-event.c index 9c0e437..504ed10 100644 --- a/src/grail-event.c +++ b/src/grail-event.c @@ -62,15 +62,15 @@ int gin_add_contact_props(const struct gesture_inserter *gin, if (ntouch > 5) ntouch = 5; compute_bbox(&min, &max, frame); - prop[n++] = gin_prop_x(gin, min.x); - prop[n++] = gin_prop_y(gin, min.y); - prop[n++] = gin_prop_x(gin, max.x); - prop[n++] = gin_prop_y(gin, max.y); + prop[n++] = min.x; + prop[n++] = min.y; + prop[n++] = max.x; + prop[n++] = max.y; for (i = 0; i < ntouch; i++) { const struct utouch_contact *ct = frame->active[i]; prop[n++] = ct->id; - prop[n++] = gin_prop_x(gin, ct->x); - prop[n++] = gin_prop_y(gin, ct->y); + prop[n++] = ct->x; + prop[n++] = ct->y; } return n; } @@ -86,8 +86,8 @@ int gin_get_clients(struct grail *ge, if (!ge->get_clients) return 0; grail_mask_foreach(i, span, bspan) { - pos[npos].x = gin_prop_x(ge->gin, frame->slots[i]->x); - pos[npos].y = gin_prop_y(ge->gin, frame->slots[i]->y); + pos[npos].x = frame->slots[i]->x; + pos[npos].y = frame->slots[i]->y; npos++; } return ge->get_clients(ge, info, maxinfo, pos, npos, types, btypes); @@ -109,8 +109,8 @@ void gin_send_event(struct grail *ge, struct slot_state *s, gev.ntouch = ev->ntouch; gev.nprop = ev->nprop; gev.time = ev->time; - gev.pos.x = gin_prop_x(gin, ev->pos.x); - gev.pos.y = gin_prop_y(gin, ev->pos.y); + gev.pos.x = ev->pos.x; + gev.pos.y = ev->pos.y; memcpy(gev.prop, ev->prop, ev->nprop * sizeof(grail_prop_t)); for (i = 0; i < s->nclient; i++) { gev.client_id = s->client_id[i]; @@ -131,12 +131,12 @@ int grail_get_contacts(const struct grail *ge, const struct utouch_contact *ct = frame->active[i]; t->id = ct->id; t->tool_type = ct->tool_type; - t->pos.x = gin_prop_x(gin, ct->x); - t->pos.y = gin_prop_y(gin, ct->y); - t->touch_major = gin->scale_r * ct->touch_major; - t->touch_minor = gin->scale_r * ct->touch_minor; - t->width_major = gin->scale_r * ct->width_major; - t->width_minor = gin->scale_r * ct->width_minor; + t->pos.x = ct->x; + t->pos.y = ct->y; + t->touch_major = ct->touch_major; + t->touch_minor = ct->touch_minor; + t->width_major = ct->width_major; + t->width_minor = ct->width_minor; t->angle = ct->orientation; t->pressure = ct->pressure; } diff --git a/src/grail-gestures.c b/src/grail-gestures.c index dde8d60..c4ae0dc 100644 --- a/src/grail-gestures.c +++ b/src/grail-gestures.c @@ -151,8 +151,8 @@ void gru_init_motion(struct grail *ge) struct move_model *m = &gru->move; float D[DIM_FM]; int i; - D[FM_X] = s->max_x - s->min_x; - D[FM_Y] = s->max_y - s->min_y; + D[FM_X] = s->mapped_max_x - s->mapped_min_x; + D[FM_Y] = s->mapped_max_y - s->mapped_min_y; D[FM_R] = sqrt(D[FM_X] * D[FM_X] + D[FM_Y] * D[FM_Y]); D[FM_A] = 2 * M_PI; for (i = 0; i < DIM_FM; i++) { diff --git a/src/grail-inserter.c b/src/grail-inserter.c index f784848..ab81ece 100644 --- a/src/grail-inserter.c +++ b/src/grail-inserter.c @@ -104,11 +104,6 @@ int gin_init(struct grail *ge) return -ENOMEM; for (i = 0; i < DIM_INSTANCE; i++) grail_mask_set(gin->unused, i); - gin->scale_x = 1; - gin->scale_y = 1; - gin->scale_r = 1; - gin->trans_x = 1; - gin->trans_y = 1; ge->gin = gin; return 0; } @@ -298,17 +293,12 @@ void grail_set_bbox(struct grail *ge, const struct grail_coord *tmax) { struct utouch_surface *s = utouch_frame_get_surface(ge->impl->fh); - struct gesture_inserter *gin = ge->gin; - double tx, ty, dx, dy, sx, sy; - tx = tmax->x - tmin->x; - ty = tmax->y - tmin->y; - dx = s->max_x - s->min_x; - dy = s->max_y - s->min_y; - sx = tx / dx; - sy = ty / dy; - gin->scale_x = sx; - gin->scale_y = sy; - gin->scale_r = sqrt((tx * tx + ty * ty) / (dx * dx + dy * dy)); - gin->trans_x = tmin->x - s->min_x * sx; - gin->trans_y = tmin->y - s->min_y * sy; + + s->mapped_min_x = tmin->x; + s->mapped_min_y = tmin->y; + s->mapped_max_x = tmax->x; + s->mapped_max_y = tmax->y; + + if (ge->gru) + gru_init_motion(ge); } diff --git a/src/grail-inserter.h b/src/grail-inserter.h index 55e94a3..f8451d6 100644 --- a/src/grail-inserter.h +++ b/src/grail-inserter.h @@ -58,20 +58,8 @@ struct gesture_inserter { int gestureid; int grab_active; int grab_client; - float scale_x, scale_y, scale_r; - float trans_x, trans_y; }; -static inline float gin_prop_x(const struct gesture_inserter *gin, float x) -{ - return gin->scale_x * x + gin->trans_x; -} - -static inline float gin_prop_y(const struct gesture_inserter *gin, float y) -{ - return gin->scale_y * y + gin->trans_y; -} - int gin_add_contact_props(const struct gesture_inserter *gin, grail_prop_t *prop, const struct utouch_frame *frame); -- cgit v1.2.3