Reworked keyboard input, so Korean text input won't crash SDL

This commit is contained in:
Sergii Pylypenko
2015-06-05 21:21:59 +03:00
parent d0b7246dac
commit 81853f7ead
5 changed files with 30 additions and 22 deletions

View File

@@ -88,7 +88,6 @@ static jmethodID JavaRequestOpenExternalApp = NULL;
static int glContextLost = 0;
static int showScreenKeyboardDeferred = 0;
static const char * showScreenKeyboardOldText = "";
static int showScreenKeyboardSendBackspace = 0;
int SDL_ANDROID_IsScreenKeyboardShownFlag = 0;
int SDL_ANDROID_TextInputFinished = 0;
int SDL_ANDROID_VideoLinearFilter = 0;
@@ -166,7 +165,7 @@ int SDL_ANDROID_CallJavaSwapBuffers()
(*JavaEnv)->PushLocalFrame(JavaEnv, 1);
jstring s = (*JavaEnv)->NewStringUTF(JavaEnv, showScreenKeyboardOldText);
showScreenKeyboardDeferred = 0;
(*JavaEnv)->CallVoidMethod( JavaEnv, JavaRenderer, JavaShowScreenKeyboard, s, showScreenKeyboardSendBackspace );
(*JavaEnv)->CallVoidMethod( JavaEnv, JavaRenderer, JavaShowScreenKeyboard, s, 0 );
(*JavaEnv)->DeleteLocalRef( JavaEnv, s );
(*JavaEnv)->PopLocalFrame(JavaEnv, NULL);
}
@@ -257,7 +256,6 @@ void SDL_ANDROID_CallJavaShowScreenKeyboard(const char * oldText, char * outBuf,
{
showScreenKeyboardDeferred = 1;
showScreenKeyboardOldText = oldText;
showScreenKeyboardSendBackspace = 1;
// Move mouse by 1 pixel to force screen update
int x, y;
SDL_GetMouseState( &x, &y );
@@ -274,7 +272,6 @@ void SDL_ANDROID_CallJavaShowScreenKeyboard(const char * oldText, char * outBuf,
// Dirty hack: we may call (*JavaEnv)->CallVoidMethod(...) only from video thread
showScreenKeyboardDeferred = 1;
showScreenKeyboardOldText = oldText;
showScreenKeyboardSendBackspace = 0;
SDL_Flip(SDL_GetVideoSurface());
#endif
}

View File

@@ -46,6 +46,8 @@ static inline SDL_keysym asciiToKeysym(int ascii, int unicode)
if ( ascii < SDLK_LAST )
keysym.scancode = SDL_android_keysym_to_scancode[ascii];
keysym.sym = ascii;
if (keysym.sym < 0 || keysym.sym >= SDLK_LAST)
keysym.sym = SDLK_UNKNOWN;
keysym.mod = KMOD_NONE;
keysym.unicode = 0;
#if SDL_VERSION_ATLEAST(1,3,0)