summaryrefslogtreecommitdiff
path: root/quantum/process_keycode/process_unicodemap.c
diff options
context:
space:
mode:
authorSergey Vlasov <sigprof@gmail.com>2022-11-07 00:39:05 +0300
committerGitHub <noreply@github.com>2022-11-06 21:39:05 +0000
commita7b2f4233ca2062037303e783ced30d9376c9443 (patch)
treecdfbb9a82f695376c41a211b186f51552b3fcb73 /quantum/process_keycode/process_unicodemap.c
parent5f9b7c035bdbbbfccfcf2bbfed7d153f5043fdce (diff)
Fix keycode parameter extraction to match the new DD keycodes (#18977)
* Add macros to extract parameters from keycode values Implement both encoding and decoding for keycodes like TO(layer) or LM(layer, mod) in one place, so that the decoding won't get out of sync with the encoding. While at it, fix some macros for creating keycode values that did not apply the appropriate masks to parameters (and therefore could allow the result to be out of range if a wrong parameter was passed). * keymap_common: Use extraction macros for keycodes * pointing_device_auto_mouse: Use extraction macros for keycodes Fixes #18970. * process_autocorrect: Use extraction macros for keycodes * process_caps_word: Use extraction macros for keycodes (Also fix a minor bug - SH_TG was not handled properly) * process_leader: Use extraction macros for keycodes (Technically the code is not 100% correct, because it always assumes that the LT() or MT() action was a tap, but it's a separate issue that already existed before the keycode changes.) * process_unicode: Use extraction macros for keycodes * process_unicodemap: Use extraction macros for keycodes
Diffstat (limited to 'quantum/process_keycode/process_unicodemap.c')
-rw-r--r--quantum/process_keycode/process_unicodemap.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/quantum/process_keycode/process_unicodemap.c b/quantum/process_keycode/process_unicodemap.c
index 979d773b05..195c093e6e 100644
--- a/quantum/process_keycode/process_unicodemap.c
+++ b/quantum/process_keycode/process_unicodemap.c
@@ -24,7 +24,7 @@
__attribute__((weak)) uint16_t unicodemap_index(uint16_t keycode) {
if (keycode >= QK_UNICODEMAP_PAIR) {
// Keycode is a pair: extract index based on Shift / Caps Lock state
- uint16_t index = keycode - QK_UNICODEMAP_PAIR;
+ uint16_t index;
uint8_t mods = get_mods() | get_weak_mods();
#ifndef NO_ACTION_ONESHOT
@@ -34,13 +34,15 @@ __attribute__((weak)) uint16_t unicodemap_index(uint16_t keycode) {
bool shift = mods & MOD_MASK_SHIFT;
bool caps = host_keyboard_led_state().caps_lock;
if (shift ^ caps) {
- index >>= 7;
+ index = QK_UNICODEMAP_PAIR_GET_SHIFTED_INDEX(keycode);
+ } else {
+ index = QK_UNICODEMAP_PAIR_GET_UNSHIFTED_INDEX(keycode);
}
- return index & 0x7F;
+ return index;
} else {
// Keycode is a regular index
- return keycode - QK_UNICODEMAP;
+ return QK_UNICODEMAP_GET_INDEX(keycode);
}
}