aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/feature_space_cadet_shift.md16
-rw-r--r--quantum/quantum.c37
2 files changed, 45 insertions, 8 deletions
diff --git a/docs/feature_space_cadet_shift.md b/docs/feature_space_cadet_shift.md
index bec7cbd3d..427d2a581 100644
--- a/docs/feature_space_cadet_shift.md
+++ b/docs/feature_space_cadet_shift.md
@@ -25,9 +25,13 @@ COMMAND_ENABLE = no
25 25
26By default Space Cadet assumes a US ANSI layout, but if your layout uses different keys for parentheses, you can redefine them in your `config.h`. 26By default Space Cadet assumes a US ANSI layout, but if your layout uses different keys for parentheses, you can redefine them in your `config.h`.
27You can also disable the rollover, allowing you to use the opposite Shift key to cancel the Space Cadet state in the event of an erroneous press, instead of emitting a pair of parentheses when the keys are released. 27You can also disable the rollover, allowing you to use the opposite Shift key to cancel the Space Cadet state in the event of an erroneous press, instead of emitting a pair of parentheses when the keys are released.
28 28Also, by default, the Space Cadet applies modifiers LSPO_MOD and RSPC_MOD to keys defined by LSPO_KEY and RSPC_KEY. You can override this behavior by redefining those variables in your `config.h`. You can also prevent the Space Cadet to apply a modifier by defining DISABLE_SPACE_CADET_MODIFIER in your `config.h`.
29|Define |Default |Description | 29
30|------------------------------|-------------|------------------------------------------------------------| 30|Define |Default |Description |
31|`LSPO_KEY` |`KC_9` |The keycode to send when Left Shift is tapped | 31|------------------------------|-------------|--------------------------------------------------------------------------------|
32|`RSPC_KEY` |`KC_0` |The keycode to send when Right Shift is tapped | 32|`LSPO_KEY` |`KC_9` |The keycode to send when Left Shift is tapped |
33|`DISABLE_SPACE_CADET_ROLLOVER`|*Not defined*|If defined, use the opposite Shift key to cancel Space Cadet| 33|`RSPC_KEY` |`KC_0` |The keycode to send when Right Shift is tapped |
34|`LSPO_MOD` |`KC_LSFT` |The keycode to send when Left Shift is tapped |
35|`RSPC_MOD` |`KC_RSFT` |The keycode to send when Right Shift is tapped |
36|`DISABLE_SPACE_CADET_ROLLOVER`|*Not defined*|If defined, use the opposite Shift key to cancel Space Cadet |
37|`DISABLE_SPACE_CADET_MODIFIER`|*Not defined*|If defined, prevent the Space Cadet to apply a modifier to LSPO_KEY and RSPC_KEY|
diff --git a/quantum/quantum.c b/quantum/quantum.c
index c1829c768..bd3715c80 100644
--- a/quantum/quantum.c
+++ b/quantum/quantum.c
@@ -195,6 +195,13 @@ void reset_keyboard(void) {
195 #define RSPC_KEY KC_0 195 #define RSPC_KEY KC_0
196#endif 196#endif
197 197
198#ifndef LSPO_MOD
199 #define LSPO_MOD KC_LSFT
200#endif
201#ifndef RSPC_MOD
202 #define RSPC_MOD KC_RSFT
203#endif
204
198// Shift / Enter setup 205// Shift / Enter setup
199#ifndef SFTENT_KEY 206#ifndef SFTENT_KEY
200 #define SFTENT_KEY KC_ENT 207 #define SFTENT_KEY KC_ENT
@@ -674,14 +681,27 @@ bool process_record_quantum(keyrecord_t *record) {
674 } 681 }
675 else { 682 else {
676 #ifdef DISABLE_SPACE_CADET_ROLLOVER 683 #ifdef DISABLE_SPACE_CADET_ROLLOVER
677 if (get_mods() & MOD_BIT(KC_RSFT)) { 684 if (get_mods() & MOD_BIT(RSPC_MOD)) {
678 shift_interrupted[0] = true; 685 shift_interrupted[0] = true;
679 shift_interrupted[1] = true; 686 shift_interrupted[1] = true;
680 } 687 }
681 #endif 688 #endif
682 if (!shift_interrupted[0] && timer_elapsed(scs_timer[0]) < TAPPING_TERM) { 689 if (!shift_interrupted[0] && timer_elapsed(scs_timer[0]) < TAPPING_TERM) {
690 #ifdef DISABLE_SPACE_CADET_MODIFIER
691 unregister_mods(MOD_BIT(KC_LSFT));
692 #else
693 if( LSPO_MOD != KC_LSFT ){
694 unregister_mods(MOD_BIT(KC_LSFT));
695 register_mods(MOD_BIT(LSPO_MOD));
696 }
697 #endif
683 register_code(LSPO_KEY); 698 register_code(LSPO_KEY);
684 unregister_code(LSPO_KEY); 699 unregister_code(LSPO_KEY);
700 #ifndef DISABLE_SPACE_CADET_MODIFIER
701 if( LSPO_MOD != KC_LSFT ){
702 unregister_mods(MOD_BIT(LSPO_MOD));
703 }
704 #endif
685 } 705 }
686 unregister_mods(MOD_BIT(KC_LSFT)); 706 unregister_mods(MOD_BIT(KC_LSFT));
687 } 707 }
@@ -696,14 +716,27 @@ bool process_record_quantum(keyrecord_t *record) {
696 } 716 }
697 else { 717 else {
698 #ifdef DISABLE_SPACE_CADET_ROLLOVER 718 #ifdef DISABLE_SPACE_CADET_ROLLOVER
699 if (get_mods() & MOD_BIT(KC_LSFT)) { 719 if (get_mods() & MOD_BIT(LSPO_MOD)) {
700 shift_interrupted[0] = true; 720 shift_interrupted[0] = true;
701 shift_interrupted[1] = true; 721 shift_interrupted[1] = true;
702 } 722 }
703 #endif 723 #endif
704 if (!shift_interrupted[1] && timer_elapsed(scs_timer[1]) < TAPPING_TERM) { 724 if (!shift_interrupted[1] && timer_elapsed(scs_timer[1]) < TAPPING_TERM) {
725 #ifdef DISABLE_SPACE_CADET_MODIFIER
726 unregister_mods(MOD_BIT(KC_RSFT));
727 #else
728 if( RSPC_MOD != KC_RSFT ){
729 unregister_mods(MOD_BIT(KC_RSFT));
730 register_mods(MOD_BIT(RSPC_MOD));
731 }
732 #endif
705 register_code(RSPC_KEY); 733 register_code(RSPC_KEY);
706 unregister_code(RSPC_KEY); 734 unregister_code(RSPC_KEY);
735 #ifndef DISABLE_SPACE_CADET_MODIFIER
736 if ( RSPC_MOD != KC_RSFT ){
737 unregister_mods(MOD_BIT(RSPC_MOD));
738 }
739 #endif
707 } 740 }
708 unregister_mods(MOD_BIT(KC_RSFT)); 741 unregister_mods(MOD_BIT(KC_RSFT));
709 } 742 }