libinput
0.19.0
A wrapper library for input devices
|
Data Structures | |
struct | libinput |
A handle for accessing libinput. More... | |
struct | libinput_interface |
libinput does not open file descriptors to devices directly, instead open_restricted() and close_restricted() are called for each path that must be opened. More... | |
Typedefs | |
typedef void(* | libinput_log_handler) (struct libinput *libinput, enum libinput_log_priority priority, const char *format, va_list args) LIBINPUT_ATTRIBUTE_PRINTF(3 |
Log handler type for custom logging. More... | |
typedef void(*) voi | libinput_log_set_handler) (struct libinput *libinput, libinput_log_handler log_handler) |
Set the context's log handler. More... | |
Enumerations | |
enum | libinput_log_priority { LIBINPUT_LOG_PRIORITY_DEBUG, LIBINPUT_LOG_PRIORITY_INFO, LIBINPUT_LOG_PRIORITY_ERROR } |
Log priority for internal logging messages. More... | |
enum | libinput_event_type { LIBINPUT_EVENT_NONE, LIBINPUT_EVENT_DEVICE_ADDED, LIBINPUT_EVENT_DEVICE_REMOVED, LIBINPUT_EVENT_KEYBOARD_KEY, LIBINPUT_EVENT_POINTER_MOTION, LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE, LIBINPUT_EVENT_POINTER_BUTTON, LIBINPUT_EVENT_POINTER_AXIS, LIBINPUT_EVENT_TOUCH_DOWN, LIBINPUT_EVENT_TOUCH_UP, LIBINPUT_EVENT_TOUCH_MOTION, LIBINPUT_EVENT_TOUCH_CANCEL, LIBINPUT_EVENT_TOUCH_FRAME } |
Event type for events returned by libinput_get_event(). More... | |
Functions | |
struct libinput * | libinput_udev_create_context (const struct libinput_interface *interface, void *user_data, struct udev *udev) |
Create a new libinput context from udev. More... | |
int | libinput_udev_assign_seat (struct libinput *libinput, const char *seat_id) |
Assign a seat to this libinput context. More... | |
struct libinput * | libinput_path_create_context (const struct libinput_interface *interface, void *user_data) |
Create a new libinput context that requires the caller to manually add or remove devices with libinput_path_add_device() and libinput_path_remove_device(). More... | |
struct libinput_device * | libinput_path_add_device (struct libinput *libinput, const char *path) |
Add a device to a libinput context initialized with libinput_path_create_context(). More... | |
void | libinput_path_remove_device (struct libinput_device *device) |
Remove a device from a libinput context initialized with libinput_path_create_context() or added to such a context with libinput_path_add_device(). More... | |
int | libinput_get_fd (struct libinput *libinput) |
libinput keeps a single file descriptor for all events. More... | |
int | libinput_dispatch (struct libinput *libinput) |
Main event dispatchment function. More... | |
struct libinput_event * | libinput_get_event (struct libinput *libinput) |
Retrieve the next event from libinput's internal event queue. More... | |
enum libinput_event_type | libinput_next_event_type (struct libinput *libinput) |
Return the type of the next event in the internal queue. More... | |
void | libinput_set_user_data (struct libinput *libinput, void *user_data) |
Set caller-specific data associated with this context. More... | |
void * | libinput_get_user_data (struct libinput *libinput) |
Get the caller-specific data associated with this context, if any. More... | |
int | libinput_resume (struct libinput *libinput) |
Resume a suspended libinput context. More... | |
void | libinput_suspend (struct libinput *libinput) |
Suspend monitoring for new devices and close existing devices. More... | |
struct libinput * | libinput_ref (struct libinput *libinput) |
Add a reference to the context. More... | |
struct libinput * | libinput_unref (struct libinput *libinput) |
Dereference the libinput context. More... | |
void | libinput_log_set_priority (struct libinput *libinput, enum libinput_log_priority priority) |
Set the log priority for the libinput context. More... | |
enum libinput_log_priority | libinput_log_get_priority (const struct libinput *libinput) |
Get the context's log priority. More... | |
typedef void(* libinput_log_handler) (struct libinput *libinput, enum libinput_log_priority priority, const char *format, va_list args) LIBINPUT_ATTRIBUTE_PRINTF(3 |
Log handler type for custom logging.
libinput | The libinput context |
priority | The priority of the current message |
format | Message format in printf-style |
args | Message arguments |
typedef void(*) voi libinput_log_set_handler) (struct libinput *libinput, libinput_log_handler log_handler) |
Set the context's log handler.
Messages with priorities equal to or higher than the context's log priority will be passed to the given log handler.
The default log handler prints to stderr.
libinput | A previously initialized libinput context |
log_handler | The log handler for library messages. |
enum libinput_event_type |
Event type for events returned by libinput_get_event().
Enumerator | |
---|---|
LIBINPUT_EVENT_NONE |
This is not a real event type, and is only used to tell the user that no new event is available in the queue. |
LIBINPUT_EVENT_DEVICE_ADDED |
Signals that a device has been added to the context. The device will not be read until the next time the user calls libinput_dispatch() and data is available. This allows setting up initial device configuration before any events are created. |
LIBINPUT_EVENT_DEVICE_REMOVED |
Signals that a device has been removed. No more events from the associated device will be in the queue or be queued after this event. |
LIBINPUT_EVENT_KEYBOARD_KEY | |
LIBINPUT_EVENT_POINTER_MOTION | |
LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE | |
LIBINPUT_EVENT_POINTER_BUTTON | |
LIBINPUT_EVENT_POINTER_AXIS | |
LIBINPUT_EVENT_TOUCH_DOWN | |
LIBINPUT_EVENT_TOUCH_UP | |
LIBINPUT_EVENT_TOUCH_MOTION | |
LIBINPUT_EVENT_TOUCH_CANCEL | |
LIBINPUT_EVENT_TOUCH_FRAME |
Signals the end of a set of touchpoints at one device sample time. This event has no coordinate information attached. |
int libinput_dispatch | ( | struct libinput * | libinput | ) |
Main event dispatchment function.
Reads events of the file descriptors and processes them internally. Use libinput_get_event() to retrieve the events.
Dispatching does not necessarily queue libinput events. This function should be called immediately once data is available on the file descriptor returned by libinput_get_fd(). libinput has a number of timing-sensitive features (e.g. tap-to-click), any delay in calling libinput_dispatch() may prevent these features from working correctly.
libinput | A previously initialized libinput context |
struct libinput_event* libinput_get_event | ( | struct libinput * | libinput | ) |
Retrieve the next event from libinput's internal event queue.
After handling the retrieved event, the caller must destroy it using libinput_event_destroy().
libinput | A previously initialized libinput context |
int libinput_get_fd | ( | struct libinput * | libinput | ) |
libinput keeps a single file descriptor for all events.
Call into libinput_dispatch() if any events become available on this fd.
void* libinput_get_user_data | ( | struct libinput * | libinput | ) |
Get the caller-specific data associated with this context, if any.
libinput | A previously initialized libinput context |
enum libinput_log_priority libinput_log_get_priority | ( | const struct libinput * | libinput | ) |
Get the context's log priority.
Messages with priorities equal to or higher than the argument will be printed to the current log handler.
The default log priority is LIBINPUT_LOG_PRIORITY_ERROR.
libinput | A previously initialized libinput context |
void libinput_log_set_priority | ( | struct libinput * | libinput, |
enum libinput_log_priority | priority | ||
) |
Set the log priority for the libinput context.
Messages with priorities equal to or higher than the argument will be printed to the context's log handler.
The default log priority is LIBINPUT_LOG_PRIORITY_ERROR.
libinput | A previously initialized libinput context |
priority | The minimum priority of log messages to print. |
enum libinput_event_type libinput_next_event_type | ( | struct libinput * | libinput | ) |
Return the type of the next event in the internal queue.
This function does not pop the event off the queue and the next call to libinput_get_event() returns that event.
libinput | A previously initialized libinput context |
struct libinput_device* libinput_path_add_device | ( | struct libinput * | libinput, |
const char * | path | ||
) |
Add a device to a libinput context initialized with libinput_path_create_context().
If successful, the device will be added to the internal list and re-opened on libinput_resume(). The device can be removed with libinput_path_remove_device().
If the device was successfully initialized, it is returned in the device argument. The lifetime of the returned device pointer is limited until the next libinput_dispatch(), use libinput_device_ref() to keep a permanent reference.
libinput | A previously initialized libinput context |
path | Path to an input device |
struct libinput* libinput_path_create_context | ( | const struct libinput_interface * | interface, |
void * | user_data | ||
) |
Create a new libinput context that requires the caller to manually add or remove devices with libinput_path_add_device() and libinput_path_remove_device().
The context is fully initialized but will not generate events until at least one device has been added.
The reference count of the context is initialized to 1. See libinput_unref.
interface | The callback interface |
user_data | Caller-specific data passed to the various callback interfaces. |
void libinput_path_remove_device | ( | struct libinput_device * | device | ) |
Remove a device from a libinput context initialized with libinput_path_create_context() or added to such a context with libinput_path_add_device().
Events already processed from this input device are kept in the queue, the LIBINPUT_EVENT_DEVICE_REMOVED event marks the end of events for this device.
If no matching device exists, this function does nothing.
device | A libinput device |
Add a reference to the context.
A context is destroyed whenever the reference count reaches 0. See libinput_unref.
libinput | A previously initialized valid libinput context |
int libinput_resume | ( | struct libinput * | libinput | ) |
Resume a suspended libinput context.
This re-enables device monitoring and adds existing devices.
libinput | A previously initialized libinput context |
void libinput_set_user_data | ( | struct libinput * | libinput, |
void * | user_data | ||
) |
Set caller-specific data associated with this context.
libinput does not manage, look at, or modify this data. The caller must ensure the data is valid.
libinput | A previously initialized libinput context |
user_data | Caller-specific data passed to the various callback interfaces. |
void libinput_suspend | ( | struct libinput * | libinput | ) |
Suspend monitoring for new devices and close existing devices.
This all but terminates libinput but does keep the context valid to be resumed with libinput_resume().
libinput | A previously initialized libinput context |
int libinput_udev_assign_seat | ( | struct libinput * | libinput, |
const char * | seat_id | ||
) |
Assign a seat to this libinput context.
New devices or the removal of existing devices will appear as events during libinput_dispatch().
libinput_udev_assign_seat() succeeds even if no input devices are currently available on this seat, or if devices are available but fail to open in libinput_interface::open_restricted. Devices that do not have the minimum capabilities to be recognized as pointer, keyboard or touch device are ignored. Such devices and those that failed to open ignored until the next call to libinput_resume().
This function may only be called once per context.
libinput | A libinput context initialized with libinput_udev_create_context() |
seat_id | A seat identifier. This string must not be NULL. |
struct libinput* libinput_udev_create_context | ( | const struct libinput_interface * | interface, |
void * | user_data, | ||
struct udev * | udev | ||
) |
Create a new libinput context from udev.
This context is inactive until assigned a seat ID with libinput_udev_assign_seat().
interface | The callback interface |
user_data | Caller-specific data passed to the various callback interfaces. |
udev | An already initialized udev context |
Dereference the libinput context.
After this, the context may have been destroyed, if the last reference was dereferenced. If so, the context is invalid and may not be interacted with.
libinput | A previously initialized libinput context |