With this change, tap dance will now store the pressed state of the
tap-dance key, and allow one to make an action sooner, while the key is
still held, and only unregister when the key is released.
The registration must happen in the `on_dance_finished` callback, while
unregistering goes to `on_reset`. The surrounding code makes sure not to
call either multiple times.
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
process_tap_dance_action_on_each_tap (qk_tap_dance_state.keycode);
if (qk_tap_dance_state.keycode && qk_tap_dance_state.keycode != keycode) {
process_tap_dance_action_on_dance_finished (qk_tap_dance_state.keycode);
process_tap_dance_action_on_each_tap (qk_tap_dance_state.keycode);
if (qk_tap_dance_state.keycode && qk_tap_dance_state.keycode != keycode) {
process_tap_dance_action_on_dance_finished (qk_tap_dance_state.keycode);
+ } else if (qk_tap_dance_state.active && qk_tap_dance_state.pressed) {
+ reset_tap_dance (&qk_tap_dance_state);
+ qk_tap_dance_state.active = true;
+ qk_tap_dance_state.pressed = record->event.pressed;
if (record->event.pressed) {
qk_tap_dance_state.keycode = keycode;
qk_tap_dance_state.timer = timer_read ();
if (record->event.pressed) {
qk_tap_dance_state.keycode = keycode;
qk_tap_dance_state.timer = timer_read ();
process_tap_dance_action_on_each_tap (qk_tap_dance_state.keycode);
process_tap_dance_action_on_dance_finished (qk_tap_dance_state.keycode);
reset_tap_dance (&qk_tap_dance_state);
process_tap_dance_action_on_each_tap (qk_tap_dance_state.keycode);
process_tap_dance_action_on_dance_finished (qk_tap_dance_state.keycode);
reset_tap_dance (&qk_tap_dance_state);
+ qk_tap_dance_state.active = false;
}
void matrix_scan_tap_dance () {
}
void matrix_scan_tap_dance () {
- if (qk_tap_dance_state.keycode && timer_elapsed (qk_tap_dance_state.timer) > TAPPING_TERM) {
+ if (qk_tap_dance_state.active && timer_elapsed (qk_tap_dance_state.timer) > TAPPING_TERM) {
// if we are here, the tap dance was timed out
process_tap_dance_action_on_dance_finished (qk_tap_dance_state.keycode);
reset_tap_dance (&qk_tap_dance_state);
// if we are here, the tap dance was timed out
process_tap_dance_action_on_dance_finished (qk_tap_dance_state.keycode);
reset_tap_dance (&qk_tap_dance_state);
uint16_t idx = state->keycode - QK_TAP_DANCE;
qk_tap_dance_action_t action;
uint16_t idx = state->keycode - QK_TAP_DANCE;
qk_tap_dance_action_t action;
+ if (state->pressed)
+ return;
+
action = tap_dance_actions[idx];
switch (action.type) {
case QK_TAP_DANCE_TYPE_FN:
action = tap_dance_actions[idx];
switch (action.type) {
case QK_TAP_DANCE_TYPE_FN:
state->keycode = 0;
state->count = 0;
state->keycode = 0;
state->count = 0;
uint8_t count;
uint16_t keycode;
uint16_t timer;
uint8_t count;
uint16_t keycode;
uint16_t timer;
+ bool active:1;
+ bool pressed:1;
} qk_tap_dance_state_t;
#define TD(n) (QK_TAP_DANCE + n)
} qk_tap_dance_state_t;
#define TD(n) (QK_TAP_DANCE + n)