From b2061d76e8b74695fde960477b27212875883ce8 Mon Sep 17 00:00:00 2001 From: Sergii Pylypenko Date: Thu, 5 Nov 2015 22:27:01 +0200 Subject: [PATCH] SDL: pressing Back will hide built-in keyboard --- project/java/MainActivity.java | 31 ++++++++++++++----- .../ballfield/AndroidAppSettings.cfg | 2 +- .../jni/application/ballfield/ballfield.cpp | 2 +- project/jni/application/hid-pc-keyboard/src | 2 +- .../xserver/AndroidAppSettings.cfg | 4 +-- project/jni/application/xserver/xserver | 2 +- 6 files changed, 29 insertions(+), 14 deletions(-) diff --git a/project/java/MainActivity.java b/project/java/MainActivity.java index 23d5e4959..935cad5e7 100644 --- a/project/java/MainActivity.java +++ b/project/java/MainActivity.java @@ -908,11 +908,18 @@ public class MainActivity extends Activity @Override public boolean onKeyDown(int keyCode, final KeyEvent event) { - if( keyCode == KeyEvent.KEYCODE_BACK && (event.getSource() & InputDevice.SOURCE_MOUSE)== InputDevice.SOURCE_MOUSE ) + if( keyCode == KeyEvent.KEYCODE_BACK ) { - // Stupid Samsung and stupid Acer remaps right mouse button to BACK key - DemoGLSurfaceView.nativeMouseButtonsPressed(2, 1); - return true; + if( (event.getSource() & InputDevice.SOURCE_MOUSE) == InputDevice.SOURCE_MOUSE ) + { + // Stupid Samsung and stupid Acer remaps right mouse button to BACK key + DemoGLSurfaceView.nativeMouseButtonsPressed(2, 1); + return true; + } + else if( keyboardWithoutTextInputShown ) + { + return true; + } } if( _screenKeyboard != null && _screenKeyboard.onKeyDown(keyCode, event) ) return true; @@ -936,11 +943,19 @@ public class MainActivity extends Activity @Override public boolean onKeyUp(int keyCode, final KeyEvent event) { - if( keyCode == KeyEvent.KEYCODE_BACK && (event.getSource() & InputDevice.SOURCE_MOUSE)== InputDevice.SOURCE_MOUSE ) + if( keyCode == KeyEvent.KEYCODE_BACK ) { - // Stupid Samsung and stupid Acer remaps right mouse button to BACK key - DemoGLSurfaceView.nativeMouseButtonsPressed(2, 0); - return true; + if( (event.getSource() & InputDevice.SOURCE_MOUSE) == InputDevice.SOURCE_MOUSE ) + { + // Stupid Samsung and stupid Acer remaps right mouse button to BACK key + DemoGLSurfaceView.nativeMouseButtonsPressed(2, 0); + return true; + } + else if( keyboardWithoutTextInputShown ) + { + showScreenKeyboardWithoutTextInputField(0); // Hide keyboard + return true; + } } if( _screenKeyboard != null && _screenKeyboard.onKeyUp(keyCode, event) ) return true; diff --git a/project/jni/application/ballfield/AndroidAppSettings.cfg b/project/jni/application/ballfield/AndroidAppSettings.cfg index 5ce8a6703..b4e93664e 100644 --- a/project/jni/application/ballfield/AndroidAppSettings.cfg +++ b/project/jni/application/ballfield/AndroidAppSettings.cfg @@ -85,7 +85,7 @@ CompatibilityHacksTextInputEmulatesHwKeyboard=n # 1 - Simple QWERTY keyboard, no function keys, no arrow keys # 2 - Commodore 64 keyboard # 3 - Amiga keyboard -TextInputKeyboard=3 +TextInputKeyboard=1 # Hack for broken devices: prevent audio chopping, by sleeping a bit after pushing each audio chunk (y)/(n) CompatibilityHacksPreventAudioChopping=n diff --git a/project/jni/application/ballfield/ballfield.cpp b/project/jni/application/ballfield/ballfield.cpp index 93dc65f7a..78caf9da2 100644 --- a/project/jni/application/ballfield/ballfield.cpp +++ b/project/jni/application/ballfield/ballfield.cpp @@ -681,7 +681,7 @@ int main(int argc, char* argv[]) __android_log_print(ANDROID_LOG_INFO, "Ballfield", "SDL key event: evt %s state %s key %4d %12s scancode %4d mod %2d unicode %d", evt.type == SDL_KEYUP ? "UP " : "DOWN" , evt.key.state == SDL_PRESSED ? "PRESSED " : "RELEASED", (int)evt.key.keysym.sym, SDL_GetKeyName(evt.key.keysym.sym), (int)evt.key.keysym.scancode, (int)evt.key.keysym.mod, (int)evt.key.keysym.unicode); if(evt.key.keysym.sym == SDLK_ESCAPE) return 0; - if( evt.key.state == SDL_PRESSED ) + if( evt.key.state == SDL_RELEASED ) { if(evt.key.keysym.sym == SDLK_0) SDL_ANDROID_SetScreenKeyboardButtonShown(SDL_ANDROID_SCREENKEYBOARD_BUTTON_2, 1); diff --git a/project/jni/application/hid-pc-keyboard/src b/project/jni/application/hid-pc-keyboard/src index 2f9c11eb7..f23f5bfe0 160000 --- a/project/jni/application/hid-pc-keyboard/src +++ b/project/jni/application/hid-pc-keyboard/src @@ -1 +1 @@ -Subproject commit 2f9c11eb72e9246f804498839c63a859bb5c45b9 +Subproject commit f23f5bfe033c076b10983f09eb450ea7785df64c diff --git a/project/jni/application/xserver/AndroidAppSettings.cfg b/project/jni/application/xserver/AndroidAppSettings.cfg index bec654dcb..a6c6738c9 100644 --- a/project/jni/application/xserver/AndroidAppSettings.cfg +++ b/project/jni/application/xserver/AndroidAppSettings.cfg @@ -7,10 +7,10 @@ AppName="XServer XSDL" AppFullName=x.org.server # Application version code (integer) -AppVersionCode=11137 +AppVersionCode=11138 # Application user-visible version name (string) -AppVersionName="1.11.37" +AppVersionName="1.11.38" # 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 diff --git a/project/jni/application/xserver/xserver b/project/jni/application/xserver/xserver index ddef4689b..4dd75cbad 160000 --- a/project/jni/application/xserver/xserver +++ b/project/jni/application/xserver/xserver @@ -1 +1 @@ -Subproject commit ddef4689b5514e246f85aaafc38a5730f8279f3f +Subproject commit 4dd75cbadce270825b3f605443750c8058275eeb