Skip to content

Commit

Permalink
Allow the user to disable virtual key emulation.
Browse files Browse the repository at this point in the history
Use volume-keys=volume within termux.properties to disable.
  • Loading branch information
Edontin authored and fornwall committed Jan 6, 2020
1 parent 566d656 commit 90e6260
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/src/main/java/com/termux/app/TermuxPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ final static class KeyboardShortcut {
int mBellBehaviour = BELL_VIBRATE;

boolean mBackIsEscape;
boolean mDisableVolumeVirtualKeys;
boolean mShowExtraKeys;

String[][] mExtraKeys;
Expand Down Expand Up @@ -198,6 +199,7 @@ void reloadFromProperties(Context context) {
}

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

shortcuts.clear();
parseAction("shortcut.create-session", SHORTCUT_ACTION_CREATE_SESSION, props);
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/com/termux/app/TermuxViewClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,9 @@ public boolean onLongPress(MotionEvent event) {
/** Handle dedicated volume buttons as virtual keys if applicable. */
private boolean handleVirtualKeys(int keyCode, KeyEvent event, boolean down) {
InputDevice inputDevice = event.getDevice();
if (inputDevice != null && inputDevice.getKeyboardType() == InputDevice.KEYBOARD_TYPE_ALPHABETIC) {
if (mActivity.mSettings.mDisableVolumeVirtualKeys) {
return false;
} else if (inputDevice != null && inputDevice.getKeyboardType() == InputDevice.KEYBOARD_TYPE_ALPHABETIC) {
// Do not steal dedicated buttons from a full external keyboard.
return false;
} else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
Expand Down

0 comments on commit 90e6260

Please sign in to comment.