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,7 +163,13 @@ final class Config
boolean is_extra_key = extra_keys.contains(key.name); boolean is_extra_key = extra_keys.contains(key.name);
if (is_extra_key) if (is_extra_key)
extra_keys.remove(key.name); 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 Event:
switch (key.getEvent())
{ {
case KeyValue.EVENT_CHANGE_METHOD: case KeyValue.EVENT_CHANGE_METHOD:
return shouldOfferSwitchingToNextInputMethod ? key : null; return shouldOfferSwitchingToNextInputMethod ? key : null;
@ -174,18 +180,15 @@ final class Config
KeyValue.getKeyByName("enter") : action_key; KeyValue.getKeyByName("enter") : action_key;
case KeyValue.EVENT_SWITCH_PROGRAMMING: case KeyValue.EVENT_SWITCH_PROGRAMMING:
return shouldOfferSwitchingToProgramming ? key : null; return shouldOfferSwitchingToProgramming ? key : null;
default: }
if (key.flags != 0) break;
{ case Modifier:
if ((key.flags & KeyValue.FLAG_LOCALIZED) != 0 && !is_extra_key) if (lockable_modifiers.contains(key.getModifier()))
return null; return key.withFlags(flags | KeyValue.FLAG_LOCK);
if ((key.flags & KeyValue.FLAG_MODIFIER) != 0 break;
&& lockable_modifiers.contains(key.code))
return key.withFlags(key.flags | KeyValue.FLAG_LOCK);
} }
return key; return key;
} }
}
}); });
if (extra_keys.size() > 0) if (extra_keys.size() > 0)
{ {

View File

@ -126,7 +126,7 @@ public class EmojiGridView extends GridView
public void setEmoji(Emoji emoji) 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++) for (int i = 0; i < Emoji.num_groups; i++)
{ {
Emoji first = Emoji.getEmojisByGroup(i)[0]; 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); super(context, attrs);
setOnClickListener(this); setOnClickListener(this);
_key = KeyValue.getKeyByName(attrs.getAttributeValue(null, "key")); _key = KeyValue.getKeyByName(attrs.getAttributeValue(null, "key"));
setText(_key.symbol); setText(_key.getString());
if ((_key.flags & KeyValue.FLAG_KEY_FONT) != 0) if (_key.hasFlags(KeyValue.FLAG_KEY_FONT))
setTypeface(Theme.getSpecialKeyFont(context)); setTypeface(Theme.getSpecialKeyFont(context));
} }

View File

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

View File

