Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update features to use Custom Tapping Term when appropriate #6259

Merged
merged 12 commits into from
Jul 25, 2020
4 changes: 3 additions & 1 deletion docs/feature_tap_dance.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ After this, you'll want to use the `tap_dance_actions` array to specify what act
* `ACTION_TAP_DANCE_LAYER_TOGGLE(kc, layer)`: Sends the `kc` keycode when tapped once, or toggles the state of `layer`. (this functions like the `TG` layer keycode).
* `ACTION_TAP_DANCE_FN(fn)`: Calls the specified function - defined in the user keymap - with the final tap count of the tap dance action.
* `ACTION_TAP_DANCE_FN_ADVANCED(on_each_tap_fn, on_dance_finished_fn, on_dance_reset_fn)`: Calls the first specified function - defined in the user keymap - on every tap, the second function when the dance action finishes (like the previous option), and the last function when the tap dance action resets.
* `ACTION_TAP_DANCE_FN_ADVANCED_TIME(on_each_tap_fn, on_dance_finished_fn, on_dance_reset_fn, tap_specific_tapping_term)`: This functions identically to the `ACTION_TAP_DANCE_FN_ADVANCED` function, but uses a custom tapping term for it, instead of the predefined `TAPPING_TERM`.
* ~~`ACTION_TAP_DANCE_FN_ADVANCED_TIME(on_each_tap_fn, on_dance_finished_fn, on_dance_reset_fn, tap_specific_tapping_term)`~~: This functions identically to the `ACTION_TAP_DANCE_FN_ADVANCED` function, but uses a custom tapping term for it, instead of the predefined `TAPPING_TERM`.
* This is deprecated in favor of the Per Key Tapping Term functionality, as outlined [here](custom_quantum_functions.md#Custom_Tapping_Term). You'd want to check for the specific `TD()` macro that you want to use (such as `TD(TD_ESC_CAPS)`) instead of using this specific Tap Dance function.


The first option is enough for a lot of cases, that just want dual roles. For example, `ACTION_TAP_DANCE_DOUBLE(KC_SPC, KC_ENT)` will result in `Space` being sent on single-tap, `Enter` otherwise.

Expand Down
6 changes: 3 additions & 3 deletions keyboards/converter/usb_usb/keymaps/narze/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,17 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {

// 1. Hold for LGUI, tap for Underscore
case GUI_UNDS:
perform_space_cadet(record, KC_LGUI, KC_LSFT, KC_MINS);
perform_space_cadet(record, keycode, KC_LGUI, KC_LSFT, KC_MINS);
return false;

// 2. Hold for LSHIFT, tap for Parens open
case LSFT_LPRN:
perform_space_cadet(record, KC_LSFT, KC_LSFT, KC_9);
perform_space_cadet(record, keycode, KC_LSFT, KC_LSFT, KC_9);
return false;

// 3. Hold for RSHIFT, tap for Parens close
case RSFT_RPRN:
perform_space_cadet(record, KC_RSFT, KC_RSFT, KC_0);
perform_space_cadet(record, keycode, KC_RSFT, KC_RSFT, KC_0);
return false;

default:
Expand Down
6 changes: 3 additions & 3 deletions keyboards/ergodox_infinity/keymaps/narze/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -635,17 +635,17 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {

// 1. Hold for LGUI, tap for Underscore
case GUI_UNDS:
perform_space_cadet(record, KC_LGUI, KC_LSFT, KC_MINS);
perform_space_cadet(record, keycode, KC_LGUI, KC_LSFT, KC_MINS);
return false;

// 2. Hold for LSHIFT, tap for Parens open
case LSFT_LPRN:
perform_space_cadet(record, KC_LSFT, KC_LSFT, KC_9);
perform_space_cadet(record, keycode, KC_LSFT, KC_LSFT, KC_9);
return false;

// 3. Hold for RSHIFT, tap for Parens close
case RSFT_RPRN:
perform_space_cadet(record, KC_RSFT, KC_RSFT, KC_0);
perform_space_cadet(record, keycode, KC_RSFT, KC_RSFT, KC_0);
return false;

}
Expand Down
4 changes: 2 additions & 2 deletions keyboards/planck/keymaps/narze/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,12 +330,12 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {

// 1. Hold for LGUI, tap for Underscore
case GUI_UNDS:
perform_space_cadet(record, KC_LGUI, KC_LSFT, KC_MINS);
perform_space_cadet(record, keycode, KC_LGUI, KC_LSFT, KC_MINS);
return false;

// 2. Hold for LSHIFT, tap for Parens open
case LSFT_LPRN:
perform_space_cadet(record, KC_LSFT, KC_LSFT, KC_9);
perform_space_cadet(record, keycode, KC_LSFT, KC_LSFT, KC_9);
return false;

default:
Expand Down
22 changes: 10 additions & 12 deletions quantum/process_keycode/process_space_cadet.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "process_space_cadet.h"
#include "action_tapping.h"

#ifndef TAPPING_TERM
# define TAPPING_TERM 200
#endif

// ********** OBSOLETE DEFINES, STOP USING! (pls?) **********
// Shift / paren setup
Expand Down Expand Up @@ -85,7 +83,7 @@ static uint16_t sc_timer = 0;
static uint8_t sc_mods = 0;
#endif

void perform_space_cadet(keyrecord_t *record, uint8_t holdMod, uint8_t tapMod, uint8_t keycode) {
void perform_space_cadet(keyrecord_t *record, uint16_t sc_keycode, uint8_t holdMod, uint8_t tapMod, uint8_t keycode) {
if (record->event.pressed) {
sc_last = holdMod;
sc_timer = timer_read();
Expand All @@ -96,7 +94,7 @@ void perform_space_cadet(keyrecord_t *record, uint8_t holdMod, uint8_t tapMod, u
register_mods(MOD_BIT(holdMod));
}
} else {
if (sc_last == holdMod && timer_elapsed(sc_timer) < TAPPING_TERM) {
if (sc_last == holdMod && timer_elapsed(sc_timer) < get_tapping_term(sc_keycode, record)) {
if (holdMod != tapMod) {
if (IS_MOD(holdMod)) {
unregister_mods(MOD_BIT(holdMod));
Expand Down Expand Up @@ -126,31 +124,31 @@ void perform_space_cadet(keyrecord_t *record, uint8_t holdMod, uint8_t tapMod, u
bool process_space_cadet(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case KC_LSPO: {
perform_space_cadet(record, LSPO_KEYS);
perform_space_cadet(record, keycode, LSPO_KEYS);
return false;
}
case KC_RSPC: {
perform_space_cadet(record, RSPC_KEYS);
perform_space_cadet(record, keycode, RSPC_KEYS);
return false;
}
case KC_LCPO: {
perform_space_cadet(record, LCPO_KEYS);
perform_space_cadet(record, keycode, LCPO_KEYS);
return false;
}
case KC_RCPC: {
perform_space_cadet(record, RCPC_KEYS);
perform_space_cadet(record, keycode, RCPC_KEYS);
return false;
}
case KC_LAPO: {
perform_space_cadet(record, LAPO_KEYS);
perform_space_cadet(record, keycode, LAPO_KEYS);
return false;
}
case KC_RAPC: {
perform_space_cadet(record, RAPC_KEYS);
perform_space_cadet(record, keycode, RAPC_KEYS);
return false;
}
case KC_SFTENT: {
perform_space_cadet(record, SFTENT_KEYS);
perform_space_cadet(record, keycode, SFTENT_KEYS);
return false;
}
default: {
Expand Down
2 changes: 1 addition & 1 deletion quantum/process_keycode/process_space_cadet.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@

#include "quantum.h"

void perform_space_cadet(keyrecord_t *record, uint8_t holdMod, uint8_t tapMod, uint8_t keycode);
void perform_space_cadet(keyrecord_t *record, uint16_t sc_keycode, uint8_t holdMod, uint8_t tapMod, uint8_t keycode);
bool process_space_cadet(uint16_t keycode, keyrecord_t *record);
6 changes: 1 addition & 5 deletions quantum/process_keycode/process_tap_dance.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
#include "quantum.h"
#include "action_tapping.h"

#ifndef TAPPING_TERM
# define TAPPING_TERM 200
#endif

#ifndef NO_ACTION_ONESHOT
uint8_t get_oneshot_mods(void);
#endif
Expand Down Expand Up @@ -171,7 +167,7 @@ void matrix_scan_tap_dance() {
if (action->custom_tapping_term > 0) {
tap_user_defined = action->custom_tapping_term;
} else {
tap_user_defined = TAPPING_TERM;
tap_user_defined = get_tapping_term(action->state.keycode, NULL);
}
if (action->state.count && timer_elapsed(action->state.timer) > tap_user_defined) {
process_tap_dance_action_on_dance_finished(action);
Expand Down