Refactor: Abstract KeyValue fields

The meaning of the public fields of KeyValue was quite complicated and
not handled consistently accross the app.

Make these fields private and add a more abstract API on top.

The meaning of these fields changed recently and it wasn't an easy
change. I plan on making more changes in the future.
This commit is contained in:
Jules Aguillon 2022-06-05 17:26:34 +02:00
parent d03e96da3e
commit e10c587dc5
10 changed files with 357 additions and 242 deletions

View File

@ -163,28 +163,31 @@ final class Config
boolean is_extra_key = extra_keys.contains(key.name);
if (is_extra_key)
extra_keys.remove(key.name);
switch (key.code)
int flags = key.getFlags();
if ((flags & KeyValue.FLAG_LOCALIZED) != 0 && !is_extra_key)
return null;
switch (key.getKind())
{
case KeyValue.EVENT_CHANGE_METHOD:
return shouldOfferSwitchingToNextInputMethod ? key : null;
case KeyEvent.KEYCODE_ENTER:
return (swapEnterActionKey && action_key != null) ? action_key : key;
case KeyValue.EVENT_ACTION:
return (swapEnterActionKey && action_key != null) ?
KeyValue.getKeyByName("enter") : action_key;
case KeyValue.EVENT_SWITCH_PROGRAMMING:
return shouldOfferSwitchingToProgramming ? key : null;
default:
if (key.flags != 0)
case Event:
switch (key.getEvent())
{
if ((key.flags & KeyValue.FLAG_LOCALIZED) != 0 && !is_extra_key)
return null;
if ((key.flags & KeyValue.FLAG_MODIFIER) != 0
&& lockable_modifiers.contains(key.code))
return key.withFlags(key.flags | KeyValue.FLAG_LOCK);
case KeyValue.EVENT_CHANGE_METHOD:
return shouldOfferSwitchingToNextInputMethod ? key : null;
case KeyEvent.KEYCODE_ENTER:
return (swapEnterActionKey && action_key != null) ? action_key : key;
case KeyValue.EVENT_ACTION:
return (swapEnterActionKey && action_key != null) ?
KeyValue.getKeyByName("enter") : action_key;
case KeyValue.EVENT_SWITCH_PROGRAMMING:
return shouldOfferSwitchingToProgramming ? key : null;
}
return key;
break;
case Modifier:
if (lockable_modifiers.contains(key.getModifier()))
return key.withFlags(flags | KeyValue.FLAG_LOCK);
break;
}
return key;
}
});
if (extra_keys.size() > 0)

View File

@ -126,7 +126,7 @@ public class EmojiGridView extends GridView
public void setEmoji(Emoji emoji)
{
setText(emoji.symbol);
setText(emoji.getString());
}
}

View File

@ -15,7 +15,7 @@ public class EmojiGroupButtonsBar extends LinearLayout
for (int i = 0; i < Emoji.num_groups; i++)
{
Emoji first = Emoji.getEmojisByGroup(i)[0];
add_group(i, first.symbol);
add_group(i, first.getString());
}
}

View File

@ -15,8 +15,8 @@ public class EmojiKeyButton extends Button
super(context, attrs);
setOnClickListener(this);
_key = KeyValue.getKeyByName(attrs.getAttributeValue(null, "key"));
setText(_key.symbol);
if ((_key.flags & KeyValue.FLAG_KEY_FONT) != 0)
setText(_key.getString());
if (_key.hasFlags(KeyValue.FLAG_KEY_FONT))
setTypeface(Theme.getSpecialKeyFont(context));
}

View File

