18
18
* with this program. If not, see <http://www.gnu.org/licenses/>.
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))
39
int utouch_frame_is_supported_xi2(Display *dpy, const XIDeviceInfo *dev)
39
int oif_frame_is_supported_xi2(Display *dpy, const XIDeviceInfo *dev)
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)
54
struct utouch_surface *s = fh->surface;
54
struct oif_surface *s = fh->surface;
55
55
XITouchClassInfo *v;
78
78
fh->map[0] = fh->map[4] = fh->map[8] = 1;
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)
83
83
unsigned long nitem, nbyte;
84
84
unsigned char *data;
102
static void update_screen(utouch_frame_handle fh, Display *dpy)
102
static void update_screen(oif_frame_handle fh, Display *dpy)
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;
123
123
s->mapped_max_x, s->mapped_max_y, s->mapped_max_pressure);
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)
129
struct utouch_surface *s = fh->surface;
129
struct oif_surface *s = fh->surface;
130
130
XITouchValuatorClassInfo *v;
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)
200
200
fh->evmap =calloc(dev->num_classes, sizeof(int));
204
if (!utouch_frame_is_supported_xi2(dpy, dev))
204
if (!oif_frame_is_supported_xi2(dpy, dev))
207
207
init_properties(fh, dpy, dev);
215
static int handle_event(utouch_frame_handle fh,
216
struct utouch_contact *slot,
215
static int handle_event(oif_frame_handle fh, struct oif_contact *slot, int ix,
219
218
switch (fh->evmap[ix]) {
220
219
case ABS_MT_POSITION_X:
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)
264
262
update_screen(fh, ev->display);
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)
271
struct utouch_frame *next = fh->next;
268
struct oif_frame *next = fh->next;
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];
281
return utouch_frame_sync(fh, time);
278
return oif_frame_sync(fh, time);
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)
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;
293
290
switch (ev->evtype) {
300
297
nbyte = ev->valuators.mask_len;
301
298
nbit = nbyte << 3;
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);
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;