summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@euromail.se>2011-03-14 15:17:01 +0100
committerHenrik Rydberg <rydberg@euromail.se>2011-04-04 19:46:29 +0200
commit1fb331ca738e92e5815fe8b7ce503c187f52fecc (patch)
tree8ad4fc720e2585faefdbafa7126dc57743f5b320
parentd55a299efd74431e98c8a4f24cffd07c95d419d6 (diff)
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 <rydberg@euromail.se>
-rw-r--r--src/gestures-drag.c20
-rw-r--r--src/gestures-pinch.c6
-rw-r--r--src/gestures-tapping.c4
-rw-r--r--src/grail-event.c32
-rw-r--r--src/grail-gestures.c4
-rw-r--r--src/grail-inserter.c26
-rw-r--r--src/grail-inserter.h12
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,
38 const struct utouch_frame *frame) 38 const struct utouch_frame *frame)
39{ 39{
40 if (m->single) { 40 if (m->single) {
41 s->prop[GRAIL_PROP_DRAG_DX] = 41 s->prop[GRAIL_PROP_DRAG_DX] = m->fm[FM_X].raw_delta;
42 gin->scale_x * m->fm[FM_X].raw_delta; 42 s->prop[GRAIL_PROP_DRAG_DY] = m->fm[FM_Y].raw_delta;
43 s->prop[GRAIL_PROP_DRAG_DY] =
44 gin->scale_y * m->fm[FM_Y].raw_delta;
45 } else { 43 } else {
46 s->prop[GRAIL_PROP_DRAG_DX] = 44 s->prop[GRAIL_PROP_DRAG_DX] = m->fm[FM_X].action_delta;
47 gin->scale_x * m->fm[FM_X].action_delta; 45 s->prop[GRAIL_PROP_DRAG_DY] = m->fm[FM_Y].action_delta;
48 s->prop[GRAIL_PROP_DRAG_DY] =
49 gin->scale_y * m->fm[FM_Y].action_delta;
50 } 46 }
51 s->prop[GRAIL_PROP_DRAG_VX] = gin->scale_x * m->fm[FM_X].velocity; 47 s->prop[GRAIL_PROP_DRAG_VX] = m->fm[FM_X].velocity;
52 s->prop[GRAIL_PROP_DRAG_VY] = gin->scale_y * m->fm[FM_Y].velocity; 48 s->prop[GRAIL_PROP_DRAG_VY] = m->fm[FM_Y].velocity;
53 s->prop[GRAIL_PROP_DRAG_X] = gin_prop_x(gin, m->fm[FM_X].value); 49 s->prop[GRAIL_PROP_DRAG_X] = m->fm[FM_X].value;
54 s->prop[GRAIL_PROP_DRAG_Y] = gin_prop_y(gin, m->fm[FM_Y].value); 50 s->prop[GRAIL_PROP_DRAG_Y] = m->fm[FM_Y].value;
55 s->nprop = 6; 51 s->nprop = 6;
56 s->nprop += gin_add_contact_props(gin, s->prop + s->nprop, frame); 52 s->nprop += gin_add_contact_props(gin, s->prop + s->nprop, frame);
57} 53}
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,
40 const struct move_model *m, 40 const struct move_model *m,
41 const struct utouch_frame *frame) 41 const struct utouch_frame *frame)
42{ 42{
43 s->prop[GRAIL_PROP_PINCH_DR] = gin->scale_r * m->fm[FM_R].action_delta; 43 s->prop[GRAIL_PROP_PINCH_DR] = m->fm[FM_R].action_delta;
44 s->prop[GRAIL_PROP_PINCH_VR] = gin->scale_r * m->fm[FM_R].velocity; 44 s->prop[GRAIL_PROP_PINCH_VR] = m->fm[FM_R].velocity;
45 s->prop[GRAIL_PROP_PINCH_R] = gin->scale_r * m->fm[FM_R].value; 45 s->prop[GRAIL_PROP_PINCH_R] = m->fm[FM_R].value;
46 s->nprop = 3; 46 s->nprop = 3;
47 s->nprop += gin_add_contact_props(gin, s->prop + s->nprop, frame); 47 s->nprop += gin_add_contact_props(gin, s->prop + s->nprop, frame);
48} 48}
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,
30 const struct utouch_frame *frame) 30 const struct utouch_frame *frame)
31{ 31{
32 s->prop[GRAIL_PROP_TAP_DT] = m->time - s->start; 32 s->prop[GRAIL_PROP_TAP_DT] = m->time - s->start;
33 s->prop[GRAIL_PROP_TAP_X] = gin_prop_x(gin, m->fm[FM_X].value); 33 s->prop[GRAIL_PROP_TAP_X] = m->fm[FM_X].value;
34 s->prop[GRAIL_PROP_TAP_Y] = gin_prop_y(gin, m->fm[FM_Y].value); 34 s->prop[GRAIL_PROP_TAP_Y] = m->fm[FM_Y].value;
35 s->nprop = 3; 35 s->nprop = 3;
36 s->nprop += gin_add_contact_props(gin, s->prop + s->nprop, frame); 36 s->nprop += gin_add_contact_props(gin, s->prop + s->nprop, frame);
37} 37}
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,
62 if (ntouch > 5) 62 if (ntouch > 5)
63 ntouch = 5; 63 ntouch = 5;
64 compute_bbox(&min, &max, frame); 64 compute_bbox(&min, &max, frame);
65 prop[n++] = gin_prop_x(gin, min.x); 65 prop[n++] = min.x;
66 prop[n++] = gin_prop_y(gin, min.y); 66 prop[n++] = min.y;
67 prop[n++] = gin_prop_x(gin, max.x); 67 prop[n++] = max.x;
68 prop[n++] = gin_prop_y(gin, max.y); 68 prop[n++] = max.y;
69 for (i = 0; i < ntouch; i++) { 69 for (i = 0; i < ntouch; i++) {
70 const struct utouch_contact *ct = frame->active[i]; 70 const struct utouch_contact *ct = frame->active[i];
71 prop[n++] = ct->id; 71 prop[n++] = ct->id;
72 prop[n++] = gin_prop_x(gin, ct->x); 72 prop[n++] = ct->x;
73 prop[n++] = gin_prop_y(gin, ct->y); 73 prop[n++] = ct->y;
74 } 74 }
75 return n; 75 return n;
76} 76}
@@ -86,8 +86,8 @@ int gin_get_clients(struct grail *ge,
86 if (!ge->get_clients) 86 if (!ge->get_clients)
87 return 0; 87 return 0;
88 grail_mask_foreach(i, span, bspan) { 88 grail_mask_foreach(i, span, bspan) {
89 pos[npos].x = gin_prop_x(ge->gin, frame->slots[i]->x); 89 pos[npos].x = frame->slots[i]->x;
90 pos[npos].y = gin_prop_y(ge->gin, frame->slots[i]->y); 90 pos[npos].y = frame->slots[i]->y;
91 npos++; 91 npos++;
92 } 92 }
93 return ge->get_clients(ge, info, maxinfo, pos, npos, types, btypes); 93 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,
109 gev.ntouch = ev->ntouch; 109 gev.ntouch = ev->ntouch;
110 gev.nprop = ev->nprop; 110 gev.nprop = ev->nprop;
111 gev.time = ev->time; 111 gev.time = ev->time;
112 gev.pos.x = gin_prop_x(gin, ev->pos.x); 112 gev.pos.x = ev->pos.x;
113 gev.pos.y = gin_prop_y(gin, ev->pos.y); 113 gev.pos.y = ev->pos.y;
114 memcpy(gev.prop, ev->prop, ev->nprop * sizeof(grail_prop_t)); 114 memcpy(gev.prop, ev->prop, ev->nprop * sizeof(grail_prop_t));
115 for (i = 0; i < s->nclient; i++) { 115 for (i = 0; i < s->nclient; i++) {
116 gev.client_id = s->client_id[i]; 116 gev.client_id = s->client_id[i];
@@ -131,12 +131,12 @@ int grail_get_contacts(const struct grail *ge,
131 const struct utouch_contact *ct = frame->active[i]; 131 const struct utouch_contact *ct = frame->active[i];
132 t->id = ct->id; 132 t->id = ct->id;
133 t->tool_type = ct->tool_type; 133 t->tool_type = ct->tool_type;
134 t->pos.x = gin_prop_x(gin, ct->x); 134 t->pos.x = ct->x;
135 t->pos.y = gin_prop_y(gin, ct->y); 135 t->pos.y = ct->y;
136 t->touch_major = gin->scale_r * ct->touch_major; 136 t->touch_major = ct->touch_major;
137 t->touch_minor = gin->scale_r * ct->touch_minor; 137 t->touch_minor = ct->touch_minor;
138 t->width_major = gin->scale_r * ct->width_major; 138 t->width_major = ct->width_major;
139 t->width_minor = gin->scale_r * ct->width_minor; 139 t->width_minor = ct->width_minor;
140 t->angle = ct->orientation; 140 t->angle = ct->orientation;
141 t->pressure = ct->pressure; 141 t->pressure = ct->pressure;
142 } 142 }
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)
151 struct move_model *m = &gru->move; 151 struct move_model *m = &gru->move;
152 float D[DIM_FM]; 152 float D[DIM_FM];
153 int i; 153 int i;
154 D[FM_X] = s->max_x - s->min_x; 154 D[FM_X] = s->mapped_max_x - s->mapped_min_x;
155 D[FM_Y] = s->max_y - s->min_y; 155 D[FM_Y] = s->mapped_max_y - s->mapped_min_y;
156 D[FM_R] = sqrt(D[FM_X] * D[FM_X] + D[FM_Y] * D[FM_Y]); 156 D[FM_R] = sqrt(D[FM_X] * D[FM_X] + D[FM_Y] * D[FM_Y]);
157 D[FM_A] = 2 * M_PI; 157 D[FM_A] = 2 * M_PI;
158 for (i = 0; i < DIM_FM; i++) { 158 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)
104 return -ENOMEM; 104 return -ENOMEM;
105 for (i = 0; i < DIM_INSTANCE; i++) 105 for (i = 0; i < DIM_INSTANCE; i++)
106 grail_mask_set(gin->unused, i); 106 grail_mask_set(gin->unused, i);
107 gin->scale_x = 1;
108 gin->scale_y = 1;
109 gin->scale_r = 1;
110 gin->trans_x = 1;
111 gin->trans_y = 1;
112 ge->gin = gin; 107 ge->gin = gin;
113 return 0; 108 return 0;
114} 109}
@@ -298,17 +293,12 @@ void grail_set_bbox(struct grail *ge,
298 const struct grail_coord *tmax) 293 const struct grail_coord *tmax)
299{ 294{
300 struct utouch_surface *s = utouch_frame_get_surface(ge->impl->fh); 295 struct utouch_surface *s = utouch_frame_get_surface(ge->impl->fh);
301 struct gesture_inserter *gin = ge->gin; 296
302 double tx, ty, dx, dy, sx, sy; 297 s->mapped_min_x = tmin->x;
303 tx = tmax->x - tmin->x; 298 s->mapped_min_y = tmin->y;
304 ty = tmax->y - tmin->y; 299 s->mapped_max_x = tmax->x;
305 dx = s->max_x - s->min_x; 300 s->mapped_max_y = tmax->y;
306 dy = s->max_y - s->min_y; 301
307 sx = tx / dx; 302 if (ge->gru)
308 sy = ty / dy; 303 gru_init_motion(ge);
309 gin->scale_x = sx;
310 gin->scale_y = sy;
311 gin->scale_r = sqrt((tx * tx + ty * ty) / (dx * dx + dy * dy));
312 gin->trans_x = tmin->x - s->min_x * sx;
313 gin->trans_y = tmin->y - s->min_y * sy;
314} 304}
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 {
58 int gestureid; 58 int gestureid;
59 int grab_active; 59 int grab_active;
60 int grab_client; 60 int grab_client;
61 float scale_x, scale_y, scale_r;
62 float trans_x, trans_y;
63}; 61};
64 62
65static inline float gin_prop_x(const struct gesture_inserter *gin, float x)
66{
67 return gin->scale_x * x + gin->trans_x;
68}
69
70static inline float gin_prop_y(const struct gesture_inserter *gin, float y)
71{
72 return gin->scale_y * y + gin->trans_y;
73}
74
75int gin_add_contact_props(const struct gesture_inserter *gin, 63int gin_add_contact_props(const struct gesture_inserter *gin,
76 grail_prop_t *prop, const struct utouch_frame *frame); 64 grail_prop_t *prop, const struct utouch_frame *frame);
77 65