libinput  0.7.0
A wrapper library for input devices
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Data Structures | Macros | Typedefs | Enumerations | Functions
libinput.h File Reference
#include <stdlib.h>
#include <stdint.h>
#include <libudev.h>

Go to the source code of this file.

Data Structures

struct  libinput_interface
 

Macros

#define LIBINPUT_ATTRIBUTE_PRINTF(_format, _args)
 
#define LIBINPUT_ATTRIBUTE_DEPRECATED
 

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 global 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_device_capability { LIBINPUT_DEVICE_CAP_KEYBOARD, LIBINPUT_DEVICE_CAP_POINTER, LIBINPUT_DEVICE_CAP_TOUCH }
 Capabilities on a device. More...
 
enum  libinput_key_state { LIBINPUT_KEY_STATE_RELEASED, LIBINPUT_KEY_STATE_PRESSED }
 Logical state of a key. More...
 
enum  libinput_led { LIBINPUT_LED_NUM_LOCK, LIBINPUT_LED_CAPS_LOCK, LIBINPUT_LED_SCROLL_LOCK }
 Mask reflecting LEDs on a device. More...
 
enum  libinput_button_state { LIBINPUT_BUTTON_STATE_RELEASED, LIBINPUT_BUTTON_STATE_PRESSED }
 Logical state of a physical button. More...
 
enum  libinput_pointer_axis { LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL }
 Axes on a device that are not x or y coordinates. 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...
 
enum  libinput_config_status { LIBINPUT_CONFIG_STATUS_SUCCESS, LIBINPUT_CONFIG_STATUS_UNSUPPORTED, LIBINPUT_CONFIG_STATUS_INVALID }
 Status codes returned when applying configuration settings. More...
 
enum  libinput_config_tap_state { LIBINPUT_CONFIG_TAP_DISABLED, LIBINPUT_CONFIG_TAP_ENABLED }
 
enum  libinput_config_send_events_mode { LIBINPUT_CONFIG_SEND_EVENTS_ENABLED, LIBINPUT_CONFIG_SEND_EVENTS_DISABLED, LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE }
 The send-event mode of a device defines when a device may generate events and pass those events to the caller. More...
 
enum  libinput_config_scroll_method { LIBINPUT_CONFIG_SCROLL_NO_SCROLL, LIBINPUT_CONFIG_SCROLL_2FG, LIBINPUT_CONFIG_SCROLL_EDGE, LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN }
 The scroll method of a device selects when to generate scroll axis events instead of pointer motion events. More...
 

Functions

void libinput_event_destroy (struct libinput_event *event)
 Destroy the event. More...
 
enum libinput_event_type libinput_event_get_type (struct libinput_event *event)
 Get the type of the event. More...
 
struct libinput * libinput_event_get_context (struct libinput_event *event)
 Get the libinput context from the event. More...
 
struct libinput_device * libinput_event_get_device (struct libinput_event *event)
 Return the device associated with this event, if applicable. More...
 
struct libinput_event_pointer * libinput_event_get_pointer_event (struct libinput_event *event)
 Return the pointer event that is this input event. More...
 
struct libinput_event_keyboard * libinput_event_get_keyboard_event (struct libinput_event *event)
 Return the keyboard event that is this input event. More...
 
struct libinput_event_touchlibinput_event_get_touch_event (struct libinput_event *event)
 Return the touch event that is this input event. More...
 
struct
libinput_event_device_notify * 
libinput_event_get_device_notify_event (struct libinput_event *event)
 Return the device event that is this input event. More...
 
struct libinput_event * libinput_event_device_notify_get_base_event (struct libinput_event_device_notify *event)
 
uint32_t libinput_event_keyboard_get_time (struct libinput_event_keyboard *event)
 
uint32_t libinput_event_keyboard_get_key (struct libinput_event_keyboard *event)
 
enum libinput_key_state libinput_event_keyboard_get_key_state (struct libinput_event_keyboard *event)
 
struct libinput_event * libinput_event_keyboard_get_base_event (struct libinput_event_keyboard *event)
 
uint32_t libinput_event_keyboard_get_seat_key_count (struct libinput_event_keyboard *event)
 For the key of a LIBINPUT_EVENT_KEYBOARD_KEY event, return the total number of keys pressed on all devices on the associated seat after the event was triggered. More...
 
uint32_t libinput_event_pointer_get_time (struct libinput_event_pointer *event)
 
double libinput_event_pointer_get_dx (struct libinput_event_pointer *event)
 Return the delta between the last event and the current event. More...
 
