aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/button.h43
-rw-r--r--include/common.h128
-rw-r--r--include/gestures.h43
-rw-r--r--include/hwdata.h75
-rw-r--r--include/hwstate.h47
-rw-r--r--include/match.h36
-rw-r--r--include/memory.h73
-rw-r--r--include/mtdev-caps.h57
-rw-r--r--include/mtdev-iobuf.h37
-rw-r--r--include/mtouch.h58
-rw-r--r--include/mtstate.h62
-rw-r--r--include/xbypass.h13
12 files changed, 672 insertions, 0 deletions
diff --git a/include/button.h b/include/button.h
new file mode 100644
index 0000000..0ebfbc7
--- /dev/null
+++ b/include/button.h
@@ -0,0 +1,43 @@
+/***************************************************************************
+ *
+ * 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
+ *
+ **************************************************************************/
+
+#ifndef BUTTON_H
+#define BUTTON_H
+
+#define DIM_BUTTON 15
+
+#define MT_BUTTON_LEFT 0
+#define MT_BUTTON_MIDDLE 1
+#define MT_BUTTON_RIGHT 2
+#define MT_BUTTON_WHEEL_UP 3
+#define MT_BUTTON_WHEEL_DOWN 4
+#define MT_BUTTON_HWHEEL_LEFT 5
+#define MT_BUTTON_HWHEEL_RIGHT 6
+#define MT_BUTTON_SWIPE_UP 7
+#define MT_BUTTON_SWIPE_DOWN 8
+#define MT_BUTTON_SWIPE_LEFT 9
+#define MT_BUTTON_SWIPE_RIGHT 10
+#define MT_BUTTON_SCALE_DOWN 11
+#define MT_BUTTON_SCALE_UP 12
+#define MT_BUTTON_ROTATE_LEFT 13
+#define MT_BUTTON_ROTATE_RIGHT 14
+
+#endif
diff --git a/include/common.h b/include/common.h
new file mode 100644
index 0000000..09582ce
--- /dev/null
+++ b/include/common.h
@@ -0,0 +1,128 @@
+/***************************************************************************
+ *
+ * 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
+ *
+ **************************************************************************/
+
+#ifndef COMMON_H
+#define COMMON_H
+
+#include "xorg-server.h"
+#include <xf86.h>
+#include <xf86_OSproc.h>
+#include <xf86Xinput.h>
+#include <linux/input.h>
+#include <errno.h>
+
+/* includes available in 2.6.30-rc5 */
+
+#ifndef BTN_TOOL_QUADTAP
+#define BTN_TOOL_QUADTAP 0x14f /* Four fingers on trackpad */
+#define ABS_MT_TOUCH_MAJOR 0x30 /* Major axis of touching ellipse */
+#define ABS_MT_TOUCH_MINOR 0x31 /* Minor axis (omit if circular) */
+#define ABS_MT_WIDTH_MAJOR 0x32 /* Major axis of approaching ellipse */
+#define ABS_MT_WIDTH_MINOR 0x33 /* Minor axis (omit if circular) */
+#define ABS_MT_ORIENTATION 0x34 /* Ellipse orientation */
+#define ABS_MT_POSITION_X 0x35 /* Center X ellipse position */
+#define ABS_MT_POSITION_Y 0x36 /* Center Y ellipse position */
+#define ABS_MT_TOOL_TYPE 0x37 /* Type of touching device */
+#define ABS_MT_BLOB_ID 0x38 /* Group a set of packets as a blob */
+#define ABS_MT_TRACKING_ID 0x39 /* Unique ID of initiated contact */
+#define SYN_MT_REPORT 2
+#define MT_TOOL_FINGER 0
+#define MT_TOOL_PEN 1
+#endif
+
+/* includes available in 2.6.33 */
+#ifndef ABS_MT_PRESSURE
+#define ABS_MT_PRESSURE 0x3a /* Pressure on contact area */
+#endif
+
+/* includes available in 2.6.36 */
+#ifndef ABS_MT_SLOT
+#define ABS_MT_SLOT 0x2f /* MT slot being modified */
+#define MT_ABS_SIZE 11 /* Size of MT_SLOT_ABS_EVENTS */
+#define MT_SLOT_ABS_EVENTS { \
+ ABS_MT_TOUCH_MAJOR, \
+ ABS_MT_TOUCH_MINOR, \
+ ABS_MT_WIDTH_MAJOR, \
+ ABS_MT_WIDTH_MINOR, \
+ ABS_MT_ORIENTATION, \
+ ABS_MT_POSITION_X, \
+ ABS_MT_POSITION_Y, \
+ ABS_MT_TOOL_TYPE, \
+ ABS_MT_BLOB_ID, \
+ ABS_MT_TRACKING_ID, \
+ ABS_MT_PRESSURE, \
+}
+#endif
+
+#define DIM_FINGER 32
+#define DIM2_FINGER (DIM_FINGER * DIM_FINGER)
+
+/* event buffer size (must be a power of two) */
+#define DIM_EVENTS 64
+
+/* year-proof millisecond event time */
+typedef __u64 mstime_t;
+
+/* all bit masks have this type */
+typedef unsigned int bitmask_t;
+
+#define BITMASK(x) (1U << (x))
+#define BITONES(x) (BITMASK(x) - 1U)
+#define GETBIT(m, x) (((m) >> (x)) & 1U)
+#define SETBIT(m, x) (m |= BITMASK(x))
+#define CLEARBIT(m, x) (m &= ~BITMASK(x))
+#define MODBIT(m, x, b) ((b) ? SETBIT(m, x) : CLEARBIT(m, x))
+
+static inline int maxval(int x, int y) { return x > y ? x : y; }
+static inline int minval(int x, int y) { return x < y ? x : y; }
+
+static inline int clamp15(int x)
+{
+ return x < -32767 ? -32767 : x > 32767 ? 32767 : x;
+}
+
+/* absolute scale is assumed to fit in 15 bits */
+static inline int dist2(int dx, int dy)
+{
+ dx = clamp15(dx);
+ dy = clamp15(dy);
+ return dx * dx + dy * dy;
+}
+
+/* Count number of bits (Sean Eron Andersson's Bit Hacks) */
+static inline int bitcount(unsigned v)
+{
+ v -= ((v>>1) & 0x55555555);
+ v = (v&0x33333333) + ((v>>2) & 0x33333333);
+ return (((v + (v>>4)) & 0xF0F0F0F) * 0x1010101) >> 24;
+}
+
+/* Return index of first bit [0-31], -1 on zero */
+#define firstbit(v) (__builtin_ffs(v) - 1)
+
+/* boost-style foreach bit */
+#define foreach_bit(i, m) \
+ for (i = firstbit(m); i >= 0; i = firstbit((m) & (~0U << i + 1)))
+
+/* robust system ioctl calls */
+#define SYSCALL(call) while (((call) == -1) && (errno == EINTR))
+
+#endif
diff --git a/include/gestures.h b/include/gestures.h
new file mode 100644
index 0000000..2866ba4
--- /dev/null
+++ b/include/gestures.h
@@ -0,0 +1,43 @@
+/***************************************************************************
+ *
+ * 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
+ *
+ **************************************************************************/
+
+#ifndef GESTURES_H
+#define GESTURES_H
+
+#include "mtouch.h"
+
+#define GS_BUTTON 0
+#define GS_MOVE 1
+#define GS_VSCROLL 2
+#define GS_HSCROLL 3
+#define GS_VSWIPE 4
+#define GS_HSWIPE 5
+#define GS_SCALE 6
+#define GS_ROTATE 7
+
+struct Gestures {
+ unsigned type, btmask, btdata;
+ int same_fingers, dx, dy, scale, rot;
+};
+
+void extract_gestures(struct Gestures *gs, struct MTouch* mt);
+
+#endif
diff --git a/include/hwdata.h b/include/hwdata.h
new file mode 100644
index 0000000..21864dc
--- /dev/null
+++ b/include/hwdata.h
@@ -0,0 +1,75 @@
+/***************************************************************************
+ *
+ * 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
+ *
+ **************************************************************************/
+
+#ifndef HWDATA_H
+#define HWDATA_H
+
+#include "common.h"
+#include "button.h"
+
+#define BIT_MT_TOUCH_MAJOR 0
+#define BIT_MT_TOUCH_MINOR 1
+#define BIT_MT_WIDTH_MAJOR 2
+#define BIT_MT_WIDTH_MINOR 3
+#define BIT_MT_ORIENTATION 4
+#define BIT_MT_PRESSURE 5
+#define BIT_MT_POSITION_X 6
+#define BIT_MT_POSITION_Y 7
+#define BIT_MT_CNT 8
+
+struct FingerData {
+ int touch_major, touch_minor;
+ int width_major, width_minor;
+ int orientation, pressure;
+ int position_x, position_y;
+};
+
+/**
+ * struct HWData - hardware reads
+ *
+ * @finger: finger data
+ * @mask: bits corresponding to data actually read (readonly)
+ * @mread: bits corresponding to data in progress (writeonly)
+ * @button: bitmask of buttons
+ * @nfinger: number of fingers actually read (readonly)
+ * @nread: number of fingers in progress (writeonly)
+ *
+ */
+struct HWData {
+ struct FingerData finger[DIM_FINGER];
+ unsigned mask[DIM_FINGER], mread[DIM_FINGER];
+ unsigned button;
+ int nfinger, mtread, nread;
+ mstime_t evtime;
+};
+
+void init_hwdata(struct HWData *hw);
+int read_hwdata(struct HWData *hw, const struct input_event* ev);
+void output_hwdata(const struct HWData *hw);
+
+static inline int finger_dist2(const struct FingerData *a,
+ const struct FingerData *b)
+{
+ return dist2(a->position_x - b->position_x,
+ a->position_y - b->position_y);
+}
+
+#endif
diff --git a/include/hwstate.h b/include/hwstate.h
new file mode 100644
index 0000000..76ed016
--- /dev/null
+++ b/include/hwstate.h
@@ -0,0 +1,47 @@
+/***************************************************************************
+ *
+ * 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
+ *
+ **************************************************************************/
+
+#ifndef HWSTATE_H
+#define HWSTATE_H
+
+#include "mtdev-caps.h"
+#include "hwdata.h"
+
+/* zero id means not mapped (not touching) */
+struct FingerState {
+ struct FingerData hw;
+ int id;
+};
+
+struct HWState {
+ struct FingerState finger[DIM_FINGER];
+ unsigned button;
+ int nfinger;
+ mstime_t evtime;
+ int lastid;
+};
+
+void init_hwstate(struct HWState *s);
+void modify_hwstate(struct HWState *s,
+ const struct HWData *hw,
+ const struct Capabilities *caps);
+
+#endif
diff --git a/include/match.h b/include/match.h
new file mode 100644
index 0000000..25842fc
--- /dev/null
+++ b/include/match.h
@@ -0,0 +1,36 @@
+/***************************************************************************
+ *
+ * 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
+ *
+ **************************************************************************/
+
+#ifndef MATCHER_H
+#define MATCHER_H
+
+/**
+ * Special implementation of the hungarian algorithm.
+ * The maximum number of fingers matches a uint32.
+ * Bitmasks are used extensively.
+ */
+
+#include "common.h"
+
+void match_fingers(int index[DIM_FINGER], int A[DIM2_FINGER],
+ int nrow, int ncol);
+
+#endif
diff --git a/include/memory.h b/include/memory.h
new file mode 100644
index 0000000..8ffbdab
--- /dev/null
+++ b/include/memory.h
@@ -0,0 +1,73 @@
+/***************************************************************************
+ *
+ * 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
+ *
+ **************************************************************************/
+
+#ifndef MEMORY_H
+#define MEMORY_H
+
+#include "mtstate.h"
+
+/**
+ * struct Memory - parsing state
+ *
+ * @btdata: logical finger state
+ * @same: true if the finger configuration is unchanged
+ * @fingers: bitmask of fingers on the pad
+ * @added: bitmask of new fingers on the pad
+ * @thumb: bitmask of thumbs on the pad
+ * @pointing: bitmask of pointing fingers
+ * @pending: bitmask of tentatively moving fingers
+ * @moving: bitmask of moving fingers
+ * @ybar: vertical position on pad marking the clicking area
+ * @mvhold: movement before this point in time is accumulated
+ * @mvforget: movement before this point in time is discarded
+ * @dx: array of accumulated horiontal movement per finger
+ * @dy: array of accumulated vertical movement per finger
+ *
+ */
+struct Memory {
+ unsigned btdata, same;
+ unsigned fingers, added, thumb;
+ unsigned pointing, pending, moving;
+ int ybar;
+ mstime_t mvhold, mvforget;
+ int dx[DIM_FINGER], dy[DIM_FINGER];
+};
+
+void init_memory(struct Memory *mem);
+void refresh_memory(struct Memory *m,
+ const struct MTState *prev_state,
+ const struct MTState *state,
+ const struct Capabilities *caps);
+void output_memory(const struct Memory *m);
+
+static inline void mem_hold_movement(struct Memory *m, mstime_t t)
+{
+ if (t > m->mvhold)
+ m->mvhold = t;
+}
+
+static inline void mem_forget_movement(struct Memory *m, mstime_t t)
+{
+ if (t > m->mvforget)
+ m->mvforget = t;
+}
+
+#endif
diff --git a/include/mtdev-caps.h b/include/mtdev-caps.h
new file mode 100644
index 0000000..8f88404
--- /dev/null
+++ b/include/mtdev-caps.h
@@ -0,0 +1,57 @@
+/***************************************************************************
+ *
+ * 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
+ *
+ **************************************************************************/
+
+#ifndef MTDEV_CAPS_H
+#define MTDEV_CAPS_H
+
+#include "common.h"
+
+struct Capabilities {
+ struct input_id devid;
+ char devname[32];
+ int has_left, has_middle;
+ int has_right, has_mtdata, has_ibt;
+ int has_touch_major, has_touch_minor;
+ int has_width_major, has_width_minor;
+ int has_orientation, has_dummy;
+ int has_position_x, has_position_y;
+ struct input_absinfo abs_touch_major;
+ struct input_absinfo abs_touch_minor;
+ struct input_absinfo abs_width_major;
+ struct input_absinfo abs_width_minor;
+ struct input_absinfo abs_orientation;
+ struct input_absinfo abs_position_x;
+ struct input_absinfo abs_position_y;
+ int xfuzz, yfuzz, wfuzz;
+ int yclick;
+};
+
+int read_capabilities(struct Capabilities *cap, int fd);
+int get_cap_xsize(const struct Capabilities *cap);
+int get_cap_ysize(const struct Capabilities *cap);
+int get_cap_wsize(const struct Capabilities *cap);
+
+int get_cap_xmid(const struct Capabilities *cap);
+int get_cap_ymid(const struct Capabilities *cap);
+
+void output_capabilities(const struct Capabilities *cap);
+
+#endif
diff --git a/include/mtdev-iobuf.h b/include/mtdev-iobuf.h
new file mode 100644
index 0000000..976b85b
--- /dev/null
+++ b/include/mtdev-iobuf.h
@@ -0,0 +1,37 @@
+/***************************************************************************
+ *
+ * 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
+ *
+ **************************************************************************/
+
+#ifndef MTDEV_IOBUF_H
+#define MTDEV_IOBUF_H
+
+#include "common.h"
+
+#define EVENT_SIZE sizeof(struct input_event)
+#define DIM_BUFFER (DIM_EVENTS * EVENT_SIZE)
+
+struct IOBuffer {
+ char begin[DIM_BUFFER], *at, *top, *end;
+};
+
+void init_iobuf(struct IOBuffer *buf);
+const struct input_event *get_iobuf_event(struct IOBuffer *buf, int fd);
+
+#endif
diff --git a/include/mtouch.h b/include/mtouch.h
new file mode 100644
index 0000000..a495960
--- /dev/null
+++ b/include/mtouch.h
@@ -0,0 +1,58 @@
+/***************************************************************************
+ *
+ * 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
+ *
+ **************************************************************************/
+
+#ifndef MTOUCH_H
+#define MTOUCH_H
+
+#include "mtdev-iobuf.h"
+#include "hwdata.h"
+#include "hwstate.h"
+#include "mtstate.h"
+#include "memory.h"
+
+struct MTouch {
+ struct Capabilities caps;
+ struct IOBuffer buf;
+ struct HWData hw;
+ struct HWState hs;
+ struct MTState prev_state, state;
+ struct Memory mem;
+};
+
+int configure_mtouch(struct MTouch *mt, int fd);
+int open_mtouch(struct MTouch *mt, int fd);
+int close_mtouch(struct MTouch *mt, int fd);
+
+int read_synchronized_event(struct MTouch *mt, int fd);
+void parse_event(struct MTouch *mt);
+
+
+static inline void mt_delay_movement(struct MTouch *mt, int t)
+{
+ mem_hold_movement(&mt->mem, mt->state.evtime + t);
+}
+
+static inline void mt_skip_movement(struct MTouch *mt, int t)
+{
+ mem_forget_movement(&mt->mem, mt->state.evtime + t);
+}
+
+#endif
diff --git a/include/mtstate.h b/include/mtstate.h
new file mode 100644
index 0000000..ac0b18d
--- /dev/null
+++ b/include/mtstate.h
@@ -0,0 +1,62 @@
+/***************************************************************************
+ *
+ * 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
+ *
+ **************************************************************************/
+
+#ifndef MTSTATE_H
+#define MTSTATE_H
+
+#include "hwstate.h"
+
+struct MTFinger {
+ struct FingerData hw;
+ int id, thumb;
+};
+
+struct MTState {
+ struct MTFinger finger[DIM_FINGER];
+ int nfinger;
+ unsigned button;
+ mstime_t evtime;
+};
+
+void init_mtstate(struct MTState *s);
+void extract_mtstate(struct MTState *s,
+ const struct HWState *hs,
+ const struct Capabilities *caps);
+void output_mtstate(const struct MTState *s);
+
+const struct MTFinger *find_finger(const struct MTState *s, int id);
+
+
+static inline int center_dist2(const struct MTFinger *a,
+ const struct Capabilities *caps)
+{
+ return dist2(a->hw.position_x - get_cap_xmid(caps),
+ a->hw.position_y - get_cap_ymid(caps));
+}
+
+static inline int center_maxdist2(const struct Capabilities *caps)
+{
+ return dist2(caps->abs_position_x.maximum - get_cap_xmid(caps),
+ caps->abs_position_y.maximum - get_cap_ymid(caps));
+}
+
+#endif
+
diff --git a/include/xbypass.h b/include/xbypass.h
new file mode 100644
index 0000000..35c65e1
--- /dev/null
+++ b/include/xbypass.h
@@ -0,0 +1,13 @@
+#ifndef XBYPASS_H
+#define XBYPASS_H
+
+#include <stdarg.h>
+void xf86Msg(int type, const char *format, ...)
+{
+ va_list args;
+ va_start(args, format);
+ vfprintf(stderr, format, args);
+ va_end(args);
+}
+
+#endif