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]

Creates new Mapping.

Returns NativeEvCode associated with button index.

Returns NativeEvCode associated with axis index.

Trait Implementations

impl Debug for MappingData
[src]

Formats the value using the given formatter.

impl Clone for MappingData
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Index<Button> for MappingData
[src]

The returned type after indexing

The method for the indexing (container[index]) operation

impl Index<Axis> for MappingData
[src]

The returned type after indexing

The method for the indexing (container[index]) operation

impl IndexMut<Button> for MappingData
[src]

The method for the mutable indexing (container[index]) operation

impl IndexMut<Axis> for MappingData
[src]

The method for the mutable indexing (container[index]) operation