mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-04-23 08:41:28 +00:00
Fixed Pacman pause button (#1894)
This commit is contained in:
parent
936e8279f9
commit
8725b01995
@ -25,19 +25,31 @@ void PacmanView::focus() {
|
|||||||
void PacmanView::paint(Painter& painter) {
|
void PacmanView::paint(Painter& painter) {
|
||||||
(void)painter;
|
(void)painter;
|
||||||
static Playfield _game;
|
static Playfield _game;
|
||||||
|
static bool wait_for_button_release{false};
|
||||||
|
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
initialized = true;
|
initialized = true;
|
||||||
_game.Init();
|
_game.Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto switches_debounced = get_switches_state().to_ulong();
|
auto switches_raw = swizzled_switches() & ((1 << (int)Switch::Right) | (1 << (int)Switch::Left) | (1 << (int)Switch::Down) | (1 << (int)Switch::Up) | (1 << (int)Switch::Sel) | (1 << (int)Switch::Dfu));
|
||||||
|
|
||||||
but_RIGHT = (switches_debounced & 0x01) == 0x01;
|
// For the Select (Start/Pause) button, wait for release to avoid repeat
|
||||||
but_LEFT = (switches_debounced & 0x02) == 0x02;
|
uint8_t buttons_to_wait_for = (1 << (int)Switch::Sel);
|
||||||
but_DOWN = (switches_debounced & 0x04) == 0x04;
|
if (wait_for_button_release) {
|
||||||
but_UP = (switches_debounced & 0x08) == 0x08;
|
if ((switches_raw & buttons_to_wait_for) == 0)
|
||||||
but_A = (switches_debounced & 0x10) == 0x10;
|
wait_for_button_release = false;
|
||||||
|
switches_raw &= ~buttons_to_wait_for;
|
||||||
|
} else {
|
||||||
|
if (switches_raw & buttons_to_wait_for)
|
||||||
|
wait_for_button_release = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
but_RIGHT = (switches_raw & (1 << (int)Switch::Right)) != 0;
|
||||||
|
but_LEFT = (switches_raw & (1 << (int)Switch::Left)) != 0;
|
||||||
|
but_DOWN = (switches_raw & (1 << (int)Switch::Down)) != 0;
|
||||||
|
but_UP = (switches_raw & (1 << (int)Switch::Up)) != 0;
|
||||||
|
but_A = (switches_raw & (1 << (int)Switch::Sel)) != 0;
|
||||||
|
|
||||||
_game.Step();
|
_game.Step();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user