diff --git a/srcs/juloo.keyboard2/KeyModifier.java b/srcs/juloo.keyboard2/KeyModifier.java index 70f7315..a5fcde2 100644 --- a/srcs/juloo.keyboard2/KeyModifier.java +++ b/srcs/juloo.keyboard2/KeyModifier.java @@ -10,6 +10,11 @@ public final class KeyModifier private static HashMap> _cache = new HashMap>(); + /** The optional modmap takes priority over modifiers usual behaviors. Set to + [null] to disable. */ + private static KeyboardData.Modmap _modmap = null; + public static void set_modmap(KeyboardData.Modmap mm) { _modmap = mm; } + /** Modify a key according to modifiers. */ public static KeyValue modify(KeyValue k, Pointers.Modifiers mods) { @@ -130,6 +135,12 @@ public final class KeyModifier private static KeyValue apply_shift(KeyValue k) { + if (_modmap != null) + { + KeyValue mapped = _modmap.shift.get(k); + if (mapped != null) + return mapped; + } switch (k.getKind()) { case Char: diff --git a/srcs/juloo.keyboard2/Keyboard2View.java b/srcs/juloo.keyboard2/Keyboard2View.java index 61a62e9..40def60 100644 --- a/srcs/juloo.keyboard2/Keyboard2View.java +++ b/srcs/juloo.keyboard2/Keyboard2View.java @@ -104,6 +104,7 @@ public class Keyboard2View extends View } _compose_kv = KeyValue.getKeyByName("compose"); _compose_key = _keyboard.findKeyWithValue(_compose_kv); + KeyModifier.set_modmap(_keyboard.modmap); reset(); } @@ -137,15 +138,6 @@ public class Keyboard2View extends View public KeyValue modifyKey(KeyValue k, Pointers.Modifiers mods) { - if (_keyboard.modmap != null) - { - if (mods.has(KeyValue.Modifier.SHIFT)) - { - KeyValue km = _keyboard.modmap.shift.get(k); - if (km != null) - return km; - } - } return KeyModifier.modify(k, mods); }