diff options
author | Sergey Vlasov <sigprof@gmail.com> | 2022-11-07 00:39:05 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-06 21:39:05 +0000 |
commit | a7b2f4233ca2062037303e783ced30d9376c9443 (patch) | |
tree | cdfbb9a82f695376c41a211b186f51552b3fcb73 /quantum/process_keycode/process_caps_word.c | |
parent | 5f9b7c035bdbbbfccfcf2bbfed7d153f5043fdce (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_caps_word.c')
-rw-r--r-- | quantum/process_keycode/process_caps_word.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/quantum/process_keycode/process_caps_word.c b/quantum/process_keycode/process_caps_word.c index 7a83f7bf49..4c0217eba7 100644 --- a/quantum/process_keycode/process_caps_word.c +++ b/quantum/process_keycode/process_caps_word.c @@ -109,7 +109,7 @@ bool process_caps_word(uint16_t keycode, keyrecord_t* record) { // * Otherwise stop Caps Word. case QK_MOD_TAP ... QK_MOD_TAP_MAX: if (record->tap.count == 0) { // Mod-tap key is held. - const uint8_t mods = (keycode >> 8) & 0x1f; + const uint8_t mods = QK_MOD_TAP_GET_MODS(keycode); switch (mods) { case MOD_LSFT: keycode = KC_LSFT; @@ -127,7 +127,7 @@ bool process_caps_word(uint16_t keycode, keyrecord_t* record) { return true; } } else { - keycode &= 0xff; + keycode = QK_MOD_TAP_GET_TAP_KEYCODE(keycode); } break; @@ -137,16 +137,18 @@ bool process_caps_word(uint16_t keycode, keyrecord_t* record) { if (record->tap.count == 0) { return true; } - keycode &= 0xff; + keycode = QK_LAYER_TAP_GET_TAP_KEYCODE(keycode); break; #endif // NO_ACTION_TAPPING #ifdef SWAP_HANDS_ENABLE case QK_SWAP_HANDS ... QK_SWAP_HANDS_MAX: - if (keycode > 0x56F0 || record->tap.count == 0) { + // Note: IS_SWAP_HANDS_KEYCODE() actually tests for the special action keycodes like SH_TG, SH_TT, ..., + // which currently overlap the SH_T(kc) range. + if (IS_SWAP_HANDS_KEYCODE(keycode) || record->tap.count == 0) { return true; } - keycode &= 0xff; + keycode = QK_SWAP_HANDS_GET_TAP_KEYCODE(keycode); break; #endif // SWAP_HANDS_ENABLE } |