From cc9d0ded3d1d59b27d1ae49946d2be484c1041e7 Mon Sep 17 00:00:00 2001 From: Rutherther Date: Sat, 14 Sep 2024 10:42:56 +0200 Subject: [PATCH] feat: caps word modifications * caps word: Disable caps word on ESC press * caps word: Do not convert minus to underscore * caps word: Invert on shift --- .../splitkb/kyria/keymaps/rutherther/config.h | 1 + .../splitkb/kyria/keymaps/rutherther/keymap.c | 33 ++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/keyboards/splitkb/kyria/keymaps/rutherther/config.h b/keyboards/splitkb/kyria/keymaps/rutherther/config.h index 536bcbdcff..b3cbac3b0c 100644 --- a/keyboards/splitkb/kyria/keymaps/rutherther/config.h +++ b/keyboards/splitkb/kyria/keymaps/rutherther/config.h @@ -23,5 +23,6 @@ #define QUICK_TAP_TERM 0 #define BOTH_SHIFTS_TURNS_ON_CAPS_WORD +#define CAPS_WORD_INVERT_ON_SHIFT /* #define ACHORDION_STREAK */ diff --git a/keyboards/splitkb/kyria/keymaps/rutherther/keymap.c b/keyboards/splitkb/kyria/keymaps/rutherther/keymap.c index e598d52054..510b6d12e6 100644 --- a/keyboards/splitkb/kyria/keymaps/rutherther/keymap.c +++ b/keyboards/splitkb/kyria/keymaps/rutherther/keymap.c @@ -3,6 +3,8 @@ #include "features/cz_accent.h" #include "features/achordion.h" +bool process_caps_word_off(uint16_t keycode, keyrecord_t* record); + enum layers { _QWERTY = 0, _QWERTY_NOHOMEMODS, @@ -177,7 +179,7 @@ void keyboard_pre_init_user(void) { bool process_record_user(uint16_t keycode, keyrecord_t *record) { static bool achordion = true; - + if (!process_caps_word_off(keycode, record)) { return false; } if (!process_czech_acute(keycode, record, CZ_ACUTED, _PLAIN)) { return false; } if (!process_czech_caret(keycode, record, CZ_CARETED, _PLAIN)) { return false; } if (!process_layer_lock(keycode, record, QK_LLCK)) { return false; } @@ -199,6 +201,16 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { return true; } +bool process_caps_word_off(uint16_t keycode, keyrecord_t* record) +{ + if (is_caps_word_on() && keycode == KC_ESC) { + caps_word_off(); + return false; + } + + return true; +} + bool achordion_chord(uint16_t tap_hold_keycode, keyrecord_t* tap_hold_record, uint16_t other_keycode, @@ -232,6 +244,25 @@ bool achordion_eager_mod(uint8_t mod) { } } +bool caps_word_press_user(uint16_t keycode) { + switch (keycode) { + // Keycodes that continue Caps Word, with shift applied. + case KC_A ... KC_Z: + add_weak_mods(MOD_BIT(KC_LSFT)); // Apply shift to 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_MINS: + return true; + default: + return false; // Deactivate Caps Word. + } +} + /* qmk-keyboard-format:json:begin { -- 2.48.1