diff options
| author | Stephen Ostermiller <stephenostermiller@users.noreply.github.com> | 2025-11-23 06:32:36 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-23 22:32:36 +1100 |
| commit | 1a954e8da5dcbd81eeccb9d6ac41b6eda64d7b85 (patch) | |
| tree | 4f09599d467a9c9bbb1dde722511139fa965ff03 /tests/tap_dance | |
| 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 'tests/tap_dance')
| -rw-r--r-- | tests/tap_dance/examples.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/tests/tap_dance/examples.c b/tests/tap_dance/examples.c index 4b6bdb2090..6aaf008232 100644 --- a/tests/tap_dance/examples.c +++ b/tests/tap_dance/examples.c | |||
| @@ -81,11 +81,13 @@ typedef struct { | |||
| 81 | 81 | ||
| 82 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | 82 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { |
| 83 | tap_dance_action_t *action; | 83 | tap_dance_action_t *action; |
| 84 | tap_dance_state_t* state; | ||
| 84 | 85 | ||
| 85 | switch (keycode) { | 86 | switch (keycode) { |
| 86 | case TD(CT_CLN): | 87 | case TD(CT_CLN): |
| 87 | action = tap_dance_get(QK_TAP_DANCE_GET_INDEX(keycode)); | 88 | action = tap_dance_get(QK_TAP_DANCE_GET_INDEX(keycode)); |
| 88 | if (!record->event.pressed && action->state.count && !action->state.finished) { | 89 | state = tap_dance_get_state(QK_TAP_DANCE_GET_INDEX(keycode)); |
| 90 | if (!record->event.pressed && state != NULL && state->count && !state->finished) { | ||
| 89 | tap_dance_tap_hold_t *tap_hold = (tap_dance_tap_hold_t *)action->user_data; | 91 | tap_dance_tap_hold_t *tap_hold = (tap_dance_tap_hold_t *)action->user_data; |
| 90 | tap_code16(tap_hold->tap); | 92 | tap_code16(tap_hold->tap); |
| 91 | } | 93 | } |
