Struct gilrs::Mapping
[−]
[src]
pub struct Mapping { /* fields omitted */ }
Stores data used to map gamepad buttons and axes.
To add new element, you should use IndexMut
operator using Axis
or Button
as index (see
example). After you add all mappings, use
Gamepad::set_mapping(…)
to change mapping of
existing gamepad.
Example
use gilrs::{Mapping, Button, Axis}; let mut data = Mapping::new(); // map native event code 3 to Axis::LeftStickX data[Axis::LeftStickX] = 3; // map native event code 3 to Button::South (although both are 3, // they refer to different things) data[Button::South] = 3; assert_eq!(data.axis(Axis::LeftStickX), Some(3)); assert_eq!(data.button(Button::South), Some(3));
See examples/mapping.rs
for more detailed example.
Methods
impl MappingData
[src]
fn new() -> Self
[src]
Creates new Mapping
.
[src]
Returns NativeEvCode
associated with button index.
fn axis(&self, idx: Axis) -> Option<NativeEvCode>
[src]
Returns NativeEvCode
associated with axis index.
[src]
Removes button and returns associated NativEvCode
.
fn remove_axis(&mut self, idx: Axis) -> Option<NativeEvCode>
[src]
Removes axis and returns associated NativEvCode
.
Trait Implementations
impl Debug for MappingData
[src]
impl Clone for MappingData
[src]
fn clone(&self) -> MappingData
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Index<Button> for MappingData
[src]
type Output = NativeEvCode
The returned type after indexing.
fn index(&self, index: Button) -> &Self::Output
[src]
Performs the indexing (container[index]
) operation.
impl Index<Axis> for MappingData
[src]
type Output = NativeEvCode
The returned type after indexing.
fn index(&self, index: Axis) -> &Self::Output
[src]
Performs the indexing (container[index]
) operation.
impl IndexMut<Button> for MappingData
[src]
fn index_mut(&mut self, index: Button) -> &mut Self::Output
[src]
Performs the mutable indexing (container[index]
) operation.