From 42698c7c8b53cbfa92d4466a17c3dd52131855fe Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Wed, 10 Jan 2024 09:45:17 +0100 Subject: QMK: pushed the latest used code --- .../sofle_choc/keymaps/custom/quad_tapdance.c | 46 ++++------------------ 1 file changed, 7 insertions(+), 39 deletions(-) (limited to 'qmk/keyboards/sofle_choc/keymaps/custom/quad_tapdance.c') diff --git a/qmk/keyboards/sofle_choc/keymaps/custom/quad_tapdance.c b/qmk/keyboards/sofle_choc/keymaps/custom/quad_tapdance.c index 9978315..19b1e46 100644 --- a/qmk/keyboards/sofle_choc/keymaps/custom/quad_tapdance.c +++ b/qmk/keyboards/sofle_choc/keymaps/custom/quad_tapdance.c @@ -33,6 +33,12 @@ td_state_t cur_dance(tap_dance_state_t *state) { if (state->count == 1) { + // The function can be called when the delay is over, or because of + // another tap. + // I do not check here if the delay is over, as soon as another tap + // occurs, I check the state of the key and switch in hold mode if the + // key is still pressed. + // if (!state->pressed) return TD_SINGLE_TAP; // Key has not been interrupted, but the key is still held. Means you want to send a 'HOLD'. else return TD_SINGLE_HOLD; @@ -174,44 +180,6 @@ void lshift_reset(tap_dance_state_t *state, void *user_data) { lshift_tap_state.state = TD_NONE; } -// Definition for the key E -// This key can transform into LEFT CONTROL when hold, but can also transform into È when double tapped. -static td_tap_t e_tap_state = { - .is_press_action = true, - .state = TD_NONE -}; - -// Functions that control what our tap dance key does -void e_finished(tap_dance_state_t *state, void *user_data) { - e_tap_state.state = cur_dance(state); - switch (e_tap_state.state) { - // Remove the layer with a single tap, this way I always have a key to remove the - // the layer, without knowing the previous state I had. - case TD_SINGLE_HOLD: register_code(KC_LEFT_CTRL); break; - case TD_DOUBLE_TAP: - register_code(BP_EGRV); break; - case TD_SINGLE_TAP: - register_code(BP_E); break; - break; - default: break; - } -} - -void e_reset(tap_dance_state_t *state, void *user_data) { - switch (e_tap_state.state) { - case TD_SINGLE_HOLD: unregister_code(KC_LEFT_CTRL); break; - case TD_DOUBLE_TAP: - unregister_code(BP_EGRV); break; - case TD_SINGLE_TAP: - unregister_code(BP_E); break; - break; - default: break; - } - e_tap_state.state = TD_NONE; -} - - - // // Declare the tapdance table here. // @@ -221,6 +189,6 @@ tap_dance_action_t tap_dance_actions[] = { [TD_W_CAPSLOCK] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, w_finished, w_reset), [TD_LAYER_SYMB] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, ql_finished, ql_reset), [TD_LSFT] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, lshift_finished, lshift_reset), - [TD_E_EE] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, e_finished, e_reset), + [TD_EE] = ACTION_TAP_DANCE_DOUBLE(BP_COMM, BP_EGRV), }; -- cgit v1.2.3