diff options
| author | Jules Aguillon | 2024-07-25 23:40:58 +0200 |
|---|---|---|
| committer | Jules Aguillon | 2024-07-25 23:40:58 +0200 |
| commit | 29b4b665dc12eb613b68e657a28d93fc5ee0f51e (patch) | |
| tree | 4efcf3678c0ba0df68af940b6c4ff899a6be5d20 /srcs/juloo.keyboard2/KeyModifier.java | |
| parent | 35f35b27be295fc3e57e330cff2081f7bdc1c286 (diff) | |
| download | unexpected-keyboard-29b4b665dc12eb613b68e657a28d93fc5ee0f51e.tar.gz unexpected-keyboard-29b4b665dc12eb613b68e657a28d93fc5ee0f51e.zip | |
Allow Ctrl modmaps in layouts
The 'ctrl' modmap is different from the other modmaps as it also applies
the built-in Ctrl modifier to the resulting character, even if it was
first modified by the custom modmap.
For example, this will map Ctrl+в to Ctrl+V (not to v):
<ctrl a="в" b="v"/>
This is intended to add keyboard shortcuts in non-latin layouts.
A caveat is that the latin character appears on the keyboard while Ctrl
is activated.
Diffstat (limited to 'srcs/juloo.keyboard2/KeyModifier.java')
| -rw-r--r-- | srcs/juloo.keyboard2/KeyModifier.java | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/srcs/juloo.keyboard2/KeyModifier.java b/srcs/juloo.keyboard2/KeyModifier.java index 8d5fbbb..0ea80ab 100644 --- a/srcs/juloo.keyboard2/KeyModifier.java +++ b/srcs/juloo.keyboard2/KeyModifier.java @@ -51,7 +51,7 @@ public final class KeyModifier { switch (mod) { - case CTRL: + case CTRL: return apply_ctrl(k); case ALT: case META: return turn_into_keyevent(k); case FN: return apply_fn(k); @@ -440,6 +440,19 @@ public final class KeyModifier } } + private static KeyValue apply_ctrl(KeyValue k) + { + if (_modmap != null) + { + KeyValue mapped = _modmap.ctrl.get(k); + // Do not return the modified character right away, first turn it into a + // key event. + if (mapped != null) + k = mapped; + } + return turn_into_keyevent(k); + } + private static KeyValue turn_into_keyevent(KeyValue k) { if (k.getKind() != KeyValue.Kind.Char) |
