diff options
Diffstat (limited to 'include/mtdev.h')
| -rw-r--r-- | include/mtdev.h | 117 |
1 files changed, 73 insertions, 44 deletions
diff --git a/include/mtdev.h b/include/mtdev.h index 15bc53b..df74e95 100644 --- a/include/mtdev.h +++ b/include/mtdev.h | |||
| @@ -62,59 +62,23 @@ extern "C" { | |||
| 62 | #ifndef ABS_MT_SLOT | 62 | #ifndef ABS_MT_SLOT |
| 63 | #define ABS_MT_SLOT 0x2f /* MT slot being modified */ | 63 | #define ABS_MT_SLOT 0x2f /* MT slot being modified */ |
| 64 | #endif | 64 | #endif |
| 65 | #ifndef MT_SLOT_ABS_EVENTS | ||
| 66 | #define MT_SLOT_ABS_EVENTS { \ | ||
| 67 | ABS_MT_TOUCH_MAJOR, \ | ||
| 68 | ABS_MT_TOUCH_MINOR, \ | ||
| 69 | ABS_MT_WIDTH_MAJOR, \ | ||
| 70 | ABS_MT_WIDTH_MINOR, \ | ||
| 71 | ABS_MT_ORIENTATION, \ | ||
| 72 | ABS_MT_POSITION_X, \ | ||
| 73 | ABS_MT_POSITION_Y, \ | ||
| 74 | ABS_MT_TOOL_TYPE, \ | ||
| 75 | ABS_MT_BLOB_ID, \ | ||
| 76 | ABS_MT_TRACKING_ID, \ | ||
| 77 | ABS_MT_PRESSURE, \ | ||
| 78 | } | ||
| 79 | #endif | ||
| 80 | |||
| 81 | #define MT_ABS_SIZE 11 | ||
| 82 | 65 | ||
| 83 | #define MT_ID_NULL (-1) | 66 | #define MT_ID_NULL (-1) |
| 84 | #define MT_ID_MIN 0 | 67 | #define MT_ID_MIN 0 |
| 85 | #define MT_ID_MAX 65535 | 68 | #define MT_ID_MAX 65535 |
| 86 | 69 | ||
| 87 | /** | 70 | /** |
| 88 | * struct mt_caps - protocol capabilities of kernel device | 71 | * mtdev_new_open - create and open a new mtdev |
| 89 | * @has_mtdata: true if the device has MT capabilities | 72 | * @fd: file descriptor of the kernel device |
| 90 | * @has_slot: true if the device sends MT slots | 73 | * |
| 91 | * @slot: slot event properties | 74 | * Create a new mtdev and open the conversion. |
| 92 | * @abs: ABS_MT event properties | ||
| 93 | */ | ||
| 94 | struct mtdev_caps { | ||
| 95 | int has_mtdata; | ||
| 96 | int has_slot; | ||
| 97 | int has_abs[MT_ABS_SIZE]; | ||
| 98 | struct input_absinfo slot; | ||
| 99 | struct input_absinfo abs[MT_ABS_SIZE]; | ||
| 100 | }; | ||
| 101 | |||
| 102 | /** | ||
| 103 | * struct mtdev - represents an input MT device | ||
| 104 | * @caps: the kernel device protocol capabilities | ||
| 105 | * @state: internal mtdev parsing state | ||
| 106 | * | 75 | * |
| 107 | * The mtdev structure represents a kernel MT device type B, emitting | 76 | * Returns zero in case of failure. |
| 108 | * MT slot events. The events put into mtdev may be from any MT | ||
| 109 | * device, specifically type A without contact tracking, type A with | ||
| 110 | * contact tracking, or type B with contact tracking. See the kernel | ||
| 111 | * documentation for further details. | ||
| 112 | * | 77 | * |
| 78 | * This call combines the plumbing functions mtdev_new() and | ||
| 79 | * mtdev_open(). | ||
| 113 | */ | 80 | */ |
| 114 | struct mtdev { | 81 | struct mtdev *mtdev_new_open(int fd); |
| 115 | struct mtdev_caps caps; | ||
| 116 | struct mtdev_state *state; | ||
| 117 | }; | ||
| 118 | 82 | ||
| 119 | /** | 83 | /** |
| 120 | * mtdev_open - open an mtdev converter | 84 | * mtdev_open - open an mtdev converter |
| @@ -132,6 +96,27 @@ struct mtdev { | |||
| 132 | int mtdev_open(struct mtdev *dev, int fd); | 96 | int mtdev_open(struct mtdev *dev, int fd); |
| 133 | 97 | ||
| 134 | /** | 98 | /** |
| 99 | * mtdev_has_mt_event - check for event type | ||
| 100 | * @dev: the mtdev in use | ||
| 101 | * @code: the ABS_MT code to look for | ||
| 102 | * | ||
| 103 | * Returns true if the given event code is present. | ||
| 104 | */ | ||
| 105 | int mtdev_has_mt_event(const struct mtdev *dev, int code); | ||
| 106 | |||
| 107 | /** | ||
| 108 | * mtdev_get_abs_<property> - get abs event property | ||
| 109 | * @dev: the mtdev in use | ||
| 110 | * @code: the ABS_MT code to look for | ||
| 111 | * | ||
| 112 | * Returns NULL if code is not a valid ABS_MT code. | ||
| 113 | */ | ||
| 114 | int mtdev_get_abs_minimum(const struct mtdev *dev, int code); | ||
| 115 | int mtdev_get_abs_maximum(const struct mtdev *dev, int code); | ||
| 116 | int mtdev_get_abs_fuzz(const struct mtdev *dev, int code); | ||
| 117 | int mtdev_get_abs_resolution(const struct mtdev *dev, int code); | ||
| 118 | |||
| 119 | /** | ||
| 135 | * mtdev_idle - check state of kernel device | 120 | * mtdev_idle - check state of kernel device |
| 136 | * @dev: the mtdev in use | 121 | * @dev: the mtdev in use |
| 137 | * @fd: file descriptor of the kernel device | 122 | * @fd: file descriptor of the kernel device |
| @@ -173,6 +158,50 @@ int mtdev_get(struct mtdev *dev, int fd, struct input_event* ev, int ev_max); | |||
| 173 | */ | 158 | */ |
| 174 | void mtdev_close(struct mtdev *dev); | 159 | void mtdev_close(struct mtdev *dev); |
| 175 | 160 | ||
| 161 | /** | ||
| 162 | * mtdev_close_delete - close conversion and delete mtdev | ||
| 163 | * @dev: the mtdev in use | ||
| 164 | * | ||
| 165 | * Flush pending buffers and deallocate all memory associated with | ||
| 166 | * mtdev. The device pointer is invalidated. This call combines the | ||
| 167 | * plumbing functions mtdev_close() and mtdev_delete(). | ||
| 168 | */ | ||
| 169 | void mtdev_close_delete(struct mtdev *dev); | ||
| 170 | |||
| 171 | #ifndef MTDEV_NO_LEGACY_API | ||
| 172 | |||
| 173 | #define MT_ABS_SIZE 11 | ||
| 174 | #ifndef MT_SLOT_ABS_EVENTS | ||
| 175 | #define MT_SLOT_ABS_EVENTS { \ | ||
| 176 | ABS_MT_TOUCH_MAJOR, \ | ||
| 177 | ABS_MT_TOUCH_MINOR, \ | ||
| 178 | ABS_MT_WIDTH_MAJOR, \ | ||
| 179 | ABS_MT_WIDTH_MINOR, \ | ||
| 180 | ABS_MT_ORIENTATION, \ | ||
| 181 | ABS_MT_POSITION_X, \ | ||
| 182 | ABS_MT_POSITION_Y, \ | ||
| 183 | ABS_MT_TOOL_TYPE, \ | ||
| 184 | ABS_MT_BLOB_ID, \ | ||
| 185 | ABS_MT_TRACKING_ID, \ | ||
| 186 | ABS_MT_PRESSURE, \ | ||
| 187 | } | ||
| 188 | #endif | ||
| 189 | |||
| 190 | struct mtdev_caps { | ||
| 191 | int has_mtdata; | ||
| 192 | int has_slot; | ||
| 193 | int has_abs[MT_ABS_SIZE]; | ||
| 194 | struct input_absinfo slot; | ||
| 195 | struct input_absinfo abs[MT_ABS_SIZE]; | ||
| 196 | }; | ||
| 197 | |||
| 198 | struct mtdev { | ||
| 199 | struct mtdev_caps caps; | ||
| 200 | struct mtdev_state *state; | ||
| 201 | }; | ||
| 202 | |||
| 203 | #endif | ||
| 204 | |||
| 176 | #ifdef __cplusplus | 205 | #ifdef __cplusplus |
| 177 | } | 206 | } |
| 178 | #endif | 207 | #endif |
