[][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.

Examples

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
    }
)

Methods

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>>
[src]

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
[src]

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
[src]

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>>
[src]

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
[src]

Removes an action binding that was assigned previously.

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

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]

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

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

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

Auto Trait Implementations

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

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

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

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

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

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

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

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

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

impl<T> SetParameter for T

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

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

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> Any for T where
    T: Any

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

impl<T> TryDefault for T where
    T: Default

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