aboutsummaryrefslogtreecommitdiffstats
path: root/quantum/process_keycode/process_tap_dance.h
diff options
context:
space:
mode:
authorGergely Nagy <algernon@madhouse-project.org>2017-08-02 07:49:06 +0200
committerJack Humbert <jack.humb@gmail.com>2017-08-02 16:06:16 -0400
commitd28b2c395b66d24eb15bacedb8b84c8a3828ac57 (patch)
treeb8dc14f4a9716f24a255d548da4fdde1fa44c077 /quantum/process_keycode/process_tap_dance.h
parentbb30ff5f71f34e638ffc0ac58b99c75c9214fe7b (diff)
downloadfirmware-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.h')
-rw-r--r--quantum/process_keycode/process_tap_dance.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/quantum/process_keycode/process_tap_dance.h b/quantum/process_keycode/process_tap_dance.h
index f42c154a0..37a27c536 100644
--- a/quantum/process_keycode/process_tap_dance.h
+++ b/quantum/process_keycode/process_tap_dance.h
@@ -54,11 +54,22 @@ typedef struct
uint16_t kc2;
} qk_tap_dance_pair_t;
+typedef struct
+{
+ uint16_t kc;
+ uint8_t layer;
+} qk_tap_dance_dual_role_t;
+
#define ACTION_TAP_DANCE_DOUBLE(kc1, kc2) { \
.fn = { NULL, qk_tap_dance_pair_finished, qk_tap_dance_pair_reset }, \
.user_data = (void *)&((qk_tap_dance_pair_t) { kc1, kc2 }), \
}
+#define ACTION_TAP_DANCE_DUAL_ROLE(kc, layer) { \
+ .fn = { NULL, qk_tap_dance_dual_role_finished, qk_tap_dance_dual_role_reset }, \
+ .user_data = (void *)&((qk_tap_dance_dual_role_t) { kc, layer }), \
+ }
+
#define ACTION_TAP_DANCE_FN(user_fn) { \
.fn = { NULL, user_fn, NULL }, \
.user_data = NULL, \
@@ -86,6 +97,9 @@ void reset_tap_dance (qk_tap_dance_state_t *state);
void qk_tap_dance_pair_finished (qk_tap_dance_state_t *state, void *user_data);
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);
+void qk_tap_dance_dual_role_reset (qk_tap_dance_state_t *state, void *user_data);
+
#else
#define TD(n) KC_NO