summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README-SWITCH.md28
-rw-r--r--src/gui/sdlinput.cpp18
2 files changed, 46 insertions, 0 deletions
diff --git a/README-SWITCH.md b/README-SWITCH.md
new file mode 100644
index 000000000..35d732bf8
--- /dev/null
+++ b/README-SWITCH.md
@@ -0,0 +1,28 @@
+Switch button mapping:
+
+```
+KEY_A JButton1
+KEY_B JButton2
+KEY_X JButton3
+KEY_Y JButton4
+KEY_LSTICK JButton5
+KEY_RSTICK JButton6
+KEY_L JButton7
+KEY_R JButton8
+KEY_ZL JButton9
+KEY_ZR JButton10
+KEY_PLUS JButton11
+KEY_MINUS JButton12
+KEY_DLEFT JButton13
+KEY_DUP JButton14
+KEY_DRIGHT JButton15
+KEY_DDOWN JButton16
+KEY_LSTICK_LEFT JButton17
+KEY_LSTICK_UP JButton18
+KEY_LSTICK_RIGHT JButton19
+KEY_LSTICK_DOWN JButton20
+KEY_RSTICK_LEFT JButton21
+KEY_RSTICK_UP JButton22
+KEY_RSTICK_RIGHT JButton23
+KEY_RSTICK_DOWN JButton24
+``` \ No newline at end of file
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: