pub struct Device { /* private fields */ }Expand description
A base handle for accessing libinput devices.
Implementations§
Source§impl Device
impl Device
Sourcepub unsafe fn from_raw(raw: *mut libinput_device) -> Self
pub unsafe fn from_raw(raw: *mut libinput_device) -> Self
Builds a new device from a raw libinput one
§Safety
The caller must ensure it’s passing a valid pointer
Sourcepub fn device_group(&self) -> DeviceGroup
pub fn device_group(&self) -> DeviceGroup
Returns the device group this device is assigned to.
Some physical devices like graphics tablets are represented by multiple kernel devices and thus by multiple libinput devices.
libinput assigns these devices to the same 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 DeviceAdded
and removed from that group on DeviceRemoved. It is up to the
caller to track how many devices are in each device group.
§Example Device Group Structure
mouse -> group1
keyboard -> group2
tablet pen -> group3
tablet touch-> group3
tablet pad -> group3Device 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.
§Note
Device groups are assigned based on the LIBINPUT_DEVICE_GROUP udev property.
See the libinput documentation for more details.
Sourcepub fn product_id(&self) -> u32
pub fn product_id(&self) -> u32
Get the product ID for this device.
Sourcepub fn name(&self) -> &CStr
pub fn name(&self) -> &CStr
The descriptive device name as advertised by the kernel and/or the hardware itself.
To get the sysname for this device, use sysname.
Sourcepub fn sysname(&self) -> &CStr
pub fn sysname(&self) -> &CStr
Get the system name of the device.
To get the descriptive device name, use name.
Sourcepub fn output_name(&self) -> Option<&CStr>
pub fn output_name(&self) -> Option<&CStr>
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.
§Note
Use of this function is discouraged.
Its return value is not precisely defined and may not be understood by the caller or may be insufficient to map the device.
Instead, the system configuration could set a udev property the caller understands and interprets correctly.
The caller could then obtain device with udev_device and query it for this property.
For more complex cases, the caller must implement monitor-to-device association heuristics.
Sourcepub fn seat(&self) -> Seat
pub fn seat(&self) -> Seat
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.
Sourcepub fn udev_device(&self) -> Option<Device>
pub fn udev_device(&self) -> Option<Device>
Return a udev handle to the device that is this libinput device, if any
Some devices may not have a udev device, or the udev device may be unobtainable. Calling this function multiple times for the same device may not return the same udev handle each time.
Sourcepub fn has_capability(&self, capability: DeviceCapability) -> bool
pub fn has_capability(&self, capability: DeviceCapability) -> bool
Check if the given device has the specified capability