From a7706913c27b3da2e364c66bb47ead79b3d67dba Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Thu, 26 Mar 2026 16:49:18 +0100 Subject: [PATCH] fix(keyboard): force redraw after shortcut opens submenu When a keyboard shortcut (e.g. 'f' for Files) opens a submenu from the main menu, the submenu draws over the screen. On exit, the main menu loop didn't know it needed to redraw, causing ESC to appear broken and navigation to produce font-size overlay glitches. Change checkShortcutPress() to return bool, and force a full redraw when it executed a shortcut command. Closes #2156 --- src/core/display.cpp | 6 +++++- src/core/mykeyboard.cpp | 11 +++++++---- src/core/mykeyboard.h | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/core/display.cpp b/src/core/display.cpp index 341234ee95..6192ecbca7 100644 --- a/src/core/display.cpp +++ b/src/core/display.cpp @@ -533,7 +533,11 @@ int loopOptions( // handleSerialCommands(); // always use serial task for it #ifdef HAS_KEYBOARD - checkShortcutPress(); // shortctus to quickly start apps without navigating the menus + if (checkShortcutPress()) { + // Shortcut opened a submenu that drew over the screen; force full redraw + redraw = true; + drawMainBorder(); + } #endif if (menuType == MENU_TYPE_REGULAR) { diff --git a/src/core/mykeyboard.cpp b/src/core/mykeyboard.cpp index 3974e785e7..b4d254e328 100644 --- a/src/core/mykeyboard.cpp +++ b/src/core/mykeyboard.cpp @@ -253,13 +253,14 @@ keyStroke _getKeyPress() { ** location: mykeyboard.cpp ** runs a function called by the shortcut action **********************************************************************/ -void checkShortcutPress() { +bool checkShortcutPress() { static JsonDocument shortcutsJson; // parsed only once + bool executed = false; // lazy init if (shortcutsJson.size() == 0) { FS *fs; - if (!getFsStorage(fs)) return; + if (!getFsStorage(fs)) return false; File file = fs->open("/shortcuts.json", FILE_READ); if (!file) { log_e("Shortcuts Config file not found. Using default values"); @@ -270,13 +271,13 @@ void checkShortcutPress() { shortcuts["b"] = "loader open badusb"; shortcuts["w"] = "loader open webui"; shortcuts["f"] = "loader open files"; - return; + return false; } // else if (deserializeJson(shortcutsJson, file)) { log_e("Failed to parse shortcuts.json"); file.close(); - return; + return false; } file.close(); } @@ -293,9 +294,11 @@ void checkShortcutPress() { if (i == *shortcut_key) { // compare the 1st char of the key string // execute the associated action serialCli.parse(String(shortcut_value)); + executed = true; } } } + return executed; } /********************************************************************* diff --git a/src/core/mykeyboard.h b/src/core/mykeyboard.h index 749d86ebc6..42d1a6b39d 100644 --- a/src/core/mykeyboard.h +++ b/src/core/mykeyboard.h @@ -23,6 +23,6 @@ keyStroke _getKeyPress(); // This function must be implemented in the interface. // by using the flag HAS_KEYBOARD // Core functions, depends on the implementation of the funtions above in the interface.h -void checkShortcutPress(); +bool checkShortcutPress(); int checkNumberShortcutPress(); char checkLetterShortcutPress();