diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/button.h | 43 | ||||
| -rw-r--r-- | include/common.h | 128 | ||||
| -rw-r--r-- | include/gestures.h | 43 | ||||
| -rw-r--r-- | include/hwdata.h | 75 | ||||
| -rw-r--r-- | include/hwstate.h | 47 | ||||
| -rw-r--r-- | include/match.h | 36 | ||||
| -rw-r--r-- | include/memory.h | 73 | ||||
| -rw-r--r-- | include/mtdev-caps.h | 57 | ||||
| -rw-r--r-- | include/mtdev-iobuf.h | 37 | ||||
| -rw-r--r-- | include/mtouch.h | 58 | ||||
| -rw-r--r-- | include/mtstate.h | 62 | ||||
| -rw-r--r-- | include/xbypass.h | 13 |
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 @@ | |||
| 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 BUTTON_H | ||
| 23 | #define BUTTON_H | ||
| 24 | |||
| 25 | #define DIM_BUTTON 15 | ||
| 26 | |||
| 27 | #define MT_BUTTON_LEFT 0 | ||
| 28 | #define MT_BUTTON_MIDDLE 1 | ||
| 29 | #define MT_BUTTON_RIGHT 2 | ||
| 30 | #define MT_BUTTON_WHEEL_UP 3 | ||
| 31 | #define MT_BUTTON_WHEEL_DOWN 4 | ||
| 32 | #define MT_BUTTON_HWHEEL_LEFT 5 | ||
| 33 | #define MT_BUTTON_HWHEEL_RIGHT 6 | ||
| 34 | #define MT_BUTTON_SWIPE_UP 7 | ||
| 35 | #define MT_BUTTON_SWIPE_DOWN 8 | ||
| 36 | #define MT_BUTTON_SWIPE_LEFT 9 | ||
| 37 | #define MT_BUTTON_SWIPE_RIGHT 10 | ||
| 38 | #define MT_BUTTON_SCALE_DOWN 11 | ||
| 39 | #define MT_BUTTON_SCALE_UP 12 | ||
| 40 | #define MT_BUTTON_ROTATE_LEFT 13 | ||
| 41 | #define MT_BUTTON_ROTATE_RIGHT 14 | ||
| 42 | |||
| 43 | #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 @@ | |||
| 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 COMMON_H | ||
| 23 | #define COMMON_H | ||
| 24 | |||
| 25 | #include "xorg-server.h" | ||
| 26 | #include <xf86.h> | ||
| 27 | #include <xf86_OSproc.h> | ||
| 28 | #include <xf86Xinput.h> | ||
| 29 | #include <linux/input.h> | ||
| 30 | #include <errno.h> | ||
| 31 | |||
| 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_ABS_SIZE 11 /* Size of MT_SLOT_ABS_EVENTS */ | ||
| 60 | #define MT_SLOT_ABS_EVENTS { \ | ||
| 61 | ABS_MT_TOUCH_MAJOR, \ | ||
| 62 | ABS_MT_TOUCH_MINOR, \ | ||
| 63 | ABS_MT_WIDTH_MAJOR, \ | ||
| 64 | ABS_MT_WIDTH_MINOR, \ | ||
| 65 | ABS_MT_ORIENTATION, \ | ||
| 66 | ABS_MT_POSITION_X, \ | ||
| 67 | ABS_MT_POSITION_Y, \ | ||
| 68 | ABS_MT_TOOL_TYPE, \ | ||
| 69 | ABS_MT_BLOB_ID, \ | ||
| 70 | ABS_MT_TRACKING_ID, \ | ||
| 71 | ABS_MT_PRESSURE, \ | ||
| 72 | } | ||
| 73 | #endif | ||
| 74 | |||
| 75 | #define DIM_FINGER 32 | ||
| 76 | #define DIM2_FINGER (DIM_FINGER * DIM_FINGER) | ||
| 77 | |||
| 78 | /* event buffer size (must be a power of two) */ | ||
| 79 | #define DIM_EVENTS 64 | ||
| 80 | |||
| 81 | /* year-proof millisecond event time */ | ||
| 82 | typedef __u64 mstime_t; | ||
| 83 | |||
| 84 | /* all bit masks have this type */ | ||
| 85 | typedef unsigned int bitmask_t; | ||
| 86 | |||
| 87 | #define BITMASK(x) (1U << (x)) | ||
| 88 | #define BITONES(x) (BITMASK(x) - 1U) | ||
| 89 | #define GETBIT(m, x) (((m) >> (x)) & 1U) | ||
| 90 | #define SETBIT(m, x) (m |= BITMASK(x)) | ||
| 91 | #define CLEARBIT(m, x) (m &= ~BITMASK(x)) | ||
| 92 | #define MODBIT(m, x, b) ((b) ? SETBIT(m, x) : CLEARBIT(m, x)) | ||
| 93 | |||
| 94 | static inline int maxval(int x, int y) { return x > y ? x : y; } | ||
| 95 | static inline int minval(int x, int y) { return x < y ? x : y; } | ||
| 96 | |||
| 97 | static inline int clamp15(int x) | ||
| 98 | { | ||
| 99 | return x < -32767 ? -32767 : x > 32767 ? 32767 : x; | ||
| 100 | } | ||
| 101 | |||
| 102 | /* absolute scale is assumed to fit in 15 bits */ | ||
| 103 | static inline int dist2(int dx, int dy) | ||
| 104 | { | ||
| 105 | dx = clamp15(dx); | ||
| 106 | dy = clamp15(dy); | ||
| 107 | return dx * dx + dy * dy; | ||
| 108 | } | ||
| 109 | |||
| 110 | /* Count number of bits (Sean Eron Andersson's Bit Hacks) */ | ||
| 111 | static inline int bitcount(unsigned v) | ||
| 112 | { | ||
| 113 | v -= ((v>>1) & 0x55555555); | ||
| 114 | v = (v&0x33333333) + ((v>>2) & 0x33333333); | ||
| 115 | return (((v + (v>>4)) & 0xF0F0F0F) * 0x1010101) >> 24; | ||
| 116 | } | ||
| 117 | |||
| 118 | /* Return index of first bit [0-31], -1 on zero */ | ||
| 119 | #define firstbit(v) (__builtin_ffs(v) - 1) | ||
| 120 | |||
| 121 | /* boost-style foreach bit */ | ||
| 122 | #define foreach_bit(i, m) \ | ||
| 123 | for (i = firstbit(m); i >= 0; i = firstbit((m) & (~0U << i + 1))) | ||
| 124 | |||
| 125 | /* robust system ioctl calls */ | ||
| 126 | #define SYSCALL(call) while (((call) == -1) && (errno == EINTR)) | ||
| 127 | |||
| 128 | #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 @@ | |||
| 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 GESTURES_H | ||
| 23 | #define GESTURES_H | ||
| 24 | |||
| 25 | #include "mtouch.h" | ||
| 26 | |||
| 27 | #define GS_BUTTON 0 | ||
| 28 | #define GS_MOVE 1 | ||
| 29 | #define GS_VSCROLL 2 | ||
| 30 | #define GS_HSCROLL 3 | ||
| 31 | #define GS_VSWIPE 4 | ||
| 32 | #define GS_HSWIPE 5 | ||
| 33 | #define GS_SCALE 6 | ||
| 34 | #define GS_ROTATE 7 | ||
| 35 | |||
| 36 | struct Gestures { | ||
| 37 | unsigned type, btmask, btdata; | ||
| 38 | int same_fingers, dx, dy, scale, rot; | ||
| 39 | }; | ||
| 40 | |||
| 41 | void extract_gestures(struct Gestures *gs, struct MTouch* mt); | ||
| 42 | |||
| 43 | #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 @@ | |||
| 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 HWDATA_H | ||
| 23 | #define HWDATA_H | ||
| 24 | |||
| 25 | #include "common.h" | ||
| 26 | #include "button.h" | ||
| 27 | |||
| 28 | #define BIT_MT_TOUCH_MAJOR 0 | ||
| 29 | #define BIT_MT_TOUCH_MINOR 1 | ||
| 30 | #define BIT_MT_WIDTH_MAJOR 2 | ||
| 31 | #define BIT_MT_WIDTH_MINOR 3 | ||
| 32 | #define BIT_MT_ORIENTATION 4 | ||
| 33 | #define BIT_MT_PRESSURE 5 | ||
| 34 | #define BIT_MT_POSITION_X 6 | ||
| 35 | #define BIT_MT_POSITION_Y 7 | ||
| 36 | #define BIT_MT_CNT 8 | ||
| 37 | |||
| 38 | struct FingerData { | ||
| 39 | int touch_major, touch_minor; | ||
| 40 | int width_major, width_minor; | ||
| 41 | int orientation, pressure; | ||
| 42 | int position_x, position_y; | ||
| 43 | }; | ||
| 44 | |||
| 45 | /** | ||
| 46 | * struct HWData - hardware reads | ||
| 47 | * | ||
| 48 | * @finger: finger data | ||
| 49 | * @mask: bits corresponding to data actually read (readonly) | ||
| 50 | * @mread: bits corresponding to data in progress (writeonly) | ||
| 51 | * @button: bitmask of buttons | ||
| 52 | * @nfinger: number of fingers actually read (readonly) | ||
| 53 | * @nread: number of fingers in progress (writeonly) | ||
| 54 | * | ||
| 55 | */ | ||
| 56 | struct HWData { | ||
| 57 | struct FingerData finger[DIM_FINGER]; | ||
| 58 | unsigned mask[DIM_FINGER], mread[DIM_FINGER]; | ||
| 59 | unsigned button; | ||
| 60 | int nfinger, mtread, nread; | ||
| 61 | mstime_t evtime; | ||
| 62 | }; | ||
| 63 | |||
| 64 | void init_hwdata(struct HWData *hw); | ||
| 65 | int read_hwdata(struct HWData *hw, const struct input_event* ev); | ||
| 66 | void output_hwdata(const struct HWData *hw); | ||
| 67 | |||
| 68 | static inline int finger_dist2(const struct FingerData *a, | ||
| 69 | const struct FingerData *b) | ||
| 70 | { | ||
| 71 | return dist2(a->position_x - b->position_x, | ||
| 72 | a->position_y - b->position_y); | ||
| 73 | } | ||
| 74 | |||
| 75 | #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 @@ | |||
| 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 HWSTATE_H | ||
| 23 | #define HWSTATE_H | ||
| 24 | |||
| 25 | #include "mtdev-caps.h" | ||
| 26 | #include "hwdata.h" | ||
| 27 | |||
| 28 | /* zero id means not mapped (not touching) */ | ||
| 29 | struct FingerState { | ||
| 30 | struct FingerData hw; | ||
| 31 | int id; | ||
| 32 | }; | ||
| 33 | |||
| 34 | struct HWState { | ||
| 35 | struct FingerState finger[DIM_FINGER]; | ||
| 36 | unsigned button; | ||
| 37 | int nfinger; | ||
| 38 | mstime_t evtime; | ||
| 39 | int lastid; | ||
| 40 | }; | ||
| 41 | |||
| 42 | void init_hwstate(struct HWState *s); | ||
| 43 | void modify_hwstate(struct HWState *s, | ||
| 44 | const struct HWData *hw, | ||
| 45 | const struct Capabilities *caps); | ||
| 46 | |||
| 47 | #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 @@ | |||
| 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 | |||
| 33 | void match_fingers(int index[DIM_FINGER], int A[DIM2_FINGER], | ||
| 34 | int nrow, int ncol); | ||
| 35 | |||
| 36 | #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 @@ | |||
| 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 MEMORY_H | ||
| 23 | #define MEMORY_H | ||
| 24 | |||
| 25 | #include "mtstate.h" | ||
| 26 | |||
| 27 | /** | ||
| 28 | * struct Memory - parsing state | ||
| 29 | * | ||
| 30 | * @btdata: logical finger state | ||
| 31 | * @same: true if the finger configuration is unchanged | ||
| 32 | * @fingers: bitmask of fingers on the pad | ||
| 33 | * @added: bitmask of new fingers on the pad | ||
| 34 | * @thumb: bitmask of thumbs on the pad | ||
| 35 | * @pointing: bitmask of pointing fingers | ||
| 36 | * @pending: bitmask of tentatively moving fingers | ||
| 37 | * @moving: bitmask of moving fingers | ||
| 38 | * @ybar: vertical position on pad marking the clicking area | ||
| 39 | * @mvhold: movement before this point in time is accumulated | ||
| 40 | * @mvforget: movement before this point in time is discarded | ||
| 41 | * @dx: array of accumulated horiontal movement per finger | ||
| 42 | * @dy: array of accumulated vertical movement per finger | ||
| 43 | * | ||
| 44 | */ | ||
| 45 | struct Memory { | ||
| 46 | unsigned btdata, same; | ||
| 47 | unsigned fingers, added, thumb; | ||
| 48 | unsigned pointing, pending, moving; | ||
| 49 | int ybar; | ||
| 50 | mstime_t mvhold, mvforget; | ||
| 51 | int dx[DIM_FINGER], dy[DIM_FINGER]; | ||
| 52 | }; | ||
| 53 | |||
| 54 | void init_memory(struct Memory *mem); | ||
| 55 | void refresh_memory(struct Memory *m, | ||
| 56 | const struct MTState *prev_state, | ||
| 57 | const struct MTState *state, | ||
| 58 | const struct Capabilities *caps); | ||
| 59 | void output_memory(const struct Memory *m); | ||
| 60 | |||
| 61 | static inline void mem_hold_movement(struct Memory *m, mstime_t t) | ||
| 62 | { | ||
| 63 | if (t > m->mvhold) | ||
| 64 | m->mvhold = t; | ||
| 65 | } | ||
| 66 | |||
| 67 | static inline void mem_forget_movement(struct Memory *m, mstime_t t) | ||
| 68 | { | ||
| 69 | if (t > m->mvforget) | ||
| 70 | m->mvforget = t; | ||
| 71 | } | ||
| 72 | |||
| 73 | #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 @@ | |||
| 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_CAPS_H | ||
| 23 | #define MTDEV_CAPS_H | ||
| 24 | |||
| 25 | #include "common.h" | ||
| 26 | |||
| 27 | struct Capabilities { | ||
| 28 | struct input_id devid; | ||
| 29 | char devname[32]; | ||
| 30 | int has_left, has_middle; | ||
| 31 | int has_right, has_mtdata, has_ibt; | ||
| 32 | int has_touch_major, has_touch_minor; | ||
| 33 | int has_width_major, has_width_minor; | ||
| 34 | int has_orientation, has_dummy; | ||
| 35 | int has_position_x, has_position_y; | ||
| 36 | struct input_absinfo abs_touch_major; | ||
| 37 | struct input_absinfo abs_touch_minor; | ||
| 38 | struct input_absinfo abs_width_major; | ||
| 39 | struct input_absinfo abs_width_minor; | ||
| 40 | struct input_absinfo abs_orientation; | ||
| 41 | struct input_absinfo abs_position_x; | ||
| 42 | struct input_absinfo abs_position_y; | ||
| 43 | int xfuzz, yfuzz, wfuzz; | ||
| 44 | int yclick; | ||
| 45 | }; | ||
| 46 | |||
| 47 | int read_capabilities(struct Capabilities *cap, int fd); | ||
| 48 | int get_cap_xsize(const struct Capabilities *cap); | ||
| 49 | int get_cap_ysize(const struct Capabilities *cap); | ||
| 50 | int get_cap_wsize(const struct Capabilities *cap); | ||
| 51 | |||
| 52 | int get_cap_xmid(const struct Capabilities *cap); | ||
| 53 | int get_cap_ymid(const struct Capabilities *cap); | ||
| 54 | |||
| 55 | void output_capabilities(const struct Capabilities *cap); | ||
| 56 | |||
| 57 | #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 @@ | |||
| 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 | |||
| 30 | struct IOBuffer { | ||
| 31 | char begin[DIM_BUFFER], *at, *top, *end; | ||
| 32 | }; | ||
| 33 | |||
| 34 | void init_iobuf(struct IOBuffer *buf); | ||
| 35 | const struct input_event *get_iobuf_event(struct IOBuffer *buf, int fd); | ||
| 36 | |||
| 37 | #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 @@ | |||
| 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 MTOUCH_H | ||
| 23 | #define MTOUCH_H | ||
| 24 | |||
| 25 | #include "mtdev-iobuf.h" | ||
| 26 | #include "hwdata.h" | ||
| 27 | #include "hwstate.h" | ||
| 28 | #include "mtstate.h" | ||
| 29 | #include "memory.h" | ||
| 30 | |||
| 31 | struct MTouch { | ||
| 32 | struct Capabilities caps; | ||
| 33 | struct IOBuffer buf; | ||
| 34 | struct HWData hw; | ||
| 35 | struct HWState hs; | ||
| 36 | struct MTState prev_state, state; | ||
| 37 | struct Memory mem; | ||
| 38 | }; | ||
| 39 | |||
| 40 | int configure_mtouch(struct MTouch *mt, int fd); | ||
| 41 | int open_mtouch(struct MTouch *mt, int fd); | ||
| 42 | int close_mtouch(struct MTouch *mt, int fd); | ||
| 43 | |||
| 44 | int read_synchronized_event(struct MTouch *mt, int fd); | ||
| 45 | void parse_event(struct MTouch *mt); | ||
| 46 | |||
| 47 | |||
| 48 | static inline void mt_delay_movement(struct MTouch *mt, int t) | ||
| 49 | { | ||
| 50 | mem_hold_movement(&mt->mem, mt->state.evtime + t); | ||
| 51 | } | ||
| 52 | |||
| 53 | static inline void mt_skip_movement(struct MTouch *mt, int t) | ||
| 54 | { | ||
| 55 | mem_forget_movement(&mt->mem, mt->state.evtime + t); | ||
| 56 | } | ||
| 57 | |||
| 58 | #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 @@ | |||
| 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 MTSTATE_H | ||
| 23 | #define MTSTATE_H | ||
| 24 | |||
| 25 | #include "hwstate.h" | ||
| 26 | |||
| 27 | struct MTFinger { | ||
| 28 | struct FingerData hw; | ||
| 29 | int id, thumb; | ||
| 30 | }; | ||
| 31 | |||
| 32 | struct MTState { | ||
| 33 | struct MTFinger finger[DIM_FINGER]; | ||
| 34 | int nfinger; | ||
| 35 | unsigned button; | ||
| 36 | mstime_t evtime; | ||
| 37 | }; | ||
| 38 | |||
| 39 | void init_mtstate(struct MTState *s); | ||
| 40 | void extract_mtstate(struct MTState *s, | ||
| 41 | const struct HWState *hs, | ||
| 42 | const struct Capabilities *caps); | ||
| 43 | void output_mtstate(const struct MTState *s); | ||
| 44 | |||
| 45 | const struct MTFinger *find_finger(const struct MTState *s, int id); | ||
| 46 | |||
| 47 | |||
| 48 | static inline int center_dist2(const struct MTFinger *a, | ||
| 49 | const struct Capabilities *caps) | ||
| 50 | { | ||
| 51 | return dist2(a->hw.position_x - get_cap_xmid(caps), | ||
| 52 | a->hw.position_y - get_cap_ymid(caps)); | ||
| 53 | } | ||
| 54 | |||
| 55 | static inline int center_maxdist2(const struct Capabilities *caps) | ||
| 56 | { | ||
| 57 | return dist2(caps->abs_position_x.maximum - get_cap_xmid(caps), | ||
| 58 | caps->abs_position_y.maximum - get_cap_ymid(caps)); | ||
| 59 | } | ||
| 60 | |||
| 61 | #endif | ||
| 62 | |||
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 @@ | |||
| 1 | #ifndef XBYPASS_H | ||
| 2 | #define XBYPASS_H | ||
| 3 | |||
| 4 | #include <stdarg.h> | ||
| 5 | void xf86Msg(int type, const char *format, ...) | ||
| 6 | { | ||
| 7 | va_list args; | ||
| 8 | va_start(args, format); | ||
| 9 | vfprintf(stderr, format, args); | ||
| 10 | va_end(args); | ||
| 11 | } | ||
| 12 | |||
| 13 | #endif | ||
