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
Creates new Mapping
.
Returns NativeEvCode
associated with button index.
fn axis(&self, idx: Axis) -> Option<NativeEvCode>
Returns NativeEvCode
associated with axis index.
Trait Implementations
impl Debug for MappingData
[src]
impl Clone for MappingData
[src]
fn clone(&self) -> MappingData
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
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
The method for 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
The method for the indexing (container[index]
) operation
impl IndexMut<Button> for MappingData
[src]
fn index_mut(&mut self, index: Button) -> &mut Self::Output
The method for the mutable indexing (container[index]
) operation