Skip to main content

FrameInput

Struct FrameInput 

Source
pub struct FrameInput<'w, A: Action> { /* private fields */ }
Expand description

Read-only logical input for the current FrameUpdate delivery.

This custom System parameter deliberately exposes no ResMut path to the runtime-owned snapshot.

Implementations§

Source§

impl<A: Action> FrameInput<'_, A>

Source

pub fn scroll_events(&self) -> impl Iterator<Item = PointerScrollEvent> + '_

Iterates over wheel events in physical order, retaining fractional line or logical-pixel units and event-time pointers. Events are frame-only, even while paused, and a focus-loss frame has no wheel events.

Source

pub fn events(&self) -> impl Iterator<Item = FrameInputEvent<A>> + '_

Interleaves action edges and wheel occurrences in physical event order. Use this when a wheel changes the camera used to interpret nearby clicks. Synthesized cancellation releases retain their normal ordering. Each queue has the input event limit; the merged view allocates no storage.

Source

pub fn relative_motion(&self) -> RelativePointerMotion

Returns this frame’s raw displacement. Apply sensitivity once, without delta-time scaling. No fixed-tick delivery or transition replay occurs.

Source

pub fn focus_lost(&self) -> bool

Reports a focus-loss boundary even when no mapped control was held. All relative motion and wheel events in that accepted batch are discarded.

Source

pub fn pointer(&self) -> Option<PointerSample>

Returns the latest accepted pointer sample, or None before motion or after leaving. Inactive-stage snapshots are empty. Use an action edge’s ActionEdge::pointer for the position of a particular click.

Source

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

Returns whether at least one bound key or mouse button for action is held.

Source

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

Returns whether this frame contains at least one press occurrence.

This does not consume the occurrence and is independent from aggregate Self::held state: another physical key for the same action may already be held, and one frame may contain both press and release occurrences. Use Self::pressed when occurrence count, order, or intent tokens are needed.

Source

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

Returns whether this frame contains at least one release occurrence.

This does not consume the occurrence. It can return true while Self::held also returns true when another physical key remains bound to and held for the same action. Use Self::released when occurrence count, order, or intent tokens are needed.

Source

pub fn digital_axis(&self, axis: DigitalAxis2d<A>) -> Vec2

Samples four held actions as a raw digital axis.

Each component is exactly -1.0, 0.0, or 1.0; opposite directions cancel. This performs four held-state lookups without allocation and does not read or consume action edges. Use Self::normalized_digital_axis when diagonal movement should retain cardinal speed.

Source

pub fn normalized_digital_axis(&self, axis: DigitalAxis2d<A>) -> Vec2

Samples four held actions as a constant-speed digital direction.

This is exactly equivalent to self.digital_axis(axis).normalized(): no input or mutually cancelled directions produce Vec2::ZERO, cardinal directions stay unchanged, and non-zero diagonals have unit length. It performs no allocation and neither reads nor consumes action edges. Use Self::digital_axis when raw diagonal magnitude or grid semantics are wanted.

Source

pub fn pressed(&self, action: A) -> impl Iterator<Item = ActionEdge<A>> + '_

Iterates over every press occurrence for action in event order.

Source

pub fn edges(&self) -> impl Iterator<Item = ActionEdge<A>> + '_

Iterates over all action edges in physical event order.

Use this for gestures whose presses and releases can both arrive in one display frame. Each mouse edge keeps its own event-time pointer; the latest pointer is not necessarily the release endpoint.

Source

pub fn released(&self, action: A) -> impl Iterator<Item = ActionEdge<A>> + '_

Iterates over every release occurrence for action in event order.

Trait Implementations§

Source§

impl<'w, 's, A: Action> ReadOnlySystemParam for FrameInput<'w, A>
where Res<'w, FrameInputState<A>>: ReadOnlySystemParam,

Source§

impl<A: Action> SystemParam for FrameInput<'_, A>

Source§

type State = FetchState<A>

Used to store data which persists across invocations of a system.
Source§

type Item<'w, 's> = FrameInput<'w, A>

The item type returned when constructing this system param. The value of this associated type should be Self, instantiated with new lifetimes. Read more
Source§

fn init_state(world: &mut World) -> Self::State

Creates a new instance of this param’s State.
Source§

fn init_access( state: &Self::State, system_meta: &mut SystemMeta, component_access_set: &mut FilteredAccessSet, world: &mut World, )

Registers any World access used by this SystemParam. Read more
Source§

fn apply(state: &mut Self::State, system_meta: &SystemMeta, world: &mut World)

Applies any deferred mutations stored in this SystemParam’s state. This is used to apply Commands during ApplyDeferred.
Source§

fn queue( state: &mut Self::State, system_meta: &SystemMeta, world: DeferredWorld<'_>, )

Queues any deferred mutations to be applied at the next ApplyDeferred.
Source§

unsafe fn get_param<'w, 's>( state: &'s mut Self::State, system_meta: &SystemMeta, world: UnsafeWorldCell<'w>, change_tick: Tick, ) -> Result<Self::Item<'w, 's>, SystemParamValidationError>

Creates a parameter to be passed into a SystemParamFunction. Read more

Auto Trait Implementations§

§

impl<'w, A> Freeze for FrameInput<'w, A>
where Res<'w, FrameInputState<A>>: Freeze,

§

impl<'w, A> RefUnwindSafe for FrameInput<'w, A>
where Res<'w, FrameInputState<A>>: RefUnwindSafe,

§

impl<'w, A> Send for FrameInput<'w, A>
where Res<'w, FrameInputState<A>>: Send,

§

impl<'w, A> Sync for FrameInput<'w, A>
where Res<'w, FrameInputState<A>>: Sync,

§

impl<'w, A> Unpin for FrameInput<'w, A>
where Res<'w, FrameInputState<A>>: Unpin,

§

impl<'w, A> UnsafeUnpin for FrameInput<'w, A>
where Res<'w, FrameInputState<A>>: UnsafeUnpin,

§

impl<'w, A> UnwindSafe for FrameInput<'w, A>
where Res<'w, FrameInputState<A>>: UnwindSafe,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> ConditionalSend for T
where T: Send,

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoResult<T> for T

Source§

fn into_result(self) -> Result<T, RunSystemError>

Converts this type into the system output type.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more