- Intercept the ESC keyboard key to allow the use of the BACK soft key.

This commit is contained in:
dgis 2019-12-19 21:12:22 +01:00
parent 7420e20f92
commit d0ae97d7b6
4 changed files with 10 additions and 12 deletions

View file

@ -54,9 +54,9 @@ NOT WORKING YET
CHANGES
Version 1.8beta1 (2019-12-18)
Version 1.8beta2 (2019-12-19)
- Try to better detect a physical keyboard to modify the mapping of the keys.
- Intercept the ESC keyboard key to allow the use of the BACK soft key.
Version 1.7 (2019-12-12)

View file

@ -33,8 +33,8 @@ android {
applicationId "org.emulator.forty.eight"
minSdkVersion 19
targetSdkVersion 28
versionCode 12
versionName "1.8beta1"
versionCode 13
versionName "1.8beta2"
setProperty("archivesBaseName", "Emu48-v$versionName")
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
externalNativeBuild {

View file

@ -54,9 +54,9 @@ NOT WORKING YET
CHANGES
Version 1.8beta1 (2019-12-18)
Version 1.8beta2 (2019-12-19)
- Try to better detect a physical keyboard to modify the mapping of the keys.
- Intercept the ESC keyboard key to allow the use of the BACK soft key.
Version 1.7 (2019-12-12)

View file

@ -203,8 +203,7 @@ public class MainScreenView extends PanAndScaleView {
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(event.getDeviceId() != -1
&& (event.getFlags() & KeyEvent.FLAG_VIRTUAL_HARD_KEY) == 0
if((event.getFlags() & KeyEvent.FLAG_VIRTUAL_HARD_KEY) == 0
&& (event.getSource() & InputDevice.SOURCE_KEYBOARD) == InputDevice.SOURCE_KEYBOARD) {
char pressedKey = (char) event.getUnicodeChar();
Integer windowsKeycode = charmap.get(pressedKey);
@ -215,7 +214,7 @@ public class MainScreenView extends PanAndScaleView {
if (windowsKeycode != 0)
NativeLib.keyDown(windowsKeycode);
else if(debug) Log.e(TAG, String.format("Unknown keyCode: %d", keyCode));
if(keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_TAB)
if(keyCode == KeyEvent.KEYCODE_ESCAPE /*KEYCODE_BACK*/ || keyCode == KeyEvent.KEYCODE_TAB)
return true;
}
return super.onKeyDown(keyCode, event);
@ -223,8 +222,7 @@ public class MainScreenView extends PanAndScaleView {
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
if(event.getDeviceId() != -1
&& (event.getFlags() & KeyEvent.FLAG_VIRTUAL_HARD_KEY) == 0
if((event.getFlags() & KeyEvent.FLAG_VIRTUAL_HARD_KEY) == 0
&& (event.getSource() & InputDevice.SOURCE_KEYBOARD) == InputDevice.SOURCE_KEYBOARD) {
char pressedKey = (char) event.getUnicodeChar();
Integer windowsKeycode = charmap.get(pressedKey);
@ -235,7 +233,7 @@ public class MainScreenView extends PanAndScaleView {
if (windowsKeycode != 0)
NativeLib.keyUp(windowsKeycode);
else if(debug) Log.e(TAG, String.format("Unknown keyCode: %d", keyCode));
if(keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_TAB)
if(keyCode == KeyEvent.KEYCODE_ESCAPE /*KEYCODE_BACK*/ || keyCode == KeyEvent.KEYCODE_TAB)
return true;
}
return super.onKeyUp(keyCode, event);