Louvre  v2.9.0-1
C++ library for Wayland compositors
Public Types | Public Member Functions | List of all members
LInputDevice Class Reference

Input Device. More...

Public Types

enum  Capability : UInt32
 Input device capabilities. More...
 

Public Member Functions

bool hasCapability (Capability capability) const noexcept
 Checks if the device has the given capability. More...
 
const std::string & name () const noexcept
 Gets the name of the input device. More...
 
UInt32 productId () const noexcept
 Gets the product ID of the input device. More...
 
UInt32 vendorId () const noexcept
 Gets the vendor ID of the input device. More...
 
void * nativeHandle () const noexcept
 Native data structure used by the current input backend. More...
 

Detailed Description

Input Device.

This class provides basic information about an input device and a way to access its underlying backend handle so that it can be configured using backend-specific APIs.

Use LSeat::inputDevices() to access all available devices, and LSeat::inputDevicePlugged() and LSeat::inputDeviceUnplugged() to listen for hotplug events.

Each subtype of LInputEvent provides access to the input device that generated it through LInputEvent::device().

Note
LInputDevice instances are not destroyed when the device is unplugged, but its nativeHandle() will return nullptr.

Capabilities

Devices are not categorized by type but by their capabilities. Use hasCapability() to check for a specific capability.

Configuration

Louvre does not provide a generic API for configuring input devices. Instead, nativeHandle() can be used to access the data structure used by the current input backend. For example, if the LInputBackendLibinput backend is used, the native handle represents a libinput_device struct, which can be configured through the libinput API.

Use LCompositor::inputBackendId() to check which input backend is currently loaded.

Warning
nativeHandle() can return nullptr if the input backend does not provide a handle or if the input device has been unplugged.

Member Enumeration Documentation

◆ Capability

Input device capabilities.

Enumerator
Pointer 

Pointer.

Keyboard 

Keyboard.

Touch 

Touch.

TabletTool 

Tablet Tool.

TabletPad 

Tablet Pad.

Gestures 

Gestures.

Switch 

Switch.

Member Function Documentation

◆ hasCapability()

bool hasCapability ( Capability  capability) const
inlinenoexcept

Checks if the device has the given capability.

Parameters
capabilityThe capability to check.
Returns
true if the device has the capability, otherwise false.

◆ name()

const std::string& name ( ) const
inlinenoexcept

Gets the name of the input device.

◆ productId()

UInt32 productId ( ) const
inlinenoexcept

Gets the product ID of the input device.

◆ vendorId()

UInt32 vendorId ( ) const
inlinenoexcept

Gets the vendor ID of the input device.

◆ nativeHandle()

void* nativeHandle ( ) const
inlinenoexcept

Native data structure used by the current input backend.

See also
LCompositor::inputBackendContextHandle().
Warning
This method can return nullptr in cases where the input backend does not provide a handle or the input device has been unplugged.
Returns
A pointer to the native data structure.