diff options
author | Gergely Nagy <algernon@madhouse-project.org> | 2017-08-02 07:49:06 +0200 |
---|---|---|
committer | Jack Humbert <jack.humb@gmail.com> | 2017-08-02 16:06:16 -0400 |
commit | d28b2c395b66d24eb15bacedb8b84c8a3828ac57 (patch) | |
tree | b8dc14f4a9716f24a255d548da4fdde1fa44c077 /quantum/process_keycode/process_tap_dance.c | |
parent | bb30ff5f71f34e638ffc0ac58b99c75c9214fe7b (diff) | |
download | firmware-d28b2c395b66d24eb15bacedb8b84c8a3828ac57.tar.gz firmware-d28b2c395b66d24eb15bacedb8b84c8a3828ac57.tar.bz2 firmware-d28b2c395b66d24eb15bacedb8b84c8a3828ac57.zip |
tap-dance: key + layer helper
This adds the `ACTION_TAP_DANCE_DUAL_ROLE` helper, which makes it easy to have
keys that act as a key on the first tap, and as a layer toggle on the second.
Fixes #1532, reported by @Ptomerty.
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
Diffstat (limited to 'quantum/process_keycode/process_tap_dance.c')
-rw-r--r-- | quantum/process_keycode/process_tap_dance.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/quantum/process_keycode/process_tap_dance.c b/quantum/process_keycode/process_tap_dance.c index 4fd45810b..00870c4e7 100644 --- a/quantum/process_keycode/process_tap_dance.c +++ b/quantum/process_keycode/process_tap_dance.c @@ -41,6 +41,24 @@ void qk_tap_dance_pair_reset (qk_tap_dance_state_t *state, void *user_data) { } } +void qk_tap_dance_dual_role_finished (qk_tap_dance_state_t *state, void *user_data) { + qk_tap_dance_dual_role_t *pair = (qk_tap_dance_dual_role_t *)user_data; + + if (state->count == 1) { + register_code16 (pair->kc); + } else if (state->count == 2) { + layer_invert (pair->layer); + } +} + +void qk_tap_dance_dual_role_reset (qk_tap_dance_state_t *state, void *user_data) { + qk_tap_dance_dual_role_t *pair = (qk_tap_dance_dual_role_t *)user_data; + + if (state->count == 1) { + unregister_code16 (pair->kc); + } +} + static inline void _process_tap_dance_action_fn (qk_tap_dance_state_t *state, void *user_data, qk_tap_dance_user_fn_t fn) |