diff options
author | Nick Brassel <nick@tzarc.org> | 2023-07-08 00:59:28 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-08 00:59:28 +1000 |
commit | 71f0fc59bef7a37b55c7e1c10b1b21b8a86475b7 (patch) | |
tree | b7e0f3ae7916ca27bcdb7d4e3d42b13c0a2cfaad /quantum | |
parent | ddc45719864e934bcb53576057c2423ed558cbc8 (diff) |
Revert "bootmagic mods covering the case when swapped mods are pressed at the same time (#21320)" (#21471)
Diffstat (limited to 'quantum')
-rw-r--r-- | quantum/keycode_config.c | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/quantum/keycode_config.c b/quantum/keycode_config.c index 864488a65c..9dd7097c86 100644 --- a/quantum/keycode_config.c +++ b/quantum/keycode_config.c @@ -122,36 +122,40 @@ __attribute__((weak)) uint16_t keycode_config(uint16_t keycode) { */ __attribute__((weak)) uint8_t mod_config(uint8_t mod) { - /** - * Note: This function is for the 5-bit packed mods, NOT the full 8-bit mods. - * More info about the mods can be seen in modifiers.h. - */ if (keymap_config.swap_lalt_lgui) { - /** If both modifiers pressed or neither pressed, do nothing - * Otherwise swap the values - * Note: The left mods are ANDed with the right-hand values to check - * if they were pressed with the right hand bit set - */ - if (((mod & MOD_RALT) == MOD_LALT) ^ ((mod & MOD_RGUI) == MOD_LGUI)) { - mod ^= (MOD_LALT | MOD_LGUI); + if ((mod & MOD_RGUI) == MOD_LGUI) { + mod &= ~MOD_LGUI; + mod |= MOD_LALT; + } else if ((mod & MOD_RALT) == MOD_LALT) { + mod &= ~MOD_LALT; + mod |= MOD_LGUI; } } if (keymap_config.swap_ralt_rgui) { - if (((mod & MOD_RALT) == MOD_RALT) ^ ((mod & MOD_RGUI) == MOD_RGUI)) { - /* lefthand values to preserve the right hand bit */ - mod ^= (MOD_LALT | MOD_LGUI); + if ((mod & MOD_RGUI) == MOD_RGUI) { + mod &= ~MOD_RGUI; + mod |= MOD_RALT; + } else if ((mod & MOD_RALT) == MOD_RALT) { + mod &= ~MOD_RALT; + mod |= MOD_RGUI; } } if (keymap_config.swap_lctl_lgui) { - /* left mods ANDed with right-hand values to check for right hand bit */ - if (((mod & MOD_RCTL) == MOD_LCTL) ^ ((mod & MOD_RGUI) == MOD_LGUI)) { - mod ^= (MOD_LCTL | MOD_LGUI); + if ((mod & MOD_RGUI) == MOD_LGUI) { + mod &= ~MOD_LGUI; + mod |= MOD_LCTL; + } else if ((mod & MOD_RCTL) == MOD_LCTL) { + mod &= ~MOD_LCTL; + mod |= MOD_LGUI; } } if (keymap_config.swap_rctl_rgui) { - if (((mod & MOD_RCTL) == MOD_RCTL) ^ ((mod & MOD_RGUI) == MOD_RGUI)) { - /* lefthand values to preserve the right hand bit */ - mod ^= (MOD_LCTL | MOD_LGUI); + if ((mod & MOD_RGUI) == MOD_RGUI) { + mod &= ~MOD_RGUI; + mod |= MOD_RCTL; + } else if ((mod & MOD_RCTL) == MOD_RCTL) { + mod &= ~MOD_RCTL; + mod |= MOD_RGUI; } } if (keymap_config.no_gui) { |