diff options
author | Drashna Jaelre <drashna@live.com> | 2020-07-24 20:05:27 -0700 |
---|---|---|
committer | James Young <18669334+noroadsleft@users.noreply.github.com> | 2020-08-29 14:30:02 -0700 |
commit | 9d3b26a47543d9898a2af2cee5f6ef53b4995e9f (patch) | |
tree | 934d032d2cdbb13c2223aa59ab854428407d5092 /quantum/process_keycode | |
parent | 3c74edbc691502228b2d2c4d42d5888311f0ca4c (diff) | |
download | qmk_firmware-9d3b26a47543d9898a2af2cee5f6ef53b4995e9f.tar.gz qmk_firmware-9d3b26a47543d9898a2af2cee5f6ef53b4995e9f.zip |
Update features to use Custom Tapping Term when appropriate (#6259)
* Update Space Cadet to use Custom Tapping Term functionality
* Detect correct keycode for space cadet tapping term
* Update tap dancing to use global custom tapping term
* Update documentation for Tap Dances
* formatting pass
* Apply suggestions from code review
Co-Authored-By: fauxpark <fauxpark@gmail.com>
* Update docs/feature_tap_dance.md
Co-authored-by: James Young <18669334+noroadsleft@users.noreply.github.com>
* Update for future
* Update user keymaps for space cadet
* Fix typos
* Clean up tapping term stuff
* Fix compiler issue if NO_ACTION_TAPPING is enabled
Co-authored-by: fauxpark <fauxpark@gmail.com>
Co-authored-by: James Young <18669334+noroadsleft@users.noreply.github.com>
Diffstat (limited to 'quantum/process_keycode')
-rw-r--r-- | quantum/process_keycode/process_space_cadet.c | 23 | ||||
-rw-r--r-- | quantum/process_keycode/process_space_cadet.h | 5 | ||||
-rw-r--r-- | quantum/process_keycode/process_tap_dance.c | 6 |
3 files changed, 17 insertions, 17 deletions
diff --git a/quantum/process_keycode/process_space_cadet.c b/quantum/process_keycode/process_space_cadet.c index 6833fdb9f..bcaf62a96 100644 --- a/quantum/process_keycode/process_space_cadet.c +++ b/quantum/process_keycode/process_space_cadet.c | |||
@@ -14,9 +14,10 @@ | |||
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
15 | */ | 15 | */ |
16 | #include "process_space_cadet.h" | 16 | #include "process_space_cadet.h" |
17 | #include "action_tapping.h" | ||
17 | 18 | ||
18 | #ifndef TAPPING_TERM | 19 | #ifdef NO_ACTION_TAPPING |
19 | # define TAPPING_TERM 200 | 20 | __attribute__((weak)) uint16_t get_tapping_term(uint16_t keycode, keyrecord_t *record) { return TAPPING_TERM; }; |
20 | #endif | 21 | #endif |
21 | 22 | ||
22 | // ********** OBSOLETE DEFINES, STOP USING! (pls?) ********** | 23 | // ********** OBSOLETE DEFINES, STOP USING! (pls?) ********** |
@@ -85,7 +86,7 @@ static uint16_t sc_timer = 0; | |||
85 | static uint8_t sc_mods = 0; | 86 | static uint8_t sc_mods = 0; |
86 | #endif | 87 | #endif |
87 | 88 | ||
88 | void perform_space_cadet(keyrecord_t *record, uint8_t holdMod, uint8_t tapMod, uint8_t keycode) { | 89 | void perform_space_cadet(keyrecord_t *record, uint16_t sc_keycode, uint8_t holdMod, uint8_t tapMod, uint8_t keycode) { |
89 | if (record->event.pressed) { | 90 | if (record->event.pressed) { |
90 | sc_last = holdMod; | 91 | sc_last = holdMod; |
91 | sc_timer = timer_read(); | 92 | sc_timer = timer_read(); |
@@ -96,7 +97,7 @@ void perform_space_cadet(keyrecord_t *record, uint8_t holdMod, uint8_t tapMod, u | |||
96 | register_mods(MOD_BIT(holdMod)); | 97 | register_mods(MOD_BIT(holdMod)); |
97 | } | 98 | } |
98 | } else { | 99 | } else { |
99 | if (sc_last == holdMod && timer_elapsed(sc_timer) < TAPPING_TERM) { | 100 | if (sc_last == holdMod && timer_elapsed(sc_timer) < get_tapping_term(sc_keycode, record)) { |
100 | if (holdMod != tapMod) { | 101 | if (holdMod != tapMod) { |
101 | if (IS_MOD(holdMod)) { | 102 | if (IS_MOD(holdMod)) { |
102 | unregister_mods(MOD_BIT(holdMod)); | 103 | unregister_mods(MOD_BIT(holdMod)); |
@@ -126,31 +127,31 @@ void perform_space_cadet(keyrecord_t *record, uint8_t holdMod, uint8_t tapMod, u | |||
126 | bool process_space_cadet(uint16_t keycode, keyrecord_t *record) { | 127 | bool process_space_cadet(uint16_t keycode, keyrecord_t *record) { |
127 | switch (keycode) { | 128 | switch (keycode) { |
128 | case KC_LSPO: { | 129 | case KC_LSPO: { |
129 | perform_space_cadet(record, LSPO_KEYS); | 130 | perform_space_cadet(record, keycode, LSPO_KEYS); |
130 | return false; | 131 | return false; |
131 | } | 132 | } |
132 | case KC_RSPC: { | 133 | case KC_RSPC: { |
133 | perform_space_cadet(record, RSPC_KEYS); | 134 | perform_space_cadet(record, keycode, RSPC_KEYS); |
134 | return false; | 135 | return false; |
135 | } | 136 | } |
136 | case KC_LCPO: { | 137 | case KC_LCPO: { |
137 | perform_space_cadet(record, LCPO_KEYS); | 138 | perform_space_cadet(record, keycode, LCPO_KEYS); |
138 | return false; | 139 | return false; |
139 | } | 140 | } |
140 | case KC_RCPC: { | 141 | case KC_RCPC: { |
141 | perform_space_cadet(record, RCPC_KEYS); | 142 | perform_space_cadet(record, keycode, RCPC_KEYS); |
142 | return false; | 143 | return false; |
143 | } | 144 | } |
144 | case KC_LAPO: { | 145 | case KC_LAPO: { |
145 | perform_space_cadet(record, LAPO_KEYS); | 146 | perform_space_cadet(record, keycode, LAPO_KEYS); |
146 | return false; | 147 | return false; |
147 | } | 148 | } |
148 | case KC_RAPC: { | 149 | case KC_RAPC: { |
149 | perform_space_cadet(record, RAPC_KEYS); | 150 | perform_space_cadet(record, keycode, RAPC_KEYS); |
150 | return false; | 151 | return false; |
151 | } | 152 | } |
152 | case KC_SFTENT: { | 153 | case KC_SFTENT: { |
153 | perform_space_cadet(record, SFTENT_KEYS); | 154 | perform_space_cadet(record, keycode, SFTENT_KEYS); |
154 | return false; | 155 | return false; |
155 | } | 156 | } |
156 | default: { | 157 | default: { |
diff --git a/quantum/process_keycode/process_space_cadet.h b/quantum/process_keycode/process_space_cadet.h index c82314350..3ace07399 100644 --- a/quantum/process_keycode/process_space_cadet.h +++ b/quantum/process_keycode/process_space_cadet.h | |||
@@ -17,5 +17,8 @@ | |||
17 | 17 | ||
18 | #include "quantum.h" | 18 | #include "quantum.h" |
19 | 19 | ||
20 | void perform_space_cadet(keyrecord_t *record, uint8_t holdMod, uint8_t tapMod, uint8_t keycode); | 20 | void perform_space_cadet(keyrecord_t *record, uint16_t sc_keycode, uint8_t holdMod, uint8_t tapMod, uint8_t keycode); |
21 | bool process_space_cadet(uint16_t keycode, keyrecord_t *record); | 21 | bool process_space_cadet(uint16_t keycode, keyrecord_t *record); |
22 | #ifdef NO_ACTION_TAPPING | ||
23 | uint16_t get_tapping_term(uint16_t keycode, keyrecord_t *record); | ||
24 | #endif | ||
diff --git a/quantum/process_keycode/process_tap_dance.c b/quantum/process_keycode/process_tap_dance.c index 16756e59c..0c7b6353e 100644 --- a/quantum/process_keycode/process_tap_dance.c +++ b/quantum/process_keycode/process_tap_dance.c | |||
@@ -16,10 +16,6 @@ | |||
16 | #include "quantum.h" | 16 | #include "quantum.h" |
17 | #include "action_tapping.h" | 17 | #include "action_tapping.h" |
18 | 18 | ||
19 | #ifndef TAPPING_TERM | ||
20 | # define TAPPING_TERM 200 | ||
21 | #endif | ||
22 | |||
23 | #ifndef NO_ACTION_ONESHOT | 19 | #ifndef NO_ACTION_ONESHOT |
24 | uint8_t get_oneshot_mods(void); | 20 | uint8_t get_oneshot_mods(void); |
25 | #endif | 21 | #endif |
@@ -171,7 +167,7 @@ void matrix_scan_tap_dance() { | |||
171 | if (action->custom_tapping_term > 0) { | 167 | if (action->custom_tapping_term > 0) { |
172 | tap_user_defined = action->custom_tapping_term; | 168 | tap_user_defined = action->custom_tapping_term; |
173 | } else { | 169 | } else { |
174 | tap_user_defined = TAPPING_TERM; | 170 | tap_user_defined = get_tapping_term(action->state.keycode, NULL); |
175 | } | 171 | } |
176 | if (action->state.count && timer_elapsed(action->state.timer) > tap_user_defined) { | 172 | if (action->state.count && timer_elapsed(action->state.timer) > tap_user_defined) { |
177 | process_tap_dance_action_on_dance_finished(action); | 173 | process_tap_dance_action_on_dance_finished(action); |