Struct gilrs::mapping::Mapping

source ·
pub struct Mapping {
    mappings: FnvHashMap<EvCode, AxisOrBtn>,
    name: String,
    default: bool,
    hats_mapped: u8,
}
Expand description

Store mappings from one EvCode (u16) to another.

This struct is internal, MappingData is exported in public interface as Mapping.

Fields§

§mappings: FnvHashMap<EvCode, AxisOrBtn>§name: String§default: bool§hats_mapped: u8

Implementations§

source§

impl Mapping

source

pub fn new() -> Self

source

pub fn default(gamepad: &Gamepad) -> Self

source

pub fn name(&self) -> &str

source

pub fn from_data( data: &MappingData, buttons: &[EvCode], axes: &[EvCode], name: &str, uuid: Uuid, ) -> Result<(Self, String), MappingError>

source

pub fn parse_sdl_mapping( line: &str, buttons: &[EvCode], axes: &[EvCode], ) -> Result<Self, ParseSdlMappingError>

source

fn add_button( ident: &str, ev_code: EvCode, mapped_btn: Button, buttons: &[EvCode], sdl_mappings: &mut String, mappings: &mut FnvHashMap<EvCode, AxisOrBtn>, ) -> Result<(), MappingError>

source

fn add_axis( ident: &str, ev_code: EvCode, mapped_axis: Axis, axes: &[EvCode], sdl_mappings: &mut String, mappings: &mut FnvHashMap<EvCode, AxisOrBtn>, ) -> Result<(), MappingError>

source

fn is_name_valid(name: &str) -> bool

source

pub fn map(&self, code: &EvCode) -> Option<AxisOrBtn>

source

pub fn map_rev(&self, el: &AxisOrBtn) -> Option<EvCode>

source

pub fn is_default(&self) -> bool

source

pub fn hats_mapped(&self) -> u8

Return bit field with mapped hats. Only for mappings created from SDL format this function can return non-zero value.

Trait Implementations§

source§

impl Debug for Mapping

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.