pub struct GamepadMap {
pub sprint: GamepadButton,
pub jump: GamepadButton,
pub interact: GamepadButton,
}Expand description
The canonical action -> gamepad button map. Persisted in the engine’s
controls settings and applied by the input sampling; carried live to
consumers via ControlsCommand on a rebind. Each field is
#[serde(default)] so adding an action in a future build never invalidates
an existing settings file.
Fields§
§sprint: GamepadButtonHeld to sprint while moving.
jump: GamepadButtonOne-frame jump press.
interact: GamepadButtonOne-frame interact press.
Implementations§
Source§impl GamepadMap
impl GamepadMap
Sourcepub const DEFAULT: GamepadMap
pub const DEFAULT: GamepadMap
The default bindings: sprint on the left-stick click, jump on the bottom face button, interact on the left face button.
Sourcepub fn get(self, action: GamepadAction) -> GamepadButton
pub fn get(self, action: GamepadAction) -> GamepadButton
The button currently bound to an action.
Sourcepub fn set(&mut self, action: GamepadAction, button: GamepadButton)
pub fn set(&mut self, action: GamepadAction, button: GamepadButton)
Bind an action to a button directly (no conflict handling).
The action a button is bound to, or None if unbound. The map keeps
each button bound to at most one action (the invariant rebind
maintains), so this is the unique holder.
Sourcepub fn rebind(&mut self, action: GamepadAction, new_button: GamepadButton)
pub fn rebind(&mut self, action: GamepadAction, new_button: GamepadButton)
Bind action to new_button, swapping with whichever action already
holds new_button so every action stays bound. Rebinding an action to
its own button is a no-op.
Trait Implementations§
Source§impl Clone for GamepadMap
impl Clone for GamepadMap
Source§fn clone(&self) -> GamepadMap
fn clone(&self) -> GamepadMap
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for GamepadMap
Source§impl Debug for GamepadMap
impl Debug for GamepadMap
Source§impl Default for GamepadMap
impl Default for GamepadMap
Source§fn default() -> GamepadMap
fn default() -> GamepadMap
Source§impl<'de> Deserialize<'de> for GamepadMap
impl<'de> Deserialize<'de> for GamepadMap
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<GamepadMap, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<GamepadMap, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
impl Eq for GamepadMap
Source§impl PartialEq for GamepadMap
impl PartialEq for GamepadMap
Source§impl Serialize for GamepadMap
impl Serialize for GamepadMap
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for GamepadMap
Auto Trait Implementations§
impl Freeze for GamepadMap
impl RefUnwindSafe for GamepadMap
impl Send for GamepadMap
impl Sync for GamepadMap
impl Unpin for GamepadMap
impl UnsafeUnpin for GamepadMap
impl UnwindSafe for GamepadMap
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().