Skip to main content

InputDevice

Struct InputDevice 

Source
pub struct InputDevice(pub u64);
Expand description

An input device.

Tuple Fields§

§0: u64

Implementations§

Source§

impl InputDevice

Source

pub fn set_seat(self, seat: Seat)

Assigns the input device to a seat.

Source

pub fn set_keymap(self, keymap: Keymap)

Sets the keymap of the device.

This overrides the keymap set for the seat. The keymap becomes active when a key on the device is pressed.

Setting the invalid keymap reverts to the seat keymap.

Source

pub fn has_capability(self, cap: Capability) -> bool

Returns whether the device has the specified capability.

Source

pub fn set_left_handed(self, left_handed: bool)

Sets the device to be left handed.

This has the effect of swapping the left and right mouse button. See the libinput documentation for more details.

Source

pub fn set_accel_profile(self, profile: AccelProfile)

Sets the acceleration profile of the device.

This corresponds to the libinput setting of the same name.

Source

pub fn set_accel_speed(self, speed: f64)

Sets the acceleration speed of the device.

This corresponds to the libinput setting of the same name.

Source

pub fn set_transform_matrix(self, matrix: [[f64; 2]; 2])

Sets the transformation matrix of the device.

This is not a libinput setting but a setting of the compositor. It currently affects relative mouse motions in that the matrix is applied to the motion. To reduce the mouse speed to 35%, use the following matrix:

[
    [0.35, 1.0],
    [1.0, 0.35],
]

This might give you better results than using set_accel_profile and set_accel_speed.

Source

pub fn set_calibration_matrix(self, matrix: [[f32; 3]; 2])

Sets the calibration matrix of the device.

This corresponds to the libinput setting of the same name.

Source

pub fn name(self) -> String

Returns the name of the device.

Source

pub fn set_px_per_wheel_scroll(self, px: f64)

Sets how many pixel to scroll per scroll wheel dedent.

Default: 15.0

This setting has no effect on non-wheel input such as touchpads.

Some mouse wheels support high-resolution scrolling without discrete steps. In this case a value proportional to this setting will be used.

Source

pub fn set_px_scroll_multiplier(self, mul: f64)

Sets a multiplier for pixel scroll events.

Default: 1.0

This setting has no effect on scroll events created by a scroll wheel.

Source

pub fn set_tap_enabled(self, enabled: bool)

Sets whether tap-to-click is enabled for this device.

See https://wayland.freedesktop.org/libinput/doc/latest/tapping.html

Source

pub fn set_drag_enabled(self, enabled: bool)

Sets whether tap-and-drag is enabled for this device.

See https://wayland.freedesktop.org/libinput/doc/latest/tapping.html

Source

pub fn set_drag_lock_enabled(self, enabled: bool)

Sets whether drag lock is enabled for this device.

See https://wayland.freedesktop.org/libinput/doc/latest/tapping.html

Source

pub fn set_natural_scrolling_enabled(self, enabled: bool)

Sets whether natural scrolling is enabled for this device.

See https://wayland.freedesktop.org/libinput/doc/latest/scrolling.html

Source

pub fn set_click_method(self, method: ClickMethod)

Source

pub fn set_middle_button_emulation_enabled(self, enabled: bool)

Sets whether middle button emulation is enabled for this device.

See https://wayland.freedesktop.org/libinput/doc/latest/configuration.html#middle-button-emulation

Source

pub fn set_scroll_method(self, method: ScrollMethod)

Source

pub fn set_scroll_button(self, button: InputEventCode)

Source

pub fn set_scroll_button_lock(self, enabled: bool)

Sets whether scroll button locking is enabled for the device.

See https://wayland.freedesktop.org/libinput/doc/latest/scrolling.html

Source

pub fn syspath(self) -> String

Returns the syspath of this device.

E.g. /sys/devices/pci0000:00/0000:00:08.1/0000:14:00.4/usb5/5-1/5-1.1/5-1.1.3/5-1.1.3:1.0.

Source

pub fn devnode(self) -> String

Returns the devnode of this device.

E.g. /dev/input/event7.

Source

pub fn on_switch_event<F: FnMut(SwitchEvent) + 'static>(self, f: F)

Sets a callback that will be run if this device triggers a switch event.

Source

pub fn set_connector(self, connector: Connector)

Maps this input device to a connector.

The connector should be connected.

This should be used for touch screens and graphics tablets.

Source

pub fn remove_mapping(self)

Removes the mapping of this device to a connector.

Trait Implementations§

Source§

impl Clone for InputDevice

Source§

fn clone(&self) -> InputDevice

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for InputDevice

Source§

impl Debug for InputDevice

Source§

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

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

impl<'de> Deserialize<'de> for InputDevice

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for InputDevice

Source§

impl Hash for InputDevice

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for InputDevice

Source§

fn eq(&self, other: &InputDevice) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for InputDevice

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for InputDevice

Auto Trait Implementations§

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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.