abouttreesummaryrefslogcommitdiff
path: root/srcs/juloo.keyboard2
diff options
context:
space:
mode:
authorRaphael2022-03-05 14:17:45 -0500
committerGitHub2022-03-05 20:17:45 +0100
commit5404e7432d9240b3c88dce3a8cf240362016293c (patch)
tree1040c96d81da6609c725e1cb05c6b5f31f0ccae3 /srcs/juloo.keyboard2
parente92504ae92873ca7f0efa80421893bc69f98fa11 (diff)
downloadunexpected-keyboard-5404e7432d9240b3c88dce3a8cf240362016293c.tar.gz
unexpected-keyboard-5404e7432d9240b3c88dce3a8cf240362016293c.zip
Clicking twice on CTRL or ALT will lock them in 'ON' state (#72)
* Clicking twice on CTRL or ALT will lock them in 'ON' state * Make Locking behaviour optional, configurable in preferences * Nest the new settings into a different page To avoid spamming the settings page and repetition in the summaries. Cannot be a popup unfortunately because that would require API >= 11. * Add Fn and Meta Co-authored-by: Jules Aguillon <jules@j3s.fr>
Diffstat (limited to 'srcs/juloo.keyboard2')
-rw-r--r--srcs/juloo.keyboard2/Config.java16
-rw-r--r--srcs/juloo.keyboard2/KeyValue.java7
2 files changed, 20 insertions, 3 deletions
diff --git a/srcs/juloo.keyboard2/Config.java b/srcs/juloo.keyboard2/Config.java
index b477c92..cd9629a 100644
--- a/srcs/juloo.keyboard2/Config.java
+++ b/srcs/juloo.keyboard2/Config.java
@@ -33,6 +33,7 @@ final class Config
public float keyVerticalInterval;
public float keyHorizontalInterval;
public boolean preciseRepeat;
+ public int lockable_modifiers;
public float characterSize; // Ratio
public int accents; // Values are R.values.pref_accents_v_*
public int theme; // Values are R.style.*
@@ -114,6 +115,12 @@ 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);
characterSize = prefs.getFloat("character_size", characterSize);
accents = Integer.valueOf(prefs.getString("accents", "1"));
theme = getThemeId(res, prefs.getString("theme", ""));
@@ -143,8 +150,13 @@ final class Config
return (swapEnterActionKey && action_key != null) ?
KeyValue.getKeyByName("enter") : action_key;
default:
- if ((key.flags & key_flags_to_remove) != 0)
- return null;
+ if (key.flags != 0)
+ {
+ if ((key.flags & key_flags_to_remove) != 0)
+ return null;
+ if ((key.flags & lockable_modifiers) != 0)
+ return key.withFlags(key.flags | KeyValue.FLAG_LOCK);
+ }
return key;
}});
}
diff --git a/srcs/juloo.keyboard2/KeyValue.java b/srcs/juloo.keyboard2/KeyValue.java
index ec29991..dd42f42 100644
--- a/srcs/juloo.keyboard2/KeyValue.java
+++ b/srcs/juloo.keyboard2/KeyValue.java
@@ -87,6 +87,11 @@ class KeyValue
return new KeyValue(name, s, c, eventCode, flags);
}
+ public KeyValue withFlags(int f)
+ {
+ return new KeyValue(name, symbol, char_, eventCode, f);
+ }
+
private static HashMap<String, KeyValue> keys = new HashMap<String, KeyValue>();
public KeyValue(String n, String s, char c, int e, int f)
@@ -154,7 +159,7 @@ class KeyValue
static
{
addModifierKey("shift", "\uE808",
- FLAG_LOCK | FLAG_SHIFT | FLAG_KEY_FONT | FLAG_SMALLER_FONT);
+ FLAG_SHIFT | FLAG_KEY_FONT | FLAG_SMALLER_FONT);
addModifierKey("ctrl", "Ctrl", FLAG_CTRL | FLAG_SMALLER_FONT);
addModifierKey("alt", "Alt", FLAG_ALT | FLAG_SMALLER_FONT);
addModifierKey("accent_aigu", "◌́", FLAG_ACCENT2);