aboutsummaryrefslogtreecommitdiffstats
path: root/mtdev
diff options
context:
space:
mode:
Diffstat (limited to 'mtdev')
-rw-r--r--mtdev/caps.c175
-rw-r--r--mtdev/core.c402
-rw-r--r--mtdev/iobuf.c63
-rw-r--r--mtdev/mapgen.c69
-rw-r--r--mtdev/test.c79
5 files changed, 0 insertions, 788 deletions
diff --git a/mtdev/caps.c b/mtdev/caps.c
deleted file mode 100644
index 069816e..0000000
--- a/mtdev/caps.c
+++ /dev/null
@@ -1,175 +0,0 @@
-/***************************************************************************
- *
- * Multitouch X driver
- * Copyright (C) 2008 Henrik Rydberg <rydberg@euromail.se>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- **************************************************************************/
-
-#include "mtdev-caps.h"
-#include "mtbit.h"
-
-#define SETABS(c, x, map, key, fd) \
- (c->has_##x = getbit(map, key) && getabs(&c->x, key, fd))
-
-#define ADDCAP(s, c, x) strcat(s, c->has_##x ? " " #x : "")
-
-static const int SN_COORD = 250; /* coordinate signal-to-noise ratio */
-static const int SN_WIDTH = 100; /* width signal-to-noise ratio */
-static const int SN_ORIENT = 10; /* orientation signal-to-noise ratio */
-
-static const int bits_per_long = 8 * sizeof(long);
-
-static inline int nlongs(int nbit)
-{
- return (nbit + bits_per_long - 1) / bits_per_long;
-}
-
-static inline int getbit(const unsigned long *map, int key)
-{
- return (map[key / bits_per_long] >> (key % bits_per_long)) & 0x01;
-}
-
-static int getabs(struct input_absinfo *abs, int key, int fd)
-{
- int rc;
- SYSCALL(rc = ioctl(fd, EVIOCGABS(key), abs));
- return rc >= 0;
-}
-
-static int has_mt_data(const struct Capabilities *cap)
-{
- return cap->has_abs[BIT_POSITION_X] && cap->has_abs[BIT_POSITION_Y];
-}
-
-static int has_integrated_button(const struct Capabilities *cap)
-{
- static const int bcm5974_vmask_ibt = 1;
- if (strcmp(cap->devname, "bcm5974"))
- return 0;
- return cap->devid.version & bcm5974_vmask_ibt;
-}
-
-static void default_fuzz(struct Capabilities *cap, unsigned int code, int sn)
-{
- int bit = abs2mt(code);
- if (cap->has_abs[bit] && cap->abs[bit].fuzz == 0)
- cap->abs[bit].fuzz =
- (cap->abs[bit].maximum - cap->abs[bit].minimum) / sn;
-}
-
-int read_capabilities(struct Capabilities *cap, int fd)
-{
- unsigned long evbits[nlongs(EV_MAX)];
- unsigned long absbits[nlongs(ABS_MAX)];
- unsigned long keybits[nlongs(KEY_MAX)];
- int rc, i;
-
- memset(cap, 0, sizeof(struct Capabilities));
-
- SYSCALL(rc = ioctl(fd, EVIOCGID, &cap->devid));
- if (rc < 0)
- return rc;
- SYSCALL(rc = ioctl(fd, EVIOCGNAME(sizeof(cap->devname)), cap->devname));
- if (rc < 0)
- return rc;
- SYSCALL(rc = ioctl(fd, EVIOCGBIT(EV_SYN, sizeof(evbits)), evbits));
- if (rc < 0)
- return rc;
- SYSCALL(rc = ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(keybits)), keybits));
- if (rc < 0)
- return rc;
- SYSCALL(rc = ioctl(fd, EVIOCGBIT(EV_ABS, sizeof(absbits)), absbits));
- if (rc < 0)
- return rc;
-
- cap->has_left = getbit(keybits, BTN_LEFT);
- cap->has_middle = getbit(keybits, BTN_MIDDLE);
- cap->has_right = getbit(keybits, BTN_RIGHT);
-
- SETABS(cap, slot, absbits, ABS_MT_SLOT, fd);
- for (i = 0; i < MT_ABS_SIZE; i++)
- SETABS(cap, abs[i], absbits, mt2abs(i), fd);
-
- cap->has_mtdata = has_mt_data(cap);
- cap->has_ibt = has_integrated_button(cap);
-
- if (cap->has_abs[BIT_TRACKING_ID])
- cap->nullid = cap->abs[BIT_TRACKING_ID].minimum - 1;
-
- default_fuzz(cap, ABS_MT_POSITION_X, SN_COORD);
- default_fuzz(cap, ABS_MT_POSITION_Y, SN_COORD);
- default_fuzz(cap, ABS_MT_TOUCH_MAJOR, SN_WIDTH);
- default_fuzz(cap, ABS_MT_TOUCH_MINOR, SN_WIDTH);
- default_fuzz(cap, ABS_MT_WIDTH_MAJOR, SN_WIDTH);
- default_fuzz(cap, ABS_MT_WIDTH_MINOR, SN_WIDTH);
- default_fuzz(cap, ABS_MT_ORIENTATION, SN_ORIENT);
-
- return 0;
-}
-
-int get_cap_xsize(const struct Capabilities *cap)
-{
- const struct input_absinfo *x = &cap->abs[BIT_POSITION_X];
- return x->maximum - x->minimum;
-}
-
-int get_cap_ysize(const struct Capabilities *cap)
-{
- const struct input_absinfo *y = &cap->abs[BIT_POSITION_Y];
- return y->maximum - y->minimum;
-}
-
-int get_cap_wsize(const struct Capabilities *cap)
-{
- const struct input_absinfo *w = &cap->abs[BIT_TOUCH_MAJOR];
- return w->maximum - w->minimum;
-}
-
-int get_cap_xmid(const struct Capabilities *cap)
-{
- const struct input_absinfo *x = &cap->abs[BIT_POSITION_X];
- return (x->maximum + x->minimum) >> 1;
-}
-
-int get_cap_ymid(const struct Capabilities *cap)
-{
- const struct input_absinfo *y = &cap->abs[BIT_POSITION_Y];
- return (y->maximum + y->minimum) >> 1;
-}
-
-void output_capabilities(const struct Capabilities *cap)
-{
- char line[1024];
- int i;
- memset(line, 0, sizeof(line));
- ADDCAP(line, cap, left);
- ADDCAP(line, cap, middle);
- ADDCAP(line, cap, right);
- ADDCAP(line, cap, mtdata);
- ADDCAP(line, cap, ibt);
- xf86Msg(X_INFO, "multitouch: devname: %s\n", cap->devname);
- xf86Msg(X_INFO, "multitouch: devid: %x %x %x\n",
- cap->devid.vendor, cap->devid.product, cap->devid.version);
- xf86Msg(X_INFO, "multitouch: caps:%s\n", line);
- for (i = 0; i < MT_ABS_SIZE; i++) {
- if (cap->has_abs[i])
- xf86Msg(X_INFO, "multitouch: %d: min: %d max: %d\n",
- i,
- cap->abs[i].minimum,
- cap->abs[i].maximum);
- }
-}
diff --git a/mtdev/core.c b/mtdev/core.c
deleted file mode 100644
index f13da13..0000000
--- a/mtdev/core.c
+++ /dev/null
@@ -1,402 +0,0 @@
-/***************************************************************************
- *
- * Multitouch X driver
- * Copyright (C) 2008 Henrik Rydberg <rydberg@euromail.se>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- **************************************************************************/
-
-#include "mtdev.h"
-#include "mtbit.h"
-
-/**
- * struct MTSlot - represents the state of an input MT slot
- * @abs: current values of ABS_MT axes for this slot
- */
-struct MTSlot {
- int abs[MT_ABS_SIZE];
-};
-
-/**
- * struct MTDevState - MT slot parsing
- * @data: array of scratch slot data
- * @used: bitmask of currently used slots
- * @slot: slot currently being modified
- * @lastid: last used tracking id
- */
-struct MTDevState {
- struct MTSlot data[DIM_FINGER];
- bitmask_t used;
- bitmask_t slot;
- bitmask_t lastid;
-};
-
-/**
- * mtdev_init - init MT device
- * @dev: device to initialize
- * @caps: device capabilities
- */
-int mtdev_init(struct MTDev *dev, const struct Capabilities *caps)
-{
- memset(dev, 0, sizeof(struct MTDev));
- if (!caps->has_mtdata)
- return -ENODEV;
- if (!caps->has_slot) {
- dev->priv = calloc(1, sizeof(struct MTDevState));
- if (!dev->priv)
- return -ENOMEM;
- }
- return 0;
-}
-
-static inline int istouch(const struct MTSlot *data,
- const struct Capabilities *caps)
-{
- return data->abs[BIT_TOUCH_MAJOR] || !caps->has_abs[BIT_TOUCH_MAJOR];
-}
-
-/* Dmitry Torokhov's code from kernel/driver/input/input.c */
-static int defuzz(int value, int old_val, int fuzz)
-{
- if (fuzz) {
- if (value > old_val - fuzz / 2 && value < old_val + fuzz / 2)
- return old_val;
-
- if (value > old_val - fuzz && value < old_val + fuzz)
- return (old_val * 3 + value) / 4;
-
- if (value > old_val - fuzz * 2 && value < old_val + fuzz * 2)
- return (old_val + value) / 2;
- }
-
- return value;
-}
-
-/*
- * solve - solve contact matching problem
- * @priv: parsing state
- * @caps: device capabilities
- * @sid: array of current tracking ids
- * @sx: array of current position x
- * @sy: array of current position y
- * @sn: number of current contacts
- * @nid: array of new or matched tracking ids, to be filled
- * @nx: array of new position x
- * @ny: array of new position y
- * @nn: number of new contacts
- * @touch: which of the new contacts to fill
- */
-static void solve(struct MTDevState *priv, const struct Capabilities *caps,
- const int *sid, const int *sx, const int *sy, int sn,
- int *nid, const int *nx, const int *ny, int nn,
- bitmask_t touch)
-{
- int A[DIM2_FINGER], *row;
- int n2s[DIM_FINGER];
- int id, i, j;
-
- /* setup distance matrix for contact matching */
- for (j = 0; j < sn; j++) {
- row = A + nn * j;
- for (i = 0; i < nn; i++)
- row[i] = dist2(nx[i] - sx[j], ny[i] - sy[j]);
- }
-
- match_fingers(n2s, A, nn, sn);
-
- /* update matched contacts and create new ones */
- foreach_bit(i, touch) {
- j = n2s[i];
- id = j >= 0 ? sid[j] : caps->nullid;
- while (id == caps->nullid)
- id = ++priv->lastid;
- nid[i] = id;
- }
-}
-
-/*
- * assign_tracking_id - assign tracking ids to all contacts
- * @priv: parsing state
- * @caps: device capabilities
- * @data: array of all present contacts, to be filled
- * @prop: array of all set contacts properties
- * @size: number of contacts in array
- * @touch: which of the contacts are actual touches
- */
-static void assign_tracking_id(struct MTDevState *priv,
- const struct Capabilities *caps,
- struct MTSlot *data, bitmask_t *prop,
- int size, bitmask_t touch)
-{
- int sid[DIM_FINGER], sx[DIM_FINGER], sy[DIM_FINGER], sn = 0;
- int nid[DIM_FINGER], nx[DIM_FINGER], ny[DIM_FINGER], i;
- foreach_bit(i, priv->used) {
- sid[sn] = priv->data[i].abs[BIT_TRACKING_ID];
- sx[sn] = priv->data[i].abs[BIT_POSITION_X];
- sy[sn] = priv->data[i].abs[BIT_POSITION_Y];
- sn++;
- }
- for (i = 0; i < size; i++) {
- nx[i] = data[i].abs[BIT_POSITION_X];
- ny[i] = data[i].abs[BIT_POSITION_Y];
- }
- solve(priv, caps, sid, sx, sy, sn, nid, nx, ny, size, touch);
- for (i = 0; i < size; i++) {
- data[i].abs[BIT_TRACKING_ID] =
- GETBIT(touch, i) ? nid[i] : caps->nullid;
- prop[i] |= BITMASK(BIT_TRACKING_ID);
- }
-}
-
-/*
- * process_typeA - consume MT events and update parsing state
- * @dev: MT device
- * @data: array of all present contacts, to be filled
- * @prop: array of all set contacts properties, to be filled
- *
- * This function is called when a SYN_REPORT is seen, right before
- * that event is pushed to the queue.
- *
- * Returns -1 if the packet is not MT related and should not affect
- * the current parsing state.
- */
-static int process_typeA(struct MTDev *dev,
- struct MTSlot *data, bitmask_t *prop)
-{
- struct input_event ev;
- int consumed, mtcode;
- int mtcnt = 0, size = 0;
- prop[size] = 0;
- while (!evbuf_empty(&dev->inbuf)) {
- evbuf_get(&dev->inbuf, &ev);
- consumed = 0;
- switch (ev.type) {
- case EV_SYN:
- switch (ev.code) {
- case SYN_MT_REPORT:
- if (size < DIM_FINGER &&
- GETBIT(prop[size], BIT_POSITION_X) &&
- GETBIT(prop[size], BIT_POSITION_Y))
- size++;
- if (size < DIM_FINGER)
- prop[size] = 0;
- mtcnt++;
- consumed = 1;
- break;
- }
- break;
- case EV_KEY:
- switch (ev.code) {
- case BTN_TOUCH:
- mtcnt++;
- break;
- }
- break;
- case EV_ABS:
- if (size < DIM_FINGER && has_abs2mt(ev.code)) {
- mtcode = abs2mt(ev.code);
- data[size].abs[mtcode] = ev.value;
- prop[size] |= BITMASK(mtcode);
- mtcnt++;
- consumed = 1;
- }
- break;
- }
- if (!consumed)
- evbuf_put(&dev->outbuf, &ev);
- }
- return mtcnt ? size : -1;
-}
-
-/*
- * process_typeB - propagate events without parsing
- * @dev: MT device
- *
- * This function is called when a SYN_REPORT is seen, right before
- * that event is pushed to the queue.
- */
-static void process_typeB(struct MTDev *dev)
-{
- struct input_event ev;
- while (!evbuf_empty(&dev->inbuf)) {
- evbuf_get(&dev->inbuf, &ev);
- evbuf_put(&dev->outbuf, &ev);
- }
-}
-
-/*
- * filter_data - apply input filtering on new incoming data
- * @priv: parsing state
- * @caps: device capabilities
- * @data: the incoming data to filter
- * @prop: the properties to filter
- * @slot: the slot the data refers to
- */
-static void filter_data(const struct MTDevState *priv,
- const struct Capabilities *caps,
- struct MTSlot *data, bitmask_t prop,
- int slot)
-{
- int i;
- foreach_bit(i, prop) {
- int fuzz = caps->abs[i].fuzz;
- int oldval = priv->data[slot].abs[i];
- data->abs[i] = defuzz(data->abs[i], oldval, fuzz);
- }
-}
-
-/*
- * push_slot_changes - propagate state changes
- * @dev: MT device
- * @data: the incoming data to propagate
- * @prop: the properties to propagate
- * @slot: the slot the data refers to
- * @syn: reference to the SYN_REPORT event
- */
-static void push_slot_changes(struct MTDev *dev,
- const struct MTSlot *data, bitmask_t prop,
- int slot, const struct input_event *syn)
-{
- struct MTDevState *priv = dev->priv;
- struct input_event ev;
- int i, count = 0;
- foreach_bit(i, prop)
- if (priv->data[slot].abs[i] != data->abs[i])
- count++;
- if (!count)
- return;
- ev.time = syn->time;
- ev.type = EV_ABS;
- ev.code = ABS_MT_SLOT;
- ev.value = slot;
- if (priv->slot != ev.value) {
- evbuf_put(&dev->outbuf, &ev);
- priv->slot = ev.value;
- }
- foreach_bit(i, prop) {
- ev.code = mt2abs(i);
- ev.value = data->abs[i];
- if (priv->data[slot].abs[i] != ev.value) {
- evbuf_put(&dev->outbuf, &ev);
- priv->data[slot].abs[i] = ev.value;
- }
- }
-}
-
-/*
- * apply_typeA_changes - parse and propagate state changes
- * @dev: MT device
- * @caps: device capabilities
- * @data: array of data to apply
- * @prop: array of properties to apply
- * @size: number of contacts in array
- * @syn: reference to the SYN_REPORT event
- */
-static void apply_typeA_changes(struct MTDev *dev,
- const struct Capabilities *caps,
- struct MTSlot *data, const bitmask_t *prop,
- int size, const struct input_event *syn)
-{
- struct MTDevState *priv = dev->priv;
- bitmask_t unused = ~priv->used;
- bitmask_t used = 0;
- int i, slot, id;
- for (i = 0; i < size; i++) {
- id = data[i].abs[BIT_TRACKING_ID];
- foreach_bit(slot, priv->used) {
- if (priv->data[slot].abs[BIT_TRACKING_ID] != id)
- continue;
- filter_data(priv, caps, &data[i], prop[i], slot);
- push_slot_changes(dev, &data[i], prop[i], slot, syn);
- SETBIT(used, slot);
- id = caps->nullid;
- break;
- }
- if (id != caps->nullid) {
- slot = firstbit(unused);
- push_slot_changes(dev, &data[i], prop[i], slot, syn);
- SETBIT(used, slot);
- CLEARBIT(unused, slot);
- }
- }
-
- /* clear unused slots and update slot usage */
- foreach_bit(slot, priv->used & ~used) {
- struct MTSlot tdata = priv->data[slot];
- bitmask_t tprop = BITMASK(BIT_TRACKING_ID);
- tdata.abs[BIT_TRACKING_ID] = caps->nullid;
- push_slot_changes(dev, &tdata, tprop, slot, syn);
- }
- priv->used = used;
-}
-
-/*
- * convert_A_to_B - propagate a type A packet as a type B packet
- * @dev: MT device
- * @caps: device capabilities
- * @syn: reference to the SYN_REPORT event
- */
-static void convert_A_to_B(struct MTDev *dev,
- const struct Capabilities *caps,
- const struct input_event *syn)
-{
- struct MTSlot data[DIM_FINGER];
- bitmask_t prop[DIM_FINGER];
- int size = process_typeA(dev, data, prop);
- if (size < 0)
- return;
- if (!caps->has_abs[BIT_TRACKING_ID]) {
- bitmask_t touch = 0;
- int i;
- for (i = 0; i < size; i++)
- MODBIT(touch, i, istouch(&data[i], caps));
- assign_tracking_id(dev->priv, caps, data, prop, size, touch);
- }
- apply_typeA_changes(dev, caps, data, prop, size, syn);
-}
-
-/**
- * mtdev_put - insert event into MT device
- * @dev: MT device
- * @caps: device capabilities
- * @syn: reference to the SYN_REPORT event
- */
-void mtdev_put(struct MTDev *dev,
- const struct Capabilities *caps,
- const struct input_event *ev)
-{
- if (ev->type == EV_SYN && ev->code == SYN_REPORT) {
- bitmask_t head = dev->outbuf.head;
- if (dev->priv)
- convert_A_to_B(dev, caps, ev);
- else
- process_typeB(dev);
- if (dev->outbuf.head != head)
- evbuf_put(&dev->outbuf, ev);
- } else {
- evbuf_put(&dev->inbuf, ev);
- }
-}
-
-/**
- * mtdev_destroy - destroy MT device
- * @dev: MT device
- */
-void mtdev_destroy(struct MTDev *dev)
-{
- free(dev->priv);
- memset(dev, 0, sizeof(struct MTDev));
-}
diff --git a/mtdev/iobuf.c b/mtdev/iobuf.c
deleted file mode 100644
index 65c33f6..0000000
--- a/mtdev/iobuf.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/***************************************************************************
- *
- * Multitouch X driver
- * Copyright (C) 2008 Henrik Rydberg <rydberg@euromail.se>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- **************************************************************************/
-
-#include <mtdev-iobuf.h>
-#include <sys/poll.h>
-
-void init_iobuf(struct IOBuffer *buf)
-{
- memset(buf, 0, sizeof(struct IOBuffer));
- buf->at = buf->begin;
- buf->top = buf->at;
- buf->end = buf->begin + DIM_BUFFER;
-}
-
-const struct input_event *get_iobuf_event(struct IOBuffer *buf, int fd)
-{
- const struct input_event *ev;
- int n = buf->top - buf->at;
- if (n < EVENT_SIZE) {
- /* partial event is available: save it */
- if (buf->at != buf->begin && n > 0)
- memmove(buf->begin, buf->at, n);
- /* start from the beginning */
- buf->at = buf->begin;
- buf->top = buf->at + n;
- /* read more data */
- SYSCALL(n = read(fd, buf->top, buf->end - buf->top));
- if (n <= 0)
- return NULL;
- buf->top += n;
- }
- if (buf->top - buf->at < EVENT_SIZE)
- return NULL;
- ev = (const struct input_event *)buf->at;
- buf->at += EVENT_SIZE;
- return ev;
-}
-
-int poll_iobuf(struct IOBuffer *buf, int fd, int ms)
-{
- struct pollfd fds = { fd, POLLIN, 0 };
- if (buf->top != buf->at)
- return 1;
- return poll(&fds, 1, ms);
-}
diff --git a/mtdev/mapgen.c b/mtdev/mapgen.c
deleted file mode 100644
index efb3524..0000000
--- a/mtdev/mapgen.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/***************************************************************************
- *
- * Multitouch X driver
- * Copyright (C) 2008 Henrik Rydberg <rydberg@euromail.se>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- **************************************************************************/
-
-#include <common.h>
-#include <fcntl.h>
-#include <xbypass.h>
-
-#define BIT_DEF(name) \
- printf("#define BIT_"#name" %d\n", \
- cabs2mt[ABS_MT_##name] - 1)
-
-static unsigned int cabs2mt[ABS_CNT];
-static unsigned int cmt2abs[MT_ABS_SIZE];
-
-void init_caps()
-{
- static const int init_abs_map[MT_ABS_SIZE] = MT_SLOT_ABS_EVENTS;
- int i;
- for (i = 0; i < MT_ABS_SIZE; i++) {
- cabs2mt[init_abs_map[i]] = i + 1;
- cmt2abs[i] = init_abs_map[i];
- }
-}
-
-static inline const char *newln(int i, int n)
-{
- return i == n - 1 || i % 8 == 7 ? "\n" : "";
-}
-
-int main(int argc, char *argv[])
-{
- int i;
- init_caps();
- printf("static const unsigned int map_abs2mt[ABS_CNT] = {\n");
- for (i = 0; i < ABS_CNT; i++)
- printf(" 0x%04x,%s", cabs2mt[i], newln(i, ABS_CNT));
- printf("};\n\n");
- printf("static const unsigned int map_mt2abs[MT_ABS_SIZE] = {\n");
- for (i = 0; i < MT_ABS_SIZE; i++)
- printf(" 0x%04x,%s", cmt2abs[i], newln(i, MT_ABS_SIZE));
- printf("};\n\n");
- BIT_DEF(TRACKING_ID);
- BIT_DEF(POSITION_X);
- BIT_DEF(POSITION_Y);
- BIT_DEF(TOUCH_MAJOR);
- BIT_DEF(TOUCH_MINOR);
- BIT_DEF(WIDTH_MAJOR);
- BIT_DEF(WIDTH_MINOR);
- printf("\n");
- return 0;
-}
diff --git a/mtdev/test.c b/mtdev/test.c
deleted file mode 100644
index 9f73fcd..0000000
--- a/mtdev/test.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/***************************************************************************
- *
- * Multitouch X driver
- * Copyright (C) 2008 Henrik Rydberg <rydberg@euromail.se>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- **************************************************************************/
-
-#include "mtdev-iobuf.h"
-#include "mtdev.h"
-#include <fcntl.h>
-#include <xbypass.h>
-
-static void print_event(const struct input_event *ev)
-{
- static const mstime_t ms = 1000;
- static int slot;
- mstime_t evtime = ev->time.tv_usec / ms + ev->time.tv_sec * ms;
- if (ev->type == EV_ABS && ev->code == ABS_MT_SLOT)
- slot = ev->value;
- fprintf(stderr, "%012llx: %04d: %04x %04x %d\n",
- evtime, slot, ev->type, ev->code, ev->value);
-}
-
-static void loop_device(int fd)
-{
- struct Capabilities caps;
- struct IOBuffer iobuf;
- struct MTDev mtdev;
- const struct input_event *ev;
- struct input_event event;
- if (read_capabilities(&caps, fd)) {
- fprintf(stderr, "error: could not read device capabilities\n");
- return;
- }
- output_capabilities(&caps);
- if (mtdev_init(&mtdev, &caps)) {
- fprintf(stderr, "error: could not initialize device\n");
- return;
- }
- init_iobuf(&iobuf);
- while (ev = get_iobuf_event(&iobuf, fd)) {
- mtdev_put(&mtdev, &caps, ev);
- while (!mtdev_empty(&mtdev)) {
- mtdev_get(&mtdev, &event);
- print_event(&event);
- }
- }
- mtdev_destroy(&mtdev);
-}
-
-int main(int argc, char *argv[])
-{
- if (argc < 2) {
- fprintf(stderr, "Usage: test <mtdev>\n");
- return -1;
- }
- int fd = open(argv[1], O_RDONLY);
- if (fd < 0) {
- fprintf(stderr, "error: could not open file\n");
- return -1;
- }
- loop_device(fd);
- close(fd);
- return 0;
-}