summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorcpasjuste <cpasjuste@gmail.com>2020-04-27 11:36:29 +0200
committercpasjuste <cpasjuste@gmail.com>2020-04-27 11:36:29 +0200
commit6e9bf7b88a055247c01d4c25bfe172748aace9a6 (patch)
tree373307196cb9098fbe9175a97c8a7374bbc298e0 /src
parent4fd097015d4b38a64e0aad56720be020b1729348 (diff)
downloadplus-6e9bf7b88a055247c01d4c25bfe172748aace9a6.tar.gz
plus-6e9bf7b88a055247c01d4c25bfe172748aace9a6.tar.bz2
plus-6e9bf7b88a055247c01d4c25bfe172748aace9a6.tar.xz
plus-6e9bf7b88a055247c01d4c25bfe172748aace9a6.zip
switch: send gui escape/cancel event on keyboard dismiss
switch: add README-SWITCH.md
Diffstat (limited to 'src')
-rw-r--r--src/gui/sdlinput.cpp18
1 files changed, 18 insertions, 0 deletions
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: