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]

[src]

Creates new Mapping.

[src]

Returns NativeEvCode associated with button index.

[src]

Returns NativeEvCode associated with axis index.

[src]

Removes button and returns associated NativEvCode.

[src]

Removes axis and returns associated NativEvCode.

Trait Implementations

impl Debug for MappingData
[src]

[src]

Formats the value using the given formatter.

impl Clone for MappingData
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Index<Button> for MappingData
[src]

The returned type after indexing.

[src]

Performs the indexing (container[index]) operation.

impl Index<Axis> for MappingData
[src]

The returned type after indexing.

[src]

Performs the indexing (container[index]) operation.

impl IndexMut<Button> for MappingData
[src]

[src]

Performs the mutable indexing (container[index]) operation.

impl IndexMut<Axis> for MappingData
[src]

[src]

Performs the mutable indexing (container[index]) operation.