diff options
-rw-r--r-- | docs/feature_space_cadet.md | 1 | ||||
-rw-r--r-- | quantum/process_keycode/process_space_cadet.c | 12 |
2 files changed, 13 insertions, 0 deletions
diff --git a/docs/feature_space_cadet.md b/docs/feature_space_cadet.md index 075578522..41a44627e 100644 --- a/docs/feature_space_cadet.md +++ b/docs/feature_space_cadet.md | |||
@@ -43,6 +43,7 @@ By default Space Cadet assumes a US ANSI layout, but if your layout uses differe | |||
43 | |`LAPO_KEYS` |`KC_LALT, KC_LSFT, KC_9` |Send `KC_LALT` when held, the mod `KC_LSFT` with the key `KC_9` when tapped. | | 43 | |`LAPO_KEYS` |`KC_LALT, KC_LSFT, KC_9` |Send `KC_LALT` when held, the mod `KC_LSFT` with the key `KC_9` when tapped. | |
44 | |`RAPC_KEYS` |`KC_RALT, KC_RSFT, KC_0` |Send `KC_RALT` when held, the mod `KC_RSFT` with the key `KC_0` when tapped. | | 44 | |`RAPC_KEYS` |`KC_RALT, KC_RSFT, KC_0` |Send `KC_RALT` when held, the mod `KC_RSFT` with the key `KC_0` when tapped. | |
45 | |`SFTENT_KEYS` |`KC_RSFT, KC_TRNS, SFTENT_KEY` |Send `KC_RSFT` when held, no mod with the key `SFTENT_KEY` when tapped. | | 45 | |`SFTENT_KEYS` |`KC_RSFT, KC_TRNS, SFTENT_KEY` |Send `KC_RSFT` when held, no mod with the key `SFTENT_KEY` when tapped. | |
46 | |`SPACE_CADET_MODIFIER_CARRYOVER` |*Not defined* |Store current modifiers before the hold mod is pressed and use them with the tap mod and keycode. Useful for when you frequently release a modifier before triggering Space Cadet. | | ||
46 | 47 | ||
47 | 48 | ||
48 | ## Obsolete Configuration | 49 | ## Obsolete Configuration |
diff --git a/quantum/process_keycode/process_space_cadet.c b/quantum/process_keycode/process_space_cadet.c index 089199eee..c8721d446 100644 --- a/quantum/process_keycode/process_space_cadet.c +++ b/quantum/process_keycode/process_space_cadet.c | |||
@@ -81,11 +81,17 @@ | |||
81 | 81 | ||
82 | static uint8_t sc_last = 0; | 82 | static uint8_t sc_last = 0; |
83 | static uint16_t sc_timer = 0; | 83 | static uint16_t sc_timer = 0; |
84 | #ifdef SPACE_CADET_MODIFIER_CARRYOVER | ||
85 | static uint8_t sc_mods = 0; | ||
86 | #endif | ||
84 | 87 | ||
85 | void perform_space_cadet(keyrecord_t *record, uint8_t holdMod, uint8_t tapMod, uint8_t keycode) { | 88 | void perform_space_cadet(keyrecord_t *record, uint8_t holdMod, uint8_t tapMod, uint8_t keycode) { |
86 | if (record->event.pressed) { | 89 | if (record->event.pressed) { |
87 | sc_last = holdMod; | 90 | sc_last = holdMod; |
88 | sc_timer = timer_read (); | 91 | sc_timer = timer_read (); |
92 | #ifdef SPACE_CADET_MODIFIER_CARRYOVER | ||
93 | sc_mods = get_mods(); | ||
94 | #endif | ||
89 | if (IS_MOD(holdMod)) { | 95 | if (IS_MOD(holdMod)) { |
90 | register_mods(MOD_BIT(holdMod)); | 96 | register_mods(MOD_BIT(holdMod)); |
91 | } | 97 | } |
@@ -100,7 +106,13 @@ void perform_space_cadet(keyrecord_t *record, uint8_t holdMod, uint8_t tapMod, u | |||
100 | register_mods(MOD_BIT(tapMod)); | 106 | register_mods(MOD_BIT(tapMod)); |
101 | } | 107 | } |
102 | } | 108 | } |
109 | #ifdef SPACE_CADET_MODIFIER_CARRYOVER | ||
110 | set_weak_mods(sc_mods); | ||
111 | #endif | ||
103 | tap_code(keycode); | 112 | tap_code(keycode); |
113 | #ifdef SPACE_CADET_MODIFIER_CARRYOVER | ||
114 | clear_weak_mods(); | ||
115 | #endif | ||
104 | if (IS_MOD(tapMod)) { | 116 | if (IS_MOD(tapMod)) { |
105 | unregister_mods(MOD_BIT(tapMod)); | 117 | unregister_mods(MOD_BIT(tapMod)); |
106 | } | 118 | } |