@ -13,25 +13,40 @@ class KeyEventHandler implements Config.IKeyEventHandler
public void handleKeyUp(KeyValue key, Pointers.Modifiers mods)
{
if (key == null || (key.flags & KeyValue.FLAG_MODIFIER) != 0)
if (key == null)
return;
switch (key.code)
int event;
switch (key.getKind())
{
case KeyValue.EVENT_CONFIG: _recv.showKeyboardConfig(); return;
case KeyValue.EVENT_SWITCH_TEXT: _recv.switchMain(); return;
case KeyValue.EVENT_SWITCH_NUMERIC: _recv.switchNumeric(); return;
case KeyValue.EVENT_SWITCH_EMOJI: _recv.setPane_emoji(); return;
case KeyValue.EVENT_SWITCH_BACK_EMOJI: _recv.setPane_normal(); return;
case KeyValue.EVENT_CHANGE_METHOD: _recv.switchToNextInputMethod(); return;
case KeyValue.EVENT_ACTION: _recv.performAction(); return;
case KeyValue.EVENT_SWITCH_PROGRAMMING: _recv.switchProgramming(); return;
default:
if (shouldSendEvents(key, mods))
handleKeyUpWithModifier(key, mods);
else if (key.char_ != KeyValue.CHAR_NONE)
_recv.commitChar(key.char_);
else
_recv.commitText(key.symbol);
case Char:
// Send an event if some modifiers are active.
event = key.getCharEvent();
if (shouldSendEvents(mods) && event != KeyValue.EVENT_NONE)
handleKeyUpWithModifier(event, mods);
_recv.commitChar(key.getChar());
break;
case String:
_recv.commitText(key.getString());
break;
case Event:
event = key.getEvent();
switch (event)
{
case KeyValue.EVENT_CONFIG: _recv.showKeyboardConfig(); break;
case KeyValue.EVENT_SWITCH_TEXT: _recv.switchMain(); break;
case KeyValue.EVENT_SWITCH_NUMERIC: _recv.switchNumeric(); break;
case KeyValue.EVENT_SWITCH_EMOJI: _recv.setPane_emoji(); break;
case KeyValue.EVENT_SWITCH_BACK_EMOJI: _recv.setPane_normal(); break;
case KeyValue.EVENT_CHANGE_METHOD: _recv.switchToNextInputMethod(); break;
case KeyValue.EVENT_ACTION: _recv.performAction(); break;
case KeyValue.EVENT_SWITCH_PROGRAMMING: _recv.switchProgramming(); break;
default:
handleKeyUpWithModifier(event, mods);
break;
}
break;
case Modifier:
break;
}
}
@ -74,21 +89,21 @@ class KeyEventHandler implements Config.IKeyEventHandler
/*
* Don't set KeyEvent.FLAG_SOFT_KEYBOARD.
*/
private void handleKeyUpWithModifier(KeyValue key, Pointers.Modifiers mods)
private void handleKeyUpWithModifier(int keyCode, Pointers.Modifiers mods)
{
if (key.code == KeyValue.EVENT_NONE)
if (keyCode == KeyValue.EVENT_NONE)
return ;
int metaState = 0;
for (int i = 0; i < mods.size(); i++)
metaState = sendMetaKeyForModifier(mods.get(i), metaState, true);
_recv.sendKeyEvent(KeyEvent.ACTION_DOWN, key.code, metaState);
_recv.sendKeyEvent(KeyEvent.ACTION_UP, key.code, metaState);
_recv.sendKeyEvent(KeyEvent.ACTION_DOWN, keyCode, metaState);
_recv.sendKeyEvent(KeyEvent.ACTION_UP, keyCode, metaState);
for (int i = mods.size() - 1; i >= 0; i--)
metaState = sendMetaKeyForModifier(mods.get(i), metaState, false);
}
/** Whether to send up and down events (true) or commit the text (false). */
private boolean shouldSendEvents(KeyValue key, Pointers.Modifiers mods)
private boolean shouldSendEvents(Pointers.Modifiers mods)
{
// Check for modifiers
for (int i = 0; i < mods.size(); i++)
@ -101,9 +116,6 @@ class KeyEventHandler implements Config.IKeyEventHandler
default: break;
}
}
// Key has no char but has a key event
if (key.char_ == KeyValue.CHAR_NONE && key.code >= 0)
return true;
return false;
}

