diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/evemu.h | 227 |
1 files changed, 227 insertions, 0 deletions
diff --git a/include/evemu.h b/include/evemu.h index 6e6ed44..1f55d5c 100644 --- a/include/evemu.h +++ b/include/evemu.h | |||
| @@ -49,41 +49,268 @@ | |||
| 49 | 49 | ||
| 50 | #define EVEMU_VERSION 0x00010000 | 50 | #define EVEMU_VERSION 0x00010000 |
| 51 | 51 | ||
| 52 | /** | ||
| 53 | * evemu_new() - allocate a new evemu device | ||
| 54 | * @name: wanted input device name (or NULL to leave empty) | ||
| 55 | * | ||
| 56 | * This function allocates a new evemu device structure and | ||
| 57 | * initializes all fields to zero. If name is non-null and the length | ||
| 58 | * is sane, it is copied to the device name. | ||
| 59 | * | ||
| 60 | * Returns NULL in case of memory failure. | ||
| 61 | */ | ||
| 52 | struct evemu_device *evemu_new(const char *name); | 62 | struct evemu_device *evemu_new(const char *name); |
| 63 | |||
| 64 | /** | ||
| 65 | * evemu_delete() - free and allocated evemu device | ||
| 66 | * @dev: the device to free | ||
| 67 | * | ||
| 68 | * The device pointer is invalidated by this call. | ||
| 69 | */ | ||
| 53 | void evemu_delete(struct evemu_device *dev); | 70 | void evemu_delete(struct evemu_device *dev); |
| 54 | 71 | ||
| 72 | /** | ||
| 73 | * evemu_get_version() - get library version | ||
| 74 | * @dev: the device in use | ||
| 75 | * | ||
| 76 | * Returns the library version used to create this evemu instance. The | ||
| 77 | * version may differ from the value of EVEMU_VERSION in this header | ||
| 78 | * file. | ||
| 79 | */ | ||
| 55 | unsigned int evemu_get_version(const struct evemu_device *dev); | 80 | unsigned int evemu_get_version(const struct evemu_device *dev); |
| 56 | 81 | ||
| 82 | /** | ||
| 83 | * evemu_get_name() - get device name | ||
| 84 | * @dev: the device in use | ||
| 85 | * | ||
| 86 | * Returns the name of the device. The pointer is owned by the evemu | ||
| 87 | * instance and has evemu scope. | ||
| 88 | */ | ||
| 57 | const char *evemu_get_name(const struct evemu_device *dev); | 89 | const char *evemu_get_name(const struct evemu_device *dev); |
| 90 | |||
| 91 | /** | ||
| 92 | * evemu_set_name() - set device name | ||
| 93 | * @dev: the device in use | ||
| 94 | * | ||
| 95 | * Sets the name of the device. If name is non-null and the length is | ||
| 96 | * sane, it is copied to the device name. | ||
| 97 | */ | ||
| 58 | void evemu_set_name(struct evemu_device *dev, const char *name); | 98 | void evemu_set_name(struct evemu_device *dev, const char *name); |
| 59 | 99 | ||
| 100 | /** | ||
| 101 | * evemu_get_id_bustype() - get kernel device bustype | ||
| 102 | * @dev: the device in use | ||
| 103 | * | ||
| 104 | * Returns the kernel bus type used by the device. | ||
| 105 | */ | ||
| 60 | unsigned int evemu_get_id_bustype(const struct evemu_device *dev); | 106 | unsigned int evemu_get_id_bustype(const struct evemu_device *dev); |
| 107 | |||
| 108 | /** | ||
| 109 | * evemu_get_id_vendor() - get kernel device vendor id | ||
| 110 | * @dev: the device in use | ||
| 111 | * | ||
| 112 | * Returns the kernel vendor id used by the device. | ||
| 113 | */ | ||
| 61 | unsigned int evemu_get_id_vendor(const struct evemu_device *dev); | 114 | unsigned int evemu_get_id_vendor(const struct evemu_device *dev); |
| 115 | |||
| 116 | /** | ||
| 117 | * evemu_get_id_product() - get kernel device product id | ||
| 118 | * @dev: the device in use | ||
| 119 | * | ||
| 120 | * Returns the kernel product id used by the device. | ||
| 121 | */ | ||
| 62 | unsigned int evemu_get_id_product(const struct evemu_device *dev); | 122 | unsigned int evemu_get_id_product(const struct evemu_device *dev); |
| 123 | |||
| 124 | /** | ||
| 125 | * evemu_get_id_version() - get kernel device id version | ||
| 126 | * @dev: the device in use | ||
| 127 | * | ||
| 128 | * Returns the kernel device id used by the device. | ||
| 129 | */ | ||
| 63 | unsigned int evemu_get_id_version(const struct evemu_device *dev); | 130 | unsigned int evemu_get_id_version(const struct evemu_device *dev); |
| 64 | 131 | ||
| 132 | /** | ||
| 133 | * evemu_get_abs_minimum() - get kernel minimum value of event type | ||
| 134 | * @dev: the device in use | ||
| 135 | * @code: the event type code to query | ||
| 136 | * | ||
| 137 | * Returns the range minimum of the specified event type. | ||
| 138 | */ | ||
| 65 | int evemu_get_abs_minimum(const struct evemu_device *dev, int code); | 139 | int evemu_get_abs_minimum(const struct evemu_device *dev, int code); |
| 140 | |||
| 141 | /** | ||
| 142 | * evemu_get_abs_maximum() - get kernel maximum value of event type | ||
| 143 | * @dev: the device in use | ||
| 144 | * @code: the event type code to query | ||
| 145 | * | ||
| 146 | * Returns the range maximum of the specified event type. | ||
| 147 | */ | ||
| 66 | int evemu_get_abs_maximum(const struct evemu_device *dev, int code); | 148 | int evemu_get_abs_maximum(const struct evemu_device *dev, int code); |
| 149 | |||
| 150 | /** | ||
| 151 | * evemu_get_abs_maximum() - get kernel filter fuzz of event type | ||
| 152 | * @dev: the device in use | ||
| 153 | * @code: the event type code to query | ||
| 154 | * | ||
| 155 | * Returns the filter fuzz of the specified event type. | ||
| 156 | */ | ||
| 67 | int evemu_get_abs_fuzz(const struct evemu_device *dev, int code); | 157 | int evemu_get_abs_fuzz(const struct evemu_device *dev, int code); |
| 158 | |||
| 159 | /** | ||
| 160 | * evemu_get_abs_maximum() - get kernel flat value of event type | ||
| 161 | * @dev: the device in use | ||
| 162 | * @code: the event type code to query | ||
| 163 | * | ||
| 164 | * Returns the flat value of the specified event type. Only used for | ||
| 165 | * joysticks. | ||
| 166 | */ | ||
| 68 | int evemu_get_abs_flat(const struct evemu_device *dev, int code); | 167 | int evemu_get_abs_flat(const struct evemu_device *dev, int code); |
| 168 | |||
| 169 | /** | ||
| 170 | * evemu_get_abs_resolution() - get kernel resolution of event type | ||
| 171 | * @dev: the device in use | ||
| 172 | * @code: the event type code to query | ||
| 173 | * | ||
| 174 | * Returns the resolution of the specified event type. Resolution is | ||
| 175 | * specified in units per millimeter (units/mm), or units per radian | ||
| 176 | * where appropriate. | ||
| 177 | */ | ||
| 69 | int evemu_get_abs_resolution(const struct evemu_device *dev, int code); | 178 | int evemu_get_abs_resolution(const struct evemu_device *dev, int code); |
| 70 | 179 | ||
| 180 | /** | ||
| 181 | * evemu_has_prop() - check if device has a certain property | ||
| 182 | * @dev: the device in use | ||
| 183 | * @code: the property type code to query | ||
| 184 | * | ||
| 185 | * Returns true if the device has the given property. | ||
| 186 | */ | ||
| 71 | int evemu_has_prop(const struct evemu_device *dev, int code); | 187 | int evemu_has_prop(const struct evemu_device *dev, int code); |
| 188 | |||
| 189 | /** | ||
| 190 | * evemu_has_event() - check if device has a certain event type | ||
| 191 | * @dev: the device in use | ||
| 192 | * @code: the event type code to query | ||
| 193 | * | ||
| 194 | * Returns true if the event type is supported by the device. | ||
| 195 | */ | ||
| 72 | int evemu_has_event(const struct evemu_device *dev, int type, int code); | 196 | int evemu_has_event(const struct evemu_device *dev, int type, int code); |
| 73 | 197 | ||
| 198 | /** | ||
| 199 | * evemu_extract() - configure evemu instance directly from the kernel device | ||
| 200 | * @dev: the device in use | ||
| 201 | * @fd: file descriptor of the kernel device to query | ||
| 202 | * | ||
| 203 | * Returns zero if successful, negative error otherwise. | ||
| 204 | */ | ||
| 74 | int evemu_extract(struct evemu_device *dev, int fd); | 205 | int evemu_extract(struct evemu_device *dev, int fd); |
| 206 | |||
| 207 | /** | ||
| 208 | * evemu_write() - write evemu configuration to a file | ||
| 209 | * @dev: the device in use | ||
| 210 | * @fp: file pointer to write the evemu configuration to | ||
| 211 | * | ||
| 212 | * Returns zero if successful, negative error otherwise. | ||
| 213 | */ | ||
| 75 | int evemu_write(const struct evemu_device *dev, FILE *fp); | 214 | int evemu_write(const struct evemu_device *dev, FILE *fp); |
| 215 | |||
| 216 | /** | ||
| 217 | * evemu_read() - read evemu configuration from a file | ||
| 218 | * @dev: the device in use | ||
| 219 | * @fp: file pointer to read the evemu configuration from | ||
| 220 | * | ||
| 221 | * Returns a positive number if successful, zero or negative error | ||
| 222 | * otherwise. | ||
| 223 | */ | ||
| 76 | int evemu_read(struct evemu_device *dev, FILE *fp); | 224 | int evemu_read(struct evemu_device *dev, FILE *fp); |
| 77 | 225 | ||
| 226 | /** | ||
| 227 | * evemu_write_event() - write kernel event to file | ||
| 228 | * @fp: file pointer to write the event to | ||
| 229 | * @ev: pointer to the kernel event to write | ||
| 230 | * | ||
| 231 | * Writes the kernel event to the file. | ||
| 232 | * | ||
| 233 | * Returns a positive number if successful, zero or negative error | ||
| 234 | * otherwise. | ||
| 235 | */ | ||
| 78 | int evemu_write_event(FILE *fp, const struct input_event *ev); | 236 | int evemu_write_event(FILE *fp, const struct input_event *ev); |
| 237 | |||
| 238 | /** | ||
| 239 | * evemu_read_event() - read kernel event from file | ||
| 240 | * @fp: file pointer to read the event from | ||
| 241 | * @ev: pointer to the kernel event to be filled | ||
| 242 | * | ||
| 243 | * Reads a kernel event from the file. | ||
| 244 | * | ||
| 245 | * Returns a positive number if successful, zero or negative error | ||
| 246 | * otherwise. | ||
| 247 | */ | ||
| 79 | int evemu_read_event(FILE *fp, struct input_event *ev); | 248 | int evemu_read_event(FILE *fp, struct input_event *ev); |
| 249 | |||
| 250 | /** | ||
| 251 | * evemu_read_event_realtime() - read kernel events in realtime | ||
| 252 | * @fp: file pointer to read the event from | ||
| 253 | * @ev: pointer to the kernel event to be filled | ||
| 254 | * @evtime: pointer to a timeval struct | ||
| 255 | * | ||
| 256 | * The evtime struct should be cleared (zeroed) before the first call | ||
| 257 | * to this function. This function reads a kernel event from the file, | ||
| 258 | * and performs the microsleep necessary to deliver the event with the | ||
| 259 | * same timings as originally received. | ||
| 260 | * | ||
| 261 | * Returns a positive number if successful, zero or negative error | ||
| 262 | * otherwise. | ||
| 263 | */ | ||
| 80 | int evemu_read_event_realtime(FILE *fp, struct input_event *ev, | 264 | int evemu_read_event_realtime(FILE *fp, struct input_event *ev, |
| 81 | struct timeval *evtime); | 265 | struct timeval *evtime); |
| 82 | 266 | ||
| 267 | /** | ||
| 268 | * evemu_record() - read events directly from a kernel device | ||
| 269 | * @fp: file pointer to write the events to | ||
| 270 | * @fd: file descriptor of kernel device to read from | ||
| 271 | * @ms: maximum time to wait for an event to appear before reading (ms) | ||
| 272 | * | ||
| 273 | * Contiuously reads events from the kernel device and writes them to | ||
| 274 | * the file. The function terminates after ms milliseconds of | ||
| 275 | * inactivity. | ||
| 276 | * to this function. This function reads a kernel event from the file, | ||
| 277 | * and performs the microsleep necessary to deliver the event with the | ||
| 278 | * same timings as originally received. | ||
| 279 | * | ||
| 280 | * Returns zero if successful, negative error otherwise. | ||
| 281 | */ | ||
| 83 | int evemu_record(FILE *fp, int fd, int ms); | 282 | int evemu_record(FILE *fp, int fd, int ms); |
| 283 | |||
| 284 | /** | ||
| 285 | * evemu_play() - replay events from file to kernel device in realtime | ||
| 286 | * @fp: file pointer to read the events from | ||
| 287 | * @fd: file descriptor of kernel device to write to | ||
| 288 | * | ||
| 289 | * Contiuously reads events from the file and writes them to the | ||
| 290 | * kernel device, in realtime. The function terminates when end of | ||
| 291 | * file has been reached. | ||
| 292 | * | ||
| 293 | * Returns zero if successful, negative error otherwise. | ||
| 294 | */ | ||
| 84 | int evemu_play(FILE *fp, int fd); | 295 | int evemu_play(FILE *fp, int fd); |
| 85 | 296 | ||
| 297 | /** | ||
| 298 | * evemu_create() - create a kernel device from the evemu configuration | ||
| 299 | * @dev: the device in use | ||
| 300 | * @fd: file descriptor of the special kernel uinput device | ||
| 301 | * | ||
| 302 | * Creates a new device with all the properties of the evemu device. | ||
| 303 | * | ||
| 304 | * Returns zero if successful, negative error otherwise. | ||
| 305 | */ | ||
| 86 | int evemu_create(const struct evemu_device *dev, int fd); | 306 | int evemu_create(const struct evemu_device *dev, int fd); |
| 307 | |||
| 308 | /** | ||
| 309 | * evemu_destroy() - destroy all created kernel devices | ||
| 310 | * @fd: file descriptor of the special kernel uinput device | ||
| 311 | * | ||
| 312 | * Destroys all devices created using this file descriptor. | ||
| 313 | */ | ||
| 87 | void evemu_destroy(int fd); | 314 | void evemu_destroy(int fd); |
| 88 | 315 | ||
| 89 | #endif | 316 | #endif |
