From 5223f423d88a384f9aa3068a15e1bc0b7dcc58b6 Mon Sep 17 00:00:00 2001 From: Sergii Pylypenko Date: Tue, 26 Sep 2017 22:27:53 +0300 Subject: [PATCH] SDL: Attempt to fix async text input --- project/java/MainActivity.java | 4 ++-- project/jni/application/ballfield/AndroidAppSettings.cfg | 2 +- project/jni/application/ballfield/ballfield.cpp | 7 ++----- project/jni/application/openttd-jgrpp/src | 2 +- project/jni/sdl-1.2/src/video/android/SDL_androidinput.c | 1 + .../sdl-1.2/src/video/android/SDL_touchscreenkeyboard.c | 2 +- 6 files changed, 8 insertions(+), 10 deletions(-) diff --git a/project/java/MainActivity.java b/project/java/MainActivity.java index 9f690c359..63f00fb74 100644 --- a/project/java/MainActivity.java +++ b/project/java/MainActivity.java @@ -867,8 +867,8 @@ public class MainActivity extends Activity screenKeyboard.setText(oldText); screenKeyboard.setSelection(screenKeyboard.getText().length()); screenKeyboard.setOnKeyListener(new simpleKeyListener(this)); - screenKeyboard.setBackgroundColor(Color.BLACK); // Full opaque - do not show semi-transparent edit box, it's confusing - screenKeyboard.setTextColor(Color.WHITE); // Just to be sure about gamma + screenKeyboard.setBackgroundColor(this.getColor(android.R.color.primary_text_light)); + screenKeyboard.setTextColor(this.getColor(android.R.color.background_light)); // Just to be sure about gamma if( isRunningOnOUYA() && Globals.TvBorders ) screenKeyboard.setPadding(100, 100, 100, 100); // Bad bad HDMI TVs all have cropped borders _screenKeyboard = screenKeyboard; diff --git a/project/jni/application/ballfield/AndroidAppSettings.cfg b/project/jni/application/ballfield/AndroidAppSettings.cfg index cf051843b..6da66eff5 100644 --- a/project/jni/application/ballfield/AndroidAppSettings.cfg +++ b/project/jni/application/ballfield/AndroidAppSettings.cfg @@ -255,7 +255,7 @@ APP_PLATFORM= # Specify architectures to compile, 'all' or 'y' to compile for all architectures. # Available architectures: armeabi armeabi-v7a x86 mips arm64-v8a -MultiABI='armeabi-v7a x86 arm64-v8a' +MultiABI='armeabi-v7a' # x86 arm64-v8a # Optional shared libraries to compile - removing some of them will save space # MP3 support by libMAD is encumbered by patents and libMAD is GPL-ed diff --git a/project/jni/application/ballfield/ballfield.cpp b/project/jni/application/ballfield/ballfield.cpp index f334ab178..e61a3556f 100644 --- a/project/jni/application/ballfield/ballfield.cpp +++ b/project/jni/application/ballfield/ballfield.cpp @@ -442,7 +442,6 @@ int main(int argc, char* argv[]) int accel[5], screenjoy[4], gamepads[4][8]; SDL_Surface *mouse[4]; int screenKeyboardShown = 0; - int asyncTextInput = 0; char asyncTextInputBuf[256]; @@ -699,7 +698,6 @@ int main(int argc, char* argv[]) if(evt.key.keysym.sym == SDLK_2) { __android_log_print(ANDROID_LOG_INFO, "Ballfield", "Async text input started"); - asyncTextInput = 1; asyncTextInputBuf[0] = 0; SDL_ANDROID_GetScreenKeyboardTextInputAsync(asyncTextInputBuf, sizeof(asyncTextInputBuf)); } @@ -758,12 +756,11 @@ int main(int argc, char* argv[]) __android_log_print(ANDROID_LOG_INFO, "Ballfield", "Screen keyboard shown: %d -> %d", screenKeyboardShown, SDL_IsScreenKeyboardShown(NULL)); screenKeyboardShown = SDL_IsScreenKeyboardShown(NULL); } - if( asyncTextInput ) + if( SDL_IsScreenKeyboardShown(NULL) ) { - if( SDL_ANDROID_GetScreenKeyboardTextInputAsync(asyncTextInputBuf, sizeof(asyncTextInputBuf)) == SDL_ANDROID_TEXTINPUT_ASYNC_FINISHED) + if(SDL_ANDROID_GetScreenKeyboardTextInputAsync(asyncTextInputBuf, sizeof(asyncTextInputBuf)) == SDL_ANDROID_TEXTINPUT_ASYNC_FINISHED) { __android_log_print(ANDROID_LOG_INFO, "Ballfield", "Async text input: %s", asyncTextInputBuf); - asyncTextInput = 0; } } diff --git a/project/jni/application/openttd-jgrpp/src b/project/jni/application/openttd-jgrpp/src index 8817a75e6..aaccfa272 160000 --- a/project/jni/application/openttd-jgrpp/src +++ b/project/jni/application/openttd-jgrpp/src @@ -1 +1 @@ -Subproject commit 8817a75e6cebdf140ecdb24799561ecb886bedc1 +Subproject commit aaccfa2725dc950b9460b9beb029a1a59b631293 diff --git a/project/jni/sdl-1.2/src/video/android/SDL_androidinput.c b/project/jni/sdl-1.2/src/video/android/SDL_androidinput.c index 995cf24b1..a67c29ffa 100644 --- a/project/jni/sdl-1.2/src/video/android/SDL_androidinput.c +++ b/project/jni/sdl-1.2/src/video/android/SDL_androidinput.c @@ -1035,6 +1035,7 @@ JAVA_EXPORT_NAME(DemoRenderer_nativeTextInputFinished) ( JNIEnv* env, jobject t textInputBuffer[0] = 0; textInputBuffer = NULL; SDL_ANDROID_TextInputFinished = 1; + SDL_ANDROID_IsScreenKeyboardShownFlag = 0; } JNIEXPORT void JNICALL diff --git a/project/jni/sdl-1.2/src/video/android/SDL_touchscreenkeyboard.c b/project/jni/sdl-1.2/src/video/android/SDL_touchscreenkeyboard.c index 20e053040..d3ffd45a5 100644 --- a/project/jni/sdl-1.2/src/video/android/SDL_touchscreenkeyboard.c +++ b/project/jni/sdl-1.2/src/video/android/SDL_touchscreenkeyboard.c @@ -1252,7 +1252,7 @@ SDL_AndroidTextInputAsyncStatus_t SDLCALL SDL_ANDROID_GetScreenKeyboardTextInput SDL_ANDROID_AsyncTextInputActive = 0; return SDL_ANDROID_TEXTINPUT_ASYNC_FINISHED; } - if( !SDL_ANDROID_IsScreenKeyboardShownFlag && !SDL_ANDROID_AsyncTextInputActive ) + if( !SDL_ANDROID_IsScreenKeyboardShownFlag ) { SDL_ANDROID_AsyncTextInputActive = 1; SDL_ANDROID_CallJavaShowScreenKeyboard(textBuf, textBuf, textBufSize, 1);