From c0666a895e7fe8e488332263fd106ced0ed7cab7 Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Sun, 2 Jan 2011 11:00:52 +0100 Subject: Replace touch logic with utouch frame engine The original grail uses an internal touch framework and exports some touch information as extended attributes to gesture events. This was never quite the intention, but rather to expose gestures and touches on a similar footing, such that grail can be input agnostic. This patch starts off by replacing the internal touch framework with the utouch-frame engine. Signed-off-by: Henrik Rydberg --- src/grail-gestures.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'src/grail-gestures.c') diff --git a/src/grail-gestures.c b/src/grail-gestures.c index ed937a4..035a199 100644 --- a/src/grail-gestures.c +++ b/src/grail-gestures.c @@ -31,15 +31,15 @@ static const grail_time_t SAMPLE_MS = 10; static const float EPS = 1e-3; static void compute_position(float *x, float *y, - const struct touch_frame *frame) + const struct utouch_frame *frame) { - int i, n = frame->nactive; + int i, n = frame->num_active; *x = 0; *y = 0; if (n < 1) return; for (i = 0; i < n; i++) { - const struct touch *t = frame->active[i]; + const struct utouch_contact *t = frame->active[i]; *x += t->x; *y += t->y; } @@ -48,14 +48,14 @@ static void compute_position(float *x, float *y, } static float compute_radius(float x, float y, - const struct touch_frame *frame) + const struct utouch_frame *frame) { - int i, n = frame->nactive; + int i, n = frame->num_active; float r = 0, r2 = 0; if (n < 2) return r; for (i = 0; i < n; i++) { - const struct touch *t = frame->active[i]; + const struct utouch_contact *t = frame->active[i]; float dx = t->x - x; float dy = t->y - y; r2 += dx * dx + dy * dy; @@ -66,16 +66,15 @@ static float compute_radius(float x, float y, } static float compute_rotation(float x, float y, float r, - const struct touch_frame *prev, - const struct touch_frame *frame) + const struct utouch_frame *frame) { - int i, n = frame->nactive; + int i, n = frame->num_active; float da = 0, darc2 = 0; if (n < 2) return da; for (i = 0; i < n; i++) { - const struct touch *t = frame->active[i]; - const struct touch *ot = &prev->touch[t->slot]; + const struct utouch_contact *t = frame->active[i]; + const struct utouch_contact *ot = t->prev; float dx = t->x - x; float dy = t->y - y; float mx = t->x - ot->x; @@ -142,13 +141,13 @@ static void move_update(struct move_model *m, int i, float x, grail_time_t t) void gru_init_motion(struct grail *ge) { - struct touch_caps *caps = &ge->impl->dev.caps; + struct utouch_surface *s = utouch_frame_get_surface(ge->impl->fh); struct gesture_recognizer *gru = ge->gru; struct move_model *m = &gru->move; float D[DIM_FM]; int i; - D[FM_X] = caps->max_x - caps->min_x; - D[FM_Y] = caps->max_y - caps->min_y; + D[FM_X] = s->max_x - s->min_x; + D[FM_Y] = s->max_y - s->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++) { @@ -159,14 +158,15 @@ void gru_init_motion(struct grail *ge) } void gru_motion(struct grail *ge, - const struct touch_frame *frame) + const struct utouch_frame *frame) { struct gesture_recognizer *gru = ge->gru; struct move_model *m = &gru->move; grail_time_t t = frame->time; float x, y, r, a; + compute_position(&x, &y, frame); - if (frame->ncreate || frame->ndestroy) { + if (frame->prev->revision != frame->revision) { r = compute_radius(x, y, frame); a = 0; move_reset(m, FM_X, x, t); @@ -175,7 +175,7 @@ void gru_motion(struct grail *ge, move_reset(m, FM_A, a, t); m->single = 0; m->multi = 0; - } else if (frame->nactive < 2) { + } else if (frame->num_active < 2) { r = 0; a = 0; move_update(m, FM_X, x, t); @@ -190,7 +190,7 @@ void gru_motion(struct grail *ge, r = compute_radius(x, y, frame); r = move_filter(&m->fm[FM_R], r); a = m->fm[FM_A].value; - a += compute_rotation(x, y, r, &gru->frame, frame); + a += compute_rotation(x, y, r, frame); a = move_filter(&m->fm[FM_A], a); move_update(m, FM_X, x, t); move_update(m, FM_Y, y, t); @@ -199,7 +199,7 @@ void gru_motion(struct grail *ge, m->single = 0; m->multi = 1; } - m->ntouch = frame->nactive; + m->ntouch = frame->num_active; m->time = t; } -- cgit v1.2.3