summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/abs2mt.h39
-rw-r--r--include/capabilities.h (renamed from include/mtdev-caps.h)8
-rw-r--r--include/common.h49
-rw-r--r--include/hwstate.h6
-rw-r--r--include/match.h36
-rw-r--r--include/mtbit.h14
-rw-r--r--include/mtdev-evbuf.h57
-rw-r--r--include/mtdev-iobuf.h38
-rw-r--r--include/mtdev.h57
-rw-r--r--include/mtouch.h7
10 files changed, 9 insertions, 302 deletions
diff --git a/include/abs2mt.h b/include/abs2mt.h
deleted file mode 100644
index 6021d8d..0000000
--- a/include/abs2mt.h
+++ /dev/null
@@ -1,39 +0,0 @@
1/* generated by mapgen - do not edit */
2
3#ifndef ABS2MT_H
4#define ABS2MT_H
5
6#include "common.h"
7
8static const unsigned int map_abs2mt[ABS_CNT] = {
9 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
10 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
11 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
12 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
13 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
14 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
15 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008,
16 0x0009, 0x000a, 0x000b, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
17};
18
19static const unsigned int map_mt2abs[MT_ABS_SIZE] = {
20 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
21 0x0038, 0x0039, 0x003a,
22};
23
24static inline int has_abs2mt(unsigned int code)
25{
26 return map_abs2mt[code];
27}
28
29static inline unsigned int abs2mt(unsigned int code)
30{
31 return map_abs2mt[code] - 1;
32}
33
34static inline unsigned int mt2abs(unsigned int mtcode)
35{
36 return map_mt2abs[mtcode];
37}
38
39#endif
diff --git a/include/mtdev-caps.h b/include/capabilities.h
index 727cd11..0dfc73b 100644
--- a/include/mtdev-caps.h
+++ b/include/capabilities.h
@@ -19,20 +19,18 @@
19 * 19 *
20 **************************************************************************/ 20 **************************************************************************/
21 21
22#ifndef MTDEV_CAPS_H 22#ifndef CAPABILITIES_H
23#define MTDEV_CAPS_H 23#define CAPABILITIES_H
24 24
25#include "common.h" 25#include "common.h"
26#include "button.h" 26#include "button.h"
27#include "abs2mt.h"
28#include "mtbit.h"
29 27
30struct Capabilities { 28struct Capabilities {
31 struct input_id devid; 29 struct input_id devid;
32 char devname[32]; 30 char devname[32];
33 int has_left, has_middle, has_right; 31 int has_left, has_middle, has_right;
34 int has_mtdata, has_ibt; 32 int has_mtdata, has_ibt;
35 int has_slot, nullid; 33 int has_slot;
36 int has_abs[MT_ABS_SIZE]; 34 int has_abs[MT_ABS_SIZE];
37 struct input_absinfo slot; 35 struct input_absinfo slot;
38 struct input_absinfo abs[MT_ABS_SIZE]; 36 struct input_absinfo abs[MT_ABS_SIZE];
diff --git a/include/common.h b/include/common.h
index e13088f..6d00d6e 100644
--- a/include/common.h
+++ b/include/common.h
@@ -26,59 +26,12 @@
26#include <xf86.h> 26#include <xf86.h>
27#include <xf86_OSproc.h> 27#include <xf86_OSproc.h>
28#include <xf86Xinput.h> 28#include <xf86Xinput.h>
29#include <linux/input.h>
30#include <errno.h> 29#include <errno.h>
31 30#include <mtdev-mapping.h>
32/* includes available in 2.6.30-rc5 */
33
34#ifndef BTN_TOOL_QUADTAP
35#define BTN_TOOL_QUADTAP 0x14f /* Four fingers on trackpad */
36#define ABS_MT_TOUCH_MAJOR 0x30 /* Major axis of touching ellipse */
37#define ABS_MT_TOUCH_MINOR 0x31 /* Minor axis (omit if circular) */
38#define ABS_MT_WIDTH_MAJOR 0x32 /* Major axis of approaching ellipse */
39#define ABS_MT_WIDTH_MINOR 0x33 /* Minor axis (omit if circular) */
40#define ABS_MT_ORIENTATION 0x34 /* Ellipse orientation */
41#define ABS_MT_POSITION_X 0x35 /* Center X ellipse position */
42#define ABS_MT_POSITION_Y 0x36 /* Center Y ellipse position */
43#define ABS_MT_TOOL_TYPE 0x37 /* Type of touching device */
44#define ABS_MT_BLOB_ID 0x38 /* Group a set of packets as a blob */
45#define ABS_MT_TRACKING_ID 0x39 /* Unique ID of initiated contact */
46#define SYN_MT_REPORT 2
47#define MT_TOOL_FINGER 0
48#define MT_TOOL_PEN 1
49#endif
50
51/* includes available in 2.6.33 */
52#ifndef ABS_MT_PRESSURE
53#define ABS_MT_PRESSURE 0x3a /* Pressure on contact area */
54#endif
55
56/* includes available in 2.6.36 */
57#ifndef ABS_MT_SLOT
58#define ABS_MT_SLOT 0x2f /* MT slot being modified */
59#define MT_SLOT_ABS_EVENTS { \
60 ABS_MT_TOUCH_MAJOR, \
61 ABS_MT_TOUCH_MINOR, \
62 ABS_MT_WIDTH_MAJOR, \
63 ABS_MT_WIDTH_MINOR, \
64 ABS_MT_ORIENTATION, \
65 ABS_MT_POSITION_X, \
66 ABS_MT_POSITION_Y, \
67 ABS_MT_TOOL_TYPE, \
68 ABS_MT_BLOB_ID, \
69 ABS_MT_TRACKING_ID, \
70 ABS_MT_PRESSURE, \
71}
72#endif
73
74#define MT_ABS_SIZE 11 /* Size of MT_SLOT_ABS_EVENTS */
75 31
76#define DIM_FINGER 32 32#define DIM_FINGER 32
77#define DIM2_FINGER (DIM_FINGER * DIM_FINGER) 33#define DIM2_FINGER (DIM_FINGER * DIM_FINGER)
78 34
79/* event buffer size (must be a power of two) */
80#define DIM_EVENTS 512
81
82/* year-proof millisecond event time */ 35/* year-proof millisecond event time */
83typedef __u64 mstime_t; 36typedef __u64 mstime_t;
84 37
diff --git a/include/hwstate.h b/include/hwstate.h
index efd291f..4c59a1e 100644
--- a/include/hwstate.h
+++ b/include/hwstate.h
@@ -22,7 +22,7 @@
22#ifndef HWSTATE_H 22#ifndef HWSTATE_H
23#define HWSTATE_H 23#define HWSTATE_H
24 24
25#include "mtdev.h" 25#include "capabilities.h"
26 26
27struct FingerState { 27struct FingerState {
28 int touch_major, touch_minor; 28 int touch_major, touch_minor;
@@ -42,8 +42,8 @@ struct HWState {
42 42
43void init_hwstate(struct HWState *s, 43void init_hwstate(struct HWState *s,
44 const struct Capabilities *caps); 44 const struct Capabilities *caps);
45int hwstate_read(struct HWState *s, const struct Capabilities *caps, 45int modify_hwstate(struct HWState *s, struct mtdev *dev, int fd,
46 const struct input_event *ev); 46 const struct Capabilities *caps);
47void output_hwstate(const struct HWState *s); 47void output_hwstate(const struct HWState *s);
48 48
49static inline int finger_dist2(const struct FingerState *a, 49static inline int finger_dist2(const struct FingerState *a,
diff --git a/include/match.h b/include/match.h
deleted file mode 100644
index 25842fc..0000000
--- a/include/match.h
+++ /dev/null
@@ -1,36 +0,0 @@
1/***************************************************************************
2 *
3 * Multitouch X driver
4 * Copyright (C) 2008 Henrik Rydberg <rydberg@euromail.se>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 **************************************************************************/
21
22#ifndef MATCHER_H
23#define MATCHER_H
24
25/**
26 * Special implementation of the hungarian algorithm.
27 * The maximum number of fingers matches a uint32.
28 * Bitmasks are used extensively.
29 */
30
31#include "common.h"
32
33void match_fingers(int index[DIM_FINGER], int A[DIM2_FINGER],
34 int nrow, int ncol);
35
36#endif
diff --git a/include/mtbit.h b/include/mtbit.h
deleted file mode 100644
index 2c4dacb..0000000
--- a/include/mtbit.h
+++ /dev/null
@@ -1,14 +0,0 @@
1/* generated by mapgen - do not edit */
2
3#ifndef MTBIT_H
4#define MTBIT_H
5
6#define BIT_TRACKING_ID 9
7#define BIT_POSITION_X 5
8#define BIT_POSITION_Y 6
9#define BIT_TOUCH_MAJOR 0
10#define BIT_TOUCH_MINOR 1
11#define BIT_WIDTH_MAJOR 2
12#define BIT_WIDTH_MINOR 3
13
14#endif
diff --git a/include/mtdev-evbuf.h b/include/mtdev-evbuf.h
deleted file mode 100644
index 77fec41..0000000
--- a/include/mtdev-evbuf.h
+++ /dev/null
@@ -1,57 +0,0 @@
1/***************************************************************************
2 *
3 * Multitouch X driver
4 * Copyright (C) 2008 Henrik Rydberg <rydberg@euromail.se>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 **************************************************************************/
21
22#ifndef MTDEV_EVBUF_H
23#define MTDEV_EVBUF_H
24
25#include "common.h"
26
27struct EventBuffer {
28 int head;
29 int tail;
30 struct input_event buffer[DIM_EVENTS];
31};
32
33static inline void evbuf_init(struct EventBuffer *evbuf)
34{
35 memset(evbuf, 0, sizeof(*evbuf));
36}
37
38static inline int evbuf_empty(const struct EventBuffer *evbuf)
39{
40 return evbuf->head == evbuf->tail;
41}
42
43static inline void evbuf_put(struct EventBuffer *evbuf,
44 const struct input_event *ev)
45{
46 evbuf->buffer[evbuf->head++] = *ev;
47 evbuf->head &= DIM_EVENTS - 1;
48}
49
50static inline void evbuf_get(struct EventBuffer *evbuf,
51 struct input_event *ev)
52{
53 *ev = evbuf->buffer[evbuf->tail++];
54 evbuf->tail &= DIM_EVENTS - 1;
55}
56
57#endif
diff --git a/include/mtdev-iobuf.h b/include/mtdev-iobuf.h
deleted file mode 100644
index 7d4265c..0000000
--- a/include/mtdev-iobuf.h
+++ /dev/null
@@ -1,38 +0,0 @@
1/***************************************************************************
2 *
3 * Multitouch X driver
4 * Copyright (C) 2008 Henrik Rydberg <rydberg@euromail.se>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 **************************************************************************/
21
22#ifndef MTDEV_IOBUF_H
23#define MTDEV_IOBUF_H
24
25#include "common.h"
26
27#define EVENT_SIZE sizeof(struct input_event)
28#define DIM_BUFFER (DIM_EVENTS * EVENT_SIZE)
29
30struct IOBuffer {
31 char begin[DIM_BUFFER], *at, *top, *end;
32};
33
34void init_iobuf(struct IOBuffer *buf);
35const struct input_event *get_iobuf_event(struct IOBuffer *buf, int fd);
36int poll_iobuf(struct IOBuffer *buf, int fd, int ms);
37
38#endif
diff --git a/include/mtdev.h b/include/mtdev.h
deleted file mode 100644
index 936d597..0000000
--- a/include/mtdev.h
+++ /dev/null
@@ -1,57 +0,0 @@
1/***************************************************************************
2 *
3 * Multitouch X driver
4 * Copyright (C) 2008 Henrik Rydberg <rydberg@euromail.se>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 **************************************************************************/
21
22#ifndef MTDEV_H
23#define MTDEV_H
24
25#include "mtdev-caps.h"
26#include "mtdev-evbuf.h"
27
28/**
29 * struct MTDev - represents an input MT device
30 * @inbuf: input event buffer
31 * @outbuf: output event buffer
32 * @priv: structure of private data
33 */
34struct MTDev {
35 struct EventBuffer inbuf;
36 struct EventBuffer outbuf;
37 struct MTDevState *priv;
38};
39
40int mtdev_init(struct MTDev *mtdev, const struct Capabilities *caps);
41
42static inline int mtdev_empty(struct MTDev *mtdev)
43{
44 return evbuf_empty(&mtdev->outbuf);
45}
46
47void mtdev_put(struct MTDev *dev, const struct Capabilities *caps,
48 const struct input_event *ev);
49
50static inline void mtdev_get(struct MTDev *mtdev, struct input_event* ev)
51{
52 evbuf_get(&mtdev->outbuf, ev);
53}
54
55void mtdev_destroy(struct MTDev *mtdev);
56
57#endif
diff --git a/include/mtouch.h b/include/mtouch.h
index 482d010..aedb02c 100644
--- a/include/mtouch.h
+++ b/include/mtouch.h
@@ -23,12 +23,10 @@
23#define MTOUCH_H 23#define MTOUCH_H
24 24
25#include "memory.h" 25#include "memory.h"
26#include "mtdev-iobuf.h"
27 26
28struct MTouch { 27struct MTouch {
29 struct Capabilities caps; 28 struct Capabilities caps;
30 struct MTDev dev; 29 struct mtdev dev;
31 struct IOBuffer buf;
32 struct HWState hs; 30 struct HWState hs;
33 struct MTState prev_state, state; 31 struct MTState prev_state, state;
34 struct Memory mem; 32 struct Memory mem;
@@ -36,10 +34,9 @@ struct MTouch {
36 34
37int configure_mtouch(struct MTouch *mt, int fd); 35int configure_mtouch(struct MTouch *mt, int fd);
38int open_mtouch(struct MTouch *mt, int fd); 36int open_mtouch(struct MTouch *mt, int fd);
39int get_mtouch(struct MTouch *mt, int fd, struct input_event* ev, int ev_max);
40int close_mtouch(struct MTouch *mt, int fd); 37int close_mtouch(struct MTouch *mt, int fd);
41 38
42int parse_event(struct MTouch *mt, const struct input_event *ev); 39int read_packet(struct MTouch *mt, int fd);
43 40
44int has_delayed_gestures(struct MTouch *mt, int fd); 41int has_delayed_gestures(struct MTouch *mt, int fd);
45 42