2015-07-30 20:14:55 +02:00
|
|
|
package juloo.keyboard2;
|
|
|
|
|
2015-08-18 01:25:47 +02:00
|
|
|
import android.view.KeyCharacterMap;
|
2015-07-30 20:14:55 +02:00
|
|
|
import android.view.KeyEvent;
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
2022-06-05 20:14:16 +02:00
|
|
|
final class KeyValue
|
2015-07-30 20:14:55 +02:00
|
|
|
{
|
2022-06-05 19:30:53 +02:00
|
|
|
public static enum Event
|
|
|
|
{
|
|
|
|
CONFIG,
|
|
|
|
SWITCH_TEXT,
|
|
|
|
SWITCH_NUMERIC,
|
|
|
|
SWITCH_EMOJI,
|
|
|
|
SWITCH_BACK_EMOJI,
|
|
|
|
CHANGE_METHOD,
|
|
|
|
ACTION,
|
2022-11-13 00:24:23 +01:00
|
|
|
SWITCH_SECOND,
|
|
|
|
SWITCH_SECOND_BACK,
|
2022-10-23 21:34:05 +02:00
|
|
|
SWITCH_GREEKMATH,
|
|
|
|
CAPS_LOCK,
|
2022-06-05 19:30:53 +02:00
|
|
|
}
|
|
|
|
|
2022-06-05 01:38:42 +02:00
|
|
|
// Must be evaluated in the reverse order of their values.
|
2022-06-05 19:30:53 +02:00
|
|
|
public static enum Modifier
|
|
|
|
{
|
|
|
|
SHIFT,
|
|
|
|
CTRL,
|
|
|
|
ALT,
|
|
|
|
META,
|
|
|
|
DOUBLE_AIGU,
|
|
|
|
DOT_ABOVE,
|
|
|
|
GRAVE,
|
|
|
|
AIGU,
|
|
|
|
CIRCONFLEXE,
|
|
|
|
TILDE,
|
|
|
|
CEDILLE,
|
|
|
|
TREMA,
|
|
|
|
SUPERSCRIPT,
|
|
|
|
SUBSCRIPT,
|
|
|
|
RING,
|
|
|
|
CARON,
|
|
|
|
MACRON,
|
|
|
|
ORDINAL,
|
|
|
|
ARROWS,
|
|
|
|
BOX,
|
|
|
|
OGONEK,
|
|
|
|
SLASH,
|
2022-10-15 23:28:36 +02:00
|
|
|
ARROW_RIGHT,
|
2022-11-05 10:29:36 +01:00
|
|
|
BREVE,
|
2022-11-05 19:26:49 +01:00
|
|
|
BAR,
|
2022-11-05 10:29:36 +01:00
|
|
|
FN, // Must be placed last to be applied first
|
2022-06-05 19:30:53 +02:00
|
|
|
}
|
2022-06-05 01:38:42 +02:00
|
|
|
|
2022-11-13 16:45:57 +01:00
|
|
|
public static enum Editing
|
|
|
|
{
|
|
|
|
COPY,
|
|
|
|
PASTE,
|
|
|
|
CUT,
|
|
|
|
SELECT_ALL,
|
|
|
|
}
|
|
|
|
|
2022-11-13 15:19:50 +01:00
|
|
|
public static enum Kind
|
|
|
|
{
|
2022-11-13 16:45:57 +01:00
|
|
|
Char, String, Keyevent, Event, Modifier, Editing
|
2022-11-13 15:19:50 +01:00
|
|
|
}
|
|
|
|
|
2022-06-05 19:55:55 +02:00
|
|
|
// Behavior flags.
|
|
|
|
public static final int FLAG_LATCH = (1 << 20);
|
|
|
|
public static final int FLAG_LOCK = (1 << 21);
|
|
|
|
// Special keys are not repeated and don't clear latched modifiers.
|
|
|
|
public static final int FLAG_SPECIAL = (1 << 22);
|
|
|
|
public static final int FLAG_PRECISE_REPEAT = (1 << 23);
|
|
|
|
// Rendering flags.
|
2022-11-11 19:15:25 +01:00
|
|
|
public static final int FLAG_KEY_FONT = (1 << 24); // special font file
|
|
|
|
public static final int FLAG_SMALLER_FONT = (1 << 25); // 25% smaller symbols
|
|
|
|
public static final int FLAG_SECONDARY = (1 << 26); // dimmer
|
2022-06-05 19:55:55 +02:00
|
|
|
// Used by [Pointers].
|
2022-11-11 19:15:25 +01:00
|
|
|
public static final int FLAG_LOCKED = (1 << 28);
|
|
|
|
public static final int FLAG_FAKE_PTR = (1 << 29);
|
2022-06-05 19:55:55 +02:00
|
|
|
|
|
|
|
// Ranges for the different components
|
|
|
|
private static final int FLAGS_BITS = (0b111111111 << 20); // 9 bits wide
|
|
|
|
private static final int KIND_BITS = (0b111 << 29); // 3 bits wide
|
|
|
|
private static final int VALUE_BITS = ~(FLAGS_BITS | KIND_BITS); // 20 bits wide
|
|
|
|
static
|
|
|
|
{
|
|
|
|
check((FLAGS_BITS & KIND_BITS) == 0); // No overlap
|
|
|
|
check((FLAGS_BITS | KIND_BITS | VALUE_BITS) == ~0); // No holes
|
|
|
|
}
|
2022-06-05 18:14:50 +02:00
|
|
|
|
2022-06-05 17:26:34 +02:00
|
|
|
private final String _symbol;
|
2022-06-05 01:38:42 +02:00
|
|
|
|
2022-11-13 15:19:50 +01:00
|
|
|
/** This field encodes three things: Kind, flags and value. */
|
2022-06-05 17:26:34 +02:00
|
|
|
private final int _code;
|
|
|
|
|
|
|
|
public Kind getKind()
|
|
|
|
{
|
2022-11-13 15:19:50 +01:00
|
|
|
return Kind.values()[(_code & KIND_BITS) >>> 29];
|
2022-06-05 17:26:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public int getFlags()
|
|
|
|
{
|
2022-06-05 19:55:55 +02:00
|
|
|
return (_code & FLAGS_BITS);
|
2022-06-05 17:26:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean hasFlags(int has)
|
|
|
|
{
|
2022-06-05 19:55:55 +02:00
|
|
|
return ((_code & has) == has);
|
2022-06-05 17:26:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/** The string to render on the keyboard.
|
|
|
|
When [getKind() == Kind.String], also the string to send. */
|
|
|
|
public String getString()
|
|
|
|
{
|
|
|
|
return _symbol;
|
|
|
|
}
|
|
|
|
|
2022-06-05 19:30:53 +02:00
|
|
|
/** Defined only when [getKind() == Kind.Char]. */
|
2022-06-05 17:26:34 +02:00
|
|
|
public char getChar()
|
|
|
|
{
|
2022-06-05 19:55:55 +02:00
|
|
|
return (char)(_code & VALUE_BITS);
|
2022-06-05 17:26:34 +02:00
|
|
|
}
|
|
|
|
|
2022-06-05 19:30:53 +02:00
|
|
|
/** Defined only when [getKind() == Kind.Keyevent]. */
|
|
|
|
public int getKeyevent()
|
2022-06-05 17:26:34 +02:00
|
|
|
{
|
2022-06-05 19:55:55 +02:00
|
|
|
return (_code & VALUE_BITS);
|
2022-06-05 17:26:34 +02:00
|
|
|
}
|
|
|
|
|
2022-06-05 19:30:53 +02:00
|
|
|
/** Defined only when [getKind() == Kind.Event]. */
|
|
|
|
public Event getEvent()
|
2022-06-05 17:26:34 +02:00
|
|
|
{
|
2022-06-05 19:55:55 +02:00
|
|
|
return Event.values()[(_code & VALUE_BITS)];
|
2022-06-05 19:30:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Defined only when [getKind() == Kind.Modifier]. */
|
|
|
|
public Modifier getModifier()
|
|
|
|
{
|
2022-06-05 19:55:55 +02:00
|
|
|
return Modifier.values()[(_code & VALUE_BITS)];
|
2022-06-05 17:26:34 +02:00
|
|
|
}
|
2021-04-18 23:28:49 +02:00
|
|
|
|
2022-11-13 16:45:57 +01:00
|
|
|
/** Defined only when [getKind() == Kind.Editing]. */
|
|
|
|
public Editing getEditing()
|
|
|
|
{
|
|
|
|
return Editing.values()[(_code & VALUE_BITS)];
|
|
|
|
}
|
|
|
|
|
2021-05-08 02:00:47 +02:00
|
|
|
/* Update the char and the symbol. */
|
2022-06-05 18:14:50 +02:00
|
|
|
public KeyValue withChar(char c)
|
2021-05-08 02:00:47 +02:00
|
|
|
{
|
2022-11-13 15:19:50 +01:00
|
|
|
return new KeyValue(String.valueOf(c), Kind.Char, c, getFlags());
|
2021-05-08 02:00:47 +02:00
|
|
|
}
|
|
|
|
|
2022-06-05 18:14:50 +02:00
|
|
|
public KeyValue withString(String s)
|
2021-04-18 23:28:49 +02:00
|
|
|
{
|
2022-11-13 15:19:50 +01:00
|
|
|
return new KeyValue(s, Kind.String, 0, getFlags());
|
2021-04-18 23:28:49 +02:00
|
|
|
}
|
|
|
|
|
2022-06-06 00:23:45 +02:00
|
|
|
public KeyValue withSymbol(String s)
|
2022-03-06 19:36:09 +01:00
|
|
|
{
|
2022-06-06 00:23:45 +02:00
|
|
|
return new KeyValue(s, (_code & KIND_BITS), (_code & VALUE_BITS), getFlags());
|
2022-03-06 19:36:09 +01:00
|
|
|
}
|
|
|
|
|
2022-06-05 19:30:53 +02:00
|
|
|
public KeyValue withKeyevent(int code)
|
2022-06-05 17:44:00 +02:00
|
|
|
{
|
2022-11-13 15:19:50 +01:00
|
|
|
return new KeyValue(_symbol, Kind.Keyevent, code, getFlags());
|
2022-06-05 17:44:00 +02:00
|
|
|
}
|
|
|
|
|
2022-03-05 20:17:45 +01:00
|
|
|
public KeyValue withFlags(int f)
|
|
|
|
{
|
2022-06-06 00:23:45 +02:00
|
|
|
return new KeyValue(_symbol, (_code & KIND_BITS), (_code & VALUE_BITS), f);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean equals(Object obj)
|
|
|
|
{
|
|
|
|
KeyValue snd = (KeyValue)obj;
|
|
|
|
return _symbol.equals(snd._symbol) && _code == snd._code;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int hashCode()
|
|
|
|
{
|
|
|
|
return _symbol.hashCode() + _code;
|
2022-03-05 20:17:45 +01:00
|
|
|
}
|
|
|
|
|
2021-04-18 23:28:49 +02:00
|
|
|
private static HashMap<String, KeyValue> keys = new HashMap<String, KeyValue>();
|
|
|
|
|
2022-06-06 00:23:45 +02:00
|
|
|
public KeyValue(String s, int kind, int value, int flags)
|
2021-04-18 23:28:49 +02:00
|
|
|
{
|
2022-06-05 19:55:55 +02:00
|
|
|
check((kind & ~KIND_BITS) == 0);
|
|
|
|
check((flags & ~FLAGS_BITS) == 0);
|
|
|
|
check((value & ~VALUE_BITS) == 0);
|
2022-06-05 17:26:34 +02:00
|
|
|
_symbol = s;
|
2022-06-05 19:55:55 +02:00
|
|
|
_code = kind | flags | value;
|
2021-04-18 23:28:49 +02:00
|
|
|
}
|
|
|
|
|
2022-11-13 15:19:50 +01:00
|
|
|
public KeyValue(String s, Kind k, int v, int f)
|
|
|
|
{
|
|
|
|
this(s, (k.ordinal() << 29), v, f);
|
|
|
|
}
|
|
|
|
|
2021-12-19 19:44:27 +01:00
|
|
|
public static KeyValue getKeyByName(String name)
|
2021-04-18 23:28:49 +02:00
|
|
|
{
|
2022-06-24 20:26:27 +02:00
|
|
|
KeyValue kv = keys.get(name);
|
2021-05-08 02:00:47 +02:00
|
|
|
if (kv != null)
|
|
|
|
return kv;
|
2022-06-05 18:14:50 +02:00
|
|
|
if (name.length() == 1)
|
2022-11-13 15:19:50 +01:00
|
|
|
return new KeyValue(name, Kind.Char, name.charAt(0), 0);
|
2022-06-05 18:14:50 +02:00
|
|
|
else
|
2022-11-13 15:19:50 +01:00
|
|
|
return new KeyValue(name, Kind.String, 0, 0);
|
2021-04-18 23:28:49 +02:00
|
|
|
}
|
2015-08-01 16:33:30 +02:00
|
|
|
|
2022-11-13 15:19:50 +01:00
|
|
|
private static void addKey(String name, String symbol, Kind kind, int code, int flags)
|
2021-04-18 21:58:13 +02:00
|
|
|
{
|
2022-06-06 00:23:45 +02:00
|
|
|
keys.put(name, new KeyValue(symbol, kind, code, flags));
|
2021-04-18 21:58:13 +02:00
|
|
|
}
|
|
|
|
|
2022-06-05 17:44:00 +02:00
|
|
|
private static void addCharKey(String name, String symbol, char c, int flags)
|
2022-01-09 12:49:28 +01:00
|
|
|
{
|
2022-11-13 15:19:50 +01:00
|
|
|
addKey(name, symbol, Kind.Char, c, flags);
|
2021-04-18 21:58:13 +02:00
|
|
|
}
|
|
|
|
|
2022-10-23 21:42:03 +02:00
|
|
|
private static void addModifierKey(String name, String symbol, Modifier m, int flags)
|
2021-04-18 21:58:13 +02:00
|
|
|
{
|
2022-10-23 21:42:03 +02:00
|
|
|
if (symbol.length() > 1)
|
|
|
|
flags |= FLAG_SMALLER_FONT;
|
2022-11-13 15:19:50 +01:00
|
|
|
addKey(name, symbol, Kind.Modifier, m.ordinal(),
|
2022-11-11 19:15:25 +01:00
|
|
|
FLAG_LATCH | FLAG_SPECIAL | FLAG_SECONDARY | flags);
|
2022-02-13 13:46:37 +01:00
|
|
|
}
|
|
|
|
|
2022-10-23 21:42:03 +02:00
|
|
|
private static void addModifierKey(String name, int symbol, Modifier m, int flags)
|
2022-10-15 23:28:36 +02:00
|
|
|
{
|
2022-10-23 21:42:03 +02:00
|
|
|
addModifierKey(name, String.valueOf((char)symbol), m, flags | FLAG_KEY_FONT);
|
|
|
|
}
|
|
|
|
|
|
|
|
private static void addDiacritic(String name, int symbol, Modifier m)
|
|
|
|
{
|
2022-11-13 15:19:50 +01:00
|
|
|
addKey(name, String.valueOf((char)symbol), Kind.Modifier, m.ordinal(),
|
2022-11-11 19:15:25 +01:00
|
|
|
FLAG_LATCH | FLAG_SPECIAL | FLAG_KEY_FONT);
|
2022-10-15 23:28:36 +02:00
|
|
|
}
|
|
|
|
|
2022-06-05 19:30:53 +02:00
|
|
|
private static void addEventKey(String name, String symbol, Event e, int flags)
|
2022-02-13 13:46:37 +01:00
|
|
|
{
|
2022-11-13 15:19:50 +01:00
|
|
|
addKey(name, symbol, Kind.Event, e.ordinal(), flags | FLAG_SPECIAL | FLAG_SECONDARY);
|
2021-04-18 21:58:13 +02:00
|
|
|
}
|
|
|
|
|
2022-10-23 21:42:03 +02:00
|
|
|
private static void addEventKey(String name, int symbol, Event e, int flags)
|
|
|
|
{
|
|
|
|
addEventKey(name, String.valueOf((char)symbol), e, flags | FLAG_KEY_FONT);
|
|
|
|
}
|
|
|
|
|
2022-06-05 19:30:53 +02:00
|
|
|
private static void addKeyeventKey(String name, String symbol, int code, int flags)
|
2021-04-19 22:29:20 +02:00
|
|
|
{
|
2022-11-13 15:19:50 +01:00
|
|
|
addKey(name, symbol, Kind.Keyevent, code, flags | FLAG_SECONDARY);
|
2021-04-19 22:29:20 +02:00
|
|
|
}
|
|
|
|
|
2022-10-23 21:42:03 +02:00
|
|
|
private static void addKeyeventKey(String name, int symbol, int code, int flags)
|
|
|
|
{
|
|
|
|
addKeyeventKey(name, String.valueOf((char)symbol), code, flags | FLAG_KEY_FONT);
|
|
|
|
}
|
|
|
|
|
2022-11-13 16:45:57 +01:00
|
|
|
private static void addEditingKey(String name, String symbol, Editing action)
|
|
|
|
{
|
|
|
|
addKey(name, symbol, Kind.Editing, action.ordinal(),
|
|
|
|
FLAG_SPECIAL | FLAG_SECONDARY | FLAG_SMALLER_FONT);
|
|
|
|
}
|
|
|
|
|
2022-06-24 20:56:04 +02:00
|
|
|
// Within VALUE_BITS
|
|
|
|
private static int placeholder_unique_id = 0;
|
|
|
|
|
|
|
|
/** Use a unique id as the value because the symbol is shared between every
|
|
|
|
placeholders (it is the empty string). */
|
2022-06-06 00:23:45 +02:00
|
|
|
private static void addPlaceholderKey(String name)
|
|
|
|
{
|
2022-11-13 15:19:50 +01:00
|
|
|
addKey(name, "", Kind.String, placeholder_unique_id++, 0);
|
2022-06-06 00:23:45 +02:00
|
|
|
}
|
|
|
|
|
2021-04-18 21:58:13 +02:00
|
|
|
static
|
|
|
|
{
|
2022-10-23 22:02:41 +02:00
|
|
|
addModifierKey("shift", 0x0A, Modifier.SHIFT, 0);
|
2022-10-23 21:42:03 +02:00
|
|
|
addModifierKey("ctrl", "Ctrl", Modifier.CTRL, 0);
|
|
|
|
addModifierKey("alt", "Alt", Modifier.ALT, 0);
|
2022-10-15 23:28:36 +02:00
|
|
|
addDiacritic("accent_aigu", 0x50, Modifier.AIGU);
|
|
|
|
addDiacritic("accent_caron", 0x51, Modifier.CARON);
|
|
|
|
addDiacritic("accent_cedille", 0x52, Modifier.CEDILLE);
|
|
|
|
addDiacritic("accent_circonflexe", 0x53, Modifier.CIRCONFLEXE);
|
|
|
|
addDiacritic("accent_grave", 0x54, Modifier.GRAVE);
|
|
|
|
addDiacritic("accent_macron", 0x55, Modifier.MACRON);
|
|
|
|
addDiacritic("accent_ring", 0x56, Modifier.RING);
|
|
|
|
addDiacritic("accent_tilde", 0x57, Modifier.TILDE);
|
|
|
|
addDiacritic("accent_trema", 0x58, Modifier.TREMA);
|
|
|
|
addDiacritic("accent_ogonek", 0x59, Modifier.OGONEK);
|
|
|
|
addDiacritic("accent_dot_above", 0x5A, Modifier.DOT_ABOVE);
|
|
|
|
addDiacritic("accent_double_aigu", 0x5B, Modifier.DOUBLE_AIGU);
|
|
|
|
addDiacritic("accent_slash", 0x5C, Modifier.SLASH);
|
|
|
|
addDiacritic("accent_arrow_right", 0x5D, Modifier.ARROW_RIGHT);
|
|
|
|
addDiacritic("accent_breve", 0x5E, Modifier.BREVE);
|
2022-11-05 19:26:49 +01:00
|
|
|
addDiacritic("accent_bar", 0x5F, Modifier.BAR);
|
2022-10-23 21:42:03 +02:00
|
|
|
addModifierKey("superscript", "Sup", Modifier.SUPERSCRIPT, 0);
|
|
|
|
addModifierKey("subscript", "Sub", Modifier.SUBSCRIPT, 0);
|
|
|
|
addModifierKey("ordinal", "Ord", Modifier.ORDINAL, 0);
|
|
|
|
addModifierKey("arrows", "Arr", Modifier.ARROWS, 0);
|
|
|
|
addModifierKey("box", "Box", Modifier.BOX, 0);
|
|
|
|
addModifierKey("fn", "Fn", Modifier.FN, 0);
|
|
|
|
addModifierKey("meta", "Meta", Modifier.META, 0);
|
|
|
|
|
|
|
|
addEventKey("config", 0x04, Event.CONFIG, FLAG_SMALLER_FONT);
|
2022-06-05 19:30:53 +02:00
|
|
|
addEventKey("switch_text", "ABC", Event.SWITCH_TEXT, FLAG_SMALLER_FONT);
|
|
|
|
addEventKey("switch_numeric", "123+", Event.SWITCH_NUMERIC, FLAG_SMALLER_FONT);
|
2022-10-23 21:42:03 +02:00
|
|
|
addEventKey("switch_emoji", 0x01, Event.SWITCH_EMOJI, FLAG_SMALLER_FONT);
|
2022-06-05 19:30:53 +02:00
|
|
|
addEventKey("switch_back_emoji", "ABC", Event.SWITCH_BACK_EMOJI, 0);
|
2022-11-13 00:24:23 +01:00
|
|
|
addEventKey("switch_second", 0x13, Event.SWITCH_SECOND, FLAG_SMALLER_FONT);
|
|
|
|
addEventKey("switch_second_back", 0x14, Event.SWITCH_SECOND_BACK, FLAG_SMALLER_FONT);
|
2022-07-09 17:30:26 +02:00
|
|
|
addEventKey("switch_greekmath", "πλ∇¬", Event.SWITCH_GREEKMATH, FLAG_SMALLER_FONT);
|
2022-10-23 21:42:03 +02:00
|
|
|
addEventKey("change_method", 0x09, Event.CHANGE_METHOD, FLAG_SMALLER_FONT);
|
2022-06-05 19:30:53 +02:00
|
|
|
addEventKey("action", "Action", Event.ACTION, FLAG_SMALLER_FONT); // Will always be replaced
|
2022-10-23 21:42:03 +02:00
|
|
|
addEventKey("capslock", 0x12, Event.CAPS_LOCK, 0);
|
2022-06-05 19:30:53 +02:00
|
|
|
|
|
|
|
addKeyeventKey("esc", "Esc", KeyEvent.KEYCODE_ESCAPE, FLAG_SMALLER_FONT);
|
2022-10-23 21:42:03 +02:00
|
|
|
addKeyeventKey("enter", 0x0E, KeyEvent.KEYCODE_ENTER, 0);
|
|
|
|
addKeyeventKey("up", 0x05, KeyEvent.KEYCODE_DPAD_UP, FLAG_PRECISE_REPEAT);
|
|
|
|
addKeyeventKey("right", 0x06, KeyEvent.KEYCODE_DPAD_RIGHT, FLAG_PRECISE_REPEAT);
|
|
|
|
addKeyeventKey("down", 0x07, KeyEvent.KEYCODE_DPAD_DOWN, FLAG_PRECISE_REPEAT);
|
|
|
|
addKeyeventKey("left", 0x08, KeyEvent.KEYCODE_DPAD_LEFT, FLAG_PRECISE_REPEAT);
|
|
|
|
addKeyeventKey("page_up", 0x02, KeyEvent.KEYCODE_PAGE_UP, 0);
|
|
|
|
addKeyeventKey("page_down", 0x03, KeyEvent.KEYCODE_PAGE_DOWN, 0);
|
|
|
|
addKeyeventKey("home", 0x0B, KeyEvent.KEYCODE_MOVE_HOME, 0);
|
|
|
|
addKeyeventKey("end", 0x0C, KeyEvent.KEYCODE_MOVE_END, 0);
|
|
|
|
addKeyeventKey("backspace", 0x11, KeyEvent.KEYCODE_DEL, 0);
|
|
|
|
addKeyeventKey("delete", 0x10, KeyEvent.KEYCODE_FORWARD_DEL, 0);
|
2022-06-05 19:30:53 +02:00
|
|
|
addKeyeventKey("insert", "Ins", KeyEvent.KEYCODE_INSERT, FLAG_SMALLER_FONT);
|
|
|
|
addKeyeventKey("f1", "F1", KeyEvent.KEYCODE_F1, 0);
|
|
|
|
addKeyeventKey("f2", "F2", KeyEvent.KEYCODE_F2, 0);
|
|
|
|
addKeyeventKey("f3", "F3", KeyEvent.KEYCODE_F3, 0);
|
|
|
|
addKeyeventKey("f4", "F4", KeyEvent.KEYCODE_F4, 0);
|
|
|
|
addKeyeventKey("f5", "F5", KeyEvent.KEYCODE_F5, 0);
|
|
|
|
addKeyeventKey("f6", "F6", KeyEvent.KEYCODE_F6, 0);
|
|
|
|
addKeyeventKey("f7", "F7", KeyEvent.KEYCODE_F7, 0);
|
|
|
|
addKeyeventKey("f8", "F8", KeyEvent.KEYCODE_F8, 0);
|
|
|
|
addKeyeventKey("f9", "F9", KeyEvent.KEYCODE_F9, 0);
|
|
|
|
addKeyeventKey("f10", "F10", KeyEvent.KEYCODE_F10, 0);
|
|
|
|
addKeyeventKey("f11", "F11", KeyEvent.KEYCODE_F11, FLAG_SMALLER_FONT);
|
|
|
|
addKeyeventKey("f12", "F12", KeyEvent.KEYCODE_F12, FLAG_SMALLER_FONT);
|
2022-10-23 21:42:03 +02:00
|
|
|
addKeyeventKey("tab", 0x0F, KeyEvent.KEYCODE_TAB, FLAG_SMALLER_FONT);
|
2021-04-18 21:58:13 +02:00
|
|
|
|
2022-06-05 17:44:00 +02:00
|
|
|
addCharKey("\\t", "\\t", '\t', 0); // Send the tab character
|
2022-11-11 19:15:25 +01:00
|
|
|
addCharKey("space", "\r", ' ', FLAG_KEY_FONT | FLAG_SECONDARY);
|
2022-10-23 21:42:03 +02:00
|
|
|
addCharKey("nbsp", "\u237d", '\u00a0', FLAG_SMALLER_FONT);
|
2022-06-05 20:15:11 +02:00
|
|
|
|
2022-06-06 00:23:45 +02:00
|
|
|
addPlaceholderKey("removed");
|
|
|
|
addPlaceholderKey("f11_placeholder");
|
|
|
|
addPlaceholderKey("f12_placeholder");
|
2022-11-13 16:45:57 +01:00
|
|
|
|
|
|
|
addEditingKey("copy", "copy", Editing.COPY);
|
|
|
|
addEditingKey("paste", "paste", Editing.PASTE);
|
|
|
|
addEditingKey("cut", "cut", Editing.CUT);
|
|
|
|
addEditingKey("select_all", "s. all", Editing.SELECT_ALL);
|
2021-04-18 21:58:13 +02:00
|
|
|
}
|
2022-06-05 19:55:55 +02:00
|
|
|
|
2022-10-23 21:51:43 +02:00
|
|
|
static final HashMap<String, String> keys_descr = new HashMap<String, String>();
|
|
|
|
|
|
|
|
/* Some keys have a description attached. Return [null] if otherwise. */
|
|
|
|
public static String getKeyDescription(String name)
|
|
|
|
{
|
|
|
|
return keys_descr.get(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void addKeyDescr(String name, String descr)
|
|
|
|
{
|
|
|
|
keys_descr.put(name, descr);
|
|
|
|
}
|
|
|
|
|
|
|
|
static {
|
|
|
|
/* Keys description is shown in the settings. */
|
|
|
|
addKeyDescr("capslock", "Caps lock");
|
|
|
|
addKeyDescr("switch_greekmath", "Greek & math symbols");
|
|
|
|
}
|
|
|
|
|
2022-06-05 19:55:55 +02:00
|
|
|
// Substitute for [assert], which has no effect on Android.
|
|
|
|
private static void check(boolean b)
|
|
|
|
{
|
|
|
|
if (!b)
|
|
|
|
throw new RuntimeException("Assertion failure");
|
|
|
|
}
|
2015-07-30 20:14:55 +02:00
|
|
|
}
|