34#define A_BUTTON (1u << 0)
35#define B_BUTTON (1u << 1)
36#define UP_BUTTON (1u << 2)
37#define DOWN_BUTTON (1u << 3)
38#define LEFT_BUTTON (1u << 4)
39#define RIGHT_BUTTON (1u << 5)
40#define START_BUTTON (1u << 6)
41#define SELECT_BUTTON (1u << 7)
90 bool pressed(uint8_t b)
const {
return (cur & b) == b; }
94 bool anyPressed(uint8_t b)
const {
return (cur & b) != 0; }
98 bool justPressed(uint8_t b)
const {
return (cur & ~prev & b) != 0; }
112 bool repeat(uint8_t b, uint8_t delay = 18, uint8_t rate = 5)
const;
142 uint8_t cur = 0, prev = 0;
143 uint16_t held[8] = {};
144 uint32_t period = 16667, next = 0;
The board's buttons and frame clock. There is one, chgame.
Definition Input.h:59
uint8_t injected
Buttons ORed into the physical ones (the debug protocol's K).
Definition Input.h:129
void clearButtonState()
Forget this frame's presses: justPressed() and justReleased() are false until the buttons change agai...
Definition Input.h:117
uint32_t frameCount
Frames since boot, counted by nextFrame().
Definition Input.h:128
bool anyPressed(uint8_t b) const
Whether any of the buttons in a mask is held.
Definition Input.h:94
bool justPressed(uint8_t b) const
Whether a button went down this frame.
Definition Input.h:98
void exitToMenu()
Leave the game for the SD game menu.
Definition Input.h:126
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:138
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:90
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:102
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:86
bool everyXFrames(uint16_t n) const
Whether frameCount is a multiple of n: something to do every n frames.
Definition Input.h:122
bool startExits
START held 3 s calls exitToMenu(); a game that needs a long START hold clears it in setup().
Definition Input.h:132
uint8_t justPressedMask() const
Every button that went down this frame.
Definition Input.h:105
void setFrameRate(uint8_t fps)
Set the frame rate nextFrame() paces to.