summaryrefslogtreecommitdiff
path: root/quantum
diff options
context:
space:
mode:
authorPascal Getreuer <50221757+getreuer@users.noreply.github.com>2022-08-14 12:25:32 -0700
committerGitHub <noreply@github.com>2022-08-14 20:25:32 +0100
commit95c43a275984fb57cdf6e5afd02190700e0205bc (patch)
treea6bc77a909d48aa89c209a00cfd0cf4ca788d84c /quantum
parent6fc7c03e9581ddde68b32f2f76f8053628da6465 (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')
-rw-r--r--quantum/process_keycode/process_caps_word.c32
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) {
return true;
#ifndef NO_ACTION_TAPPING
+ // Corresponding to mod keys above, a held mod-tap is handled as:
+ // * For shift mods, pass KC_LSFT or KC_RSFT to
+ // caps_word_press_user() to determine whether to continue.
+ // * For Shift + AltGr (MOD_RSFT | MOD_RALT), pass RSFT(KC_RALT).
+ // * AltGr (MOD_RALT) is ignored.
+ // * Otherwise stop Caps Word.
case QK_MOD_TAP ... QK_MOD_TAP_MAX:
- if (record->tap.count == 0) {
- // Deactivate if a mod becomes active through holding
- // a mod-tap key.
- caps_word_off();
- return true;
+ if (record->tap.count == 0) { // Mod-tap key is held.
+ const uint8_t mods = (keycode >> 8) & 0x1f;
+ switch (mods) {
+ case MOD_LSFT:
+ keycode = KC_LSFT;
+ break;
+ case MOD_RSFT:
+ keycode = KC_RSFT;
+ break;
+ case MOD_RSFT | MOD_RALT:
+ keycode = RSFT(KC_RALT);
+ break;
+ case MOD_RALT:
+ return true;
+ default:
+ caps_word_off();
+ return true;
+ }
+ } else {
+ keycode &= 0xff;
}
- keycode &= 0xff;
break;
# ifndef NO_ACTION_LAYER