Struct Builder

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

A builder for creating a UinputDevice.

Returned by UinputDevice::builder.

Implementations§

Source§

impl Builder

Source

pub fn with_device_id(self, id: InputId) -> Result<Self>

Configures the device’s hardware IDs.

Source

pub fn with_phys(self, path: &str) -> Result<Self>

Sets the physical path of the device.

By default, the physical path of a uinput device is unset, and the corresponding Evdev::phys method will return None.

This method can be used to change that behavior and expose the proper hardware location to consumers.

Source

pub fn with_phys_cstr(self, path: &CStr) -> Result<Self>

Sets the physical path of the device to a CStr.

It is typically easier to use Builder::with_phys instead.

Source

pub fn with_props( self, props: impl IntoIterator<Item = InputProp>, ) -> Result<Self>

Sets the given InputProps for the device.

InputProps can be used to advertise a specific type of device, like a drawing tablet.

Source

pub fn with_keys(self, keys: impl IntoIterator<Item = Key>) -> Result<Self>

Enables the given list of Keys to be reported by the device.

Source

pub fn with_rel_axes(self, rel: impl IntoIterator<Item = Rel>) -> Result<Self>

Enables the given list of Relative axes to be reported by the device.

Source

pub fn with_misc(self, misc: impl IntoIterator<Item = Misc>) -> Result<Self>

Enables the given list of Misc events to be reported by the device.

Source

pub fn with_leds(self, leds: impl IntoIterator<Item = Led>) -> Result<Self>

Enables the given list of Leds.

LEDs may be controlled by either the uinput or evdev side, by writing the appropriate event to the stream.

Source

pub fn with_sounds( self, sounds: impl IntoIterator<Item = Sound>, ) -> Result<Self>

Enables the given list of Sounds.

Sounds are typically played by an Evdev handle by writing the appropriate event to the stream.

Source

pub fn with_switches( self, switches: impl IntoIterator<Item = Switch>, ) -> Result<Self>

Enables the given list of Switches to be reported by the device.

Source

pub fn with_abs_axes( self, axes: impl IntoIterator<Item = AbsSetup>, ) -> Result<Self>

Enables the given list of absolute axes.

The AbsInfo associated with an axis may be changed by an Evdev client via Evdev::set_abs_info.

Source

pub fn with_ff_effects_max(self, ff_max: u32) -> Result<Self>

Sets the maximum number of force-feedback effects that can be played at once.

If this is greater than 0, the device will advertise support for EventType::FF events.

Note that you also have to enable the specific force-feedback features you intend to support by calling Builder::with_ff_features.

Source

pub fn with_ff_features( self, feat: impl IntoIterator<Item = Feature>, ) -> Result<Self>

Advertises the given force-feedback capabilities.

If you call this method, you also have to call Builder::with_ff_effects_max to configure the maximum number of force-feedback effects the device can accept, or the functionality won’t work.

Source

pub fn with_key_repeat(self) -> Result<Self>

Enables support for autorepeat.

If this is called, RepeatEvents may be written to the stream to change the autorepeat settings. This will also allow Evdev clients to query and modify the key repeat settings via Evdev::key_repeat and Evdev::set_key_repeat.

Source

pub fn build(self, name: &str) -> Result<UinputDevice>

Creates the uinput device.

After this method returns successfully, the device will show up in /dev/input and emit hotplug events accordingly.

NOTE: Because of how udev works, devices can show up with incorrect permission bits for a short time, before those permissions are set correctly by the system. This means that calling enumerate immediately after creating a uinput device (or immediately after plugging in a physical device) might fail to access the device. However, hotplug events should arrive only after the device has been given the correct permissions.

§Parameters
  • name: The name of the device. Should be ASCII, and must not be longer than 79 bytes, or this method will return an error.

Trait Implementations§

Source§

impl Debug for Builder

Source§

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

Formats the value using the given formatter. Read more

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> 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, 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.