Reworked keyboard input, so Korean text input won't crash SDL
This commit is contained in:
@@ -501,7 +501,7 @@ public class MainActivity extends Activity
|
||||
}
|
||||
}
|
||||
|
||||
public void showScreenKeyboard(final String oldText, boolean sendBackspace)
|
||||
public void showScreenKeyboard(final String oldText)
|
||||
{
|
||||
if(Globals.CompatibilityHacksTextInputEmulatesHwKeyboard)
|
||||
{
|
||||
@@ -513,8 +513,7 @@ public class MainActivity extends Activity
|
||||
class simpleKeyListener implements OnKeyListener
|
||||
{
|
||||
MainActivity _parent;
|
||||
boolean sendBackspace;
|
||||
simpleKeyListener(MainActivity parent, boolean sendBackspace) { _parent = parent; this.sendBackspace = sendBackspace; };
|
||||
simpleKeyListener(MainActivity parent) { _parent = parent; };
|
||||
public boolean onKey(View v, int keyCode, KeyEvent event)
|
||||
{
|
||||
if ((event.getAction() == KeyEvent.ACTION_UP) && (
|
||||
@@ -533,14 +532,9 @@ public class MainActivity extends Activity
|
||||
_parent.hideScreenKeyboard();
|
||||
return true;
|
||||
}
|
||||
/*
|
||||
if (keyCode == KeyEvent.KEYCODE_DEL || keyCode == KeyEvent.KEYCODE_CLEAR)
|
||||
{
|
||||
if (sendBackspace && event.getAction() == KeyEvent.ACTION_UP)
|
||||
{
|
||||
synchronized(textInput) {
|
||||
DemoRenderer.nativeTextInput( 8, 0 ); // Send backspace to native code
|
||||
}
|
||||
}
|
||||
// EditText deletes two characters at a time, here's a hacky fix
|
||||
if (event.getAction() == KeyEvent.ACTION_DOWN && (event.getFlags() | KeyEvent.FLAG_SOFT_KEYBOARD) != 0)
|
||||
{
|
||||
@@ -561,6 +555,7 @@ public class MainActivity extends Activity
|
||||
return true;
|
||||
}
|
||||
}
|
||||
*/
|
||||
//Log.i("SDL", "Key " + keyCode + " flags " + event.getFlags() + " action " + event.getAction());
|
||||
return false;
|
||||
}
|
||||
@@ -582,7 +577,7 @@ public class MainActivity extends Activity
|
||||
_screenKeyboard.setHint(hint != null ? hint : getString(R.string.text_edit_click_here));
|
||||
_screenKeyboard.setText(oldText);
|
||||
_screenKeyboard.setSelection(_screenKeyboard.getText().length());
|
||||
_screenKeyboard.setOnKeyListener(new simpleKeyListener(this, sendBackspace));
|
||||
_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
|
||||
if( isRunningOnOUYA() )
|
||||
@@ -821,9 +816,14 @@ public class MainActivity extends Activity
|
||||
@Override
|
||||
public boolean onKeyMultiple(int keyCode, int repeatCount, final KeyEvent event)
|
||||
{
|
||||
// International text input
|
||||
if( mGLView != null && event.getCharacters() != null )
|
||||
if( _screenKeyboard != null )
|
||||
{
|
||||
_screenKeyboard.onKeyMultiple(keyCode, repeatCount, event);
|
||||
return true;
|
||||
}
|
||||
else if( mGLView != null && event.getCharacters() != null )
|
||||
{
|
||||
// International text input
|
||||
for(int i = 0; i < event.getCharacters().length(); i++ )
|
||||
{
|
||||
mGLView.nativeKey( event.getKeyCode(), 1, event.getCharacters().codePointAt(i) );
|
||||
@@ -834,6 +834,17 @@ public class MainActivity extends Activity
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyLongPress (int keyCode, KeyEvent event)
|
||||
{
|
||||
if( _screenKeyboard != null )
|
||||
{
|
||||
_screenKeyboard.onKeyLongPress(keyCode, event);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dispatchTouchEvent(final MotionEvent ev)
|
||||
{
|
||||
|
||||
@@ -772,22 +772,20 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer
|
||||
context.runOnUiThread(cb);
|
||||
}
|
||||
|
||||
public void showScreenKeyboard(final String oldText, int sendBackspace) // Called from native code
|
||||
public void showScreenKeyboard(final String oldText, int unused) // Called from native code
|
||||
{
|
||||
class Callback implements Runnable
|
||||
{
|
||||
public MainActivity parent;
|
||||
public String oldText;
|
||||
public boolean sendBackspace;
|
||||
public void run()
|
||||
{
|
||||
parent.showScreenKeyboard(oldText, sendBackspace);
|
||||
parent.showScreenKeyboard(oldText);
|
||||
}
|
||||
}
|
||||
Callback cb = new Callback();
|
||||
cb.parent = context;
|
||||
cb.oldText = oldText;
|
||||
cb.sendBackspace = (sendBackspace != 0);
|
||||
context.runOnUiThread(cb);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,10 +7,10 @@ AppName="XServer XSDL"
|
||||
AppFullName=x.org.server
|
||||
|
||||
# Application version code (integer)
|
||||
AppVersionCode=11127
|
||||
AppVersionCode=11128
|
||||
|
||||
# Application user-visible version name (string)
|
||||
AppVersionName="1.11.27"
|
||||
AppVersionName="1.11.28"
|
||||
|
||||
# Specify path to download application data in zip archive in the form 'Description|URL|MirrorURL^Description2|URL2|MirrorURL2^...'
|
||||
# If you'll start Description with '!' symbol it will be enabled by default, other downloads should be selected by user from startup config menu
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user