double libinput_event_pointer_get_dy (struct libinput_event_pointer *event)
 Return the delta between the last event and the current event. More...
 
double libinput_event_pointer_get_dx_unaccelerated (struct libinput_event_pointer *event)
 Return the relative delta of the unaccelerated motion vector of the current event. More...
 
double libinput_event_pointer_get_dy_unaccelerated (struct libinput_event_pointer *event)
 Return the relative delta of the unaccelerated motion vector of the current event. More...
 
double libinput_event_pointer_get_absolute_x (struct libinput_event_pointer *event)
 Return the current absolute x coordinate of the pointer event, in mm from the top left corner of the device. More...
 
double libinput_event_pointer_get_absolute_y (struct libinput_event_pointer *event)
 Return the current absolute y coordinate of the pointer event, in mm from the top left corner of the device. More...
 
double libinput_event_pointer_get_absolute_x_transformed (struct libinput_event_pointer *event, uint32_t width)
 Return the current absolute x coordinate of the pointer event, transformed to screen coordinates. More...
 
double libinput_event_pointer_get_absolute_y_transformed (struct libinput_event_pointer *event, uint32_t height)
 Return the current absolute y coordinate of the pointer event, transformed to screen coordinates. More...
 
uint32_t libinput_event_pointer_get_button (struct libinput_event_pointer *event)
 Return the button that triggered this event. More...
 
enum libinput_button_state libinput_event_pointer_get_button_state (struct libinput_event_pointer *event)
 Return the button state that triggered this event. More...
 
uint32_t libinput_event_pointer_get_seat_button_count (struct libinput_event_pointer *event)
 For the button of a LIBINPUT_EVENT_POINTER_BUTTON event, return the total number of buttons pressed on all devices on the associated seat after the the event was triggered. More...
 
enum libinput_pointer_axis libinput_event_pointer_get_axis (struct libinput_event_pointer *event)
 Return the axis that triggered this event. More...
 
double libinput_event_pointer_get_axis_value (struct libinput_event_pointer *event)
 Return the axis value of the given axis. More...
 
struct libinput_event * libinput_event_pointer_get_base_event (struct libinput_event_pointer *event)
 
uint32_t libinput_event_touch_get_time (struct libinput_event_touch *event)
 
int32_t libinput_event_touch_get_slot (struct libinput_event_touch *event)
 Get the slot of this touch event. More...
 
int32_t libinput_event_touch_get_seat_slot (struct libinput_event_touch *event)
 Get the seat slot of the touch event. More...
 
double libinput_event_touch_get_x (struct libinput_event_touch *event)
 Return the current absolute x coordinate of the touch event, in mm from the top left corner of the device. More...
 
double libinput_event_touch_get_y (struct libinput_event_touch *event)
 Return the current absolute y coordinate of the touch event, in mm from the top left corner of the device. More...
 
double libinput_event_touch_get_x_transformed (struct libinput_event_touch *event, uint32_t width)
 Return the current absolute x coordinate of the touch event, transformed to screen coordinates. More...
 
double libinput_event_touch_get_y_transformed (struct libinput_event_touch *event, uint32_t height)
 Return the current absolute y coordinate of the touch event, transformed to screen coordinates. More...
 
struct libinput_event * libinput_event_touch_get_base_event (struct libinput_event_touch *event)
 
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_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...
 
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 global log priority. More...
 
enum libinput_log_priority libinput_log_get_priority (const struct libinput *libinput)
 Get the global log priority. More...
 
struct libinput_seat * libinput_seat_ref (struct libinput_seat *seat)
 Increase the refcount of the seat. More...
 
struct libinput_seat * libinput_seat_unref (struct libinput_seat *seat)
 Decrease the refcount of the seat. More...
 
void libinput_seat_set_user_data (struct libinput_seat *seat, void *user_data)
 Set caller-specific data associated with this seat. More...
 
void * libinput_seat_get_user_data (struct libinput_seat *seat)
 Get the caller-specific data associated with this seat, if any. More...
 
struct libinput * libinput_seat_get_context (struct libinput_seat *seat)
 Get the libinput context from the seat. More...
 
const char * libinput_seat_get_physical_name (struct libinput_seat *seat)
 Return the physical name of the seat. More...
 
const char * libinput_seat_get_logical_name (struct libinput_seat *seat)
 Return the logical name of the seat. More...
 
struct libinput_device * libinput_device_ref (struct libinput_device *device)
 Increase the refcount of the input device. More...
 
struct libinput_device * libinput_device_unref (struct libinput_device *device)
 Decrease the refcount of the input device. More...
 
