fix: swap reader menu navigation direction in CCW/inverted (#2321) (#2341)

Co-authored-by: Uri Tauber <uritaube@gmail.com>
This commit is contained in:
Ronin
2026-06-15 22:19:34 +03:00
committed by GitHub
co-authored by Uri Tauber
parent 55a56914d7
commit 02bab00be6
5 changed files with 45 additions and 18 deletions
+16 -2
View File
@@ -2,9 +2,11 @@
#include <HalGPIO.h>
class GfxRenderer;
class MappedInputManager {
public:
enum class Button { Back, Confirm, Left, Right, Up, Down, Power, PageBack, PageForward };
enum class Button { Back, Confirm, Left, Right, Up, Down, Power, PageBack, PageForward, NavNext, NavPrevious };
struct Labels {
const char* btn1;
@@ -13,7 +15,7 @@ class MappedInputManager {
const char* btn4;
};
explicit MappedInputManager(HalGPIO& gpio) : gpio(gpio) {}
MappedInputManager(HalGPIO& gpio, const GfxRenderer& renderer) : gpio(gpio), renderer(renderer) {}
void update() const { gpio.update(); }
bool wasPressed(Button button) const;
@@ -26,8 +28,20 @@ class MappedInputManager {
// Returns the raw front button index that was pressed this frame (or -1 if none).
int getPressedFrontButton() const;
// True when the control axis is flipped relative to the physical buttons: the user opted into
// orientation-following front buttons AND the screen is *currently rendered* rotated (INVERTED /
// LANDSCAPE_CCW). Keyed on the live renderer orientation rather than the persisted reader setting,
// so portrait UI (home, settings) never swaps while the reader and its menus do.
[[nodiscard]] bool isNavDirectionSwapped() const;
private:
HalGPIO& gpio;
// Logical-to-physical button mapping depends on what the user is actually looking at: when the
// screen is rendered rotated, the directional buttons must flip to match. The renderer is the only
// authority on the *live* orientation (the reader rotates it and restores portrait on exit), so we
// read it here instead of CrossPointSettings.orientation, which is just the persisted reader
// preference and stays "rotated" even while portrait UI like home/settings is on screen.
const GfxRenderer& renderer;
bool mapButton(Button button, bool (HalGPIO::*fn)(uint8_t) const) const;
};