summaryrefslogtreecommitdiff
path: root/src/grail-inserter.c
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@euromail.se>2011-01-02 11:00:52 +0100
committerHenrik Rydberg <rydberg@euromail.se>2011-01-02 12:39:07 +0100
commitc0666a895e7fe8e488332263fd106ced0ed7cab7 (patch)
treefca88fbee4aaed6e1eed050a749ce6246a7f1966 /src/grail-inserter.c
parent1e07054fbeab6e90f104c279d3246097dd838a17 (diff)
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 <rydberg@euromail.se>
Diffstat (limited to 'src/grail-inserter.c')
-rw-r--r--src/grail-inserter.c31
1 files changed, 13 insertions, 18 deletions
diff --git a/src/grail-inserter.c b/src/grail-inserter.c
index 847995a..6f9a034 100644
--- a/src/grail-inserter.c
+++ b/src/grail-inserter.c
@@ -40,7 +40,7 @@ static int find_gslot(const struct gesture_inserter *gin, int gid)
40 40
41// todo: spanning tree for multi-user case 41// todo: spanning tree for multi-user case
42static void setup_new_gestures(struct grail *ge, 42static void setup_new_gestures(struct grail *ge,
43 const struct touch_frame *frame) 43 const struct utouch_frame *frame)
44{ 44{
45 struct gesture_inserter *gin = ge->gin; 45 struct gesture_inserter *gin = ge->gin;
46 grail_mask_t types[DIM_GRAIL_TYPE_BYTES]; 46 grail_mask_t types[DIM_GRAIL_TYPE_BYTES];
@@ -100,14 +100,14 @@ void gin_destroy(struct grail *ge)
100 ge->gin = NULL; 100 ge->gin = NULL;
101} 101}
102 102
103void gin_frame_begin(struct grail *ge, const struct touch_frame *frame) 103void gin_frame_begin(struct grail *ge, const struct utouch_frame *frame)
104{ 104{
105 struct gesture_inserter *gin = ge->gin; 105 struct gesture_inserter *gin = ge->gin;
106 memset(gin->types, 0, sizeof(gin->types)); 106 memset(gin->types, 0, sizeof(gin->types));
107 gin->time = frame->time; 107 gin->time = frame->time;
108} 108}
109 109
110void gin_frame_end(struct grail *ge, const struct touch_frame *frame) 110void gin_frame_end(struct grail *ge, const struct utouch_frame *frame)
111{ 111{
112 struct gesture_inserter *gin = ge->gin; 112 struct gesture_inserter *gin = ge->gin;
113 int i, hold = 0, discard = 0; 113 int i, hold = 0, discard = 0;
@@ -151,11 +151,12 @@ void gin_frame_end(struct grail *ge, const struct touch_frame *frame)
151 } 151 }
152} 152}
153 153
154int gin_gid_begin_select(struct grail *ge, int type, int priority, 154int gin_gid_begin(struct grail *ge, int type, int priority,
155 const grail_mask_t *span, int nspan) 155 const struct utouch_frame *frame)
156{ 156{
157 struct gesture_inserter *gin = ge->gin; 157 struct gesture_inserter *gin = ge->gin;
158 struct slot_state *s; 158 struct slot_state *s;
159 int slot;
159 int i = grail_mask_get_first(gin->unused, sizeof(gin->unused)); 160 int i = grail_mask_get_first(gin->unused, sizeof(gin->unused));
160 if (i < 0) 161 if (i < 0)
161 return -1; 162 return -1;
@@ -165,7 +166,8 @@ int gin_gid_begin_select(struct grail *ge, int type, int priority,
165 s->id = gin->gestureid++ & MAX_GESTURE_ID; 166 s->id = gin->gestureid++ & MAX_GESTURE_ID;
166 s->status = GRAIL_STATUS_BEGIN; 167 s->status = GRAIL_STATUS_BEGIN;
167 s->nclient = 0; 168 s->nclient = 0;
168 memcpy(s->span, span, nspan); 169 for (slot = 0; slot < DIM_TOUCH; slot++)
170 grail_mask_modify(s->span, slot, frame->slots[slot]->active);
169 gebuf_clear(&s->buf); 171 gebuf_clear(&s->buf);
170 grail_mask_clear(gin->unused, i); 172 grail_mask_clear(gin->unused, i);
171 grail_mask_set(gin->fresh, i); 173 grail_mask_set(gin->fresh, i);
@@ -173,13 +175,6 @@ int gin_gid_begin_select(struct grail *ge, int type, int priority,
173 return s->id; 175 return s->id;
174} 176}
175 177
176int gin_gid_begin(struct grail *ge, int type, int priority,
177 const struct touch_frame *frame)
178{
179 return gin_gid_begin_select(ge, type, priority,
180 frame->touches, sizeof(frame->touches));
181}
182
183void gin_gid_discard(struct grail *ge, int gid) 178void gin_gid_discard(struct grail *ge, int gid)
184{ 179{
185 struct gesture_inserter *gin = ge->gin; 180 struct gesture_inserter *gin = ge->gin;
@@ -248,18 +243,18 @@ void grail_set_bbox(struct grail *ge,
248 const struct grail_coord *tmin, 243 const struct grail_coord *tmin,
249 const struct grail_coord *tmax) 244 const struct grail_coord *tmax)
250{ 245{
251 struct touch_caps *caps = &ge->impl->dev.caps; 246 struct utouch_surface *s = utouch_frame_get_surface(ge->impl->fh);
252 struct gesture_inserter *gin = ge->gin; 247 struct gesture_inserter *gin = ge->gin;
253 double tx, ty, dx, dy, sx, sy; 248 double tx, ty, dx, dy, sx, sy;
254 tx = tmax->x - tmin->x; 249 tx = tmax->x - tmin->x;
255 ty = tmax->y - tmin->y; 250 ty = tmax->y - tmin->y;
256 dx = caps->max_x - caps->min_x; 251 dx = s->max_x - s->min_x;
257 dy = caps->max_y - caps->min_y; 252 dy = s->max_y - s->min_y;
258 sx = tx / dx; 253 sx = tx / dx;
259 sy = ty / dy; 254 sy = ty / dy;
260 gin->scale_x = sx; 255 gin->scale_x = sx;
261 gin->scale_y = sy; 256 gin->scale_y = sy;
262 gin->scale_r = sqrt((tx * tx + ty * ty) / (dx * dx + dy * dy)); 257 gin->scale_r = sqrt((tx * tx + ty * ty) / (dx * dx + dy * dy));
263 gin->trans_x = tmin->x - caps->min_x * sx; 258 gin->trans_x = tmin->x - s->min_x * sx;
264 gin->trans_y = tmin->y - caps->min_y * sy; 259 gin->trans_y = tmin->y - s->min_y * sy;
265} 260}