diff --git a/radio/src/gui/128x64/popups.cpp b/radio/src/gui/128x64/popups.cpp index f16ec58a85..1b07d1909b 100644 --- a/radio/src/gui/128x64/popups.cpp +++ b/radio/src/gui/128x64/popups.cpp @@ -88,7 +88,7 @@ void showAlertBox(const char * title, const char * text, const char * action , u lcdRefresh(); lcdSetContrast(); - clearKeyEvents(); + waitKeysReleased(); resetBacklightTimeout(); checkBacklight(); } @@ -101,6 +101,7 @@ void runPopupWarning(event_t event) lcdDrawSizedText(WARNING_LINE_X, WARNING_LINE_Y+FH, warningInfoText, warningInfoLength, warningInfoFlags); } lcdDrawText(WARNING_LINE_X, WARNING_LINE_Y+4*FH+2, warningType == WARNING_TYPE_ASTERISK ? STR_EXIT : STR_POPUPS_ENTER_EXIT); + switch (event) { case EVT_KEY_BREAK(KEY_ENTER): if (warningType == WARNING_TYPE_ASTERISK) diff --git a/radio/src/gui/128x64/popups.h b/radio/src/gui/128x64/popups.h index 6fc9d72aee..1c1107daf4 100644 --- a/radio/src/gui/128x64/popups.h +++ b/radio/src/gui/128x64/popups.h @@ -97,6 +97,7 @@ enum inline void POPUP_WARNING(const char * s) { + // killAllEvents(); warningText = s; warningInfoText = nullptr; warningType = WARNING_TYPE_ASTERISK; @@ -117,6 +118,7 @@ enum inline void POPUP_INPUT(const char * s, PopupFunc func) { + // killAllEvents(); warningText = s; warningInfoText = nullptr; warningType = WARNING_TYPE_INPUT; @@ -130,6 +132,17 @@ enum warningInfoFlags = flags; } + inline bool isEventCaughtByPopup() + { + if (warningText && warningType != WARNING_TYPE_WAIT) + return true; + + if (popupMenuItemsCount > 0) + return true; + + return false; + } + inline void POPUP_MENU_ADD_ITEM(const char * s) { popupMenuOffsetType = MENU_OFFSET_INTERNAL; @@ -157,7 +170,7 @@ inline void POPUP_MENU_TITLE(const char * s) inline void POPUP_MENU_START(PopupMenuHandler handler) { if (handler != popupMenuHandler) { - // killAllEvents(); // not ported yet + // killAllEvents(); AUDIO_KEY_PRESS(); popupMenuHandler = handler; } diff --git a/radio/src/gui/128x64/radio_setup.cpp b/radio/src/gui/128x64/radio_setup.cpp index 8de9abd5fb..294f7450c6 100644 --- a/radio/src/gui/128x64/radio_setup.cpp +++ b/radio/src/gui/128x64/radio_setup.cpp @@ -614,7 +614,7 @@ void menuRadioSetup(event_t event) g_eeGeneral.stickMode = reusableBuffer.generalSettings.stickMode; checkThrottleStick(); resumePulses(); - clearKeyEvents(); + waitKeysReleased(); } break; } diff --git a/radio/src/gui/212x64/popups.cpp b/radio/src/gui/212x64/popups.cpp index 2030ffdb53..9911ebd71b 100644 --- a/radio/src/gui/212x64/popups.cpp +++ b/radio/src/gui/212x64/popups.cpp @@ -79,7 +79,7 @@ void showAlertBox(const char * title, const char * text, const char * action, ui AUDIO_ERROR_MESSAGE(sound); lcdRefresh(); lcdSetContrast(); - clearKeyEvents(); + waitKeysReleased(); resetBacklightTimeout(); checkBacklight(); } diff --git a/radio/src/gui/212x64/radio_setup.cpp b/radio/src/gui/212x64/radio_setup.cpp index af3795189e..5ec851a7a6 100644 --- a/radio/src/gui/212x64/radio_setup.cpp +++ b/radio/src/gui/212x64/radio_setup.cpp @@ -503,7 +503,7 @@ void menuRadioSetup(event_t event) g_eeGeneral.stickMode = reusableBuffer.generalSettings.stickMode; checkThrottleStick(); resumePulses(); - clearKeyEvents(); + waitKeysReleased(); } break; } diff --git a/radio/src/gui/common/stdlcd/view_text.cpp b/radio/src/gui/common/stdlcd/view_text.cpp index 8cfbd3d198..62a5f09ef9 100644 --- a/radio/src/gui/common/stdlcd/view_text.cpp +++ b/radio/src/gui/common/stdlcd/view_text.cpp @@ -110,7 +110,7 @@ void readModelNotes() char *buf = strcat_modelname(&reusableBuffer.viewText.filename[sizeof(MODELS_PATH)], g_eeGeneral.currModel); strcpy(buf, TEXT_EXT); - clearKeyEvents(); + waitKeysReleased(); event_t event = EVT_ENTRY; while (event != EVT_KEY_BREAK(KEY_EXIT)) { lcdRefreshWait(); diff --git a/radio/src/keys.cpp b/radio/src/keys.cpp index af713fba9c..17d740ef95 100644 --- a/radio/src/keys.cpp +++ b/radio/src/keys.cpp @@ -166,7 +166,14 @@ void killEvents(event_t event) { } } -bool clearKeyEvents() { +void killAllEvents() +{ + for (uint8_t key = 0; key < DIM(keys); key++) { + keys[key].killEvents(); + } +} + +bool waitKeysReleased() { // loop until all keys are up #if !defined(BOOT) diff --git a/radio/src/keys.h b/radio/src/keys.h index 3b78a8475d..9102648c5a 100644 --- a/radio/src/keys.h +++ b/radio/src/keys.h @@ -110,11 +110,9 @@ inline void putEvent(event_t evt) void pauseEvents(event_t event); void killEvents(event_t event); - -bool clearKeyEvents(); +void killAllEvents(); +bool waitKeysReleased(); event_t getEvent(bool trim=false); bool keyDown(); - - #endif // _KEYS_H_ diff --git a/radio/src/main.cpp b/radio/src/main.cpp index 555f958ff0..f323c3afe4 100644 --- a/radio/src/main.cpp +++ b/radio/src/main.cpp @@ -381,24 +381,20 @@ void guiMain(event_t evt) menuEvent = 0; } + handleGui(isEventCaughtByPopup() ? 0 : evt); + if (warningText) { // show warning on top of the normal menus - handleGui(0); // suppress events, they are handled by the warning DISPLAY_WARNING(evt); } else if (popupMenuItemsCount > 0) { // popup menu is active display it on top of normal menus - handleGui(0); // suppress events, they are handled by the popup const char * result = runPopupMenu(evt); if (result) { TRACE("popupMenuHandler(%s)", result); popupMenuHandler(result); } } - else { - // normal menus - handleGui(evt); - } lcdRefresh(); } diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index 1a2c94fd5e..74e4bd6e18 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -858,7 +858,7 @@ void checkAll() { } #endif - if (!clearKeyEvents()) { + if (!waitKeysReleased()) { showMessageBox(STR_KEYSTUCK); tmr10ms_t tgtime = get_tmr10ms() + 500; while (tgtime != get_tmr10ms()) { diff --git a/radio/src/switches.cpp b/radio/src/switches.cpp index 6176d38a83..aae097453d 100644 --- a/radio/src/switches.cpp +++ b/radio/src/switches.cpp @@ -719,7 +719,7 @@ void checkSwitches() lcdRefresh(); lcdSetContrast(); - clearKeyEvents(); + waitKeysReleased(); last_bad_switches = switches_states; }