pub struct InputBindingMap { /* private fields */ }Expand description
Rebindable input binding map. Maps VirtualKey → InputAction. Multiple keys can map to the same action, but each key maps to at most one action. If a single physical input should trigger context-dependent behavior (e.g., MouseLeft is PrimaryAction in UI but Attack in combat), resolve that at the game layer, not here.
Implementations§
Source§impl InputBindingMap
impl InputBindingMap
pub fn new() -> Self
Sourcepub fn default_bindings() -> Self
pub fn default_bindings() -> Self
Create default WASD + mouse bindings for tile-based and 3D movement.
Sourcepub fn bind(&mut self, key: VirtualKey, action: InputAction)
pub fn bind(&mut self, key: VirtualKey, action: InputAction)
Bind a key to an action.
Sourcepub fn unbind(&mut self, key: VirtualKey)
pub fn unbind(&mut self, key: VirtualKey)
Remove a binding.
Sourcepub fn action_for(&self, key: VirtualKey) -> Option<InputAction>
pub fn action_for(&self, key: VirtualKey) -> Option<InputAction>
Look up the action for a key.
Sourcepub fn iter(&self) -> impl Iterator<Item = (&VirtualKey, &InputAction)>
pub fn iter(&self) -> impl Iterator<Item = (&VirtualKey, &InputAction)>
All bindings as (key, action) pairs.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for InputBindingMap
impl RefUnwindSafe for InputBindingMap
impl Send for InputBindingMap
impl Sync for InputBindingMap
impl Unpin for InputBindingMap
impl UnsafeUnpin for InputBindingMap
impl UnwindSafe for InputBindingMap
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
Mutably borrows from an owned value. Read more