Expand description
Frame-to-frame button tracking: edges, auto-repeat, handoff suppression.
Every project grew this trio by hand: gameplay wants just-pressed edges
((new ^ prev) & new), menu cursors want delay-then-rate auto-repeat,
and anything that switches contexts (a collection launcher starting a
game, a menu opening over gameplay) wants buttons already held at the
handoff ignored until re-pressed. One tracker, fed the polled button
mask once per frame, answers all three.
ⓘ
let mut pad = PadTracker::new();
loop {
pad.update(poll_port1().buttons);
if pad.just_pressed(button::CROSS) { jump(); }
if pad.repeats(button::DOWN, 15, 4) { cursor_down(); }
}Structs§
- PadTracker
- Frame-to-frame tracker over an active-high 16-bit button mask
(the
PadState::buttonsrepresentation).