diff options
| author | Sébastien Dailly <sebastien@dailly.me> | 2026-07-29 08:32:38 +0200 |
|---|---|---|
| committer | Sébastien Dailly <sebastien@dailly.me> | 2026-08-04 15:40:13 +0200 |
| commit | d0f494918c32b391ed0e0feaa69160cccc98f4a6 (patch) | |
| tree | 6da083d6f538866e1783c355d1f4aaf849e1302b /qmk/keyboards/sofle_choc/keymaps/custom/layer_dance.h | |
| parent | 340ddb0390f4b835e6723616a6a9956b206a7433 (diff) | |
QMK: Uses of custom_data in tap_dance instead of duplicating the code
Diffstat (limited to 'qmk/keyboards/sofle_choc/keymaps/custom/layer_dance.h')
| -rw-r--r-- | qmk/keyboards/sofle_choc/keymaps/custom/layer_dance.h | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/qmk/keyboards/sofle_choc/keymaps/custom/layer_dance.h b/qmk/keyboards/sofle_choc/keymaps/custom/layer_dance.h index bdca598..efa1f7a 100644 --- a/qmk/keyboards/sofle_choc/keymaps/custom/layer_dance.h +++ b/qmk/keyboards/sofle_choc/keymaps/custom/layer_dance.h @@ -1,9 +1,23 @@ #pragma once #include QMK_KEYBOARD_H -void keypad_finished(tap_dance_state_t *state, void *user_data); -void keypad_reset(tap_dance_state_t *state, void *user_data); +/** + * State of the tapdance, hold both the tapdance state, and the layer we need + * to activate when the key is activated. + */ +typedef struct { + td_state_t state; + uint8_t layer; +} tap_dance_layer_t; +void tap_dance_layer_finished(tap_dance_state_t *state, void *user_data); +void tap_dance_layer_reset(tap_dance_state_t *state, void *user_data); -void arrow_finished(tap_dance_state_t *state, void *user_data); -void arrow_reset(tap_dance_state_t *state, void *user_data); +/** + * Helper for creating the tap_dance key. + */ +#define ACTION_TAP_DANCE_LAYER(layer) \ + { \ + .fn = {NULL, tap_dance_layer_finished, tap_dance_layer_reset}, \ + .user_data = (void *)&((tap_dance_layer_t){TD_NONE, layer}), \ + } |
