Skip to main content

PadBindings

Struct PadBindings 

Source
pub struct PadBindings<A: ActionSet> { /* private fields */ }
Expand description

The player-edited controller buttons: every rebindable action’s button slots, each holding a button or a button chord (ticket 1034; a chord and its buttons on their own are different bindings). One setup for both keyboard layouts (docs/design/controls.md, Rebinding buttons); no button is reserved, and both sticks’ directions count as buttons.

The pure editing API for the Key bindings screen (0816), the same shape as LayoutBindings: bind, clear, defaults (restore defaults), unmapped_required.

Implementations§

Source§

impl<A: ActionSet> PadBindings<A>

Source

pub fn defaults(def: &KeymapDef<A>) -> Self

The default buttons from keymap.ron’s pad table, each action’s buttons in its slots in file order.

Source

pub fn slots(&self, action: A) -> ButtonSlots

action’s button slots (all empty for Debug, which has none).

Source

pub fn find( &self, group: A::Group, button: impl Into<ButtonChord>, ) -> Option<(A, usize)>

The slot of one of group’s actions holding button (a button or a button chord), if any.

Source

pub fn bind( &mut self, action: A, i: usize, button: impl Into<ButtonChord>, ) -> Result<Option<(A, usize)>, BindError<A>>

Puts button (a button or a button chord) in action’s slot i, replacing what was there. If button was in another slot (of any action of action’s group, including action), that slot is emptied and returned: the button moves, which may leave that action with no button. An action of another group keeps it.

Source

pub fn clear(&mut self, action: A, i: usize)

Empties action’s slot i (nothing happens for a slot that doesn’t exist).

Source

pub fn is_unmapped(&self, action: A) -> bool

Whether every slot of action is empty (shows ! not mapped).

Source

pub fn unmapped_required(&self) -> Vec<A>

The required actions with no button, in ActionSet::ALL order. The Key bindings screen can’t be left while this isn’t empty.

Source

pub fn pairs(&self) -> impl Iterator<Item = (ButtonChord, A)> + '_

Every bound button and button chord with its action, for Keymap::with_pad: in action then slot order.

Trait Implementations§

Source§

impl<A: Clone + ActionSet> Clone for PadBindings<A>

Source§

fn clone(&self) -> PadBindings<A>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<A: Debug + ActionSet> Debug for PadBindings<A>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<A: Eq + ActionSet> Eq for PadBindings<A>

Source§

impl<A: PartialEq + ActionSet> PartialEq for PadBindings<A>

Source§

fn eq(&self, other: &PadBindings<A>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<A: PartialEq + ActionSet> StructuralPartialEq for PadBindings<A>

Auto Trait Implementations§

§

impl<A> Freeze for PadBindings<A>

§

impl<A> RefUnwindSafe for PadBindings<A>
where A: RefUnwindSafe,

§

impl<A> Send for PadBindings<A>
where A: Send,

§

impl<A> Sync for PadBindings<A>
where A: Sync,

§

impl<A> Unpin for PadBindings<A>

§

impl<A> UnsafeUnpin for PadBindings<A>

§

impl<A> UnwindSafe for PadBindings<A>
where A: RefUnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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>,

Source§

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.