aboutsummaryrefslogtreecommitdiffstats
path: root/include/common.h
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@euromail.se>2010-06-16 02:27:32 +0200
committerHenrik Rydberg <rydberg@euromail.se>2010-06-16 02:27:32 +0200
commitff88de5cd38b5b51bad0e63d373d66745f1f8d31 (patch)
tree3fbf4adc8c807bc79a8272c4df1623c3677a9b2f /include/common.h
parentad6faf6c53bc1924986e1cc10bb42e5d157cba8f (diff)
downloadxorg-input-kobomultitouch-ff88de5cd38b5b51bad0e63d373d66745f1f8d31.tar.gz
xorg-input-kobomultitouch-ff88de5cd38b5b51bad0e63d373d66745f1f8d31.tar.bz2
xorg-input-kobomultitouch-ff88de5cd38b5b51bad0e63d373d66745f1f8d31.zip
refactor: Move files
Move all headers into include, separate source files into modules match, mtdev, src and driver, move some common definitions to common.h, and include define support for the MT slot protocol. This patch does not introduce any logical changes. Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'include/common.h')
-rw-r--r--include/common.h128
1 files changed, 128 insertions, 0 deletions
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