forked from mirrors/qmk_userspace
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>
This commit is contained in:
parent
6fc7c03e95
commit
95c43a2759
2 changed files with 185 additions and 6 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue