libinput
0.14.1
A wrapper library for input devices
|
Data Structures | |
struct | libinput_device |
A base handle for accessing libinput devices. More... | |
struct | libinput_device_group |
A base handle for accessing libinput device groups. 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 with the capability LIBINPUT_DEVICE_CAP_POINTER 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_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... | |
struct libinput_device_group * | libinput_device_get_device_group (struct libinput_device *device) |
Get the device group this device is assigned to. 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, see Seats for details. 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_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_pointer_has_button (struct libinput_device *device, uint32_t code) |
Check if a LIBINPUT_DEVICE_CAP_POINTER device has a button with the given code (see linux/input.h). More... | |
struct libinput_device_group * | libinput_device_group_ref (struct libinput_device_group *group) |
Increase the refcount of the device group. More... | |
struct libinput_device_group * | libinput_device_group_unref (struct libinput_device_group *group) |
Decrease the refcount of the device group. More... | |
void | libinput_device_group_set_user_data (struct libinput_device_group *group, void *user_data) |
Set caller-specific data associated with this device group. More... | |
void * | libinput_device_group_get_user_data (struct libinput_device_group *group) |
Get the caller-specific data associated with this input device group, if any. More... | |
enum libinput_key_state |
enum libinput_led |
Axes on a device with the capability LIBINPUT_DEVICE_CAP_POINTER 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.
struct libinput* libinput_device_get_context | ( | struct libinput_device * | device | ) |
Get the libinput context from the device.
device | A previously obtained device |
struct libinput_device_group* libinput_device_get_device_group | ( | struct libinput_device * | device | ) |
Get the device group this device is assigned to.
Some physical devices like graphics tablets are represented by multiple kernel devices and thus by multiple struct libinput_device.
libinput assigns these devices to the same libinput_device_group allowing the caller to identify such devices and adjust configuration settings accordingly. For example, setting a tablet to left-handed often means turning it upside down. A touch device on the same tablet would need to be turned upside down too to work correctly.
All devices are part of a device group though for most devices the group will be a singleton. A device is assigned to a device group on LIBINPUT_EVENT_DEVICE_ADDED and removed from that group on LIBINPUT_EVENT_DEVICE_REMOVED. It is up to the caller to track how many devices are in each device group.
Device groups do not get re-used once the last device in the group was removed, i.e. unplugging and re-plugging a physical device with grouped devices will return a different device group after every unplug.
The returned device group is not refcounted and may become invalid after the next call to libinput. Use libinput_device_group_ref() and libinput_device_group_unref() to continue using the handle outside of the immediate scope.
Device groups are assigned based on the LIBINPUT_DEVICE_GROUP udev property, see Static device configuration via udev.
unsigned int libinput_device_get_id_product | ( | struct libinput_device * | device | ) |
Get the product ID for this device.
device | A previously obtained device |
unsigned int libinput_device_get_id_vendor | ( | struct libinput_device * | device | ) |
Get the vendor ID for this device.
device | A previously obtained 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.
device | A previously obtained device |
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.
struct libinput_seat* libinput_device_get_seat | ( | struct libinput_device * | device | ) |
Get the seat associated with this input device, see Seats for details.
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.
device | A previously obtained device |
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.
device | The device |
width | Set to the width of the device |
height | Set to the height of the device |
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().
device | A previously obtained device |
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. See the libudev documentation for details.
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.
device | A previously obtained device |
NULL | This device is not represented by a udev device |
void* libinput_device_get_user_data | ( | struct libinput_device * | device | ) |
Get the caller-specific data associated with this input device, if any.
device | A previously obtained device |
void* libinput_device_group_get_user_data | ( | struct libinput_device_group * | group | ) |
Get the caller-specific data associated with this input device group, if any.
group | A previously obtained group |
struct libinput_device_group* libinput_device_group_ref | ( | struct libinput_device_group * | group | ) |
Increase the refcount of the device group.
A device group will be freed whenever the refcount reaches 0. This may happen during libinput_dispatch() if all devices of this group were removed from the system. A caller must ensure to reference the device group correctly to avoid dangling pointers.
group | A previously obtained device group |
void libinput_device_group_set_user_data | ( | struct libinput_device_group * | group, |
void * | user_data | ||
) |
Set caller-specific data associated with this device group.
libinput does not manage, look at, or modify this data. The caller must ensure the data is valid.
group | A previously obtained device group |
user_data | Caller-specific data pointer |
struct libinput_device_group* libinput_device_group_unref | ( | struct libinput_device_group * | group | ) |
Decrease the refcount of the device group.
A device group will be freed whenever the refcount reaches 0. This may happen during libinput_dispatch() if all devices of this group were removed from the system. A caller must ensure to reference the device group correctly to avoid dangling pointers.
group | A previously obtained device group |
int libinput_device_has_capability | ( | struct libinput_device * | device, |
enum libinput_device_capability | capability | ||
) |
Check if the given device has the specified capability.
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.
device | A previously obtained device |
leds | A mask of the LEDs to set, or unset. |
int libinput_device_pointer_has_button | ( | struct libinput_device * | device, |
uint32_t | code | ||
) |
Check if a LIBINPUT_DEVICE_CAP_POINTER device has a button with the given code (see linux/input.h).
device | A current input device |
code | Button code to check for, e.g. BTN_LEFT |
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 libinput_dispatch() if the device was removed from the system. A caller must ensure to reference the device correctly to avoid dangling pointers.
device | A previously obtained 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 will generate a LIBINPUT_EVENT_DEVICE_REMOVED event and this libinput_device is considered removed from the context; it will not generate further events and will be freed when the refcount reaches zero. A LIBINPUT_EVENT_DEVICE_ADDED event is generated with a new libinput_device handle. It is the caller's responsibility to update references to the new device accordingly.
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.
device | A previously obtained device |
name | The new logical seat name |
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.
device | A previously obtained device |
user_data | Caller-specific data pointer |
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 libinput_dispatch if the device was removed from the system. A caller must ensure to reference the device correctly to avoid dangling pointers.
device | A previously obtained device |