pub struct Input { /* private fields */ }Expand description
Contiguous action states; reads and sampling allocate nothing after setup.
Multiple physical bindings must be ORed before calling Self::set.
Consume edges after each fixed update, not after every render frame.
use rayengine_core::input::{Action, Input};
const JUMP: Action = Action(0);
let mut input = Input::with_capacity(1);
input.set(JUMP, true);
assert!(input.pressed(JUMP));
input.consume_edges();
assert!(input.down(JUMP));
assert!(!input.pressed(JUMP));Implementations§
Source§impl Input
impl Input
Sourcepub fn routed<'a>(
&'a self,
blocked: &'a [Action],
block_motion: bool,
) -> InputView<'a>
pub fn routed<'a>( &'a self, blocked: &'a [Action], block_motion: bool, ) -> InputView<'a>
Borrows action input with explicit per-update masks, without changing the original states or allocating. Block UI-owned actions and relative look motion before passing this view to gameplay. Held actions resume when unmasked; edges still follow the caller’s normal tick consumption.
Sourcepub fn with_capacity(actions: usize) -> Self
pub fn with_capacity(actions: usize) -> Self
Preallocates action slots to avoid allocation during input sampling.
Sourcepub fn with_capacities(actions: usize, axes: usize) -> Self
pub fn with_capacities(actions: usize, axes: usize) -> Self
Preallocates independent button and analog slots for frame sampling.
Sourcepub fn set_axis(&mut self, axis: Axis, value: f32)
pub fn set_axis(&mut self, axis: Axis, value: f32)
Stores the latest analog value, clamped to [-1, 1]. Nonfinite values
become neutral. Unlike pointer displacement, values persist across ticks.
Sourcepub fn value(&self, axis: Axis) -> f32
pub fn value(&self, axis: Axis) -> f32
Latest sampled analog value. Unbound/unknown axes return zero.
Sourcepub fn set(&mut self, action: Action, down: bool)
pub fn set(&mut self, action: Action, down: bool)
Samples a combined action state. Automatically grows for new action IDs.
Sourcepub fn pressed(&self, action: Action) -> bool
pub fn pressed(&self, action: Action) -> bool
Whether an action was pressed since the last consumed tick.
Sourcepub fn released(&self, action: Action) -> bool
pub fn released(&self, action: Action) -> bool
Whether an action was released since the last consumed tick.
Sourcepub fn axis(&self, negative: Action, positive: Action) -> f32
pub fn axis(&self, negative: Action, positive: Action) -> f32
Digital axis in [-1, 1]; opposing held actions cancel.
Sourcepub fn add_pointer_delta(&mut self, delta: Vec2)
pub fn add_pointer_delta(&mut self, delta: Vec2)
Accumulates relative pointer motion sampled between fixed updates. The SDK supplies logical window units, independent of viewport scaling. Panics for nonfinite motion.
Sourcepub fn pointer_delta(&self) -> Vec2
pub fn pointer_delta(&self) -> Vec2
Relative pointer motion since the previous consumed tick. Apply sensitivity directly; this is displacement, not velocity.
Sourcepub fn reset_pending(&self) -> bool
pub fn reset_pending(&self) -> bool
Whether focus loss/reset occurred since the previous consumed tick. Retained through paused render frames so UI capture can be cancelled even if the window regains focus before simulation resumes.
Sourcepub fn consume_edges(&mut self)
pub fn consume_edges(&mut self)
Clears transitions and pointer motion after one fixed update, preserving held actions.
Sourcepub fn release_all(&mut self)
pub fn release_all(&mut self)
Releases every held action, e.g. on focus loss. Releases are observable.