mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-06-09 08:07:42 +00:00
add missing key codes to Key.isModifier, and move the information into KeyCode
This commit is contained in:
parent
f81f6a7f7d
commit
7499c38e13
3 changed files with 10 additions and 9 deletions
|
@ -518,11 +518,7 @@ public class Key implements Comparable<Key> {
|
|||
}
|
||||
|
||||
public final boolean isModifier() {
|
||||
return switch (mCode) {
|
||||
case KeyCode.SHIFT, KeyCode.SYMBOL_ALPHA, KeyCode.ALPHA, KeyCode.SYMBOL, KeyCode.NUMPAD, KeyCode.CTRL,
|
||||
KeyCode.ALT, KeyCode.FN, KeyCode.META -> true;
|
||||
default -> false;
|
||||
};
|
||||
return KeyCode.INSTANCE.isModifier(mCode);
|
||||
}
|
||||
|
||||
public final boolean isRepeatable() {
|
||||
|
|
|
@ -202,6 +202,12 @@ object KeyCode {
|
|||
else -> throw IllegalStateException("key code $this not yet supported")
|
||||
}
|
||||
|
||||
fun Int.isModifier() = when (this) {
|
||||
SHIFT, SYMBOL_ALPHA, ALPHA, SYMBOL, NUMPAD, FN, CTRL, CTRL_LEFT, CTRL_RIGHT, ALT, ALT_LEFT, ALT_RIGHT,
|
||||
META, META_LEFT, META_RIGHT -> true
|
||||
else -> false
|
||||
}
|
||||
|
||||
// todo: there are many more keys, see near https://developer.android.com/reference/android/view/KeyEvent#KEYCODE_0
|
||||
/**
|
||||
* Convert a keyCode / codePoint to a KeyEvent.KEYCODE_<xxx>.
|
||||
|
|
|
@ -814,12 +814,11 @@ public final class InputLogic {
|
|||
// {@link KeyboardSwitcher#onEvent(Event)}, or {@link #onPressKey(int,int,boolean)} and {@link #onReleaseKey(int,boolean)}.
|
||||
// We need to switch to the shortcut IME. This is handled by LatinIME since the
|
||||
// input logic has no business with IME switching.
|
||||
case KeyCode.CAPS_LOCK, KeyCode.SYMBOL_ALPHA, KeyCode.ALPHA, KeyCode.SYMBOL, KeyCode.NUMPAD, KeyCode.EMOJI,
|
||||
KeyCode.TOGGLE_ONE_HANDED_MODE, KeyCode.SWITCH_ONE_HANDED_MODE, KeyCode.FN,
|
||||
KeyCode.CTRL, KeyCode.CTRL_LEFT, KeyCode.CTRL_RIGHT, KeyCode.ALT, KeyCode.ALT_LEFT, KeyCode.ALT_RIGHT,
|
||||
KeyCode.META, KeyCode.META_LEFT, KeyCode.META_RIGHT:
|
||||
case KeyCode.CAPS_LOCK, KeyCode.EMOJI, KeyCode.TOGGLE_ONE_HANDED_MODE, KeyCode.SWITCH_ONE_HANDED_MODE:
|
||||
break;
|
||||
default:
|
||||
if (KeyCode.INSTANCE.isModifier(event.getMKeyCode()))
|
||||
return; // continuation of previous switch case, but modifiers are in a separate place
|
||||
if (event.getMMetaState() != 0) {
|
||||
// need to convert codepoint to KeyEvent.KEYCODE_<xxx>
|
||||
final int codeToConvert = event.getMKeyCode() < 0 ? event.getMKeyCode() : event.getMCodePoint();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue