libinput  0.8.0
A wrapper library for input devices
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Data Structures | Enumerations | Functions
Initialization and manipulation of input devices

Data Structures

struct  libinput_device
 A base handle for accessing libinput devices. More...
 

Enumerations

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_pointer_axis_source { LIBINPUT_POINTER_AXIS_SOURCE_WHEEL, LIBINPUT_POINTER_AXIS_SOURCE_FINGER, LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS }
 The source for a libinput_pointer_axis event. More...
 

Functions

struct libinput_devicelibinput_device_ref (struct libinput_device *device)
 Increase the refcount of the input device. More...
 
struct libinput_devicelibinput_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 libinputlibinput_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_seatlibinput_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...
 
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_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...
 

Detailed Description

Enumeration Type Documentation

Logical state of a physical button.

Note that the logical state may not represent the physical state of the button.

Enumerator
LIBINPUT_BUTTON_STATE_RELEASED 
LIBINPUT_BUTTON_STATE_PRESSED 

Capabilities on a device.

A device may have one or more capabilities at a time, and capabilities may appear or disappear during the lifetime of the device.

Enumerator
LIBINPUT_DEVICE_CAP_KEYBOARD 
LIBINPUT_DEVICE_CAP_POINTER 
LIBINPUT_DEVICE_CAP_TOUCH 

Logical state of a key.

Note that the logical state may not represent the physical state of the key.

Enumerator
LIBINPUT_KEY_STATE_RELEASED 
LIBINPUT_KEY_STATE_PRESSED 

Mask reflecting LEDs on a device.

Enumerator
LIBINPUT_LED_NUM_LOCK 
LIBINPUT_LED_CAPS_LOCK 
LIBINPUT_LED_SCROLL_LOCK 

Axes on a device that are not x or y coordinates.

The two scroll axes LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL and LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL are engaged separately, depending on the device. libinput provides some scroll direction locking but it is up to the caller to determine which axis is needed and appropriate in the current interaction

Enumerator
LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL 
LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL 

The source for a libinput_pointer_axis event.

See libinput_event_pointer_get_axis_source() for details.

Enumerator
LIBINPUT_POINTER_AXIS_SOURCE_WHEEL 

The event is caused by the rotation of a wheel.

LIBINPUT_POINTER_AXIS_SOURCE_FINGER 

The event is caused by the movement of one or more fingers on a device.

LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS 

The event is caused by the motion of some device.

Function Documentation

struct libinput* libinput_device_get_context ( struct libinput_device device)

Get the libinput context from the device.

Parameters
deviceA previously obtained device
Returns
The libinput context for this device.
unsigned int libinput_device_get_id_product ( struct libinput_device device)

Get the product ID for this device.

Parameters
deviceA previously obtained device
Returns
The product ID of this device
unsigned int libinput_device_get_id_vendor ( struct libinput_device device)

Get the vendor ID for this device.

Parameters
deviceA previously obtained device
Returns
The vendor ID of this device
const char* libinput_device_get_name ( struct libinput_device device)

The descriptive device name as advertised by the kernel and/or the hardware itself.

To get the sysname for this device, use libinput_device_get_sysname().

The lifetime of the returned string is tied to the struct libinput_device. The string may be the empty string but is never NULL.

Parameters
deviceA previously obtained device
Returns
The device name
const char* libinput_device_get_output_name ( struct libinput_device device)

A device may be mapped to a single output, or all available outputs.

If a device is mapped to a single output only, a relative device may not move beyond the boundaries of this output. An absolute device has its input coordinates mapped to the extents of this output.

Returns
the name of the output this device is mapped to, or NULL if no output is set
struct libinput_seat* libinput_device_get_seat ( struct libinput_device device)

Get the seat associated with this input device.

A seat can be uniquely identified by the physical and logical seat name. There will ever be only one seat instance with a given physical and logical seat name pair at any given time, but if no external reference is kept, it may be destroyed if no device belonging to it is left.

Parameters
deviceA previously obtained device
Returns
The seat this input device belongs to
int libinput_device_get_size ( struct libinput_device device,
double *  width,
double *  height 
)

Get the physical size of a device in mm, where meaningful.

This function only succeeds on devices with the required data, i.e. tablets, touchpads and touchscreens.

If this function returns nonzero, width and height are unmodified.

Parameters
deviceThe device
widthSet to the width of the device
heightSet to the height of the device
Returns
0 on success, or nonzero otherwise
const char* libinput_device_get_sysname ( struct libinput_device device)

Get the system name of the device.

To get the descriptive device name, use libinput_device_get_name().

Parameters
deviceA previously obtained device
Returns
System name of the device
void* libinput_device_get_user_data ( struct libinput_device device)

Get the caller-specific data associated with this input device, if any.

Parameters
deviceA previously obtained device
Returns
Caller-specific data pointer or NULL if none was set
See also
libinput_device_set_user_data
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).

Parameters
deviceA current input device
codebutton code to check for
Returns
1 if the device supports this button code, 0 if it does not, -1 on error.
int libinput_device_has_capability ( struct libinput_device device,
enum libinput_device_capability  capability 
)

Check if the given device has the specified capability.

Returns
1 if the given device has the capability or 0 if not
void libinput_device_led_update ( struct libinput_device device,
enum libinput_led  leds 
)

Update the LEDs on the device, if any.

If the device does not have LEDs, or does not have one or more of the LEDs given in the mask, this function does nothing.

Parameters
deviceA previously obtained device
ledsA mask of the LEDs to set, or unset.
struct libinput_device* libinput_device_ref ( struct libinput_device device)

Increase the refcount of the input device.

An input device will be freed whenever the refcount reaches 0. This may happen during dispatch if the device was removed from the system. A caller must ensure to reference the device correctly to avoid dangling pointers.

Parameters
deviceA previously obtained device
Returns
The passed device
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.

This command is identical to physically unplugging the device, then re-plugging it as member of the new seat, LIBINPUT_EVENT_DEVICE_REMOVED and LIBINPUT_EVENT_DEVICE_ADDED events are sent accordingly. Those events mark the end of the lifetime of this device and the start of a new device.

If the logical seat name already exists in the device's physical seat, the device is added to this seat. Otherwise, a new seat is created.

Note
This change applies to this device until removal or libinput_suspend(), whichever happens earlier.
Parameters
deviceA previously obtained device
nameThe new logical seat name
Returns
0 on success, non-zero on error
void libinput_device_set_user_data ( struct libinput_device device,
void *  user_data 
)

Set caller-specific data associated with this input device.

libinput does not manage, look at, or modify this data. The caller must ensure the data is valid.

Parameters
deviceA previously obtained device
user_dataCaller-specific data pointer
See also
libinput_device_get_user_data
struct libinput_device* libinput_device_unref ( struct libinput_device device)

Decrease the refcount of the input device.

An input device will be freed whenever the refcount reaches 0. This may happen during dispatch if the device was removed from the system. A caller must ensure to reference the device correctly to avoid dangling pointers.

Parameters
deviceA previously obtained device
Returns
NULL if device was destroyed, otherwise the passed device