Device

Struct Device 

Source
pub struct Device { /* private fields */ }
Expand description

A base handle for accessing libinput devices.

Implementations§

Source§

impl Device

Source

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

Source

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  -> group3

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.

§Note

Device groups are assigned based on the LIBINPUT_DEVICE_GROUP udev property. See the libinput documentation for more details.

Source

pub fn product_id(&self) -> u32

Get the product ID for this device.

Source

pub fn vendor_id(&self) -> u32

Get the vendor ID for this device.

Source

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.

Source

pub fn sysname(&self) -> &CStr

Get the system name of the device. To get the descriptive device name, use name.

Source

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.

Source

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.

Source

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.

Source

pub fn has_capability(&self, capability: DeviceCapability) -> bool

Check if the given device has the specified capability

Trait Implementations§

Source§

impl Clone for Device

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Device

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Device

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl Freeze for Device

§

impl RefUnwindSafe for Device

§

impl !Send for Device

§

impl !Sync for Device

§

impl Unpin for Device

§

impl UnwindSafe for Device

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more