这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ public Map<SpecialButton, SpecialButtonState> getDefaultSpecialButtons(ExtraKeys
put(SpecialButton.CTRL, new SpecialButtonState(extraKeysView));
put(SpecialButton.ALT, new SpecialButtonState(extraKeysView));
put(SpecialButton.SHIFT, new SpecialButtonState(extraKeysView));
put(SpecialButton.META, new SpecialButtonState(extraKeysView));
put(SpecialButton.FN, new SpecialButtonState(extraKeysView));
}};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class SpecialButton {
public static final SpecialButton CTRL = new SpecialButton("CTRL");
public static final SpecialButton ALT = new SpecialButton("ALT");
public static final SpecialButton SHIFT = new SpecialButton("SHIFT");
public static final SpecialButton META = new SpecialButton("META");
public static final SpecialButton FN = new SpecialButton("FN");

/** The special button key. */
Expand Down
24 changes: 19 additions & 5 deletions app/src/main/java/com/termux/x11/utils/TermuxX11ExtraKeys.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class TermuxX11ExtraKeys implements ExtraKeysView.IExtraKeysView {
private boolean ctrlDown;
private boolean altDown;
private boolean shiftDown;
private boolean metaDown;

/** Defines the key for extra keys */
public static final String DEFAULT_IVALUE_EXTRA_KEYS = "[['ESC','/',{key: '-', popup: '|'},'HOME','UP','END','PGUP'], ['TAB','CTRL','ALT','LEFT','DOWN','RIGHT','PGDN']]"; // Double row
Expand All @@ -61,6 +62,7 @@ public void onExtraKeyButtonClick(View view, ExtraKeyButton buttonInfo, Button b
boolean ctrlDown = false;
boolean altDown = false;
boolean shiftDown = false;
boolean metaDown = false;
boolean fnDown = false;
for (String key : keys) {
if (SpecialButton.CTRL.getKey().equals(key)) {
Expand All @@ -69,22 +71,25 @@ public void onExtraKeyButtonClick(View view, ExtraKeyButton buttonInfo, Button b
altDown = true;
} else if (SpecialButton.SHIFT.getKey().equals(key)) {
shiftDown = true;
} else if (SpecialButton.META.getKey().equals(key)) {
metaDown = true;
} else if (SpecialButton.FN.getKey().equals(key)) {
fnDown = true;
} else {
ctrlDown = false;
altDown = false;
shiftDown = false;
metaDown = false;
fnDown = false;
}
onLorieExtraKeyButtonClick(view, key, ctrlDown, altDown, shiftDown, fnDown);
onLorieExtraKeyButtonClick(view, key, ctrlDown, altDown, shiftDown, metaDown, fnDown);
}
} else {
onLorieExtraKeyButtonClick(view, buttonInfo.key, false, false, false, false);
onLorieExtraKeyButtonClick(view, buttonInfo.key, false, false, false, false, false);
}
}

protected void onTerminalExtraKeyButtonClick(@SuppressWarnings("unused") View view, String key, boolean ctrlDown, boolean altDown, boolean shiftDown, @SuppressWarnings("unused") boolean fnDown) {
protected void onTerminalExtraKeyButtonClick(@SuppressWarnings("unused") View view, String key, boolean ctrlDown, boolean altDown, boolean shiftDown, boolean metaDown, @SuppressWarnings("unused") boolean fnDown) {
if (this.ctrlDown != ctrlDown) {
this.ctrlDown = ctrlDown;
mActivity.getLorieView().sendKeyEvent(0, KeyEvent.KEYCODE_CTRL_LEFT, ctrlDown);
Expand All @@ -100,6 +105,11 @@ protected void onTerminalExtraKeyButtonClick(@SuppressWarnings("unused") View vi
mActivity.getLorieView().sendKeyEvent(0, KeyEvent.KEYCODE_SHIFT_LEFT, shiftDown);
}

if (this.metaDown != metaDown) {
this.metaDown = metaDown;
mActivity.getLorieView().sendKeyEvent(0, KeyEvent.KEYCODE_META_LEFT, metaDown);
}

if (PRIMARY_KEY_CODES_FOR_STRINGS.containsKey(key)) {
Integer keyCode = PRIMARY_KEY_CODES_FOR_STRINGS.get(key);
if (keyCode == null) return;
Expand Down Expand Up @@ -129,6 +139,10 @@ public boolean performExtraKeyButtonHapticFeedback(View view, ExtraKeyButton but
pressed = Boolean.TRUE.equals(mExtraKeysView.readSpecialButton(SpecialButton.SHIFT, false));
mActivity.getLorieView().sendKeyEvent(0, KeyEvent.KEYCODE_SHIFT_LEFT, pressed);
break;
case "META":
pressed = Boolean.TRUE.equals(mExtraKeysView.readSpecialButton(SpecialButton.META, false));
mActivity.getLorieView().sendKeyEvent(0, KeyEvent.KEYCODE_META_LEFT, pressed);
break;
}
}, 100);

Expand All @@ -150,7 +164,7 @@ private ViewPager getToolbarViewPager() {
}

@SuppressLint("RtlHardcoded")
public void onLorieExtraKeyButtonClick(View view, String key, boolean ctrlDown, boolean altDown, boolean shiftDown, boolean fnDown) {
public void onLorieExtraKeyButtonClick(View view, String key, boolean ctrlDown, boolean altDown, boolean shiftDown, boolean metaDown, boolean fnDown) {
if ("KEYBOARD".equals(key)) {
if (getToolbarViewPager()!=null) {
getToolbarViewPager().requestFocus();
Expand All @@ -168,7 +182,7 @@ public void onLorieExtraKeyButtonClick(View view, String key, boolean ctrlDown,
if (!TextUtils.isEmpty(pasted)) paste(pasted);
}
} else {
onTerminalExtraKeyButtonClick(view, key, ctrlDown, altDown, shiftDown, fnDown);
onTerminalExtraKeyButtonClick(view, key, ctrlDown, altDown, shiftDown, metaDown, fnDown);
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<string name="not_connected">Not connected</string>
<string name="help_button_text">   Help   </string>
<string name="preferences_button_text">   Preferences   </string>
<string name="extra_keys_config_desc">Here you can set value of extra-keys variable like in Termux app. Read <a href="http://wiki.termux.com/wiki/Touch_Keyboard#Extra_Keys_Row">this</a>.
<string name="extra_keys_config_desc">Here you can set value of extra-keys variable like in Termux app (read <a href="http://wiki.termux.com/wiki/Touch_Keyboard#Extra_Keys_Row">this</a>) and more (e.g. META).
Put empty string for the default value.</string>

<!-- Log Level -->
Expand Down