Libsuinput
Thin userspace wrapper library on top of Linux uinput kernel module.
| License: | GPLv3+ |
|---|---|
| Bug tracker: | Launchpad |
| Source code: | GitHub |
Libsuinput introduces several C functions which aim to help in uinput device configuration and usage. All functions operate on uinput file descriptors and therefore libsuinput just complements the standard ioctl-interface. User is free to mix ioctl-commands and suinput function calls as she sees fit. Hence, libsuinput is considered as a thin wrapper.
API
Because libsuinput acts as a thin wrapper for several system calls,
error handling follows the same standard system call error scheme: on
error -1 is returned and errno is set
accordingly.
int suinput_open(void);
Queries sysfs for the filepath of uinput device node, opens the device and returns its file descriptor.
int suinput_enable_event(int uinput_fd, uint16_t ev_type, uint16_t ev_code);
Enables an event capability which is defined by the event type and code.
int suinput_create(int uinput_fd, const struct uinput_user_dev *user_dev_p);
Creates and initializes a new event device. This function should be called after all event capabilities has been defined.
int suinput_write_event(int uinput_fd, const struct input_event *event_p);
Writes the given event to the event device.
int suinput_emit(int uinput_fd, uint16_t ev_type, uint16_t ev_code, int32_t ev_value);
Acts just like suinput_write_event(), but get's the event
timestamp from the system
clock. Calls suinput_write_event() internally.
int suinput_syn(int uinput_fd);
Emits EV_SYN event.
int suinput_destroy(int uinput_fd);
Destroys the device and closes its file descriptor.