View File

@ -50,55 +50,72 @@ class KeyModifier
case KeyValue.MOD_MACRON: return apply_dead_char(k, '\u00AF');
case KeyValue.MOD_OGONEK: return apply_dead_char(k, '\u02DB');
case KeyValue.MOD_DOT_ABOVE: return apply_dead_char(k, '\u02D9');
case KeyValue.MOD_DOUBLE_AIGU:
return maybe_modify_char(k, map_char_double_aigu(k.char_));
case KeyValue.MOD_ORDINAL:
return maybe_modify_char(k, map_char_ordinal(k.char_));
case KeyValue.MOD_SUPERSCRIPT:
return maybe_modify_char(k, map_char_superscript(k.char_));
case KeyValue.MOD_SUBSCRIPT:
return maybe_modify_char(k, map_char_subscript(k.char_));
case KeyValue.MOD_ARROWS:
return maybe_modify_char(k, map_char_arrows(k.char_));
case KeyValue.MOD_BOX:
return maybe_modify_char(k, map_char_box(k.char_));
case KeyValue.MOD_SLASH:
return maybe_modify_char(k, map_char_slash(k.char_));
case KeyValue.MOD_DOUBLE_AIGU: return apply_map_char(k, map_char_double_aigu);
case KeyValue.MOD_ORDINAL: return apply_map_char(k, map_char_ordinal);
case KeyValue.MOD_SUPERSCRIPT: return apply_map_char(k, map_char_superscript);
case KeyValue.MOD_SUBSCRIPT: return apply_map_char(k, map_char_subscript);
case KeyValue.MOD_ARROWS: return apply_map_char(k, map_char_arrows);
case KeyValue.MOD_BOX: return apply_map_char(k, map_char_box);
case KeyValue.MOD_SLASH: return apply_map_char(k, map_char_slash);
case KeyValue.MOD_ARROW_RIGHT: return apply_combining(k, "\u20D7");
default: return k;
}
}
private static KeyValue apply_map_char(KeyValue k, Map_char map)
{
switch (k.getKind())
{
case Char:
char kc = k.getChar();
char c = map.apply(kc);
return (kc == c) ? k : k.withCharAndSymbol(c);
default: return k;
}
}
private static KeyValue apply_dead_char(KeyValue k, char dead_char)
{
char c = k.char_;
if (c != KeyValue.CHAR_NONE)
c = (char)KeyCharacterMap.getDeadChar(dead_char, c);
return maybe_modify_char(k, c);
switch (k.getKind())
{
case Char:
char kc = k.getChar();
char c = (char)KeyCharacterMap.getDeadChar(dead_char, kc);
if (c == 0 || kc == c)
return k;
return k.withCharAndSymbol(c);
default: return k;
}
}
private static KeyValue apply_combining(KeyValue k, String combining)
{
if (k.char_ == KeyValue.CHAR_NONE)
return k;
return KeyValue.getKeyByName(String.valueOf(k.char_) + combining);
switch (k.getKind())
{
case Char:
String s = String.valueOf(k.getChar()) + combining;
return k.withCharAndSymbol(s, KeyValue.CHAR_NONE);
default: return k;
}
}
private static KeyValue apply_shift(KeyValue k)
{
char c = k.char_;
if (c == KeyValue.CHAR_NONE)
switch (k.getKind())
{
// The key is a string
if (k.code == KeyValue.EVENT_NONE)
return k.withCharAndSymbol(k.symbol.toUpperCase(), KeyValue.CHAR_NONE);
else
return k;
case Char:
char kc = k.getChar();
char c = map_char_shift(kc);
if (kc == c)
c = Character.toUpperCase(kc);
if (kc == c)
return k;
return k.withCharAndSymbol(c);
case String:
String s = k.getString().toUpperCase();
return k.withCharAndSymbol(s, KeyValue.CHAR_NONE);
default: return k;
}
c = map_char_shift(c);
if (c == k.char_)
c = Character.toUpperCase(c);
return maybe_modify_char(k, c);
}
private static KeyValue apply_fn(KeyValue k)
@ -180,14 +197,6 @@ class KeyModifier
}
}
/** Helper, update [k] with the char [c] if it's not [0]. */
private static KeyValue maybe_modify_char(KeyValue k, char c)
{
if (c == 0 || c == KeyValue.CHAR_NONE || c == k.char_)
return k;
return k.withCharAndSymbol(c);
}
/* Lookup the cache entry for a key. Create it needed. */
private static HashMap<Pointers.Modifiers, KeyValue> cacheEntry(KeyValue k)
{
@ -200,6 +209,11 @@ class KeyModifier
return ks;
}
private static abstract class Map_char
{
public abstract char apply(char c);
}
private static char map_char_shift(char c)
{
switch (c)
@ -227,138 +241,159 @@ class KeyModifier
}
}
private static char map_char_double_aigu(char c)
{
switch (c)
{
// Composite characters: ӳ
case 'o': return 'ő';
case 'u': return 'ű';
case ' ': return '˝';
default: return c;
}
}
private static final Map_char map_char_double_aigu =
new Map_char() {
public char apply(char c)
{
switch (c)
{
// Composite characters: ӳ
case 'o': return 'ő';
case 'u': return 'ű';
case ' ': return '˝';
default: return c;
}
}
};
private static char map_char_ordinal(char c)
{
switch (c)
{
case 'a': return 'ª';
case 'o': return 'º';
case '1': return 'ª';
case '2': return 'º';
case '3': return 'ⁿ';
case '4': return 'ᵈ';
case '5': return 'ᵉ';
case '6': return 'ʳ';
case '7': return 'ˢ';
case '8': return 'ᵗ';
case '9': return 'ʰ';
case '*': return '°';
default: return c;
}
}
private static final Map_char map_char_ordinal =
new Map_char() {
public char apply(char c)
{
switch (c)
{
case 'a': return 'ª';
case 'o': return 'º';
case '1': return 'ª';
case '2': return 'º';
case '3': return 'ⁿ';
case '4': return 'ᵈ';
case '5': return 'ᵉ';
case '6': return 'ʳ';
case '7': return 'ˢ';
case '8': return 'ᵗ';
case '9': return 'ʰ';
case '*': return '°';
default: return c;
}
}
};
private static char map_char_superscript(char c)
{
switch (c)
{
case '1': return '¹';
case '2': return '²';
case '3': return '³';
case '4': return '⁴';
case '5': return '⁵';
case '6': return '⁶';
case '7': return '⁷';
case '8': return '⁸';
case '9': return '⁹';
case '0': return '⁰';
case 'i': return 'ⁱ';
case '+': return '⁺';
case '-': return '⁻';
case '=': return '⁼';
case '(': return '⁽';
case ')': return '⁾';
case 'n': return 'ⁿ';
default: return c;
}
}
private static final Map_char map_char_superscript =
new Map_char() {
public char apply(char c)
{
switch (c)
{
case '1': return '¹';
case '2': return '²';
case '3': return '³';
case '4': return '⁴';
case '5': return '⁵';
case '6': return '⁶';
case '7': return '⁷';
case '8': return '⁸';
case '9': return '⁹';
case '0': return '⁰';
case 'i': return 'ⁱ';
case '+': return '⁺';
case '-': return '⁻';
case '=': return '⁼';
case '(': return '⁽';
case ')': return '⁾';
case 'n': return 'ⁿ';
default: return c;
}
}
};
private static char map_char_subscript(char c)
{
switch (c)
{
case '1': return '₁';
case '2': return '₂';
case '3': return '₃';
case '4': return '₄';
case '5': return '₅';
case '6': return '₆';
case '7': return '₇';
case '8': return '₈';
case '9': return '₉';
case '0': return '₀';
case '+': return '₊';
case '-': return '₋';
case '=': return '₌';
case '(': return '₍';
case ')': return '₎';
case 'e': return 'ₑ';
case 'a': return 'ₐ';
case 'x': return 'ₓ';
case 'o': return 'ₒ';
default: return c;
}
}
private static final Map_char map_char_subscript =
new Map_char() {
public char apply(char c)
{
switch (c)
{
case '1': return '₁';
case '2': return '₂';
case '3': return '₃';
case '4': return '₄';
case '5': return '₅';
case '6': return '₆';
case '7': return '₇';
case '8': return '₈';
case '9': return '₉';
case '0': return '₀';
case '+': return '₊';
case '-': return '₋';
case '=': return '₌';
case '(': return '₍';
case ')': return '₎';
case 'e': return 'ₑ';
case 'a': return 'ₐ';
case 'x': return 'ₓ';
case 'o': return 'ₒ';
default: return c;
}
}
};
private static char map_char_arrows(char c)
{
switch (c)
{
case '1': return '↙';
case '2': return '↓';
case '3': return '↘';
case '4': return '←';
case '6': return '→';
case '7': return '↖';
case '8': return '↑';
case '9': return '↗';
default: return c;
}
}
private static final Map_char map_char_arrows =
new Map_char() {
public char apply(char c)
{
switch (c)
{
case '1': return '↙';
case '2': return '↓';
case '3': return '↘';
case '4': return '←';
case '6': return '→';
case '7': return '↖';
case '8': return '↑';
case '9': return '↗';
default: return c;
}
}
};
private static char map_char_box(char c)
{
switch (c)
{
case '1': return '└';
case '2': return '┴';
case '3': return '┘';
case '4': return '├';
case '5': return '┼';
case '6': return '┤';
case '7': return '┌';
case '8': return '┬';
case '9': return '┐';
case '0': return '─';
case '.': return '│';
default: return c;
}
}
private static final Map_char map_char_box =
new Map_char() {
public char apply(char c)
{
switch (c)
{
case '1': return '└';
case '2': return '┴';
case '3': return '┘';
case '4': return '├';
case '5': return '┼';
case '6': return '┤';
case '7': return '┌';
case '8': return '┬';
case '9': return '┐';
case '0': return '─';
case '.': return '│';
default: return c;
}
}
};
private static char map_char_slash(char c)
{
switch (c)
{
case 'a': return 'ⱥ';
case 'c': return 'ȼ';
case 'e': return 'ɇ';
case 'g': return 'ꞡ';
case 'l': return 'ł';
case 'n': return 'ꞥ';
case 'o': return 'ø';
case ' ': return '/';
default: return c;
}
}
private static final Map_char map_char_slash =
new Map_char() {
public char apply(char c)
{
switch (c)
{
case 'a': return 'ⱥ';
case 'c': return 'ȼ';
case 'e': return 'ɇ';
case 'g': return 'ꞡ';
case 'l': return 'ł';
case 'n': return 'ꞥ';
case 'o': return 'ø';
case ' ': return '/';
default: return c;
}
}
};
}

