From c383fc6b95a89eeb460db03123616ab5a6f5e0af Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Thu, 8 Dec 2022 20:41:59 +0300 Subject: [PATCH] Add mobile keyboard support (#206) --- src/character_editor.cc | 4 ++++ src/dbox.cc | 4 ++++ src/input.cc | 10 ++++++++++ src/input.h | 3 +++ src/loadsave.cc | 4 ++++ 5 files changed, 25 insertions(+) diff --git a/src/character_editor.cc b/src/character_editor.cc index 020e689..c176823 100644 --- a/src/character_editor.cc +++ b/src/character_editor.cc @@ -1931,6 +1931,8 @@ static int _get_input_str(int win, int cancelKeyCode, char* text, int maxLength, windowRefresh(win); + beginTextInput(); + int blinkingCounter = 3; bool blink = false; @@ -1994,6 +1996,8 @@ static int _get_input_str(int win, int cancelKeyCode, char* text, int maxLength, sharedFpsLimiter.throttle(); } + endTextInput(); + if (rc == 0 || nameLength > 0) { copy[nameLength] = '\0'; strcpy(text, copy); diff --git a/src/dbox.cc b/src/dbox.cc index f30b358..c545524 100644 --- a/src/dbox.cc +++ b/src/dbox.cc @@ -1089,6 +1089,8 @@ int showSaveFileDialog(char* title, char** fileList, char* dest, int fileListLen windowRefresh(win); + beginTextInput(); + int blinkingCounter = 3; bool blink = false; @@ -1353,6 +1355,8 @@ int showSaveFileDialog(char* title, char** fileList, char* dest, int fileListLen sharedFpsLimiter.throttle(); } + endTextInput(); + if (rc == 0) { if (fileNameCopyLength != 0) { fileNameCopy[fileNameCopyLength] = '\0'; diff --git a/src/input.cc b/src/input.cc index 9d61b69..368f5b4 100644 --- a/src/input.cc +++ b/src/input.cc @@ -1209,4 +1209,14 @@ static void idleImpl() SDL_Delay(125); } +void beginTextInput() +{ + SDL_StartTextInput(); +} + +void endTextInput() +{ + SDL_StopTextInput(); +} + } // namespace fallout diff --git a/src/input.h b/src/input.h index 6728480..93a0c93 100644 --- a/src/input.h +++ b/src/input.h @@ -44,6 +44,9 @@ void _GNW95_process_message(); void _GNW95_clear_time_stamps(); void _GNW95_lost_focus(); +void beginTextInput(); +void endTextInput(); + } // namespace fallout #endif /* FALLOUT_INPUT_H_ */ diff --git a/src/loadsave.cc b/src/loadsave.cc index 60f8c5c..5c1adf5 100644 --- a/src/loadsave.cc +++ b/src/loadsave.cc @@ -2213,6 +2213,8 @@ static int _get_input_str2(int win, int doneKeyCode, int cancelKeyCode, char* de windowRefresh(win); renderPresent(); + beginTextInput(); + int blinkCounter = 3; bool blink = false; @@ -2282,6 +2284,8 @@ static int _get_input_str2(int win, int doneKeyCode, int cancelKeyCode, char* de sharedFpsLimiter.throttle(); } + endTextInput(); + if (rc == 0) { text[textLength] = '\0'; strcpy(description, text);