#include QMK_KEYBOARD_H #include "quad_tapdance.h" #include "tap_hold_dance.h" void tap_hold_dance_released(tap_dance_state_t *state, void *user_data) { if (state->finished || state->interrupted) return; tap_hold_dance_t *tap_hold_dance = (tap_hold_dance_t *)user_data; tap_code(tap_hold_dance->tap); } void tap_hold_dance_finished(tap_dance_state_t *state, void *user_data) { tap_hold_dance_t *tap_hold_dance = (tap_hold_dance_t *)user_data; tap_hold_dance->state = cur_dance(state); switch (tap_hold_dance->state) { case TD_SINGLE_HOLD: /* If a key is pressed before the TAPPING_TERM delay, consider a * tap instead of switching to the mod. */ if (state->interrupted) { tap_hold_dance->held = tap_hold_dance->tap; } else { tap_hold_dance->held = tap_hold_dance->hold; } register_code(tap_hold_dance->held); break; case TD_DOUBLE_HOLD: tap_hold_dance->held = tap_hold_dance->tap; register_code(tap_hold_dance->tap); default: break; } } void tap_hold_dance_reset(tap_dance_state_t *state, void *user_data) { tap_hold_dance_t *tap_hold_dance = (tap_hold_dance_t *)user_data; if (tap_hold_dance->state != TD_NONE && tap_hold_dance->held) { unregister_code(tap_hold_dance->held); tap_hold_dance->held = 0; } tap_hold_dance->state = TD_NONE; }