Merge branch 'tap-dance-release' into vial

This commit is contained in:
Ilya Zhuravlev 2021-10-22 19:57:31 -04:00
commit 52e90179d0
5 changed files with 37 additions and 1 deletions

View file

@ -514,3 +514,33 @@ static void reload_combo(void) {
}
}
#endif
#ifdef VIAL_TAP_DANCE_ENABLE
void process_tap_dance_action_on_dance_finished(qk_tap_dance_action_t *action);
#endif
bool process_record_vial(uint16_t keycode, keyrecord_t *record) {
#ifdef VIAL_TAP_DANCE_ENABLE
/* process releases before tap-dance timeout arrives */
if (!record->event.pressed && keycode >= QK_TAP_DANCE && keycode <= QK_TAP_DANCE_MAX) {
uint16_t idx = keycode - QK_TAP_DANCE;
if (dynamic_keymap_get_tap_dance(idx, &td_entry) != 0)
return true;
qk_tap_dance_action_t *action = &tap_dance_actions[idx];
/* only care about 2 possibilities here
- tap and hold set, everything else unset: process first release early (count == 1)
- double tap set: process second release early (count == 2)
*/
if ((action->state.count == 1 && td_entry.on_tap && td_entry.on_hold && !td_entry.on_double_tap && !td_entry.on_tap_hold)
|| (action->state.count == 2 && td_entry.on_double_tap)) {
action->state.pressed = false;
process_tap_dance_action_on_dance_finished(action);
/* reset_tap_dance() will get called in process_tap_dance() */
}
}
#endif
return true;
}