diff options
| author | Pascal Getreuer <50221757+getreuer@users.noreply.github.com> | 2022-08-14 12:25:32 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-14 20:25:32 +0100 |
| commit | 95c43a275984fb57cdf6e5afd02190700e0205bc (patch) | |
| tree | a6bc77a909d48aa89c209a00cfd0cf4ca788d84c /quantum/process_keycode/process_caps_word.c | |
| parent | 6fc7c03e9581ddde68b32f2f76f8053628da6465 (diff) | |
Fix Caps Word to treat mod-taps more consistently. (#17463)
* Fix Caps Word to treat mod-taps more consistently.
Previously, holding any mod-tap key while Caps Word is active stops Caps
Word, and this happens regardless of `caps_word_press_user()`. Yet for
regular mod keys, AltGr (KC_RALT) is ignored, Shift keys are passed to
`caps_word_press_user()` to determine whether to continue, and
similarly, a key `RSFT(KC_RALT)` representing Right Shift + Alt is
passed to `caps_word_press_user()` to determine whether to continue.
This commit makes held mod-tap keys consistent with regular mod keys:
* Holding a `RALT_T` mod-tap is ignored.
* When holding a shift mod-tap key, `KC_LSFT` or `KC_RSFT` is passed to
`caps_word_press_user()` to determine whether to continue.
* When holding a Right Shift + Alt (`RSA_T`) mod-tap, `RSFT(KC_RALT)` is
passed to `caps_word_press_user()`.
Particularly, with this fix a user may choose to continue Caps Word when
a shift mod-tap key is held by adding `KC_LSFT` and `KC_RSFT` cases in
`caps_word_press_user()`. For instance as
```
bool caps_word_press_user(uint16_t keycode) {
switch (keycode) {
// Keycodes that continue Caps Word, with shift applied.
case KC_A ... KC_Z:
case KC_MINS:
add_weak_mods(MOD_BIT(KC_LSFT)); // Apply shift to the next key.
return true;
// Keycodes that continue Caps Word, without shifting.
case KC_1 ... KC_0:
case KC_BSPC:
case KC_DEL:
case KC_UNDS:
case KC_LSFT: // <<< Added here.
case KC_RSFT:
return true;
default:
return false; // Deactivate Caps Word.
}
}
```
* Fix Caps Word to treat mod-taps more consistently.
Previously, holding any mod-tap key while Caps Word is active stops Caps
Word, and this happens regardless of `caps_word_press_user()`. Yet for
regular mod keys, AltGr (KC_RALT) is ignored, Shift keys are passed to
`caps_word_press_user()` to determine whether to continue, and
similarly, a key `RSFT(KC_RALT)` representing Right Shift + Alt is
passed to `caps_word_press_user()` to determine whether to continue.
This commit makes held mod-tap keys consistent with regular mod keys:
* Holding a `RALT_T` mod-tap is ignored.
* When holding a shift mod-tap key, `KC_LSFT` or `KC_RSFT` is passed to
`caps_word_press_user()` to determine whether to continue.
* When holding a Right Shift + Alt (`RSA_T`) mod-tap, `RSFT(KC_RALT)` is
passed to `caps_word_press_user()`.
Particularly, with this fix a user may choose to continue Caps Word when
a shift mod-tap key is held by adding `KC_LSFT` and `KC_RSFT` cases in
`caps_word_press_user()`. For instance as
```
bool caps_word_press_user(uint16_t keycode) {
switch (keycode) {
// Keycodes that continue Caps Word, with shift applied.
case KC_A ... KC_Z:
case KC_MINS:
add_weak_mods(MOD_BIT(KC_LSFT)); // Apply shift to the next key.
return true;
// Keycodes that continue Caps Word, without shifting.
case KC_1 ... KC_0:
case KC_BSPC:
case KC_DEL:
case KC_UNDS:
case KC_LSFT: // <<< Added here.
case KC_RSFT:
return true;
default:
return false; // Deactivate Caps Word.
}
}
```
* Update quantum/process_keycode/process_caps_word.c
Co-authored-by: Joel Challis <git@zvecr.com>
Diffstat (limited to 'quantum/process_keycode/process_caps_word.c')
| -rw-r--r-- | quantum/process_keycode/process_caps_word.c | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/quantum/process_keycode/process_caps_word.c b/quantum/process_keycode/process_caps_word.c index bc4369846c..1b9583196d 100644 --- a/quantum/process_keycode/process_caps_word.c +++ b/quantum/process_keycode/process_caps_word.c | |||
| @@ -101,14 +101,34 @@ bool process_caps_word(uint16_t keycode, keyrecord_t* record) { | |||
| 101 | return true; | 101 | return true; |
| 102 | 102 | ||
| 103 | #ifndef NO_ACTION_TAPPING | 103 | #ifndef NO_ACTION_TAPPING |
| 104 | // Corresponding to mod keys above, a held mod-tap is handled as: | ||
| 105 | // * For shift mods, pass KC_LSFT or KC_RSFT to | ||
| 106 | // caps_word_press_user() to determine whether to continue. | ||
| 107 | // * For Shift + AltGr (MOD_RSFT | MOD_RALT), pass RSFT(KC_RALT). | ||
| 108 | // * AltGr (MOD_RALT) is ignored. | ||
| 109 | // * Otherwise stop Caps Word. | ||
| 104 | case QK_MOD_TAP ... QK_MOD_TAP_MAX: | 110 | case QK_MOD_TAP ... QK_MOD_TAP_MAX: |
| 105 | if (record->tap.count == 0) { | 111 | if (record->tap.count == 0) { // Mod-tap key is held. |
| 106 | // Deactivate if a mod becomes active through holding | 112 | const uint8_t mods = (keycode >> 8) & 0x1f; |
| 107 | // a mod-tap key. | 113 | switch (mods) { |
| 108 | caps_word_off(); | 114 | case MOD_LSFT: |
| 109 | return true; | 115 | keycode = KC_LSFT; |
| 116 | break; | ||
| 117 | case MOD_RSFT: | ||
| 118 | keycode = KC_RSFT; | ||
| 119 | break; | ||
| 120 | case MOD_RSFT | MOD_RALT: | ||
| 121 | keycode = RSFT(KC_RALT); | ||
| 122 | break; | ||
| 123 | case MOD_RALT: | ||
| 124 | return true; | ||
| 125 | default: | ||
| 126 | caps_word_off(); | ||
| 127 | return true; | ||
| 128 | } | ||
| 129 | } else { | ||
| 130 | keycode &= 0xff; | ||
| 110 | } | 131 | } |
| 111 | keycode &= 0xff; | ||
| 112 | break; | 132 | break; |
| 113 | 133 | ||
| 114 | # ifndef NO_ACTION_LAYER | 134 | # ifndef NO_ACTION_LAYER |
