~oif-team/frame/1.1.4

« back to all changes in this revision

Viewing changes to src/frame-mtdev.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
 *
19
19
 *
20
20
 ****************************************************************************/
21
21
 
22
 
#include <utouch/frame-mtdev.h>
 
22
#include <oif/frame-mtdev.h>
23
23
#include "frame-impl.h"
24
24
#include <linux/input.h>
25
25
#include <errno.h>
35
35
                evemu_has_event(dev, EV_KEY, BTN_LEFT);
36
36
}
37
37
 
38
 
int utouch_frame_is_supported_mtdev(const struct evemu_device *dev)
 
38
int oif_frame_is_supported_mtdev(const struct evemu_device *dev)
39
39
{
40
40
 
41
41
        /* only support pure absolute devices at this time */
56
56
                evemu_has_event(dev, EV_KEY, BTN_TOOL_DOUBLETAP);
57
57
}
58
58
 
59
 
int utouch_frame_init_mtdev(utouch_frame_handle fh,
60
 
                             const struct evemu_device *dev)
 
59
int oif_frame_init_mtdev(oif_frame_handle fh, const struct evemu_device *dev)
61
60
{
62
 
        struct utouch_surface *s = fh->surface;
 
61
        struct oif_surface *s = fh->surface;
63
62
        float tmp;
64
63
 
65
 
        if (!utouch_frame_is_supported_mtdev(dev))
 
64
        if (!oif_frame_is_supported_mtdev(dev))
66
65
                return -ENODEV;
67
66
 
68
67
        if (is_pointer(dev)) {
157
156
        return 0;
158
157
}
159
158
 
160
 
static int handle_abs_event(utouch_frame_handle fh,
 
159
static int handle_abs_event(oif_frame_handle fh,
161
160
                            const struct input_event *ev)
162
161
{
163
 
        struct utouch_contact *t = utouch_frame_get_current_slot(fh);
 
162
        struct oif_contact *t = oif_frame_get_current_slot(fh);
164
163
 
165
164
        switch (ev->code) {
166
165
        case ABS_MT_SLOT:
167
 
                utouch_frame_set_current_slot(fh, ev->value);
 
166
                oif_frame_set_current_slot(fh, ev->value);
168
167
                return 1;
169
168
        case ABS_MT_POSITION_X:
170
169
                t->x = ev->value;
213
212
        }
214
213
}
215
214
 
216
 
static int handle_key_event(utouch_frame_handle fh,
 
215
static int handle_key_event(oif_frame_handle fh,
217
216
                            const struct input_event *ev)
218
217
{
219
218
        /* EV_KEY events are only used for semi-mt touch count */
246
245
        }
247
246
}
248
247
 
249
 
static utouch_frame_time_t get_evtime_ms(const struct input_event *syn)
 
248
static oif_frame_time_t get_evtime_ms(const struct input_event *syn)
250
249
{
251
 
        static const utouch_frame_time_t ms = 1000;
 
250
        static const oif_frame_time_t ms = 1000;
252
251
        return syn->time.tv_usec / ms + syn->time.tv_sec * ms;
253
252
}
254
253
 
255
 
const struct utouch_frame *
256
 
utouch_frame_pump_mtdev(utouch_frame_handle fh, const struct input_event *ev)
 
254
const struct oif_frame *
 
255
oif_frame_pump_mtdev(oif_frame_handle fh, const struct input_event *ev)
257
256
{
258
 
        const struct utouch_frame *f = 0;
 
257
        const struct oif_frame *f = 0;
259
258
 
260
259
        if (ev->type == EV_SYN && ev->code == SYN_REPORT)
261
 
                f = utouch_frame_sync(fh, get_evtime_ms(ev));
 
260
                f = oif_frame_sync(fh, get_evtime_ms(ev));
262
261
        else if (ev->type == EV_ABS)
263
262
                handle_abs_event(fh, ev);
264
263
        else if (ev->type == EV_KEY)