diff options
| author | Stephen Ostermiller | 2025-11-23 12:32:36 +0100 |
|---|---|---|
| committer | GitHub | 2025-11-23 12:32:36 +0100 |
| commit | 1a954e8da5dcbd81eeccb9d6ac41b6eda64d7b85 (patch) | |
| tree | 4f09599d467a9c9bbb1dde722511139fa965ff03 /docs/ChangeLog | |
| parent | c7e17538eea98540dbee71de5d024db99f7786fe (diff) | |
Reduce tap dance memory usage, move state out of data (#25415)
* Use less tap dance memory.
Use dynamically allocated sparse array for tap dance state, dynamically allocate tap dance state when needed and free it when the tap dance is done.
* new approach
* Use null, check for null
* Reformat with docker
* Use uint8 with idx rather than uint16 with keycode in state
* fix accidental change
* reformat
* Add null check
* add documentation tip suggested by tzarc
* Only allow tap dance state allocation on key down, not on key up
Co-authored-by: Sergey Vlasov <sigprof@gmail.com>
* Only allow tap dance allocation on key down, not on key up
Co-authored-by: Sergey Vlasov <sigprof@gmail.com>
* add user action required section
---------
Co-authored-by: Sergey Vlasov <sigprof@gmail.com>
Diffstat (limited to 'docs/ChangeLog')
| -rw-r--r-- | docs/ChangeLog/20250831/pr25415.md | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/docs/ChangeLog/20250831/pr25415.md b/docs/ChangeLog/20250831/pr25415.md new file mode 100644 index 0000000000..54eb8c737e --- /dev/null +++ b/docs/ChangeLog/20250831/pr25415.md @@ -0,0 +1,47 @@ +# Tap dance state removed from `tap_dance_action_t` + +The tap dance state has been separated from the action structure. Custom tap dance functions now receive the state as a separate parameter instead of accessing it through `action->state`. + +## User Action Required + +If your keymap uses custom tap dance functions that access the tap dance state, you need to update your code. + + - You can't use `action->state`. Instead you need to call `tap_dance_state_t *tap_dance_get_state(uint8_t tap_dance_idx)` to get the state. + - You now get a pointer to the state, so use `->` notation rather than `.` notation to get fields from it. + +### Before: +```c +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + tap_dance_action_t *action; + + switch (keycode) { + case TD(CT_CLN): + action = tap_dance_get(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; +} +``` + +### After: +```c +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + tap_dance_action_t *action; + tap_dance_state_t* state; + + switch (keycode) { + case TD(CT_CLN): + action = tap_dance_get(QK_TAP_DANCE_GET_INDEX(keycode)); + state = tap_dance_get_state(QK_TAP_DANCE_GET_INDEX(keycode)); + if (!record->event.pressed && state != NULL && state->count && !state->finished) { + tap_dance_tap_hold_t *tap_hold = (tap_dance_tap_hold_t *)action->user_data; + tap_code16(tap_hold->tap); + } + } + return true; +} +``` |