diff options
author | Pavlos Vinieratos <pvinis@gmail.com> | 2016-07-13 16:47:45 +0200 |
---|---|---|
committer | Pavlos Vinieratos <pvinis@gmail.com> | 2016-07-16 00:04:12 +0200 |
commit | f3b56701ed7e6c622dc48e429780124ba5fde172 (patch) | |
tree | fa9ae933e8a5b67e17d7f41cf7bbc32c4e5f079e /quantum/process_keycode/process_tap_dance.c | |
parent | 1a7e954f9fc4d250ba1ae46e3bfc168aca2b5cce (diff) | |
download | firmware-f3b56701ed7e6c622dc48e429780124ba5fde172.tar.gz firmware-f3b56701ed7e6c622dc48e429780124ba5fde172.tar.bz2 firmware-f3b56701ed7e6c622dc48e429780124ba5fde172.zip |
add an `anyway` and a `reset` callback
when using tap dance, we have the `regular` callback that is called on
the last tap. this commit adds an `anyway` callback that is called on
every tap, and a `reset` callback that is called on reset of the tap
dance taps.
Diffstat (limited to 'quantum/process_keycode/process_tap_dance.c')
-rw-r--r-- | quantum/process_keycode/process_tap_dance.c | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/quantum/process_keycode/process_tap_dance.c b/quantum/process_keycode/process_tap_dance.c index 186889bc2..40fba2a6a 100644 --- a/quantum/process_keycode/process_tap_dance.c +++ b/quantum/process_keycode/process_tap_dance.c @@ -40,7 +40,24 @@ void process_tap_dance_action (uint16_t keycode) action.pair.kc1, action.pair.kc2); break; case QK_TAP_DANCE_TYPE_FN: - _process_tap_dance_action_fn (&qk_tap_dance_state, action.fn); + _process_tap_dance_action_fn (&qk_tap_dance_state, action.fn.regular); + break; + + default: + break; + } +} + +void process_tap_dance_action_anyway (uint16_t keycode) +{ + uint16_t idx = keycode - QK_TAP_DANCE; + qk_tap_dance_action_t action; + + action = tap_dance_actions[idx]; + + switch (action.type) { + case QK_TAP_DANCE_TYPE_FN: + _process_tap_dance_action_fn (&qk_tap_dance_state, action.fn.anyway); break; default: @@ -53,6 +70,7 @@ bool process_tap_dance(uint16_t keycode, keyrecord_t *record) { switch(keycode) { case QK_TAP_DANCE ... QK_TAP_DANCE_MAX: + process_tap_dance_action_anyway (qk_tap_dance_state.keycode); if (qk_tap_dance_state.keycode && qk_tap_dance_state.keycode != keycode) { process_tap_dance_action (qk_tap_dance_state.keycode); } else { @@ -68,6 +86,7 @@ bool process_tap_dance(uint16_t keycode, keyrecord_t *record) { default: if (qk_tap_dance_state.keycode) { + //process_tap_dance_action_anyway (qk_tap_dance_state.keycode); process_tap_dance_action (qk_tap_dance_state.keycode); reset_tap_dance (&qk_tap_dance_state); @@ -87,6 +106,21 @@ void matrix_scan_tap_dance () { } void reset_tap_dance (qk_tap_dance_state_t *state) { + uint16_t idx = state->keycode - QK_TAP_DANCE; + qk_tap_dance_action_t action; + + action = tap_dance_actions[idx]; + switch (action.type) { + case QK_TAP_DANCE_TYPE_FN: + if (action.fn.reset) { + action.fn.reset(); + } + break; + + default: + break; + } + state->keycode = 0; state->count = 0; } |