~oif-team/frame/1.1.4

« back to all changes in this revision

Viewing changes to src/frame-xi2.c

  • Committer: Chase Douglas
  • Date: 2012-08-15 19:05:52 UTC
  • Revision ID: chase.douglas@canonical.com-20120815190552-ul59r06he8a8j7f8
Rename project to simply 'frame'

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*****************************************************************************
2
2
 *
3
 
 * utouch-frame - Touch Frame Library
 
3
 * frame - Touch Frame Library
4
4
 *
5
5
 * Copyright (C) 2010 Canonical Ltd.
6
6
 *
18
18
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
19
19
 *
20
20
 ****************************************************************************/
21
 
#include <utouch/frame-xi2.h>
 
21
#include <oif/frame-xi2.h>
22
22
#include <xorg/xserver-properties.h>
23
23
#include <linux/input.h>
24
24
#include "frame-impl.h"
36
36
        if (!strcmp(name, AXIS_LABEL_PROP_##field) &&           \
37
37
            (fh->evmap[number] = field))
38
38
 
39
 
int utouch_frame_is_supported_xi2(Display *dpy, const XIDeviceInfo *dev)
 
39
int oif_frame_is_supported_xi2(Display *dpy, const XIDeviceInfo *dev)
40
40
{
41
41
 
42
42
    int i;
48
48
    return 0;
49
49
}
50
50
 
51
 
static void init_properties(utouch_frame_handle fh,
52
 
                            Display *dpy, const XIDeviceInfo *dev)
 
51
static void init_properties(oif_frame_handle fh, Display *dpy,
 
52
                            const XIDeviceInfo *dev)
53
53
{
54
 
        struct utouch_surface *s = fh->surface;
 
54
        struct oif_surface *s = fh->surface;
55
55
        XITouchClassInfo *v;
56
56
        int i;
57
57
 
78
78
        fh->map[0] = fh->map[4] = fh->map[8] = 1;
79
79
}
80
80
 
81
 
static void update_transform(utouch_frame_handle fh, Display *dpy, int devid)
 
81
static void update_transform(oif_frame_handle fh, Display *dpy, int devid)
82
82
{
83
83
        unsigned long nitem, nbyte;
84
84
        unsigned char *data;
99
99
        XFree(data);
100
100
}
101
101
 
102
 
static void update_screen(utouch_frame_handle fh, Display *dpy)
 
102
static void update_screen(oif_frame_handle fh, Display *dpy)
103
103
{
104
 
        struct utouch_surface *s = fh->surface;
 
104
        struct oif_surface *s = fh->surface;
105
105
        XWindowAttributes attrs;
106
106
        float x1, y1, x2, y2;
107
107
 
123
123
                s->mapped_max_x, s->mapped_max_y, s->mapped_max_pressure);
124
124
}
125
125
 
126
 
static void init_valuators(utouch_frame_handle fh,
127
 
                           Display *dpy, const XIDeviceInfo *dev)
 
126
static void init_valuators(oif_frame_handle fh, Display *dpy,
 
127
                           const XIDeviceInfo *dev)
128
128
{
129
 
        struct utouch_surface *s = fh->surface;
 
129
        struct oif_surface *s = fh->surface;
130
130
        XITouchValuatorClassInfo *v;
131
131
        char *name;
132
132
        int i;
193
193
        }
194
194
}
195
195
 
196
 
int utouch_frame_init_xi2(utouch_frame_handle fh,
197
 
                          Display *dpy, const XIDeviceInfo *dev)
 
196
int oif_frame_init_xi2(oif_frame_handle fh, Display *dpy,
 
197
                       const XIDeviceInfo *dev)
198
198
{
199
199
        free(fh->evmap);
200
200
        fh->evmap =calloc(dev->num_classes, sizeof(int));
201
201
        if (!fh->evmap)
202
202
                return -ENOMEM;
203
203
 
204
 
        if (!utouch_frame_is_supported_xi2(dpy, dev))
 
204
        if (!oif_frame_is_supported_xi2(dpy, dev))
205
205
                return -ENODEV;
206
206
 
207
207
        init_properties(fh, dpy, dev);
212
212
        return 0;
213
213
}
214
214
 
215
 
static int handle_event(utouch_frame_handle fh,
216
 
                        struct utouch_contact *slot,
217
 
                        int ix, float value)
 
215
static int handle_event(oif_frame_handle fh, struct oif_contact *slot, int ix,
 
216
                        float value)
218
217
{
219
218
        switch (fh->evmap[ix]) {
220
219
        case ABS_MT_POSITION_X:
257
256
        }
258
257
}
259
258
 
260
 
int utouch_frame_configure_xi2(utouch_frame_handle fh,
261
 
                               const XConfigureEvent *ev)
 
259
int oif_frame_configure_xi2(oif_frame_handle fh, const XConfigureEvent *ev)
262
260
{
263
261
        if (ev->display)
264
262
                update_screen(fh, ev->display);
265
263
        return 1;
266
264
}
267
265
 
268
 
const struct utouch_frame *sync_xi2(utouch_frame_handle fh,
269
 
                                    utouch_frame_time_t time)
 
266
const struct oif_frame *sync_xi2(oif_frame_handle fh, oif_frame_time_t time)
270
267
{
271
 
        struct utouch_frame *next = fh->next;
 
268
        struct oif_frame *next = fh->next;
272
269
        int i;
273
270
 
274
271
        /* no velocity adjustments without device time stamps in place */
275
272
        for (i = 0; i < fh->num_slots; i++) {
276
 
                struct utouch_contact *q = next->slots[i];
 
273
                struct oif_contact *q = next->slots[i];
277
274
                q->vx = 0;
278
275
                q->vy = 0;
279
276
        }
280
277
 
281
 
        return utouch_frame_sync(fh, time);
 
278
        return oif_frame_sync(fh, time);
282
279
}
283
280
 
284
 
const struct utouch_frame *
285
 
utouch_frame_pump_xi2(utouch_frame_handle fh, const XIDeviceEvent *ev)
 
281
const struct oif_frame *
 
282
oif_frame_pump_xi2(oif_frame_handle fh, const XIDeviceEvent *ev)
286
283
{
287
284
        const XIPropertyEvent *prop_ev;
288
285
        const double *value;
289
286
        const unsigned char *mask;
290
 
        struct utouch_contact *slot;
 
287
        struct oif_contact *slot;
291
288
        int touchid, nbyte, nbit, num, i;
292
289
 
293
290
        switch (ev->evtype) {
300
297
                nbyte = ev->valuators.mask_len;
301
298
                nbit = nbyte << 3;
302
299
 
303
 
                utouch_frame_set_current_id(fh, touchid);
304
 
                slot = utouch_frame_get_current_slot(fh);
 
300
                oif_frame_set_current_id(fh, touchid);
 
301
                slot = oif_frame_get_current_slot(fh);
305
302
                num = 0;
306
303
                for (i = 0; i < nbit; i++)
307
304
                        if (XIMaskIsSet(mask, i))
308
305
                                handle_event(fh, slot, i, value[num++]);
309
306
                if (ev->evtype == XI_TouchBegin)
310
 
                        utouch_frame_get_current_slot(fh)->active = 1;
 
307
                        oif_frame_get_current_slot(fh)->active = 1;
311
308
                else if (ev->evtype == XI_TouchEnd)
312
 
                        utouch_frame_get_current_slot(fh)->active = 0;
 
309
                        oif_frame_get_current_slot(fh)->active = 0;
313
310
                return sync_xi2(fh, ev->time);
314
311
        case XI_PropertyEvent:
315
312
                prop_ev = (XIPropertyEvent *)ev;