diff options
author | timovp <[email protected]> | 2025-06-26 09:19:42 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2025-06-26 08:19:42 +0100 |
commit | 5354ec57915d2a17f977583ff21ee8bfe3bf6747 (patch) | |
tree | 38707cf04ab227c73fee970646ca870ba3c1e863 /docs/features | |
parent | 235d18f360dbb5ab0585c734050d5b2b332fd592 (diff) | |
download | qmk_firmware-5354ec57915d2a17f977583ff21ee8bfe3bf6747.tar.gz qmk_firmware-5354ec57915d2a17f977583ff21ee8bfe3bf6747.zip |
fix order of code in tapdance example3 (#25410)
Diffstat (limited to 'docs/features')
-rw-r--r-- | docs/features/tap_dance.md | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/docs/features/tap_dance.md b/docs/features/tap_dance.md index 8fdd83c18d..d533e41aaa 100644 --- a/docs/features/tap_dance.md +++ b/docs/features/tap_dance.md @@ -170,20 +170,6 @@ typedef struct { uint16_t held; } tap_dance_tap_hold_t; -bool process_record_user(uint16_t keycode, keyrecord_t *record) { - tap_dance_action_t *action; - - switch (keycode) { - case TD(CT_CLN): // list all tap dance keycodes with tap-hold configurations - action = &tap_dance_actions[QK_TAP_DANCE_GET_INDEX(keycode)]; - if (!record->event.pressed && action->state.count && !action->state.finished) { - tap_dance_tap_hold_t *tap_hold = (tap_dance_tap_hold_t *)action->user_data; - tap_code16(tap_hold->tap); - } - } - return true; -} - void tap_dance_tap_hold_finished(tap_dance_state_t *state, void *user_data) { tap_dance_tap_hold_t *tap_hold = (tap_dance_tap_hold_t *)user_data; @@ -211,12 +197,29 @@ void tap_dance_tap_hold_reset(tap_dance_state_t *state, void *user_data) { } } -#define ACTION_TAP_DANCE_TAP_HOLD(tap, hold) \ - { .fn = {NULL, tap_dance_tap_hold_finished, tap_dance_tap_hold_reset}, .user_data = (void *)&((tap_dance_tap_hold_t){tap, hold, 0}), } +#define ACTION_TAP_DANCE_TAP_HOLD(tap, hold) \ + { \ + .fn = {NULL, tap_dance_tap_hold_finished, tap_dance_tap_hold_reset}, \ + .user_data = (void *)&((tap_dance_tap_hold_t){tap, hold, 0}), \ + } tap_dance_action_t tap_dance_actions[] = { [CT_CLN] = ACTION_TAP_DANCE_TAP_HOLD(KC_COLN, KC_SCLN), }; + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + tap_dance_action_t *action; + + switch (keycode) { + case TD(CT_CLN): // list all tap dance keycodes with tap-hold configurations + action = &tap_dance_actions[QK_TAP_DANCE_GET_INDEX(keycode)]; + if (!record->event.pressed && action->state.count && !action->state.finished) { + tap_dance_tap_hold_t *tap_hold = (tap_dance_tap_hold_t *)action->user_data; + tap_code16(tap_hold->tap); + } + } + return true; +} ``` #### Example 4: 'Quad Function Tap-Dance' {#example-4} |