[][src]Struct amethyst_input::Bindings

pub struct Bindings<T: BindingTypes> { /* fields omitted */ }

Used for saving and loading input settings.

An action can either be a single button or a combination of them.


Example Ron config file:

    axes: {
        "updown": Emulated(
            pos: Key(Up),
            neg: Key(Down)
        "leftright": Emulated(
            pos: Key(Right),
            neg: Key(Left)
    actions: {
        "fire": [ [Mouse(Left)], [Key(X)] ], // Multiple bindings for one action
        "reload": [ [Key(LControl), Key(R)] ] // Combinations of multiple bindings possible


impl<T: BindingTypes> Bindings<T>[src]

pub fn new() -> Self[src]

Creates a new empty Bindings structure

impl<T: BindingTypes> Bindings<T>[src]

pub fn insert_axis<A: Into<T::Axis>>(
    &mut self,
    id: A,
    axis: Axis
) -> Result<Option<Axis>, BindingError<T>>

Assign an axis to an ID value

This will insert a new axis if no entry for this id exists. If one does exist this will replace the axis at that id and return it.

pub fn remove_axis<A: ?Sized>(&mut self, id: &A) -> Option<Axis> where
    T::Axis: Borrow<A>,
    A: Hash + Eq

Removes an axis, this will return the removed axis if successful.

pub fn axis<A: ?Sized>(&self, id: &A) -> Option<&Axis> where
    T::Axis: Borrow<A>,
    A: Hash + Eq

Returns a reference to an axis.

pub fn axes(&self) -> impl Iterator<Item = &T::Axis>[src]

Gets a list of all axes

pub fn insert_action_binding<B: IntoIterator<Item = Button>>(
    &mut self,
    id: T::Action,
    binding: B
) -> Result<(), BindingError<T>>

Add a button or button combination to an action.

This will attempt to insert a new binding between this action and the button(s).

pub fn remove_action_binding<A: ?Sized>(
    &mut self,
    id: &A,
    binding: &[Button]
) -> Result<(), ActionRemovedError> where
    T::Action: Borrow<A>,
    A: Hash + Eq

Removes an action binding that was assigned previously.

pub fn action_bindings<A: ?Sized>(
    id: &A
) -> impl Iterator<Item = &[Button]> where
    T::Action: Borrow<A>,
    A: Hash + Eq

Returns an action's bindings.

pub fn actions(&self) -> impl Iterator<Item = &T::Action>[src]

Gets a list of all action bindings

pub fn check_invariants(&mut self) -> Result<(), BindingError<T>>[src]

Check that this structure upholds its guarantees. Should only be necessary when serializing or deserializing the bindings.

Trait Implementations

impl<T: BindingTypes> Default for Bindings<T>[src]

impl<T: BindingTypes> Clone for Bindings<T>[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<T: BindingTypes> Debug for Bindings<T>[src]

impl<T: BindingTypes> Serialize for Bindings<T> where
    T::Axis: Serialize,
    T::Action: Serialize

impl<'de, T: BindingTypes> Deserialize<'de> for Bindings<T> where
    T::Axis: Deserialize<'de>,
    T::Action: Deserialize<'de>, 

Auto Trait Implementations

impl<T> Send for Bindings<T> where
    <T as BindingTypes>::Action: Send,
    <T as BindingTypes>::Axis: Send

impl<T> Sync for Bindings<T> where
    <T as BindingTypes>::Action: Sync,
    <T as BindingTypes>::Axis: Sync

Blanket Implementations

impl<T> From<T> for T[src]

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

impl<T> ToOwned for T where
    T: Clone

type Owned = T

The resulting type after obtaining ownership.

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

type Error = Infallible

The type returned in the event of a conversion error.

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.

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

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

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

impl<T> SetParameter for T

fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
    T: Parameter<Self>, 

Sets value as a parameter of self.

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 

impl<T> Config for T where
    T: Deserialize<'a> + Serialize + Default

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<SS, SP> SupersetOf<SS> for SP where
    SS: SubsetOf<SP>, 

impl<T> Event for T where
    T: Send + Sync + 'static, 

impl<T> Resource for T where
    T: Any + Send + Sync

impl<T> TryDefault for T where
    T: Default

fn unwrap_default() -> Self

Calls try_default and panics on an error case.

impl<T> Any for T where
    T: Any