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>
This commit is contained in:
parent
c7e17538ee
commit
1a954e8da5
5 changed files with 152 additions and 44 deletions
|
|
@ -28,15 +28,16 @@ typedef struct {
|
|||
#ifndef NO_ACTION_ONESHOT
|
||||
uint8_t oneshot_mods;
|
||||
#endif
|
||||
bool pressed : 1;
|
||||
bool finished : 1;
|
||||
bool interrupted : 1;
|
||||
bool pressed : 1;
|
||||
bool finished : 1;
|
||||
bool interrupted : 1;
|
||||
bool in_use : 1;
|
||||
uint8_t index;
|
||||
} tap_dance_state_t;
|
||||
|
||||
typedef void (*tap_dance_user_fn_t)(tap_dance_state_t *state, void *user_data);
|
||||
|
||||
typedef struct tap_dance_action_t {
|
||||
tap_dance_state_t state;
|
||||
struct {
|
||||
tap_dance_user_fn_t on_each_tap;
|
||||
tap_dance_user_fn_t on_dance_finished;
|
||||
|
|
@ -80,6 +81,8 @@ typedef struct {
|
|||
|
||||
void reset_tap_dance(tap_dance_state_t *state);
|
||||
|
||||
tap_dance_state_t *tap_dance_get_state(uint8_t tap_dance_idx);
|
||||
|
||||
/* To be used internally */
|
||||
|
||||
bool preprocess_tap_dance(uint16_t keycode, keyrecord_t *record);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue