From 6e9bf7b88a055247c01d4c25bfe172748aace9a6 Mon Sep 17 00:00:00 2001 From: cpasjuste Date: Mon, 27 Apr 2020 11:36:29 +0200 Subject: switch: send gui escape/cancel event on keyboard dismiss switch: add README-SWITCH.md --- src/gui/sdlinput.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src') diff --git a/src/gui/sdlinput.cpp b/src/gui/sdlinput.cpp index 97ac0ac5e..b6fabd8a5 100644 --- a/src/gui/sdlinput.cpp +++ b/src/gui/sdlinput.cpp @@ -91,6 +91,10 @@ PRAGMA48(GCC diagnostic pop) #include "debug.h" +#ifdef __SWITCH__ +bool keyboardClosed = false; +#endif + extern volatile time_t cur_time; SDLInput *guiInput = nullptr; @@ -134,6 +138,20 @@ void SDLInput::pushInput(const SDL_Event &event) KeyInput keyInput; MouseInput mouseInput; +#ifdef __SWITCH__ + // send an escape/cancel key on keyboard dismiss event + bool visible = SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE; + if(visible) + { + keyboardClosed = false; + } + else if(!keyboardClosed) + { + simulateKey(KeyValue::ESCAPE, InputAction::GUI_CANCEL); + keyboardClosed = true; + } +#endif + switch (event.type) { case SDL_KEYDOWN: -- cgit v1.2.3-60-g2f50