~chasedouglas/grail/original-touch-state

« back to all changes in this revision

Viewing changes to src/grail-inserter.c

  • Committer: Henrik Rydberg
  • Date: 2011-01-02 12:08:08 UTC
  • Revision ID: rydberg@bitmath.org-20110102120808-0nzbo3fcpp91sir5
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.

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
 
41
41
// todo: spanning tree for multi-user case
42
42
static void setup_new_gestures(struct grail *ge,
43
 
                               const struct touch_frame *frame)
 
43
                               const struct utouch_frame *frame)
44
44
{
45
45
        struct gesture_inserter *gin = ge->gin;
46
46
        grail_mask_t types[DIM_GRAIL_TYPE_BYTES];
100
100
        ge->gin = NULL;
101
101
}
102
102
 
103
 
void gin_frame_begin(struct grail *ge, const struct touch_frame *frame)
 
103
void gin_frame_begin(struct grail *ge, const struct utouch_frame *frame)
104
104
{
105
105
        struct gesture_inserter *gin = ge->gin;
106
106
        memset(gin->types, 0, sizeof(gin->types));
107
107
        gin->time = frame->time;
108
108
}
109
109
 
110
 
void gin_frame_end(struct grail *ge, const struct touch_frame *frame)
 
110
void gin_frame_end(struct grail *ge, const struct utouch_frame *frame)
111
111
{
112
112
        struct gesture_inserter *gin = ge->gin;
113
113
        int i, hold = 0, discard = 0;
151
151
        }
152
152
}
153
153
 
154
 
int gin_gid_begin_select(struct grail *ge, int type, int priority,
155
 
                         const grail_mask_t *span, int nspan)
 
154
int gin_gid_begin(struct grail *ge, int type, int priority,
 
155
                  const struct utouch_frame *frame)
156
156
{
157
157
        struct gesture_inserter *gin = ge->gin;
158
158
        struct slot_state *s;
 
159
        int slot;
159
160
        int i = grail_mask_get_first(gin->unused, sizeof(gin->unused));
160
161
        if (i < 0)
161
162
                return -1;
165
166
        s->id = gin->gestureid++ & MAX_GESTURE_ID;
166
167
        s->status = GRAIL_STATUS_BEGIN;
167
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
171
        gebuf_clear(&s->buf);
170
172
        grail_mask_clear(gin->unused, i);
171
173
        grail_mask_set(gin->fresh, i);
173
175
        return s->id;
174
176
}
175
177
 
176
 
int 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
 
 
183
178
void gin_gid_discard(struct grail *ge, int gid)
184
179
{
185
180
        struct gesture_inserter *gin = ge->gin;
248
243
                    const struct grail_coord *tmin,
249
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
247
        struct gesture_inserter *gin = ge->gin;
253
248
        double tx, ty, dx, dy, sx, sy;
254
249
        tx = tmax->x - tmin->x;
255
250
        ty = tmax->y - tmin->y;
256
 
        dx = caps->max_x - caps->min_x;
257
 
        dy = caps->max_y - caps->min_y;
 
251
        dx = s->max_x - s->min_x;
 
252
        dy = s->max_y - s->min_y;
258
253
        sx = tx / dx;
259
254
        sy = ty / dy;
260
255
        gin->scale_x = sx;
261
256
        gin->scale_y = sy;
262
257
        gin->scale_r = sqrt((tx * tx + ty * ty) / (dx * dx + dy * dy));
263
 
        gin->trans_x = tmin->x - caps->min_x * sx;
264
 
        gin->trans_y = tmin->y - caps->min_y * sy;
 
258
        gin->trans_x = tmin->x - s->min_x * sx;
 
259
        gin->trans_y = tmin->y - s->min_y * sy;
265
260
}