Devices and Seats¶
Device¶
-
class
libinput.device.
Device
(*args)¶ An input device.
-
sysname
¶ The system name of the device.
To get the descriptive device name, use
name
.Returns: System name of the device. Return type: str
-
name
¶ The descriptive device name as advertised by the kernel and/or the hardware itself.
To get the sysname for this device, use
sysname
.Returns: The device name. Return type: str
-
seat
¶ The seat associated with this input device, see Seats for details.
A seat can be uniquely identified by the physical and logical seat name. As long as a reference to a seat is kept, it will compare equal to another seat object with the same physical/logical name pair.
Returns: The seat this input device belongs to. Return type: Seat
-
set_seat_logical_name
(seat)¶ 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 a member of the new seat. libinput will generate a
DEVICE_REMOVED
event and thisDevice
is considered removed from the context; it will not generate further events. ADEVICE_ADDED
event is generated with a newDevice
. 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.
Note
This change applies to this device until removal or
suspend()
, whichever happens earlier.Parameters: seat (str) – The new logical seat name. Raises: AssertionError
-
udev_device
¶ 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
None
if no udev device was available.Calling this function multiple times for the same device may not return the same udev handle each time.
Returns: A udev handle to the device with a refcount of >= 1 or None
if this device is not represented by a udev device.Return type: int
-
led_update
(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 method does nothing.
Parameters: leds (Led) – A mask of the LEDs to set, or unset.
-
capabilities
¶ A tuple of capabilities this device supports.
Returns: Device capabilities. Return type: (DeviceCapability)
-
size
¶ The physical size of a device in mm, where meaningful.
This property is only valid on devices with the required data, i.e. tablets, touchpads and touchscreens. For other devices this property raises
AssertionError
.Returns: (Width, Height) in mm. Return type: (float, float) Raises: AssertionError
-
pointer
¶ Methods specific to a device with
POINTER
capability.Returns: Return type: DevicePointer
-
keyboard
¶ Methods specific to a device with
KEYBOARD
capability.Returns: Return type: DeviceKeyboard
-
tablet_pad
¶ Methods specific to a device with
TABLET_PAD
capability.Returns: Return type: DeviceTabletPad
-
config
¶ Device configuration.
Returns: An object providing device configuration methods. Return type: DeviceConfig
-
-
class
libinput.device.
DevicePointer
(*args)¶ Methods specific to a device with
POINTER
capability.Check if this device has a given button.
Parameters: button (int) – Button to check for, see input.h
for button definitions.Returns: True
if the device has this button,False
if it does not.Return type: bool Raises: AssertionError
-
class
libinput.device.
DeviceTabletPad
(*args)¶ Methods specific to a device with
TABLET_PAD
capability.The number of buttons on a device with the
TABLET_PAD
capability.Buttons on a pad device are numbered sequentially, see Tablet pad button numbers for details.
Returns: The number of buttons supported by the device. Return type: int Raises: AttributeError
-
num_rings
¶ The number of rings a device with the
TABLET_PAD
capability provides.Returns: The number of rings or 0 if the device has no rings. Return type: int Raises: AttributeError
-
num_strips
¶ The number of strips a device with the
TABLET_PAD
capability provides.Returns: The number of strips or 0 if the device has no strips. Return type: int Raises: AttributeError
-
num_mode_groups
¶ Most devices only provide a single mode group, however devices such as the Wacom Cintiq 22HD provide two mode groups.
If multiple mode groups are available, a caller should use
has_button()
,has_ring()
andhas_strip()
to associate each button, ring and strip with the correct mode group.Returns: The number of mode groups available on this device. Return type: int Raises: AttributeError
-
get_mode_group
(group)¶ While a reference is kept by the caller, the returned mode group will compare equal with mode group returned by each subsequent call of this method with the same index and mode group returned from
mode_group
, provided the event was generated by this mode group.Parameters: group (int) – A mode group index. Returns: The mode group with the given index or None
if an invalid index is given.Return type: TabletPadModeGroup
Seat¶
-
class
libinput.device.
Seat
(hseat, libinput)¶ A seat has two identifiers, the physical name and the logical name.
A device is always assigned to exactly one seat. It may change to a different logical seat but it cannot change physical seats. See Seats for details.
Two instances of
Seat
compare equal if they refer to the same physical/logical seat.-
physical_name
¶ The physical name of the seat.
For libinput contexts created from udev, this is always the same value as passed into
assign_seat()
and all seats from that context will have the same physical name.The physical name of the seat is one that is usually set by the system or lower levels of the stack. In most cases, this is the base filter for devices - devices assigned to seats outside the current seat will not be available to the caller.
Returns: The physical name of this seat. Return type: str
-
DeviceConfig¶
-
class
libinput.device.
DeviceConfig
(*args)¶ A configuration object.
-
tap
¶ Tapping-related configuration methods.
Returns: Return type: DeviceConfigTap
-
calibration
¶ Calibration matrix configuration methods.
Returns: Return type: DeviceConfigCalibration
-
send_events
¶ Event sending configuration methods.
Returns: Return type: DeviceConfigSendEvents
-
accel
¶ Pointer acceleration configuration methods.
Returns: Return type: DeviceConfigAccel
-
scroll
¶ Scrolling configuration methods.
Returns: Return type: DeviceConfigScroll
-
left_handed
¶ Left-handed usage configuration methods.
Returns: Return type: DeviceConfigLeftHanded
-
click
¶ Click method configuration methods.
Returns: Return type: DeviceConfigClick
-
middle_emulation
¶ Middle mouse button emulation configuration methods.
Returns: Return type: DeviceConfigMiddleEmulation
-
dwt
¶ Disable-while-typing configuration methods.
Returns: Return type: DeviceConfigDwt
-
rotation
¶ Rotation configuration methods.
Returns: Return type: DeviceConfigRotation
-
-
class
libinput.device.
DeviceConfigTap
(*args)¶ Tapping-related configuration methods.
-
finger_count
¶ Check if the device supports tap-to-click and how many fingers can be used for tapping.
See
set_enabled()
for more information.Returns: The number of fingers that can generate a tap event, or 0 if the device does not support tapping. Return type: int
-
set_enabled
(state)¶ 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.
Tapping is limited by the number of simultaneous touches supported by the device, see
finger_count
.Parameters: state (TapState) – ENABLED
to enable tapping orDISABLED
to disable tapping.Returns: A config status code. Disabling tapping on a device that does not support tapping always succeeds. Return type: ConfigStatus
-
enabled
¶ Check if tap-to-click is enabled on this device.
If the device does not support tapping, this property is always
DISABLED
.Returns: Whether tapping is enabled or disabled. Return type: TapState
-
default_enabled
¶ The default setting for whether tap-to-click is enabled on this device.
Returns: Whether tapping is enabled or disabled. Return type: TapState
Set the finger number to button number mapping for tap-to-click.
The default mapping on most devices is to have a 1, 2 and 3 finger tap to map to the left, right and middle button, respectively. A device may permit changing the button mapping but disallow specific maps. In this case
UNSUPPORTED
is returned, the caller is expected to handle this case correctly.Changing the button mapping may not take effect immediately, the device may wait until it is in a neutral state before applying any changes.
The mapping may be changed when tap-to-click is disabled. The new mapping takes effect when tap-to-click is enabled in the future.
If
finger_count
is 0, this method raisesAssertionError
.Parameters: button_map (TapButtonMap) – The new finger-to-button number mapping. Returns: A config status code. Return type: ConfigStatus Raises: AssertionError
The finger number to button number mapping for tap-to-click.
For devices that do not support tapping (i.e.
finger_count
is 0), this property raisesAssertionError
.Returns: The current finger-to-button number mapping. Return type: TapButtonMap Raises: AssertionError
The default finger number to button number mapping for tap-to-click.
For devices that do not support tapping (i.e.
finger_count
is 0), this property raisesAssertionError
.Returns: The default finger-to-button number mapping. Return type: TapButtonMap Raises: AssertionError
-
set_drag_enabled
(state)¶ Enable or disable tap-and-drag on this device.
When enabled, a single-finger tap immediately followed by a finger down results in a button down event, subsequent finger motion thus triggers a drag. The button is released on finger up. See Tap-and-drag for more details.
Parameters: state (DragState) – ENABLED
to enable,DISABLED
to disable tap-and-drag.Returns: Whether this method succeeds. Return type: ConfigStatus
-
drag_enabled
¶ Whether tap-and-drag is enabled or disabled on this device.
Returns: Whether tap-and-drag is enabled. Return type: DragState
-
default_drag_enabled
¶ Whether tap-and-drag is enabled or disabled by default on this device.
Returns: Whether tap-and-drag is enabled by default. Return type: DragState
-
set_drag_lock_enabled
(state)¶ Enable or disable drag-lock during tapping on this device.
When enabled, a finger may be lifted and put back on the touchpad within a timeout and the drag process continues. When disabled, lifting the finger during a tap-and-drag will immediately stop the drag. See Tap-and-drag for details.
Enabling drag lock on a device that has tapping disabled is permitted, but has no effect until tapping is enabled.
Parameters: state (DragLockState) – ENABLED
to enable drag lock orDISABLED
to disable drag lock.Returns: A config status code. Disabling drag lock on a device that does not support tapping always succeeds. Return type: ConfigStatus
-
drag_lock_enabled
¶ Check if drag-lock during tapping is enabled on this device.
If the device does not support tapping, this function always returns
DISABLED
.Drag lock may be enabled even when tapping is disabled.
Returns: Whether drag lock is enabled. Return type: DragLockState
-
default_drag_lock_enabled
¶ Check if drag-lock during tapping is enabled by default on this device.
If the device does not support tapping, this function always returns
DISABLED
.Drag lock may be enabled by default even when tapping is disabled by default.
Returns: Whether drag lock is enabled by default. Return type: DragLockState
-
-
class
libinput.device.
DeviceConfigCalibration
(*args)¶ Calibration matrix configuration methods.
-
has_matrix
()¶ Check if the device can be calibrated via a calibration matrix.
Returns: True
if the device can be calibrated,False
otherwise.Return type: bool
-
set_matrix
(matrix)¶ Apply the 3x3 transformation matrix to absolute device coordinates.
This matrix has no effect on relative events.
Given a 6-element array [a, b, c, d, e, f], the matrix is applied as
[ a b c ] [ x ] [ d e f ] * [ y ] [ 0 0 1 ] [ 1 ]
The translation component (c, f) is expected to be normalized to the device coordinate range. For example, the matrix
[ 1 0 1 ] [ 0 1 -1 ] [ 0 0 1 ]
moves all coordinates by 1 device-width to the right and 1 device-height up.
The rotation matrix for rotation around the origin is defined as
[ cos(a) -sin(a) 0 ] [ sin(a) cos(a) 0 ] [ 0 0 1 ]
Note that any rotation requires an additional translation component to translate the rotated coordinates back into the original device space. The rotation matrixes for 90, 180 and 270 degrees clockwise are:
90 deg cw: 180 deg cw: 270 deg cw: [ 0 -1 1] [ -1 0 1] [ 0 1 0 ] [ 1 0 0] [ 0 -1 1] [ -1 0 1 ] [ 0 0 1] [ 0 0 1] [ 0 0 1 ]
Parameters: matrix (iterable) – An array representing the first two rows of a 3x3 matrix as described above. Returns: A config status code. Return type: ConfigStatus
-
matrix
¶ The current calibration matrix for this device.
Returns: False
if no calibration is set and the returned matrix is the identity matrix,True
otherwise.tuple
representing the first two rows of a 3x3 matrix as described inset_matrix()
.Return type: (bool, (float, float, float, float, float, float))
-
default_matrix
¶ The default calibration matrix for this device.
On most devices, this is the identity matrix. If the udev property
LIBINPUT_CALIBRATION_MATRIX
is set on the respective udev device, that property’s value becomes the default matrix, see Static device configuration via udev.Returns: False
if no calibration is set and the returned matrix is the identity matrix,True
otherwise.tuple
representing the first two rows of a 3x3 matrix as described inconfig_calibration_set_matrix()
.Return type: (bool, (float, float, float, float, float, float))
-
-
class
libinput.device.
DeviceConfigSendEvents
(*args)¶ Event sending configuration methods.
-
modes
¶ The possible send-event modes for this device.
These modes define when a device may process and send events.
Returns: A bitmask of possible modes. Return type: SendEventsMode
-
set_mode
(mode)¶ Set the send-event mode for this device.
The mode defines when the device processes and sends events to the caller.
The selected mode may not take effect immediately. Events already received and processed from this device are unaffected and will be passed to the caller on the next call to
get_event()
.If the mode is a bitmask of
SendEventsMode
, the device may wait for or generate events until it is in a neutral state. For example, this may include waiting for or generating button release events.If the device is already suspended, this function does nothing and returns success. Changing the send-event mode on a device that has been removed is permitted.
Parameters: mode (SendEventsMode) – A bitmask of send-events modes. Returns: A config status code. Return type: ConfigStatus
-
mode
¶ The send-event mode for this device.
The mode defines when the device processes and sends events to the caller.
If a caller enables the bits for multiple modes, some of which are subsets of another mode libinput may drop the bits that are subsets. In other words, don’t expect
mode
to always be exactly the same bitmask as passed intoset_mode()
.Returns: The current bitmask of the send-event mode for this device. Return type: SendEventsMode
-
default_mode
¶ The default send-event mode for this device.
The mode defines when the device processes and sends events to the caller.
Returns: The bitmask of the send-event mode for this device. Return type: SendEventsMode
-
-
class
libinput.device.
DeviceConfigAccel
(*args)¶ Pointer acceleration configuration methods.
-
is_available
()¶ Check if a device uses libinput-internal pointer-acceleration.
Returns: False
if the device is not accelerated,True
if it is acceleratedReturn type: bool
-
set_speed
(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.
The actual pointer acceleration mechanism is implementation-dependent, as is the number of steps available within the range. libinput picks the semantically closest acceleration step if the requested value does not match a discrete setting.
Parameters: speed (float) – The normalized speed, in a range of [-1, 1]. Returns: A config status code. Return type: ConfigStatus
-
speed
¶ The current pointer acceleration setting for this pointer device.
The returned value is normalized to a range of [-1, 1]. See
set_speed()
for details.Returns: The current speed, range -1 to 1. Return type: float
-
default_speed
¶ The default speed setting for this device, normalized to a range of [-1, 1].
See
set_speed()
for details.Returns: The default speed setting for this device. Return type: float
-
profiles
¶ A bitmask of the configurable acceleration modes available on this device.
Returns: A bitmask of all configurable modes available on this device. Return type: AccelProfile
-
set_profile
(profile)¶ Set the pointer acceleration profile of this pointer device to the given mode.
Parameters: - profile (AccelProfile) – The mode to set
- device to. (the) –
Returns: A config status code.
Return type:
-
profile
¶ The current pointer acceleration profile for this pointer device.
Returns: The currently configured pointer acceleration profile. Return type: AccelProfile
-
default_profile
¶ The default pointer acceleration profile for this pointer device.
Returns: The default acceleration profile for this device. Return type: AccelProfile
-
-
class
libinput.device.
DeviceConfigScroll
(*args)¶ Scrolling configuration methods.
-
has_natural_scroll
()¶ True
if the device supports “natural scrolling”.In traditional scroll mode, the movement of fingers on a touchpad when scrolling matches the movement of the scroll bars. When the fingers move down, the scroll bar moves down, a line of text on the screen moves towards the upper end of the screen. This also matches scroll wheels on mice (wheel down, content moves up).
Natural scrolling is the term coined by Apple for inverted scrolling. In this mode, the effect of scrolling movement of fingers on a touchpad resemble physical manipulation of paper. When the fingers move down, a line of text on the screen moves down (scrollbars move up). This is the opposite of scroll wheels on mice.
A device supporting natural scrolling can be switched between traditional scroll mode and natural scroll mode.
Returns: False
if natural scrolling is not supported,True
if natural scrolling is supported by this device.Return type: bool
-
set_natural_scroll_enabled
(enable)¶ Enable or disable natural scrolling on the device.
Parameters: enable (bool) – True
to enable,False
to disable natural scrolling.Returns: A config status code. Return type: ConfigStatus
-
natural_scroll_enabled
¶ The current mode for scrolling on this device.
Returns: False
if natural scrolling is disabled,True
if enabled.Return type: bool
-
default_natural_scroll_enabled
¶ The default mode for scrolling on this device.
Returns: False
if natural scrolling is disabled by default,True
if enabled.Return type: bool
-
methods
¶ Check which scroll methods a device supports.
The method defines when to generate scroll axis events instead of pointer motion events.
Returns: A bitmask of possible methods. Return type: ScrollMethod
-
set_method
(method)¶ Set the scroll method for this device.
The method defines when to generate scroll axis events instead of pointer motion events.
Note
Setting
ON_BUTTON_DOWN
enables the scroll method, but scrolling is only activated when the configured button is held down. If no button is set, i.e.button
is 0, scrolling cannot activate.Parameters: method (ScrollMethod) – The scroll method for this device. Returns: A config status code. Return type: ConfigStatus
-
method
¶ The scroll method for this device.
The method defines when to generate scroll axis events instead of pointer motion events.
Returns: The current scroll method for this device. Return type: ScrollMethod
-
default_method
¶ The default scroll method for this device.
The method defines when to generate scroll axis events instead of pointer motion events.
Returns: The default scroll method for this device. Return type: ScrollMethod
Set the button for the
ON_BUTTON_DOWN
method for this device.When the current scroll method is set to
ON_BUTTON_DOWN
, no button press/release events will be send for the configured button.When the configured button is pressed, any motion events along a scroll-capable axis are turned into scroll axis events.
Note
Setting the button does not change the scroll method. To change the scroll method call
set_method()
. If the button is 0, button scrolling is effectively disabled.Parameters: button (int) – The button which when pressed switches to sending scroll events. Returns: A config status code. Return type: ConfigStatus
The button for the
ON_BUTTON_DOWN
method for this device.If
ON_BUTTON_DOWN
scroll method is not supported, or no button is set, this property is 0.Note
The return value is independent of the currently selected scroll-method. For button scrolling to activate, a device must have the
ON_BUTTON_DOWN
method enabled, and a non-zero button set as scroll button.Returns: The button which when pressed switches to sending scroll events. Return type: int
The default button for the
ON_BUTTON_DOWN
method for this device.If
ON_BUTTON_DOWN
scroll method is not supported, or no default button is set, this property is 0.Returns: The default button for the ON_BUTTON_DOWN
method.Return type: int
-
-
class
libinput.device.
DeviceConfigLeftHanded
(*args)¶ Left-handed usage configuration methods.
-
is_available
()¶ Check if a device has a configuration that supports left-handed usage.
Returns: True
if the device can be set to left-handed, orFalse
otherwiseReturn type: bool
-
set
(enable)¶ Set the left-handed configuration of the device.
The exact behavior is device-dependent. On a mouse and most pointing devices, left and right buttons are swapped but the middle button is unmodified. On a touchpad, physical buttons (if present) are swapped. On a clickpad, the top and bottom software-emulated buttons are swapped where present, the main area of the touchpad remains a left button. Tapping and clickfinger behavior is not affected by this setting.
Changing the left-handed configuration of a device may not take effect until all buttons have been logically released.
Parameters: Returns: A configuration status code.
Return type:
-
-
class
libinput.device.
DeviceConfigClick
(*args)¶ Click method configuration methods.
-
methods
¶ Check which button click methods a device supports.
The button click method defines when to generate software-emulated buttons, usually on a device that does not have a specific physical button available.
Returns: A bitmask of possible methods. Return type: ClickMethod
-
set_method
(method)¶ Set the button click method for this device.
The button click method defines when to generate software-emulated buttons, usually on a device that does not have a specific physical button available.
Note
The selected click method may not take effect immediately. The device may require changing to a neutral state first before activating the new method.
Parameters: method (ClickMethod) – The button click method. Returns: A config status code. Return type: ConfigStatus
-
method
¶ The button click method for this device.
The button click method defines when to generate software-emulated buttons, usually on a device that does not have a specific physical button available.
Returns: The current button click method for this device. Return type: ClickMethod
-
default_method
¶ The default button click method for this device.
The button click method defines when to generate software-emulated buttons, usually on a device that does not have a specific physical button available.
Returns: The default button click method for this device. Return type: ClickMethod
-
-
class
libinput.device.
DeviceConfigMiddleEmulation
(*args)¶ Middle mouse button emulation configuration methods.
-
is_available
()¶ Check if middle mouse button emulation configuration is available on this device.
See Middle button emulation for details.
Note
Some devices provide middle mouse button emulation but do not allow enabling/disabling that emulation. These devices return
False
inis_available
.Returns: True
if middle mouse button emulation is available and can be configured,False
otherwise.Return type: bool
-
set_enabled
(state)¶ Enable or disable middle button emulation on this device.
When enabled, a simultaneous press of the left and right button generates a middle mouse button event. Releasing the buttons generates a middle mouse button release, the left and right button events are discarded otherwise.
See Middle button emulation for details.
Parameters: state (MiddleEmulationState) – DISABLED
to disable,ENABLED
to enable middle button emulation.Returns: A config status code. Disabling middle button emulation on a device that does not support middle button emulation always succeeds. Return type: ConfigStatus
-
enabled
¶ Check if configurable middle button emulation is enabled on this device.
See Middle button emulation for details.
If the device does not have configurable middle button emulation, this method returns
DISABLED
.Note
Some devices provide middle mouse button emulation but do not allow enabling/disabling that emulation. These devices always return
DISABLED
.Returns: DISABLED
if disabled or not available/configurable,ENABLED
if enabled.Return type: MiddleEmulationState
-
default_enabled
¶ Check if configurable middle button emulation is enabled by default on this device.
See Middle button emulation for details.
If the device does not have configurable middle button emulation, this method returns
DISABLED
.Note
Some devices provide middle mouse button emulation but do not allow enabling/disabling that emulation. These devices always return
DISABLED
.Returns: DISABLED
if disabled or not available,ENABLED
if enabled.Return type: MiddleEmulationState
-
-
class
libinput.device.
DeviceConfigDwt
(*args)¶ Disable-while-typing configuration methods.
-
is_available
()¶ Check if this device supports configurable disable-while-typing feature.
This feature is usually available on built-in touchpads and disables the touchpad while typing. See Disable-while-typing for details.
Returns: False
if this device does not support disable-while-typing, orTrue
otherwise.Return type: bool
-
set_enabled
(state)¶ Enable or disable the disable-while-typing feature.
When enabled, the device will be disabled while typing and for a short period after. See Disable-while-typing for details.
Note
Enabling or disabling disable-while-typing may not take effect immediately.
Parameters: state (DwtState) – DISABLED
to disable disable-while-typing,ENABLED
to enable.Returns: A config status code. Disabling disable-while-typing on a device that does not support the feature always succeeds. Return type: ConfigStatus
-
-
class
libinput.device.
DeviceConfigRotation
(*args)¶ Rotation configuration methods.
-
is_available
()¶ Check whether a device can have a custom rotation applied.
Returns: True
if a device can be rotated,False
otherwise.Return type: bool
-
set_angle
(degrees_cw)¶ Set the rotation of a device in degrees clockwise off the logical neutral position.
Any subsequent motion events are adjusted according to the given angle.
The angle has to be in the range of [0, 360] degrees, otherwise this method returns
INVALID
. If the angle is a multiple of 360 or negative, the caller must ensure the correct ranging before calling this method.libinput guarantees that this method accepts multiples of 90 degrees. If a value is within the [0, 360] range but not a multiple of 90 degrees, this method may return
INVALID
if the underlying device or implementation does not support finer-grained rotation angles.The rotation angle is applied to all motion events emitted by the device. Thus, rotating the device also changes the angle required or presented by scrolling, gestures, etc.
Parameters: degrees_cw (int) – The angle in degrees clockwise. Returns: A config status code. Setting a rotation of 0 degrees on a device that does not support rotation always succeeds. Return type: ConfigStatus
-