]> git.donarmstrong.com Git - qmk_firmware.git/commitdiff
Added mod carry over from press to release. (#5866)
authorXScorpion2 <rcalt2vt@gmail.com>
Sun, 7 Jul 2019 04:00:05 +0000 (23:00 -0500)
committerMechMerlin <30334081+mechmerlin@users.noreply.github.com>
Sun, 7 Jul 2019 04:00:05 +0000 (21:00 -0700)
Update docs/feature_space_cadet.md

Co-Authored-By: fauxpark <fauxpark@gmail.com>
docs/feature_space_cadet.md
quantum/process_keycode/process_space_cadet.c

index 075578522e6ed2e93c4d57b61b2049763b341d78..41a44627e3c16de11081515fcc6cb051c126cbe5 100644 (file)
@@ -43,6 +43,7 @@ By default Space Cadet assumes a US ANSI layout, but if your layout uses differe
 |`LAPO_KEYS`     |`KC_LALT, KC_LSFT, KC_9`       |Send `KC_LALT` when held, the mod `KC_LSFT` with the key `KC_9` when tapped.     |
 |`RAPC_KEYS`     |`KC_RALT, KC_RSFT, KC_0`       |Send `KC_RALT` when held, the mod `KC_RSFT` with the key `KC_0` when tapped.     |
 |`SFTENT_KEYS`   |`KC_RSFT, KC_TRNS, SFTENT_KEY` |Send `KC_RSFT` when held, no mod with the key `SFTENT_KEY` when tapped.          |
+|`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.  |
 
 
 ## Obsolete Configuration
index 089199eee22b00d7d93cc113a62e409ecbb026ba..c8721d446ca256d703b81709c6b1d48dfd3d1895 100644 (file)
 
 static uint8_t sc_last = 0;
 static uint16_t sc_timer = 0;
+#ifdef SPACE_CADET_MODIFIER_CARRYOVER
+static uint8_t sc_mods = 0;
+#endif
 
 void perform_space_cadet(keyrecord_t *record, uint8_t holdMod, uint8_t tapMod, uint8_t keycode) {
   if (record->event.pressed) {
     sc_last = holdMod;
     sc_timer = timer_read ();
+#ifdef SPACE_CADET_MODIFIER_CARRYOVER
+    sc_mods = get_mods();
+#endif
     if (IS_MOD(holdMod)) {
       register_mods(MOD_BIT(holdMod));
     }
@@ -100,7 +106,13 @@ void perform_space_cadet(keyrecord_t *record, uint8_t holdMod, uint8_t tapMod, u
           register_mods(MOD_BIT(tapMod));
         }
       }
+#ifdef SPACE_CADET_MODIFIER_CARRYOVER
+    set_weak_mods(sc_mods);
+#endif
       tap_code(keycode);
+#ifdef SPACE_CADET_MODIFIER_CARRYOVER
+    clear_weak_mods();
+#endif
       if (IS_MOD(tapMod)) {
         unregister_mods(MOD_BIT(tapMod));
       }