libinput  0.1.0
A wrapper library for input devices
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups
Typedefs | Enumerations | Functions
Initialization and manipulation of libinput contexts

Typedefs

typedef void(* libinput_log_handler )(enum libinput_log_priority priority, void *user_data, const char *format, va_list args)
 Log handler type for custom logging. More...
 

Enumerations

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_for_seat (const struct libinput_interface *interface, void *user_data, struct udev *udev, const char *seat_id)
 Create a new libinput context from udev, for input devices matching the given seat ID. 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_from_device(). More...
 
void libinput_path_remove_device (struct libinput_device *device)
 Remove a device from a libinput context initialized with libinput_path_create_from_device() 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_get_user_data (struct libinput *libinput)
 
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...
 
void libinput_destroy (struct libinput *libinput)
 Destroy the libinput context. More...
 
void libinput_log_set_priority (enum libinput_log_priority priority)
 Set the global log priority. More...
 
enum libinput_log_priority libinput_log_get_priority (void)
 Get the global log priority. More...
 
void libinput_log_set_handler (libinput_log_handler log_handler, void *user_data)
 Set the global log handler. More...
 

Detailed Description

Typedef Documentation

typedef void(* libinput_log_handler)(enum libinput_log_priority priority, void *user_data, const char *format, va_list args)

Log handler type for custom logging.

Parameters
priorityThe priority of the current message
user_dataCaller-specific data pointer as previously passed into libinput_log_set_handler()
formatMessage format in printf-style
argsMessage arguments
See Also
libinput_set_log_priority
libinput_log_set_handler

Enumeration Type Documentation

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.

See libinput_next_event_type().

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.

Function Documentation

void libinput_destroy ( struct libinput *  libinput)

Destroy the libinput context.

After this, object references associated with the destroyed context are invalid and may not be interacted with.

Parameters
libinputA previously initialized libinput context
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.

Parameters
libinputA previously initialized libinput context
Returns
0 on success, or a negative errno on failure
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().

Parameters
libinputA previously initialized libinput context
Returns
The next available event, or NULL if no event is available.
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.

Returns
the file descriptor used to notify of pending events.
void* libinput_get_user_data ( struct libinput *  libinput)
Parameters
libinputA previously initialized libinput context
Returns
the caller-specific data previously assigned in libinput_create_udev().
enum libinput_log_priority libinput_log_get_priority ( void  )

Get the global 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.

Returns
The minimum priority of log messages to print.
See Also
libinput_log_set_handler
void libinput_log_set_handler ( libinput_log_handler  log_handler,
void *  user_data 
)

Set the global log handler.

Messages with priorities equal to or higher than the current log priority will be passed to the given log handler.

The default log handler prints to stderr.

Parameters
log_handlerThe log handler for library messages.
user_dataCaller-specific data pointer, passed into the log handler.
See Also
libinput_log_set_handler
void libinput_log_set_priority ( enum libinput_log_priority  priority)

Set the global 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.

Parameters
priorityThe minimum priority of log messages to print.
See Also
libinput_log_set_handler
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.

Parameters
libinputA previously initialized libinput context
Returns
The event type of the next available event or LIBINPUT_EVENT_NONE if no event is availble.
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_from_device().

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 linput_dispatch(), use libinput_device_ref() to keep a permanent reference.

Parameters
libinputA previously initialized libinput context
pathPath to an input device
Returns
The newly initiated device on success, or NULL on failure.
Note
It is an application bug to call this function on a libinput context initialize with libinput_udev_create_for_seat().
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.

Parameters
interfaceThe callback interface
user_dataCaller-specific data passed to the various callback interfaces.
Returns
An initialized, empty libinput context.
void libinput_path_remove_device ( struct libinput_device *  device)

Remove a device from a libinput context initialized with libinput_path_create_from_device() 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.

Parameters
deviceA libinput device
Note
It is an application bug to call this function on a libinput context initialize with libinput_udev_create_for_seat().
int libinput_resume ( struct libinput *  libinput)

Resume a suspended libinput context.

This re-enables device monitoring and adds existing devices.

Parameters
libinputA previously initialized libinput context
See Also
libinput_suspend
Returns
0 on success or -1 on failure
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().

Parameters
libinputA previously initialized libinput context
struct libinput* libinput_udev_create_for_seat ( const struct libinput_interface interface,
void *  user_data,
struct udev *  udev,
const char *  seat_id 
)

Create a new libinput context from udev, for input devices matching the given seat ID.

New devices or devices removed will appear as events during libinput_dispatch.

Parameters
interfaceThe callback interface
user_dataCaller-specific data passed to the various callback interfaces.
udevAn already initialized udev context
seat_idA seat identifier. This string must not be NULL.
Returns
An initialized libinput context, ready to handle events or NULL on error.