Skip to content

Commit 90e6260

Browse files
Edontinfornwall
authored andcommitted
Allow the user to disable virtual key emulation.
Use volume-keys=volume within termux.properties to disable.
1 parent 566d656 commit 90e6260

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

app/src/main/java/com/termux/app/TermuxPreferences.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ final static class KeyboardShortcut {
6666
int mBellBehaviour = BELL_VIBRATE;
6767

6868
boolean mBackIsEscape;
69+
boolean mDisableVolumeVirtualKeys;
6970
boolean mShowExtraKeys;
7071

7172
String[][] mExtraKeys;
@@ -198,6 +199,7 @@ void reloadFromProperties(Context context) {
198199
}
199200

200201
mBackIsEscape = "escape".equals(props.getProperty("back-key", "back"));
202+
mDisableVolumeVirtualKeys = "volume".equals(props.getProperty("volume-keys", "virtual"));
201203

202204
shortcuts.clear();
203205
parseAction("shortcut.create-session", SHORTCUT_ACTION_CREATE_SESSION, props);

app/src/main/java/com/termux/app/TermuxViewClient.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,9 @@ public boolean onLongPress(MotionEvent event) {
264264
/** Handle dedicated volume buttons as virtual keys if applicable. */
265265
private boolean handleVirtualKeys(int keyCode, KeyEvent event, boolean down) {
266266
InputDevice inputDevice = event.getDevice();
267-
if (inputDevice != null && inputDevice.getKeyboardType() == InputDevice.KEYBOARD_TYPE_ALPHABETIC) {
267+
if (mActivity.mSettings.mDisableVolumeVirtualKeys) {
268+
return false;
269+
} else if (inputDevice != null && inputDevice.getKeyboardType() == InputDevice.KEYBOARD_TYPE_ALPHABETIC) {
268270
// Do not steal dedicated buttons from a full external keyboard.
269271
return false;
270272
} else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {

0 commit comments

Comments
 (0)