Skip to content

Commit 5354ec5

Browse files
authored
fix order of code in tapdance example3 (#25410)
1 parent 235d18f commit 5354ec5

1 file changed

Lines changed: 19 additions & 16 deletions

File tree

docs/features/tap_dance.md

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -170,20 +170,6 @@ typedef struct {
170170
uint16_t held;
171171
} tap_dance_tap_hold_t;
172172

173-
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
174-
tap_dance_action_t *action;
175-
176-
switch (keycode) {
177-
case TD(CT_CLN): // list all tap dance keycodes with tap-hold configurations
178-
action = &tap_dance_actions[QK_TAP_DANCE_GET_INDEX(keycode)];
179-
if (!record->event.pressed && action->state.count && !action->state.finished) {
180-
tap_dance_tap_hold_t *tap_hold = (tap_dance_tap_hold_t *)action->user_data;
181-
tap_code16(tap_hold->tap);
182-
}
183-
}
184-
return true;
185-
}
186-
187173
void tap_dance_tap_hold_finished(tap_dance_state_t *state, void *user_data) {
188174
tap_dance_tap_hold_t *tap_hold = (tap_dance_tap_hold_t *)user_data;
189175

@@ -211,12 +197,29 @@ void tap_dance_tap_hold_reset(tap_dance_state_t *state, void *user_data) {
211197
}
212198
}
213199

214-
#define ACTION_TAP_DANCE_TAP_HOLD(tap, hold) \
215-
{ .fn = {NULL, tap_dance_tap_hold_finished, tap_dance_tap_hold_reset}, .user_data = (void *)&((tap_dance_tap_hold_t){tap, hold, 0}), }
200+
#define ACTION_TAP_DANCE_TAP_HOLD(tap, hold) \
201+
{ \
202+
.fn = {NULL, tap_dance_tap_hold_finished, tap_dance_tap_hold_reset}, \
203+
.user_data = (void *)&((tap_dance_tap_hold_t){tap, hold, 0}), \
204+
}
216205

217206
tap_dance_action_t tap_dance_actions[] = {
218207
[CT_CLN] = ACTION_TAP_DANCE_TAP_HOLD(KC_COLN, KC_SCLN),
219208
};
209+
210+
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
211+
tap_dance_action_t *action;
212+
213+
switch (keycode) {
214+
case TD(CT_CLN): // list all tap dance keycodes with tap-hold configurations
215+
action = &tap_dance_actions[QK_TAP_DANCE_GET_INDEX(keycode)];
216+
if (!record->event.pressed && action->state.count && !action->state.finished) {
217+
tap_dance_tap_hold_t *tap_hold = (tap_dance_tap_hold_t *)action->user_data;
218+
tap_code16(tap_hold->tap);
219+
}
220+
}
221+
return true;
222+
}
220223
```
221224
222225
#### Example 4: 'Quad Function Tap-Dance' {#example-4}

0 commit comments

Comments
 (0)