void libinput_device_set_user_data (struct libinput_device *device, void *user_data)
 Set caller-specific data associated with this input device. More...
 
void * libinput_device_get_user_data (struct libinput_device *device)
 Get the caller-specific data associated with this input device, if any. More...
 
struct libinput * libinput_device_get_context (struct libinput_device *device)
 Get the libinput context from the device. More...
 
const char * libinput_device_get_sysname (struct libinput_device *device)
 Get the system name of the device. More...
 
const char * libinput_device_get_name (struct libinput_device *device)
 The descriptive device name as advertised by the kernel and/or the hardware itself. More...
 
unsigned int libinput_device_get_id_product (struct libinput_device *device)
 Get the product ID for this device. More...
 
unsigned int libinput_device_get_id_vendor (struct libinput_device *device)
 Get the vendor ID for this device. More...
 
const char * libinput_device_get_output_name (struct libinput_device *device)
 A device may be mapped to a single output, or all available outputs. More...
 
struct libinput_seat * libinput_device_get_seat (struct libinput_device *device)
 Get the seat associated with this input device. More...
 
int libinput_device_set_seat_logical_name (struct libinput_device *device, const char *name)
 Change the logical seat associated with this device by removing the device and adding it to the new seat. More...
 
struct udev_device * libinput_device_get_udev_device (struct libinput_device *device)
 Return a udev handle to the device that is this libinput device, if any. More...
 
void libinput_device_led_update (struct libinput_device *device, enum libinput_led leds)
 Update the LEDs on the device, if any. More...
 
int libinput_device_get_keys (struct libinput_device *device, char *keys, size_t size) 1
 Set the bitmask in keys to the bitmask of the keys present on the device (see linux/input.h), up to size characters. More...
 
void libinput_device_calibrate (struct libinput_device *device, float calibration[6]) 1
 
int libinput_device_has_capability (struct libinput_device *device, enum libinput_device_capability capability)
 Check if the given device has the specified capability. More...
 
int libinput_device_get_size (struct libinput_device *device, double *width, double *height)
 Get the physical size of a device in mm, where meaningful. More...
 
int libinput_device_has_button (struct libinput_device *device, uint32_t code)
 Check if a LIBINPUT_DEVICE_CAP_POINTER device has a button with the passed in code (see linux/input.h). More...
 
const char * libinput_config_status_to_str (enum libinput_config_status status)
 Return a string describing the error. More...
 
int libinput_device_config_tap_get_finger_count (struct libinput_device *device)
 Check if the device supports tap-to-click. More...
 
enum libinput_config_status libinput_device_config_tap_set_enabled (struct libinput_device *device, enum libinput_config_tap_state enable)
 Enable or disable tap-to-click on this device, with a default mapping of 1, 2, 3 finger tap mapping to left, right, middle click, respectively. More...
 
enum libinput_config_tap_state libinput_device_config_tap_get_enabled (struct libinput_device *device)
 Check if tap-to-click is enabled on this device. More...
 
enum libinput_config_tap_state libinput_device_config_tap_get_default_enabled (struct libinput_device *device)
 Return the default setting for whether tapping is enabled on this device. More...
 
int libinput_device_config_calibration_has_matrix (struct libinput_device *device)
 Check if the device can be calibrated via a calibration matrix. More...
 
enum libinput_config_status libinput_device_config_calibration_set_matrix (struct libinput_device *device, const float matrix[6])
 Apply the 3x3 transformation matrix to absolute device coordinates. More...
 
int libinput_device_config_calibration_get_matrix (struct libinput_device *device, float matrix[6])
 Return the current calibration matrix for this device. More...
 
int libinput_device_config_calibration_get_default_matrix (struct libinput_device *device, float matrix[6])
 Return the default calibration matrix for this device. More...
 
uint32_t libinput_device_config_send_events_get_modes (struct libinput_device *device)
 Return the possible send-event modes for this device. More...
 
enum libinput_config_status libinput_device_config_send_events_set_mode (struct libinput_device *device, uint32_t mode)
 Set the send-event mode for this device. More...
 
uint32_t libinput_device_config_send_events_get_mode (struct libinput_device *device)
 Get the send-event mode for this device. More...
 
uint32_t libinput_device_config_send_events_get_default_mode (struct libinput_device *device)
 Get the default send-event mode for this device. More...
 
int libinput_device_config_accel_is_available (struct libinput_device *device)
 Check if a device uses libinput-internal pointer-acceleration. More...
 
