Skip to main content
← PSoXide SDK guides and examples · SDK f2fec1c301f1 · All Cargo features enabled; check feature gates before use.

PadTracker

Struct PadTracker 

Source
pub struct PadTracker { /* private fields */ }
Expand description

Frame-to-frame tracker over an active-high 16-bit button mask (the PadState::buttons representation).

Implementations§

Source§

impl PadTracker

Source

pub const fn new() -> Self

A tracker with nothing held and nothing suppressed.

Source

pub fn update(&mut self, buttons: u16)

Feed the current frame’s polled buttons. Call exactly once per polled frame, before any queries.

Source

pub fn is_held(&self, mask: u16) -> bool

Any button in mask is currently held (and not suppressed).

Source

pub fn just_pressed(&self, mask: u16) -> bool

Any button in mask went from released to held this frame.

Source

pub fn just_released(&self, mask: u16) -> bool

Any button in mask went from held to released this frame.

Source

pub fn repeats(&self, mask: u16, delay: u8, rate: u8) -> bool

Delay-then-rate auto-repeat for menu cursors: true on the initial press, again delay frames later, then every rate frames while held (PICO-8’s cadence is delay = 15, rate = 4). A rate of 0 is treated as 1 (every frame).

Source

pub fn prime(&mut self)

Suppress every button held right now until it is released and pressed again. Call at a context handoff (launcher starts a game, pause menu closes) so a button held across the transition does not fire in the new context.

Trait Implementations§

Source§

impl Clone for PadTracker

Source§

fn clone(&self) -> PadTracker

Returns a duplicate of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for PadTracker

Source§

fn default() -> Self

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

impl Copy for PadTracker

Auto Trait Implementations§

§

impl Freeze for PadTracker

§

impl RefUnwindSafe for PadTracker

§

impl Send for PadTracker

§

impl Sync for PadTracker

§

impl Unpin for PadTracker

§

impl UnsafeUnpin for PadTracker

§

impl UnwindSafe for PadTracker

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

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

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.