diff options
Diffstat (limited to 'src/common.h')
| -rw-r--r-- | src/common.h | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/common.h b/src/common.h index e06f7f7..43b5688 100644 --- a/src/common.h +++ b/src/common.h | |||
| @@ -29,6 +29,8 @@ | |||
| 29 | #ifndef COMMON_H | 29 | #ifndef COMMON_H |
| 30 | #define COMMON_H | 30 | #define COMMON_H |
| 31 | 31 | ||
| 32 | #define MTDEV_NO_LEGACY_API | ||
| 33 | |||
| 32 | #include <mtdev-mapping.h> | 34 | #include <mtdev-mapping.h> |
| 33 | #include <mtdev-plumbing.h> | 35 | #include <mtdev-plumbing.h> |
| 34 | #include <malloc.h> | 36 | #include <malloc.h> |
| @@ -85,4 +87,61 @@ static inline int bitcount(unsigned v) | |||
| 85 | /* robust system ioctl calls */ | 87 | /* robust system ioctl calls */ |
| 86 | #define SYSCALL(call) while (((call) == -1) && (errno == EINTR)) | 88 | #define SYSCALL(call) while (((call) == -1) && (errno == EINTR)) |
| 87 | 89 | ||
| 90 | /** | ||
| 91 | * struct mtdev - represents an input MT device | ||
| 92 | * @has_mtdata: true if the device has MT capabilities | ||
| 93 | * @has_slot: true if the device sends MT slots | ||
| 94 | * @slot: slot event properties | ||
| 95 | * @abs: ABS_MT event properties | ||
| 96 | * @state: internal mtdev parsing state | ||
| 97 | * | ||
| 98 | * The mtdev structure represents a kernel MT device type B, emitting | ||
| 99 | * MT slot events. The events put into mtdev may be from any MT | ||
| 100 | * device, specifically type A without contact tracking, type A with | ||
| 101 | * contact tracking, or type B with contact tracking. See the kernel | ||
| 102 | * documentation for further details. | ||
| 103 | * | ||
| 104 | */ | ||
| 105 | struct mtdev { | ||
| 106 | int has_mtdata; | ||
| 107 | int has_slot; | ||
| 108 | int has_abs[11]; | ||
| 109 | struct input_absinfo slot; | ||
| 110 | struct input_absinfo abs[11]; | ||
| 111 | struct mtdev_state *state; | ||
| 112 | }; | ||
| 113 | |||
| 114 | #define MT_ABS_SIZE 11 | ||
| 115 | |||
| 116 | static const unsigned int mtdev_map_abs2mt[ABS_CNT] = { | ||
| 117 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, | ||
| 118 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, | ||
| 119 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, | ||
| 120 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, | ||
| 121 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, | ||
| 122 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, | ||
| 123 | 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, | ||
| 124 | 0x0009, 0x000a, 0x000b, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, | ||
| 125 | }; | ||
| 126 | |||
| 127 | static const unsigned int mtdev_map_mt2abs[MT_ABS_SIZE] = { | ||
| 128 | 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, | ||
| 129 | 0x0038, 0x0039, 0x003a, | ||
| 130 | }; | ||
| 131 | |||
| 132 | static inline int mtdev_is_absmt(unsigned int code) | ||
| 133 | { | ||
| 134 | return mtdev_map_abs2mt[code]; | ||
| 135 | } | ||
| 136 | |||
| 137 | static inline unsigned int mtdev_abs2mt(unsigned int code) | ||
| 138 | { | ||
| 139 | return mtdev_map_abs2mt[code] - 1; | ||
| 140 | } | ||
| 141 | |||
| 142 | static inline unsigned int mtdev_mt2abs(unsigned int mtcode) | ||
| 143 | { | ||
| 144 | return mtdev_map_mt2abs[mtcode]; | ||
| 145 | } | ||
| 146 | |||
| 88 | #endif | 147 | #endif |
