void SDL_ANDROID_CallJavaShowScreenKeyboard(const char * oldText, char * outBuf, int outBufLen, int x, int y, int w, int h) { textInputFinished = 0; SDL_ANDROID_TextInputInit(outBuf, outBufLen); (*JavaEnv)->CallVoidMethod( JavaEnv, JavaRenderer, JavaShowScreenKeyboard, (*JavaEnv)->NewStringUTF(JavaEnv, oldText), x, y, w, h); while( !textInputFinished ) SDL_Delay(100); __android_log_print(ANDROID_LOG_INFO, "libSDL", "ShowScreenKeyboard got: %s\n", outBuf); }
void SDL_ANDROID_CallJavaShowScreenKeyboard(const char * oldText, char * outBuf, int outBufLen) { // Clear mouse button state, to avoid repeated clicks on the text field in some apps SDL_ANDROID_MainThreadPushMouseButton( SDL_RELEASED, SDL_BUTTON_LEFT ); SDL_ANDROID_MainThreadPushMouseButton( SDL_RELEASED, SDL_BUTTON_RIGHT ); SDL_ANDROID_MainThreadPushMouseButton( SDL_RELEASED, SDL_BUTTON_MIDDLE ); SDL_ANDROID_TextInputFinished = 0; SDL_ANDROID_IsScreenKeyboardShownFlag = 1; if( !outBuf ) { showScreenKeyboardDeferred = 1; showScreenKeyboardOldText = oldText; showScreenKeyboardSendBackspace = 1; // Move mouse by 1 pixel to force screen update int x, y; SDL_GetMouseState( &x, &y ); SDL_ANDROID_MainThreadPushMouseMotion(x > 0 ? x-1 : 0, y); } else { SDL_ANDROID_TextInputInit(outBuf, outBufLen); if( SDL_ANDROID_VideoMultithreaded ) { #if SDL_VERSION_ATLEAST(1,3,0) #else // Dirty hack: we may call (*JavaEnv)->CallVoidMethod(...) only from video thread showScreenKeyboardDeferred = 1; showScreenKeyboardOldText = oldText; showScreenKeyboardSendBackspace = 0; SDL_Flip(SDL_GetVideoSurface()); #endif } else { (*JavaEnv)->PushLocalFrame(JavaEnv, 1); jstring s = (*JavaEnv)->NewStringUTF( JavaEnv, oldText ); (*JavaEnv)->CallVoidMethod( JavaEnv, JavaRenderer, JavaShowScreenKeyboard, s, 0 ); (*JavaEnv)->DeleteLocalRef( JavaEnv, s ); (*JavaEnv)->PopLocalFrame(JavaEnv, NULL); } while( !SDL_ANDROID_TextInputFinished ) SDL_Delay(100); SDL_ANDROID_TextInputFinished = 0; SDL_ANDROID_IsScreenKeyboardShownFlag = 0; } }
void SDL_ANDROID_CallJavaShowScreenKeyboard(const char * oldText, char * outBuf, int outBufLen) { SDL_ANDROID_TextInputFinished = 0; SDL_ANDROID_IsScreenKeyboardShownFlag = 1; if( !outBuf ) { showScreenKeyboardDeferred = 1; showScreenKeyboardOldText = oldText; showScreenKeyboardSendBackspace = 1; // Move mouse by 1 pixel to force screen update int x, y; SDL_GetMouseState( &x, &y ); SDL_ANDROID_MainThreadPushMouseMotion(x > 0 ? x-1 : 0, y); } else { SDL_ANDROID_TextInputInit(outBuf, outBufLen); if( SDL_ANDROID_VideoMultithreaded ) { #if SDL_VERSION_ATLEAST(1,3,0) #else // Dirty hack: we may call (*JavaEnv)->CallVoidMethod(...) only from video thread showScreenKeyboardDeferred = 1; showScreenKeyboardOldText = oldText; showScreenKeyboardSendBackspace = 0; SDL_Flip(SDL_GetVideoSurface()); #endif } else (*JavaEnv)->CallVoidMethod( JavaEnv, JavaRenderer, JavaShowScreenKeyboard, (*JavaEnv)->NewStringUTF(JavaEnv, oldText), 0 ); while( !SDL_ANDROID_TextInputFinished ) SDL_Delay(100); SDL_ANDROID_TextInputFinished = 0; SDL_ANDROID_IsScreenKeyboardShownFlag = 0; } }