SDL: Attempt to fix async text input

This commit is contained in:
Sergii Pylypenko
2017-09-26 22:27:53 +03:00
parent 7953493704
commit 5223f423d8
6 changed files with 8 additions and 10 deletions

View File

@@ -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;

View File

@@ -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

View File

@@ -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;
}
}

View File

@@ -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

View File

@@ -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);