forked from extern/Unexpected-Keyboard
refactor: Apply the modmap in KeyModifier
This makes possible to apply other modifiers to mapped keys and ensures that the modmap really override the shift key behavior.
This commit is contained in:
parent
f17afba7be
commit
3f6b6fd232
@ -10,6 +10,11 @@ public final class KeyModifier
|
||||
private static HashMap<KeyValue, HashMap<Pointers.Modifiers, KeyValue>> _cache =
|
||||
new HashMap<KeyValue, HashMap<Pointers.Modifiers, KeyValue>>();
|
||||
|
||||
/** 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:
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user