pub struct Builder { /* private fields */ }Expand description
A builder for creating a UinputDevice.
Returned by UinputDevice::builder.
Implementations§
Source§impl Builder
impl Builder
Sourcepub fn with_device_id(self, id: InputId) -> Result<Self>
pub fn with_device_id(self, id: InputId) -> Result<Self>
Configures the device’s hardware IDs.
Sourcepub fn with_phys(self, path: &str) -> Result<Self>
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.
Sourcepub fn with_phys_cstr(self, path: &CStr) -> Result<Self>
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.
Sourcepub fn with_props(
self,
props: impl IntoIterator<Item = InputProp>,
) -> Result<Self>
pub fn with_props( self, props: impl IntoIterator<Item = InputProp>, ) -> Result<Self>
Sourcepub fn with_keys(self, keys: impl IntoIterator<Item = Key>) -> Result<Self>
pub fn with_keys(self, keys: impl IntoIterator<Item = Key>) -> Result<Self>
Enables the given list of Keys to be reported by the device.
Sourcepub fn with_rel_axes(self, rel: impl IntoIterator<Item = Rel>) -> Result<Self>
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.
Sourcepub fn with_misc(self, misc: impl IntoIterator<Item = Misc>) -> Result<Self>
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.
Sourcepub fn with_leds(self, leds: impl IntoIterator<Item = Led>) -> Result<Self>
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.
Sourcepub fn with_sounds(
self,
sounds: impl IntoIterator<Item = Sound>,
) -> Result<Self>
pub fn with_sounds( self, sounds: impl IntoIterator<Item = Sound>, ) -> Result<Self>
Sourcepub fn with_switches(
self,
switches: impl IntoIterator<Item = Switch>,
) -> Result<Self>
pub fn with_switches( self, switches: impl IntoIterator<Item = Switch>, ) -> Result<Self>
Enables the given list of Switches to be reported by the device.
Sourcepub fn with_abs_axes(
self,
axes: impl IntoIterator<Item = AbsSetup>,
) -> Result<Self>
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.
Sourcepub fn with_ff_effects_max(self, ff_max: u32) -> Result<Self>
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.
Sourcepub fn with_ff_features(
self,
feat: impl IntoIterator<Item = Feature>,
) -> Result<Self>
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.
Sourcepub fn with_key_repeat(self) -> Result<Self>
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.
Sourcepub fn build(self, name: &str) -> Result<UinputDevice>
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.