@ -50,55 +50,72 @@ class KeyModifier
case KeyValue.MOD_MACRON: return apply_dead_char(k, '\u00AF'); case KeyValue.MOD_MACRON: return apply_dead_char(k, '\u00AF');
case KeyValue.MOD_OGONEK: return apply_dead_char(k, '\u02DB'); case KeyValue.MOD_OGONEK: return apply_dead_char(k, '\u02DB');
case KeyValue.MOD_DOT_ABOVE: return apply_dead_char(k, '\u02D9'); case KeyValue.MOD_DOT_ABOVE: return apply_dead_char(k, '\u02D9');
case KeyValue.MOD_DOUBLE_AIGU: case KeyValue.MOD_DOUBLE_AIGU: return apply_map_char(k, map_char_double_aigu);
return maybe_modify_char(k, map_char_double_aigu(k.char_)); case KeyValue.MOD_ORDINAL: return apply_map_char(k, map_char_ordinal);
case KeyValue.MOD_ORDINAL: case KeyValue.MOD_SUPERSCRIPT: return apply_map_char(k, map_char_superscript);
return maybe_modify_char(k, map_char_ordinal(k.char_)); case KeyValue.MOD_SUBSCRIPT: return apply_map_char(k, map_char_subscript);
case KeyValue.MOD_SUPERSCRIPT: case KeyValue.MOD_ARROWS: return apply_map_char(k, map_char_arrows);
return maybe_modify_char(k, map_char_superscript(k.char_)); case KeyValue.MOD_BOX: return apply_map_char(k, map_char_box);
case KeyValue.MOD_SUBSCRIPT: case KeyValue.MOD_SLASH: return apply_map_char(k, map_char_slash);
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_ARROW_RIGHT: return apply_combining(k, "\u20D7"); case KeyValue.MOD_ARROW_RIGHT: return apply_combining(k, "\u20D7");
default: return k; 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) private static KeyValue apply_dead_char(KeyValue k, char dead_char)
{ {
char c = k.char_; switch (k.getKind())
if (c != KeyValue.CHAR_NONE) {
c = (char)KeyCharacterMap.getDeadChar(dead_char, c); case Char:
return maybe_modify_char(k, c); 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) private static KeyValue apply_combining(KeyValue k, String combining)
{ {
if (k.char_ == KeyValue.CHAR_NONE) switch (k.getKind())
return k; {
return KeyValue.getKeyByName(String.valueOf(k.char_) + combining); 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) private static KeyValue apply_shift(KeyValue k)
{ {
char c = k.char_; switch (k.getKind())
if (c == KeyValue.CHAR_NONE)
{ {
// The key is a string case Char:
if (k.code == KeyValue.EVENT_NONE) char kc = k.getChar();
return k.withCharAndSymbol(k.symbol.toUpperCase(), KeyValue.CHAR_NONE); char c = map_char_shift(kc);
else if (kc == c)
c = Character.toUpperCase(kc);
if (kc == c)
return k; 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) 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. */ /* Lookup the cache entry for a key. Create it needed. */
private static HashMap<Pointers.Modifiers, KeyValue> cacheEntry(KeyValue k) private static HashMap<Pointers.Modifiers, KeyValue> cacheEntry(KeyValue k)
{ {
@ -200,6 +209,11 @@ class KeyModifier
return ks; return ks;
} }
private static abstract class Map_char
{
public abstract char apply(char c);
}
private static char map_char_shift(char c) private static char map_char_shift(char c)
{ {
switch (c) switch (c)
@ -227,7 +241,9 @@ class KeyModifier
} }
} }
private static char map_char_double_aigu(char c) private static final Map_char map_char_double_aigu =
new Map_char() {
public char apply(char c)
{ {
switch (c) switch (c)
{ {
@ -238,8 +254,11 @@ class KeyModifier
default: return c; default: return c;
} }
} }
};
private static char map_char_ordinal(char c) private static final Map_char map_char_ordinal =
new Map_char() {
public char apply(char c)
{ {
switch (c) switch (c)
{ {
@ -258,8 +277,11 @@ class KeyModifier
default: return c; default: return c;
} }
} }
};
private static char map_char_superscript(char c) private static final Map_char map_char_superscript =
new Map_char() {
public char apply(char c)
{ {
switch (c) switch (c)
{ {
@ -283,8 +305,11 @@ class KeyModifier
default: return c; default: return c;
} }
} }
};
private static char map_char_subscript(char c) private static final Map_char map_char_subscript =
new Map_char() {
public char apply(char c)
{ {
switch (c) switch (c)
{ {
@ -310,8 +335,11 @@ class KeyModifier
default: return c; default: return c;
} }
} }
};
private static char map_char_arrows(char c) private static final Map_char map_char_arrows =
new Map_char() {
public char apply(char c)
{ {
switch (c) switch (c)
{ {
@ -326,8 +354,11 @@ class KeyModifier
default: return c; default: return c;
} }
} }
};
private static char map_char_box(char c) private static final Map_char map_char_box =
new Map_char() {
public char apply(char c)
{ {
switch (c) switch (c)
{ {
@ -345,8 +376,11 @@ class KeyModifier
default: return c; default: return c;
} }
} }
};
private static char map_char_slash(char c) private static final Map_char map_char_slash =
new Map_char() {
public char apply(char c)
{ {
switch (c) switch (c)
{ {
@ -361,4 +395,5 @@ class KeyModifier
default: return c; default: return c;
} }
} }
};
} }

View File

@ -47,7 +47,7 @@ class KeyValue
public static final int MOD_SLASH = -217; public static final int MOD_SLASH = -217;
public static final int MOD_ARROW_RIGHT = -218; 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'; public static final char CHAR_NONE = '\0';
// Behavior flags // Behavior flags
@ -69,8 +69,8 @@ class KeyValue
public static final int FLAG_LOCALIZED = (1 << 8); public static final int FLAG_LOCALIZED = (1 << 8);
public final String name; public final String name;
public final String symbol; private final String _symbol;
public final char char_; private final char _char;
/** Describe what the key does when it isn't a simple character. /** Describe what the key does when it isn't a simple character.
Can be one of: 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 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 is used when certain modifiers are active, the character is used
otherwise. See [KeyEventHandler]. */ otherwise. See [KeyEventHandler]. */
public final int code; private final int _code;
public final int flags; 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. */ /* Update the char and the symbol. */
public KeyValue withCharAndSymbol(char c) public KeyValue withCharAndSymbol(char c)
@ -92,17 +154,17 @@ class KeyValue
public KeyValue withCharAndSymbol(String s, char c) 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) 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) 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>(); 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) public KeyValue(String n, String s, char c, int e, int f)
{ {
name = n; name = n;
symbol = s; _symbol = s;
char_ = c; _char = c;
code = e; _code = e;
flags = f; _flags = f;
} }
private static String stripPrefix(String s, String prefix) private static String stripPrefix(String s, String prefix)
@ -135,7 +197,7 @@ class KeyValue
if (localized != null) if (localized != null)
{ {
kv = getKeyByName(localized); 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; char c = (name.length() == 1) ? name.charAt(0) : CHAR_NONE;
return new KeyValue(name, name, c, EVENT_NONE, 0); 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() { getLayout(_config.programming_layout).mapKeys(new KeyboardData.MapKeyValues() {
public KeyValue apply(KeyValue key) 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 KeyValue.getKeyByName("switch_text");
return key; return key;
} }

View File

@ -268,7 +268,7 @@ public class Keyboard2View extends View
private int labelColor(KeyValue k, boolean isKeyDown, int defaultColor) 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); int flags = _pointers.getKeyFlags(k);
if (flags != -1) if (flags != -1)
@ -288,10 +288,10 @@ public class Keyboard2View extends View
if (k == null) if (k == null)
return; return;
float textSize = scaleTextSize(k, _config.labelTextSize, keyH); 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.setColor(labelColor(k, isKeyDown, _theme.labelColor));
p.setTextSize(textSize); 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) 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) if (k == null)
return; return;
float textSize = scaleTextSize(k, _config.sublabelTextSize, keyH); 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.setColor(labelColor(k, isKeyDown, _theme.subLabelColor));
p.setTextSize(textSize); p.setTextSize(textSize);
float subPadding = _config.keyPadding; float subPadding = _config.keyPadding;
@ -312,12 +312,12 @@ public class Keyboard2View extends View
x += keyW / 2f; x += keyW / 2f;
else else
x += (a == Paint.Align.LEFT) ? subPadding : keyW - subPadding; 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) 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; return keyH * rel_size * smaller_font * _config.characterSize;
} }
} }

View File

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