terminal-view: add "ctrl-space-workaround" property

Makes it possible to run ctrl+space with hardware keyboards on
devices/ROMs where it otherwise is broken. On devices where it already
works this workaround breaks ctrl+space though.

Where to add this fix was investigated and found by @5bodnar.
This commit is contained in:
Henrik Grimler
2020-07-07 18:04:47 +02:00
parent b467b68f7b
commit f1e973f0d2

View File

@@ -539,6 +539,8 @@ public final class TerminalView extends View {
@Override @Override
public boolean onKeyPreIme(int keyCode, KeyEvent event) { public boolean onKeyPreIme(int keyCode, KeyEvent event) {
Properties props = getProperties();
if (LOG_KEY_EVENTS) if (LOG_KEY_EVENTS)
Log.i(EmulatorDebug.LOG_TAG, "onKeyPreIme(keyCode=" + keyCode + ", event=" + event + ")"); Log.i(EmulatorDebug.LOG_TAG, "onKeyPreIme(keyCode=" + keyCode + ", event=" + event + ")");
if (keyCode == KeyEvent.KEYCODE_BACK) { if (keyCode == KeyEvent.KEYCODE_BACK) {
@@ -554,6 +556,11 @@ public final class TerminalView extends View {
return onKeyUp(keyCode, event); return onKeyUp(keyCode, event);
} }
} }
} else if (props.getProperty("ctrl-space-workaround", "false").equals("true") &&
keyCode == KeyEvent.KEYCODE_SPACE && event.isCtrlPressed()) {
/* ctrl + space does not work on some ROMs without this workaround.
However, this breaks it on devices where it works out of the box. */
return onKeyDown(keyCode, event);
} }
return super.onKeyPreIme(keyCode, event); return super.onKeyPreIme(keyCode, event);
} }