abouttreesummaryrefslogcommitdiff
path: root/srcs/juloo.keyboard2/Config.java
diff options
context:
space:
mode:
authorJules Aguillon2022-06-05 01:38:42 +0200
committerJules Aguillon2022-06-05 01:43:58 +0200
commit4127aa6f033a258aa89ff3704a952505c8c056cb (patch)
tree5a1dcada711e1ed85c28d626abf0b2e484f7fcff /srcs/juloo.keyboard2/Config.java
parent4f9375373e3ce9514550fa0470b40ae7f0ff19b2 (diff)
downloadunexpected-keyboard-4127aa6f033a258aa89ff3704a952505c8c056cb.tar.gz
unexpected-keyboard-4127aa6f033a258aa89ff3704a952505c8c056cb.zip
Stop using flags for modifiers
There was no free bits left to add new modifiers. Instead of increasing the width of the 'flags' field, refactor the way modifiers are represented and used. Modifers are now represented as independent values and stored in the 'code' field. A flag is added to distinguish between modifiers and keys with a key event. The most notable change is that modifiers can no longer be or-ed into a single value but have to be represented as an array.
Diffstat (limited to 'srcs/juloo.keyboard2/Config.java')
-rw-r--r--srcs/juloo.keyboard2/Config.java27
1 files changed, 14 insertions, 13 deletions
diff --git a/srcs/juloo.keyboard2/Config.java b/srcs/juloo.keyboard2/Config.java
index 278cbd2..8059b76 100644
--- a/srcs/juloo.keyboard2/Config.java
+++ b/srcs/juloo.keyboard2/Config.java
@@ -36,7 +36,7 @@ final class Config
public float keyVerticalInterval;
public float keyHorizontalInterval;
public boolean preciseRepeat;
- public int lockable_modifiers;
+ public Set<Integer> lockable_modifiers = new HashSet<Integer>();
public float characterSize; // Ratio
public int accents; // Values are R.values.pref_accents_v_*
public int theme; // Values are R.style.*
@@ -127,15 +127,15 @@ final class Config
keyHeight = dm.heightPixels * keyboardHeightPercent / 100 / 4;
horizontalMargin = getDipPref(dm, prefs, "horizontal_margin", horizontalMargin) + res.getDimension(R.dimen.extra_horizontal_margin);
preciseRepeat = prefs.getBoolean("precise_repeat", preciseRepeat);
- lockable_modifiers =
- (prefs.getBoolean("lockable_shift", true) ? KeyValue.FLAG_SHIFT : 0)
- | (prefs.getBoolean("lockable_ctrl", false) ? KeyValue.FLAG_CTRL : 0)
- | (prefs.getBoolean("lockable_alt", false) ? KeyValue.FLAG_ALT : 0)
- | (prefs.getBoolean("lockable_fn", false) ? KeyValue.FLAG_FN : 0)
- | (prefs.getBoolean("lockable_meta", false) ? KeyValue.FLAG_META : 0)
- | (prefs.getBoolean("lockable_sup", false) ? KeyValue.FLAG_ACCENT_SUPERSCRIPT : 0)
- | (prefs.getBoolean("lockable_sub", false) ? KeyValue.FLAG_ACCENT_SUBSCRIPT : 0)
- | (prefs.getBoolean("lockable_box", false) ? KeyValue.FLAG_ACCENT_BOX : 0);
+ lockable_modifiers.clear();
+ if (prefs.getBoolean("lockable_shift", true)) lockable_modifiers.add(KeyValue.MOD_SHIFT);
+ if (prefs.getBoolean("lockable_ctrl", false)) lockable_modifiers.add(KeyValue.MOD_CTRL);
+ if (prefs.getBoolean("lockable_alt", false)) lockable_modifiers.add(KeyValue.MOD_ALT);
+ if (prefs.getBoolean("lockable_fn", false)) lockable_modifiers.add(KeyValue.MOD_FN);
+ if (prefs.getBoolean("lockable_meta", false)) lockable_modifiers.add(KeyValue.MOD_META);
+ if (prefs.getBoolean("lockable_sup", false)) lockable_modifiers.add(KeyValue.MOD_SUPERSCRIPT);
+ if (prefs.getBoolean("lockable_sub", false)) lockable_modifiers.add(KeyValue.MOD_SUBSCRIPT);
+ if (prefs.getBoolean("lockable_box", false)) lockable_modifiers.add(KeyValue.MOD_BOX);
characterSize = prefs.getFloat("character_size", characterSize);
accents = Integer.valueOf(prefs.getString("accents", "1"));
theme = getThemeId(res, prefs.getString("theme", ""));
@@ -163,7 +163,7 @@ final class Config
boolean is_extra_key = extra_keys.contains(key.name);
if (is_extra_key)
extra_keys.remove(key.name);
- switch (key.eventCode)
+ switch (key.code)
{
case KeyValue.EVENT_CHANGE_METHOD:
return shouldOfferSwitchingToNextInputMethod ? key : null;
@@ -179,7 +179,8 @@ final class Config
{
if ((key.flags & KeyValue.FLAG_LOCALIZED) != 0 && !is_extra_key)
return null;
- if ((key.flags & lockable_modifiers) != 0)
+ if ((key.flags & KeyValue.FLAG_MODIFIER) != 0
+ && lockable_modifiers.contains(key.code))
return key.withFlags(key.flags | KeyValue.FLAG_LOCK);
}
return key;
@@ -275,6 +276,6 @@ final class Config
public static interface IKeyEventHandler
{
- public void handleKeyUp(KeyValue value, int flags);
+ public void handleKeyUp(KeyValue value, Pointers.Modifiers flags);
}
}