Skip to main content

Input

Struct Input 

Source
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

Source

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.

Source

pub fn with_capacity(actions: usize) -> Self

Preallocates action slots to avoid allocation during input sampling.

Source

pub fn with_capacities(actions: usize, axes: usize) -> Self

Preallocates independent button and analog slots for frame sampling.

Source

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.

Source

pub fn value(&self, axis: Axis) -> f32

Latest sampled analog value. Unbound/unknown axes return zero.

Source

pub fn set(&mut self, action: Action, down: bool)

Samples a combined action state. Automatically grows for new action IDs.

Source

pub fn down(&self, action: Action) -> bool

Whether an action is currently held.

Source

pub fn pressed(&self, action: Action) -> bool

Whether an action was pressed since the last consumed tick.

Source

pub fn released(&self, action: Action) -> bool

Whether an action was released since the last consumed tick.

Source

pub fn axis(&self, negative: Action, positive: Action) -> f32

Digital axis in [-1, 1]; opposing held actions cancel.

Source

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.

Source

pub fn pointer_delta(&self) -> Vec2

Relative pointer motion since the previous consumed tick. Apply sensitivity directly; this is displacement, not velocity.

Source

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.

Source

pub fn consume_edges(&mut self)

Clears transitions and pointer motion after one fixed update, preserving held actions.

Source

pub fn release_all(&mut self)

Releases every held action, e.g. on focus loss. Releases are observable.

Trait Implementations§

Source§

impl Debug for Input

Source§

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

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

impl Default for Input

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Input

§

impl RefUnwindSafe for Input

§

impl Send for Input

§

impl Sync for Input

§

impl Unpin for Input

§

impl UnsafeUnpin for Input

§

impl UnwindSafe for Input

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> Component for T
where T: Send + Sync + 'static,

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.