enum libinput_config_status libinput_device_config_accel_set_speed (struct libinput_device *device, double speed)
 Set the pointer acceleration speed of this pointer device within a range of [-1, 1], where 0 is the default acceleration for this device, -1 is the slowest acceleration and 1 is the maximum acceleration available on this device. More...
 
double libinput_device_config_accel_get_speed (struct libinput_device *device)
 Get the current pointer acceleration setting for this pointer device. More...
 
double libinput_device_config_accel_get_default_speed (struct libinput_device *device)
 Return the default speed setting for this device, normalized to a range of [-1, 1]. More...
 
int libinput_device_config_scroll_has_natural_scroll (struct libinput_device *device)
 Return non-zero if the device supports "natural scrolling". More...
 
enum libinput_config_status libinput_device_config_scroll_set_natural_scroll_enabled (struct libinput_device *device, int enable)
 Enable or disable natural scrolling on the device. More...
 
int libinput_device_config_scroll_get_natural_scroll_enabled (struct libinput_device *device)
 Get the current mode for scrolling on this device. More...
 
int libinput_device_config_scroll_get_default_natural_scroll_enabled (struct libinput_device *device)
 Get the default mode for scrolling on this device. More...
 
int libinput_device_config_buttons_has_left_handed (struct libinput_device *device)
 Check if a device has a button configuration that supports left-handed usage. More...
 
enum libinput_config_status libinput_device_config_buttons_set_left_handed (struct libinput_device *device, int left_handed)
 Set the left-handed configuration of the device. More...
 
int libinput_device_config_buttons_get_left_handed (struct libinput_device *device)
 Get the current left-handed configuration of the device. More...
 
int libinput_device_config_buttons_get_default_left_handed (struct libinput_device *device)
 Get the default left-handed configuration of the device. More...
 
uint32_t libinput_device_config_scroll_get_methods (struct libinput_device *device)
 Check which scroll methods a device supports. More...
 
enum libinput_config_status libinput_device_config_scroll_set_method (struct libinput_device *device, enum libinput_config_scroll_method method)
 Set the scroll method for this device. More...
 
enum libinput_config_scroll_method libinput_device_config_scroll_get_method (struct libinput_device *device)
 Get the scroll method for this device. More...
 
enum libinput_config_scroll_method libinput_device_config_scroll_get_default_method (struct libinput_device *device)
 Get the default scroll method for this device. More...
 
enum libinput_config_status libinput_device_config_scroll_set_button (struct libinput_device *device, uint32_t button)
 Set the button for the LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN method for this device. More...
 
uint32_t libinput_device_config_scroll_get_button (struct libinput_device *device)
 Get the button for the LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN method for this device. More...
 
uint32_t libinput_device_config_scroll_get_default_button (struct libinput_device *device)
 Get the default button for LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN method for this device. More...
 

Macro Definition Documentation

#define LIBINPUT_ATTRIBUTE_DEPRECATED
#define LIBINPUT_ATTRIBUTE_PRINTF (   _format,
  _args 
)

Enumeration Type Documentation

The send-event mode of a device defines when a device may generate events and pass those events to the caller.

Enumerator
LIBINPUT_CONFIG_SEND_EVENTS_ENABLED 

Send events from this device normally.

This is a placeholder mode only, any device detected by libinput can be enabled. Do not test for this value as bitmask.

LIBINPUT_CONFIG_SEND_EVENTS_DISABLED 

Do not send events through this device.

Depending on the device, this may close all file descriptors on the device or it may leave the file descriptors open and route events through a different device.

If this bit field is set, other disable modes may be ignored. For example, if both LIBINPUT_CONFIG_SEND_EVENTS_DISABLED and LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE are set, the device remains disabled when all external pointer devices are unplugged.

LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE 

If an external pointer device is plugged in, do not send events from this device.

This option may be available on built-in touchpads.

Log priority for internal logging messages.

Enumerator
LIBINPUT_LOG_PRIORITY_DEBUG 
LIBINPUT_LOG_PRIORITY_INFO 
LIBINPUT_LOG_PRIORITY_ERROR 

Function Documentation

struct udev_device* libinput_device_get_udev_device ( struct libinput_device *  device)

Return a udev handle to the device that is this libinput device, if any.

The returned handle has a refcount of at least 1, the caller must call udev_device_unref() once to release the associated resources.

Some devices may not have a udev device, or the udev device may be unobtainable. This function returns NULL if no udev device was available.

Calling this function multiple times for the same device may not return the same udev handle each time.

Parameters
deviceA previously obtained device
Returns
A udev handle to the device with a refcount of >= 1 or NULL.
Return values
NULLThis device is not represented by a udev device