36#define A_BUTTON (1u << 0)
37#define B_BUTTON (1u << 1)
38#define UP_BUTTON (1u << 2)
39#define DOWN_BUTTON (1u << 3)
40#define LEFT_BUTTON (1u << 4)
41#define RIGHT_BUTTON (1u << 5)
42#define START_BUTTON (1u << 6)
43#define SELECT_BUTTON (1u << 7)
95 bool pressed(uint8_t b)
const {
return (cur & b) == b; }
99 bool anyPressed(uint8_t b)
const {
return (cur & b) != 0; }
103 bool justPressed(uint8_t b)
const {
return (cur & ~prev & b) != 0; }
117 bool repeat(uint8_t b, uint8_t delay = 18, uint8_t rate = 5)
const;
147 uint8_t cur = 0, prev = 0;
148 uint16_t held[8] = {};
149 uint32_t period = 16667, next = 0;
The board's buttons and frame clock. There is one, chgame.
Definition Input.h:64
uint8_t injected
Buttons ORed into the physical ones (the debug protocol's K).
Definition Input.h:134
void clearButtonState()
Forget this frame's presses: justPressed() and justReleased() are false until the buttons change agai...
Definition Input.h:122
uint32_t frameCount
Frames since boot, counted by nextFrame().
Definition Input.h:133
bool anyPressed(uint8_t b) const
Whether any of the buttons in a mask is held.
Definition Input.h:99
bool justPressed(uint8_t b) const
Whether a button went down this frame.
Definition Input.h:103
void exitToMenu()
Leave the game for the SD game menu.
Definition Input.h:131
bool repeat(uint8_t b, uint8_t delay=18, uint8_t rate=5) const
Press edge, then auto-repeat while held: for menus and adjusting a bet.
int32_t lockstep
Lockstep: < 0 free-running, else the frames nextFrame() may still run (set by the debug protocol's L ...
Definition Input.h:143
bool nextFrame()
Whether it is time for the next frame.
bool pressed(uint8_t b) const
Whether all the buttons in a mask are held.
Definition Input.h:95
void pollButtons()
Take this frame's snapshot of the buttons.
bool justReleased(uint8_t b) const
Whether a button was let go this frame.
Definition Input.h:107
void boot()
Set up the button pins (inputs with pull-ups) and take a first reading.
uint8_t buttons() const
The buttons held in this frame's snapshot.
Definition Input.h:91
bool everyXFrames(uint16_t n) const
Whether frameCount is a multiple of n: something to do every n frames.
Definition Input.h:127
bool startExits
START held 3 s calls exitToMenu(); a game that needs a long START hold clears it in setup().
Definition Input.h:137
uint8_t justPressedMask() const
Every button that went down this frame.
Definition Input.h:110
void setFrameRate(uint8_t fps)
Set the frame rate nextFrame() paces to.