pub struct Device { /* private fields */ }Expand description
Default device abstraction
Implementations§
Source§impl Device
impl Device
Sourcepub const fn axis_count(&self) -> u8
pub const fn axis_count(&self) -> u8
Get axis count
Sourcepub fn axis_mapping(&self) -> &[AbsoluteAxis; 64]
pub fn axis_mapping(&self) -> &[AbsoluteAxis; 64]
Get axes mapping
Sourcepub fn axis_mapping_at(&self, number: u8) -> AbsoluteAxis
pub fn axis_mapping_at(&self, number: u8) -> AbsoluteAxis
Get axis mapping at index
Get button count
Get buttons mapping
Get button mapping at index
Sourcepub fn driver_version(&self) -> u32
pub fn driver_version(&self) -> u32
Get driver version
Sourcepub unsafe fn from_raw_fd(fd: RawFd) -> Result<Self>
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.
Sourcepub fn get_correction_values(&self) -> Result<Vec<Correction>>
pub fn get_correction_values(&self) -> Result<Vec<Correction>>
Retrieve axes correction values. Wraps get_correction_values.
Sourcepub fn get_event(&self) -> Result<DeviceEvent>
pub fn get_event(&self) -> Result<DeviceEvent>
Read en event. Wraps get_event.
Sourcepub fn identifier(&self) -> &str
pub fn identifier(&self) -> &str
Get device identifier
Sourcepub fn new(file: File) -> Result<Self>
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.
Sourcepub fn open<P: AsRef<Path>>(path: P) -> Result<Self>
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.
Sourcepub fn refresh_axis_mapping(&mut self) -> Result<()>
pub fn refresh_axis_mapping(&mut self) -> Result<()>
Refresh axis mapping. Wraps get_axis_mapping.
Refresh button mapping. Wraps get_button_mapping.
Sourcepub fn refresh_mapping(&mut self) -> Result<()>
pub fn refresh_mapping(&mut self) -> Result<()>
Refresh mapping for both axis and buttons
Sourcepub fn set_axis_mapping(&mut self, mapping: &[AbsoluteAxis; 64]) -> Result<()>
pub fn set_axis_mapping(&mut self, mapping: &[AbsoluteAxis; 64]) -> Result<()>
Set axes mapping. Wraps set_axis_mapping.
Sourcepub fn set_axis_mapping_at(
&mut self,
number: u8,
axis: AbsoluteAxis,
) -> Result<()>
pub fn set_axis_mapping_at( &mut self, number: u8, axis: AbsoluteAxis, ) -> Result<()>
Set axis mapping at index. Wraps set_axis_mapping.
Set buttons mapping. Wraps set_button_mapping.
Set button mapping at index. Wraps set_button_mapping.
Sourcepub fn set_correction_values(&self, mapping: &[Correction; 64]) -> Result<()>
pub fn set_correction_values(&self, mapping: &[Correction; 64]) -> Result<()>
Set axes correction values. Wraps set_correction_values.