View File

@ -47,7 +47,7 @@ class KeyValue
public static final int MOD_SLASH = -217;
public static final int MOD_ARROW_RIGHT = -218;
/** Special value for the [char_] field. */
/** Special value for the [_char] field. */
public static final char CHAR_NONE = '\0';
// Behavior flags
@ -69,8 +69,8 @@ class KeyValue
public static final int FLAG_LOCALIZED = (1 << 8);
public final String name;
public final String symbol;
public final char char_;
private final String _symbol;
private final char _char;
/** Describe what the key does when it isn't a simple character.
Can be one of:
@ -81,8 +81,70 @@ class KeyValue
A key can have both a character and a key event associated, the key event
is used when certain modifiers are active, the character is used
otherwise. See [KeyEventHandler]. */
public final int code;
public final int flags;
private final int _code;
private final int _flags;
public static enum Kind
{
Char, String, Event, Modifier
}
public Kind getKind()
{
if ((_flags & FLAG_MODIFIER) != 0)
return Kind.Modifier;
if (_char != CHAR_NONE)
return Kind.Char;
if (_code != EVENT_NONE)
return Kind.Event;
return Kind.String;
}
public int getFlags()
{
return _flags;
}
public boolean hasFlags(int has)
{
return ((_flags & has) != 0);
}
/** The string to render on the keyboard.
When [getKind() == Kind.String], also the string to send. */
public String getString()
{
return _symbol;
}
/** The char to be sent when the key is pressed.
Defined only when [getKind() == Kind.Char]. */
public char getChar()
{
return _char;
}
/** An Android event or one of the [EVENT_*] constants, including
[EVENT_NONE].
Defined only when [getKind() == Kind.Char]. */
public int getCharEvent()
{
return _code;
}
/** An Android event or one of the [EVENT_*] constants, except [EVENT_NONE].
Defined only when [getKind() == Kind.Event]. */
public int getEvent()
{
return _code;
}
/** Modifier activated by this key.
Defined only when [getKind() == Kind.Modifier]. */
public int getModifier()
{
return _code;
}
/* Update the char and the symbol. */
public KeyValue withCharAndSymbol(char c)
@ -92,17 +154,17 @@ class KeyValue
public KeyValue withCharAndSymbol(String s, char c)
{
return new KeyValue(name, s, c, code, flags);
return new KeyValue(name, s, c, _code, _flags);
}
public KeyValue withNameAndSymbol(String n, String s)
{
return new KeyValue(n, s, char_, code, flags);
return new KeyValue(n, s, _char, _code, _flags);
}
public KeyValue withFlags(int f)
{
return new KeyValue(name, symbol, char_, code, f);
return new KeyValue(name, _symbol, _char, _code, f);
}
private static HashMap<String, KeyValue> keys = new HashMap<String, KeyValue>();
@ -110,10 +172,10 @@ class KeyValue
public KeyValue(String n, String s, char c, int e, int f)
{
name = n;
symbol = s;
char_ = c;
code = e;
flags = f;
_symbol = s;
_char = c;
_code = e;
_flags = f;
}
private static String stripPrefix(String s, String prefix)
@ -135,7 +197,7 @@ class KeyValue
if (localized != null)
{
kv = getKeyByName(localized);
return kv.withFlags(kv.flags | FLAG_LOCALIZED);
return kv.withFlags(kv._flags | FLAG_LOCALIZED);
}
char c = (name.length() == 1) ? name.charAt(0) : CHAR_NONE;
return new KeyValue(name, name, c, EVENT_NONE, 0);

