diff options
| -rw-r--r-- | docs/feature_tap_dance.md | 2 | ||||
| -rw-r--r-- | quantum/process_keycode/process_tap_dance.c | 6 | ||||
| -rw-r--r-- | quantum/process_keycode/process_tap_dance.h | 4 | ||||
| -rw-r--r-- | quantum/quantum_keycodes.h | 4 | ||||
| -rw-r--r-- | tests/tap_dance/examples.c | 2 |
5 files changed, 11 insertions, 7 deletions
diff --git a/docs/feature_tap_dance.md b/docs/feature_tap_dance.md index 42ea233962..bb1c2c8034 100644 --- a/docs/feature_tap_dance.md +++ b/docs/feature_tap_dance.md | |||
| @@ -173,7 +173,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |||
| 173 | 173 | ||
| 174 | switch (keycode) { | 174 | switch (keycode) { |
| 175 | case TD(CT_CLN): // list all tap dance keycodes with tap-hold configurations | 175 | case TD(CT_CLN): // list all tap dance keycodes with tap-hold configurations |
| 176 | action = &tap_dance_actions[TD_INDEX(keycode)]; | 176 | action = &tap_dance_actions[QK_TAP_DANCE_GET_INDEX(keycode)]; |
| 177 | if (!record->event.pressed && action->state.count && !action->state.finished) { | 177 | if (!record->event.pressed && action->state.count && !action->state.finished) { |
| 178 | tap_dance_tap_hold_t *tap_hold = (tap_dance_tap_hold_t *)action->user_data; | 178 | tap_dance_tap_hold_t *tap_hold = (tap_dance_tap_hold_t *)action->user_data; |
| 179 | tap_code16(tap_hold->tap); | 179 | tap_code16(tap_hold->tap); |
diff --git a/quantum/process_keycode/process_tap_dance.c b/quantum/process_keycode/process_tap_dance.c index b8a8d32f35..ce3b8fc81f 100644 --- a/quantum/process_keycode/process_tap_dance.c +++ b/quantum/process_keycode/process_tap_dance.c | |||
| @@ -133,7 +133,7 @@ bool preprocess_tap_dance(uint16_t keycode, keyrecord_t *record) { | |||
| 133 | 133 | ||
| 134 | if (!active_td || keycode == active_td) return false; | 134 | if (!active_td || keycode == active_td) return false; |
| 135 | 135 | ||
| 136 | action = &tap_dance_actions[TD_INDEX(active_td)]; | 136 | action = &tap_dance_actions[QK_TAP_DANCE_GET_INDEX(active_td)]; |
| 137 | action->state.interrupted = true; | 137 | action->state.interrupted = true; |
| 138 | action->state.interrupting_keycode = keycode; | 138 | action->state.interrupting_keycode = keycode; |
| 139 | process_tap_dance_action_on_dance_finished(action); | 139 | process_tap_dance_action_on_dance_finished(action); |
| @@ -154,7 +154,7 @@ bool process_tap_dance(uint16_t keycode, keyrecord_t *record) { | |||
| 154 | 154 | ||
| 155 | switch (keycode) { | 155 | switch (keycode) { |
| 156 | case QK_TAP_DANCE ... QK_TAP_DANCE_MAX: | 156 | case QK_TAP_DANCE ... QK_TAP_DANCE_MAX: |
| 157 | action = &tap_dance_actions[TD_INDEX(keycode)]; | 157 | action = &tap_dance_actions[QK_TAP_DANCE_GET_INDEX(keycode)]; |
| 158 | 158 | ||
| 159 | action->state.pressed = record->event.pressed; | 159 | action->state.pressed = record->event.pressed; |
| 160 | if (record->event.pressed) { | 160 | if (record->event.pressed) { |
| @@ -182,7 +182,7 @@ void tap_dance_task(void) { | |||
| 182 | 182 | ||
| 183 | if (!active_td || timer_elapsed(last_tap_time) <= GET_TAPPING_TERM(active_td, &(keyrecord_t){})) return; | 183 | if (!active_td || timer_elapsed(last_tap_time) <= GET_TAPPING_TERM(active_td, &(keyrecord_t){})) return; |
| 184 | 184 | ||
| 185 | action = &tap_dance_actions[TD_INDEX(active_td)]; | 185 | action = &tap_dance_actions[QK_TAP_DANCE_GET_INDEX(active_td)]; |
| 186 | if (!action->state.interrupted) { | 186 | if (!action->state.interrupted) { |
| 187 | process_tap_dance_action_on_dance_finished(action); | 187 | process_tap_dance_action_on_dance_finished(action); |
| 188 | } | 188 | } |
diff --git a/quantum/process_keycode/process_tap_dance.h b/quantum/process_keycode/process_tap_dance.h index 2b114dabd3..c0137c14a3 100644 --- a/quantum/process_keycode/process_tap_dance.h +++ b/quantum/process_keycode/process_tap_dance.h | |||
| @@ -19,6 +19,7 @@ | |||
| 19 | #include <stdint.h> | 19 | #include <stdint.h> |
| 20 | #include <stdbool.h> | 20 | #include <stdbool.h> |
| 21 | #include "action.h" | 21 | #include "action.h" |
| 22 | #include "quantum_keycodes.h" | ||
| 22 | 23 | ||
| 23 | typedef struct { | 24 | typedef struct { |
| 24 | uint16_t interrupting_keycode; | 25 | uint16_t interrupting_keycode; |
| @@ -74,8 +75,7 @@ typedef struct { | |||
| 74 | #define ACTION_TAP_DANCE_FN_ADVANCED_WITH_RELEASE(user_fn_on_each_tap, user_fn_on_each_release, user_fn_on_dance_finished, user_fn_on_dance_reset) \ | 75 | #define ACTION_TAP_DANCE_FN_ADVANCED_WITH_RELEASE(user_fn_on_each_tap, user_fn_on_each_release, user_fn_on_dance_finished, user_fn_on_dance_reset) \ |
| 75 | { .fn = {user_fn_on_each_tap, user_fn_on_dance_finished, user_fn_on_dance_reset, user_fn_on_each_release}, .user_data = NULL, } | 76 | { .fn = {user_fn_on_each_tap, user_fn_on_dance_finished, user_fn_on_dance_reset, user_fn_on_each_release}, .user_data = NULL, } |
| 76 | 77 | ||
| 77 | #define TD(n) (QK_TAP_DANCE | TD_INDEX(n)) | 78 | #define TD_INDEX(code) QK_TAP_DANCE_GET_INDEX(code) |
| 78 | #define TD_INDEX(code) ((code)&0xFF) | ||
| 79 | #define TAP_DANCE_KEYCODE(state) TD(((tap_dance_action_t *)state) - tap_dance_actions) | 79 | #define TAP_DANCE_KEYCODE(state) TD(((tap_dance_action_t *)state) - tap_dance_actions) |
| 80 | 80 | ||
| 81 | extern tap_dance_action_t tap_dance_actions[]; | 81 | extern tap_dance_action_t tap_dance_actions[]; |
diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index d3249bd455..882e1d07ae 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h | |||
| @@ -190,6 +190,10 @@ | |||
| 190 | #define SH_T(kc) (QK_SWAP_HANDS | ((kc)&0xFF)) | 190 | #define SH_T(kc) (QK_SWAP_HANDS | ((kc)&0xFF)) |
| 191 | #define QK_SWAP_HANDS_GET_TAP_KEYCODE(kc) ((kc)&0xFF) | 191 | #define QK_SWAP_HANDS_GET_TAP_KEYCODE(kc) ((kc)&0xFF) |
| 192 | 192 | ||
| 193 | // Tap dance | ||
| 194 | #define TD(i) (QK_TAP_DANCE | ((i)&0xFF)) | ||
| 195 | #define QK_TAP_DANCE_GET_INDEX(kc) ((kc)&0xFF) | ||
| 196 | |||
| 193 | // MIDI aliases | 197 | // MIDI aliases |
| 194 | #define MIDI_TONE_MIN QK_MIDI_NOTE_C_0 | 198 | #define MIDI_TONE_MIN QK_MIDI_NOTE_C_0 |
| 195 | #define MIDI_TONE_MAX QK_MIDI_NOTE_B_5 | 199 | #define MIDI_TONE_MAX QK_MIDI_NOTE_B_5 |
diff --git a/tests/tap_dance/examples.c b/tests/tap_dance/examples.c index 13086bbb4b..5377b397d3 100644 --- a/tests/tap_dance/examples.c +++ b/tests/tap_dance/examples.c | |||
| @@ -83,7 +83,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |||
| 83 | 83 | ||
| 84 | switch (keycode) { | 84 | switch (keycode) { |
| 85 | case TD(CT_CLN): | 85 | case TD(CT_CLN): |
| 86 | action = &tap_dance_actions[TD_INDEX(keycode)]; | 86 | action = &tap_dance_actions[QK_TAP_DANCE_GET_INDEX(keycode)]; |
| 87 | if (!record->event.pressed && action->state.count && !action->state.finished) { | 87 | if (!record->event.pressed && action->state.count && !action->state.finished) { |
| 88 | tap_dance_tap_hold_t *tap_hold = (tap_dance_tap_hold_t *)action->user_data; | 88 | tap_dance_tap_hold_t *tap_hold = (tap_dance_tap_hold_t *)action->user_data; |
| 89 | tap_code16(tap_hold->tap); | 89 | tap_code16(tap_hold->tap); |
