aboutsummaryrefslogtreecommitdiff
path: root/quantum/process_keycode/process_space_cadet.c
diff options
context:
space:
mode:
authorXScorpion2 <rcalt2vt@gmail.com>2019-05-05 18:27:02 -0500
committerDrashna Jaelre <drashna@live.com>2019-05-05 16:27:02 -0700
commite290dc5ad811e9d121e216fba6fe03666772c3a4 (patch)
tree168a662327ec21e7613887d30f0b11687592d067 /quantum/process_keycode/process_space_cadet.c
parente14732be9f52d2d79f2334384b52d36825539515 (diff)
downloadqmk_firmware-e290dc5ad811e9d121e216fba6fe03666772c3a4.tar.gz
qmk_firmware-e290dc5ad811e9d121e216fba6fe03666772c3a4.zip
Space Cadet: Reducing unnecessary reported keypresses (#5781)
* Reducing unnecessary reported keypresses and minor docs / variable name changes * Apply suggestions from code review Co-Authored-By: XScorpion2 <rcalt2vt@gmail.com>
Diffstat (limited to 'quantum/process_keycode/process_space_cadet.c')
-rw-r--r--quantum/process_keycode/process_space_cadet.c39
1 files changed, 22 insertions, 17 deletions
diff --git a/quantum/process_keycode/process_space_cadet.c b/quantum/process_keycode/process_space_cadet.c
index a9c506168..ac39df808 100644
--- a/quantum/process_keycode/process_space_cadet.c
+++ b/quantum/process_keycode/process_space_cadet.c
@@ -62,16 +62,16 @@
62#ifndef LCPO_KEYS 62#ifndef LCPO_KEYS
63 #define LCPO_KEYS KC_LCTL, KC_LCTL, KC_9 63 #define LCPO_KEYS KC_LCTL, KC_LCTL, KC_9
64#endif 64#endif
65#ifndef RCPO_KEYS 65#ifndef RCPC_KEYS
66 #define RCPO_KEYS KC_RCTL, KC_RCTL, KC_0 66 #define RCPC_KEYS KC_RCTL, KC_RCTL, KC_0
67#endif 67#endif
68 68
69// Alt / paren setup 69// Alt / paren setup
70#ifndef LAPO_KEYS 70#ifndef LAPO_KEYS
71 #define LAPO_KEYS KC_LALT, KC_LALT, KC_9 71 #define LAPO_KEYS KC_LALT, KC_LALT, KC_9
72#endif 72#endif
73#ifndef RAPO_KEYS 73#ifndef RAPC_KEYS
74 #define RAPO_KEYS KC_RALT, KC_RALT, KC_0 74 #define RAPC_KEYS KC_RALT, KC_RALT, KC_0
75#endif 75#endif
76 76
77// Shift / Enter setup 77// Shift / Enter setup
@@ -82,27 +82,32 @@
82static uint8_t sc_last = 0; 82static uint8_t sc_last = 0;
83static uint16_t sc_timer = 0; 83static uint16_t sc_timer = 0;
84 84
85void perform_space_cadet(keyrecord_t *record, uint8_t normalMod, uint8_t tapMod, uint8_t keycode) { 85void perform_space_cadet(keyrecord_t *record, uint8_t holdMod, uint8_t tapMod, uint8_t keycode) {
86 if (record->event.pressed) { 86 if (record->event.pressed) {
87 sc_last = normalMod; 87 sc_last = holdMod;
88 sc_timer = timer_read (); 88 sc_timer = timer_read ();
89 if (IS_MOD(normalMod)) { 89 if (IS_MOD(holdMod)) {
90 register_mods(MOD_BIT(normalMod)); 90 register_mods(MOD_BIT(holdMod));
91 } 91 }
92 } 92 }
93 else { 93 else {
94 if (IS_MOD(normalMod)) { 94 if (sc_last == holdMod && timer_elapsed(sc_timer) < TAPPING_TERM) {
95 unregister_mods(MOD_BIT(normalMod)); 95 if (holdMod != tapMod) {
96 } 96 if (IS_MOD(holdMod)) {
97 97 unregister_mods(MOD_BIT(holdMod));
98 if (sc_last == normalMod && timer_elapsed(sc_timer) < TAPPING_TERM) { 98 }
99 if (IS_MOD(tapMod)) { 99 if (IS_MOD(tapMod)) {
100 register_mods(MOD_BIT(tapMod)); 100 register_mods(MOD_BIT(tapMod));
101 }
101 } 102 }
102 tap_code(keycode); 103 tap_code(keycode);
103 if (IS_MOD(tapMod)) { 104 if (IS_MOD(tapMod)) {
104 unregister_mods(MOD_BIT(tapMod)); 105 unregister_mods(MOD_BIT(tapMod));
105 } 106 }
107 } else {
108 if (IS_MOD(holdMod)) {
109 unregister_mods(MOD_BIT(holdMod));
110 }
106 } 111 }
107 } 112 }
108} 113}
@@ -122,7 +127,7 @@ bool process_space_cadet(uint16_t keycode, keyrecord_t *record) {
122 return false; 127 return false;
123 } 128 }
124 case KC_RCPC: { 129 case KC_RCPC: {
125 perform_space_cadet(record, RCPO_KEYS); 130 perform_space_cadet(record, RCPC_KEYS);
126 return false; 131 return false;
127 } 132 }
128 case KC_LAPO: { 133 case KC_LAPO: {
@@ -130,7 +135,7 @@ bool process_space_cadet(uint16_t keycode, keyrecord_t *record) {
130 return false; 135 return false;
131 } 136 }
132 case KC_RAPC: { 137 case KC_RAPC: {
133 perform_space_cadet(record, RAPO_KEYS); 138 perform_space_cadet(record, RAPC_KEYS);
134 return false; 139 return false;
135 } 140 }
136 case KC_SFTENT: { 141 case KC_SFTENT: {