Add the Meta key

Currently using the diamond symbol like the history meta key: https://en.wikipedia.org/wiki/Meta_key
However, this key is actually interpreted as the Super/Windows key but
Android calls it "meta" internally.
This commit is contained in:
Jules Aguillon 2022-02-06 23:01:35 +01:00
parent e86173b895
commit 95c8acc31e
3 changed files with 6 additions and 2 deletions

View File

@ -35,7 +35,7 @@
<key width="1.5" key0="backspace" key2="delete"/> <key width="1.5" key0="backspace" key2="delete"/>
</row> </row>
<row height="0.95"> <row height="0.95">
<key width="1.8" key0="ctrl" key3="switch_numeric"/> <key width="1.8" key0="ctrl" key2="meta" key3="switch_numeric"/>
<key width="1.2" key0="alt" key1="fn" key2="change_method" key3="switch_emoji" key4="config"/> <key width="1.2" key0="alt" key1="fn" key2="change_method" key3="switch_emoji" key4="config"/>
<key width="4.0" key0="space"/> <key width="4.0" key0="space"/>
<key width="1.2" key1="up" key2="right" key3="left" key4="down"/> <key width="1.2" key1="up" key2="right" key3="left" key4="down"/>

View File

@ -24,7 +24,7 @@ class KeyEventHandler implements Config.IKeyEventHandler
case KeyValue.EVENT_CHANGE_METHOD: _recv.switchToNextInputMethod(); return; case KeyValue.EVENT_CHANGE_METHOD: _recv.switchToNextInputMethod(); return;
case KeyValue.EVENT_ACTION: _recv.performAction(); return; case KeyValue.EVENT_ACTION: _recv.performAction(); return;
default: default:
if ((flags & (KeyValue.FLAG_CTRL | KeyValue.FLAG_ALT)) != 0) if ((flags & (KeyValue.FLAG_CTRL | KeyValue.FLAG_ALT | KeyValue.FLAG_META)) != 0)
handleMetaKeyUp(key, flags); handleMetaKeyUp(key, flags);
else if (key.char_ != KeyValue.CHAR_NONE) else if (key.char_ != KeyValue.CHAR_NONE)
_recv.commitChar(key.char_); _recv.commitChar(key.char_);
@ -56,6 +56,8 @@ class KeyEventHandler implements Config.IKeyEventHandler
meta |= KeyEvent.META_ALT_LEFT_ON | KeyEvent.META_ALT_ON; meta |= KeyEvent.META_ALT_LEFT_ON | KeyEvent.META_ALT_ON;
if ((flags & KeyValue.FLAG_SHIFT) != 0) if ((flags & KeyValue.FLAG_SHIFT) != 0)
meta |= KeyEvent.META_SHIFT_LEFT_ON | KeyEvent.META_SHIFT_ON; meta |= KeyEvent.META_SHIFT_LEFT_ON | KeyEvent.META_SHIFT_ON;
if ((flags & KeyValue.FLAG_META) != 0)
meta |= KeyEvent.META_META_LEFT_ON | KeyEvent.META_META_ON;
_recv.sendKeyEvent(key.eventCode, meta); _recv.sendKeyEvent(key.eventCode, meta);
} }

View File

@ -32,6 +32,7 @@ class KeyValue
public static final int FLAG_SHIFT = (1 << 11); public static final int FLAG_SHIFT = (1 << 11);
public static final int FLAG_ALT = (1 << 12); public static final int FLAG_ALT = (1 << 12);
public static final int FLAG_FN = (1 << 13); public static final int FLAG_FN = (1 << 13);
public static final int FLAG_META = (1 << 14);
// Accent flags // Accent flags
public static final int FLAG_ACCENT1 = (1 << 16); // Grave public static final int FLAG_ACCENT1 = (1 << 16); // Grave
@ -159,6 +160,7 @@ class KeyValue
addModifierKey("superscript", "◌͆", FLAG_ACCENT_SUPERSCRIPT); addModifierKey("superscript", "◌͆", FLAG_ACCENT_SUPERSCRIPT);
addModifierKey("subscript", "◌̺", FLAG_ACCENT_SUBSCRIPT); addModifierKey("subscript", "◌̺", FLAG_ACCENT_SUBSCRIPT);
addModifierKey("fn", "Fn", FLAG_FN); addModifierKey("fn", "Fn", FLAG_FN);
addModifierKey("meta", "", FLAG_META);
addCharKey('a', KeyEvent.KEYCODE_A); addCharKey('a', KeyEvent.KEYCODE_A);
addCharKey('b', KeyEvent.KEYCODE_B); addCharKey('b', KeyEvent.KEYCODE_B);