View File

@ -298,7 +298,9 @@ public class Keyboard2 extends InputMethodService
getLayout(_config.programming_layout).mapKeys(new KeyboardData.MapKeyValues() {
public KeyValue apply(KeyValue key)
{
if (key != null && key.code == KeyValue.EVENT_SWITCH_PROGRAMMING)
if (key != null
&& key.getKind() == KeyValue.Kind.Event
&& key.getEvent() == KeyValue.EVENT_SWITCH_PROGRAMMING)
return KeyValue.getKeyByName("switch_text");
return key;
}

View File

@ -268,7 +268,7 @@ public class Keyboard2View extends View
private int labelColor(KeyValue k, boolean isKeyDown, int defaultColor)
{
if (isKeyDown && (k.flags & KeyValue.FLAG_LATCH) != 0)
if (isKeyDown && k.hasFlags(KeyValue.FLAG_LATCH))
{
int flags = _pointers.getKeyFlags(k);
if (flags != -1)
@ -288,10 +288,10 @@ public class Keyboard2View extends View
if (k == null)
return;
float textSize = scaleTextSize(k, _config.labelTextSize, keyH);
Paint p = _theme.labelPaint(((k.flags & KeyValue.FLAG_KEY_FONT) != 0));
Paint p = _theme.labelPaint(k.hasFlags(KeyValue.FLAG_KEY_FONT));
p.setColor(labelColor(k, isKeyDown, _theme.labelColor));
p.setTextSize(textSize);
canvas.drawText(k.symbol, x, (keyH - p.ascent() - p.descent()) / 2f + y, p);
canvas.drawText(k.getString(), x, (keyH - p.ascent() - p.descent()) / 2f + y, p);
}
private void drawSubLabel(Canvas canvas, KeyValue k, float x, float y, float keyW, float keyH, Paint.Align a, Vertical v, boolean isKeyDown)
@ -300,7 +300,7 @@ public class Keyboard2View extends View
if (k == null)
return;
float textSize = scaleTextSize(k, _config.sublabelTextSize, keyH);
Paint p = _theme.subLabelPaint(((k.flags & KeyValue.FLAG_KEY_FONT) != 0), a);
Paint p = _theme.subLabelPaint(k.hasFlags(KeyValue.FLAG_KEY_FONT), a);
p.setColor(labelColor(k, isKeyDown, _theme.subLabelColor));
p.setTextSize(textSize);
float subPadding = _config.keyPadding;
@ -312,12 +312,12 @@ public class Keyboard2View extends View
x += keyW / 2f;
else
x += (a == Paint.Align.LEFT) ? subPadding : keyW - subPadding;
canvas.drawText(k.symbol, x, y, p);
canvas.drawText(k.getString(), x, y, p);
}
private float scaleTextSize(KeyValue k, float rel_size, float keyH)
{
float smaller_font = ((k.flags & KeyValue.FLAG_SMALLER_FONT) == 0) ? 1.f : 0.75f;
float smaller_font = k.hasFlags(KeyValue.FLAG_SMALLER_FONT) ? 0.75f : 1.f;
return keyH * rel_size * smaller_font * _config.characterSize;
}
}

View File

@ -40,8 +40,9 @@ public final class Pointers implements Handler.Callback
mods[i] =
((skip_latched && p.pointerId == -1
&& (p.flags & KeyValue.FLAG_LOCKED) == 0)
|| p.value == null)
? 0 : p.value.code;
|| p.value == null
|| p.value.getKind() != KeyValue.Kind.Modifier)
? 0 : p.value.getModifier();
}
return Modifiers.ofArray(mods);
}
@ -146,7 +147,7 @@ public final class Pointers implements Handler.Callback
KeyValue value = _handler.modifyKey(key.key0, mods);
Pointer ptr = new Pointer(pointerId, key, value, x, y, mods);
_ptrs.add(ptr);
if (value != null && (value.flags & KeyValue.FLAG_SPECIAL) == 0)
if (value != null && !value.hasFlags(KeyValue.FLAG_SPECIAL))
startKeyRepeat(ptr);
_handler.onPointerDown(false);
}
@ -218,12 +219,12 @@ public final class Pointers implements Handler.Callback
{
int old_flags = ptr.flags;
ptr.value = newValue;
ptr.flags = newValue.flags;
ptr.flags = newValue.getFlags();
// Keep the keyrepeat going between modulated keys.
if ((old_flags & newValue.flags & KeyValue.FLAG_PRECISE_REPEAT) == 0)
if ((old_flags & ptr.flags & KeyValue.FLAG_PRECISE_REPEAT) == 0)
{
stopKeyRepeat(ptr);
if ((newValue.flags & KeyValue.FLAG_SPECIAL) == 0)
if ((ptr.flags & KeyValue.FLAG_SPECIAL) == 0)
startKeyRepeat(ptr);
}
_handler.onPointerDown(true);
@ -375,7 +376,7 @@ public final class Pointers implements Handler.Callback
downY = y;
ptrDist = 0.f;
modifiers = m;
flags = (v == null) ? 0 : v.flags;
flags = (v == null) ? 0 : v.getFlags();
timeoutWhat = -1;
repeatingPtrDist = -1.f;
}