Struct Device

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

Default device abstraction

Implementations§

Source§

impl Device

Source

pub const fn axis_count(&self) -> u8

Get axis count

Source

pub fn axis_mapping(&self) -> &[AbsoluteAxis; 64]

Get axes mapping

Source

pub fn axis_mapping_at(&self, number: u8) -> AbsoluteAxis

Get axis mapping at index

Source

pub const fn button_count(&self) -> u8

Get button count

Source

pub fn button_mapping(&self) -> &[Key; 512]

Get buttons mapping

Source

pub fn button_mapping_at(&self, number: u8) -> Key

Get button mapping at index

Source

pub fn driver_version(&self) -> u32

Get driver version

Source

pub unsafe fn from_raw_fd(fd: RawFd) -> Result<Self>

Create new device from raw fd

This function expects the file to be opened at least in read mode. Other flags are optional. Non-blocking mode is recommended unless you really don’t want it. Other flags shouldn’t have any impact.

If the file is not a valid device node the will fail gracefully.

§Safety

Safety is equivalent to that of std::fs::File::from_raw_fd.

Source

pub fn get_correction_values(&self) -> Result<Vec<Correction>>

Retrieve axes correction values. Wraps get_correction_values.

Source

pub fn get_event(&self) -> Result<DeviceEvent>

Read en event. Wraps get_event.

Source

pub fn identifier(&self) -> &str

Get device identifier

Source

pub fn new(file: File) -> Result<Self>

Create new device from file

This function expects the file to be opened at least in read mode. Other flags are optional. Non-blocking mode is recommended unless you really don’t want it. Other flags shouldn’t have any impact.

If the file is not a valid device node the will fail gracefully.

Source

pub fn open<P: AsRef<Path>>(path: P) -> Result<Self>

Create new device by opening file at path

This function always tries opening the file in read-only and non-blocking mode.

If the file is not a valid device node the will fail gracefully.

Source

pub fn refresh_axis_mapping(&mut self) -> Result<()>

Refresh axis mapping. Wraps get_axis_mapping.

Source

pub fn refresh_button_mapping(&mut self) -> Result<()>

Refresh button mapping. Wraps get_button_mapping.

Source

pub fn refresh_mapping(&mut self) -> Result<()>

Refresh mapping for both axis and buttons

Source

pub fn set_axis_mapping(&mut self, mapping: &[AbsoluteAxis; 64]) -> Result<()>

Set axes mapping. Wraps set_axis_mapping.

Source

pub fn set_axis_mapping_at( &mut self, number: u8, axis: AbsoluteAxis, ) -> Result<()>

Set axis mapping at index. Wraps set_axis_mapping.

Source

pub fn set_button_mapping(&mut self, mapping: &[Key; 512]) -> Result<()>

Set buttons mapping. Wraps set_button_mapping.

Source

pub fn set_button_mapping_at(&mut self, number: u8, button: Key) -> Result<()>

Set button mapping at index. Wraps set_button_mapping.

Source

pub fn set_correction_values(&self, mapping: &[Correction; 64]) -> Result<()>

Set axes correction values. Wraps set_correction_values.

Trait Implementations§

Source§

impl AsRawFd for Device

Source§

fn as_raw_fd(&self) -> RawFd

Extracts the raw file descriptor. 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 IntoRawFd for Device

Source§

fn into_raw_fd(self) -> RawFd

Consumes this object, returning the raw underlying file descriptor. 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> 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.