diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/mtdev-mapping.h | 4 | ||||
| -rw-r--r-- | include/mtdev-plumbing.h | 37 | ||||
| -rw-r--r-- | include/mtdev.h | 117 |
3 files changed, 114 insertions, 44 deletions
diff --git a/include/mtdev-mapping.h b/include/mtdev-mapping.h index 0e47970..0cdb39d 100644 --- a/include/mtdev-mapping.h +++ b/include/mtdev-mapping.h | |||
| @@ -37,6 +37,8 @@ extern "C" { | |||
| 37 | 37 | ||
| 38 | #include <mtdev.h> | 38 | #include <mtdev.h> |
| 39 | 39 | ||
| 40 | #ifndef MTDEV_NO_LEGACY_API | ||
| 41 | |||
| 40 | #define MTDEV_TOUCH_MAJOR 0 | 42 | #define MTDEV_TOUCH_MAJOR 0 |
| 41 | #define MTDEV_TOUCH_MINOR 1 | 43 | #define MTDEV_TOUCH_MINOR 1 |
| 42 | #define MTDEV_WIDTH_MAJOR 2 | 44 | #define MTDEV_WIDTH_MAJOR 2 |
| @@ -80,6 +82,8 @@ static inline unsigned int mtdev_mt2abs(unsigned int mtcode) | |||
| 80 | return mtdev_map_mt2abs[mtcode]; | 82 | return mtdev_map_mt2abs[mtcode]; |
| 81 | } | 83 | } |
| 82 | 84 | ||
| 85 | #endif | ||
| 86 | |||
| 83 | #ifdef __cplusplus | 87 | #ifdef __cplusplus |
| 84 | } | 88 | } |
| 85 | #endif | 89 | #endif |
diff --git a/include/mtdev-plumbing.h b/include/mtdev-plumbing.h index cadc1f7..21ca708 100644 --- a/include/mtdev-plumbing.h +++ b/include/mtdev-plumbing.h | |||
| @@ -36,6 +36,15 @@ extern "C" { | |||
| 36 | #include <mtdev.h> | 36 | #include <mtdev.h> |
| 37 | 37 | ||
| 38 | /** | 38 | /** |
| 39 | * mtdev_new - allocate a new mtdev | ||
| 40 | * | ||
| 41 | * Allocate a new mtdev. | ||
| 42 | * | ||
| 43 | * Returns zero in case of memory allocation failure. | ||
| 44 | */ | ||
| 45 | struct mtdev *mtdev_new(void); | ||
| 46 | |||
| 47 | /** | ||
| 39 | * mtdev_init - initialize mtdev converter | 48 | * mtdev_init - initialize mtdev converter |
| 40 | * @dev: the mtdev to initialize | 49 | * @dev: the mtdev to initialize |
| 41 | * | 50 | * |
| @@ -46,6 +55,26 @@ extern "C" { | |||
| 46 | int mtdev_init(struct mtdev *dev); | 55 | int mtdev_init(struct mtdev *dev); |
| 47 | 56 | ||
| 48 | /** | 57 | /** |
| 58 | * mtdev_set_mt_event - set event type | ||
| 59 | * @dev: the mtdev in use | ||
| 60 | * @code: the ABS_MT code to set | ||
| 61 | * @value: boolean value | ||
| 62 | * | ||
| 63 | * Returns true if the given event code is present. | ||
| 64 | */ | ||
| 65 | void mtdev_set_mt_event(struct mtdev *dev, int code, int value); | ||
| 66 | |||
| 67 | /** | ||
| 68 | * mtdev_set_abs_<property> - set abs event property | ||
| 69 | * @dev: the mtdev in use | ||
| 70 | * @code: the ABS_MT code to set | ||
| 71 | */ | ||
| 72 | void mtdev_set_abs_minimum(struct mtdev *dev, int code, int value); | ||
| 73 | void mtdev_set_abs_maximum(struct mtdev *dev, int code, int value); | ||
| 74 | void mtdev_set_abs_fuzz(struct mtdev *dev, int code, int value); | ||
| 75 | void mtdev_set_abs_resolution(struct mtdev *dev, int code, int value); | ||
| 76 | |||
| 77 | /** | ||
| 49 | * mtdev_configure - configure the mtdev converter | 78 | * mtdev_configure - configure the mtdev converter |
| 50 | * @dev: the mtdev to configure | 79 | * @dev: the mtdev to configure |
| 51 | * @fd: file descriptor of the kernel device | 80 | * @fd: file descriptor of the kernel device |
| @@ -106,6 +135,14 @@ int mtdev_empty(struct mtdev *dev); | |||
| 106 | */ | 135 | */ |
| 107 | void mtdev_get_event(struct mtdev *dev, struct input_event* ev); | 136 | void mtdev_get_event(struct mtdev *dev, struct input_event* ev); |
| 108 | 137 | ||
| 138 | /** | ||
| 139 | * mtdev_delete - free a previously allocated mtdev | ||
| 140 | * | ||
| 141 | * Frees the memory associated with the mtdev and invalidates the | ||
| 142 | * mtdev pointer. | ||
| 143 | */ | ||
| 144 | void mtdev_delete(struct mtdev *dev); | ||
| 145 | |||
| 109 | #ifdef __cplusplus | 146 | #ifdef __cplusplus |
| 110 | } | 147 | } |
| 111 | #endif | 148 | #endif |
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 |
