summaryrefslogtreecommitdiff
path: root/quantum/process_keycode/process_tap_dance.h
diff options
context:
space:
mode:
authorPavlos Vinieratos <pvinis@gmail.com>2016-07-13 16:47:45 +0200
committerPavlos Vinieratos <pvinis@gmail.com>2016-07-16 00:04:12 +0200
commitf3b56701ed7e6c622dc48e429780124ba5fde172 (patch)
treefa9ae933e8a5b67e17d7f41cf7bbc32c4e5f079e /quantum/process_keycode/process_tap_dance.h
parent1a7e954f9fc4d250ba1ae46e3bfc168aca2b5cce (diff)
downloadqmk_firmware-f3b56701ed7e6c622dc48e429780124ba5fde172.tar.gz
qmk_firmware-f3b56701ed7e6c622dc48e429780124ba5fde172.zip
add an `anyway` and a `reset` callback
when using tap dance, we have the `regular` callback that is called on the last tap. this commit adds an `anyway` callback that is called on every tap, and a `reset` callback that is called on reset of the tap dance taps.
Diffstat (limited to 'quantum/process_keycode/process_tap_dance.h')
-rw-r--r--quantum/process_keycode/process_tap_dance.h28
1 files changed, 24 insertions, 4 deletions
diff --git a/quantum/process_keycode/process_tap_dance.h b/quantum/process_keycode/process_tap_dance.h
index b9d7c7fcf4..bf925df0f6 100644
--- a/quantum/process_keycode/process_tap_dance.h
+++ b/quantum/process_keycode/process_tap_dance.h
@@ -22,6 +22,7 @@ typedef enum
} qk_tap_dance_type_t;
typedef void (*qk_tap_dance_user_fn_t) (qk_tap_dance_state_t *state);
+typedef void (*qk_tap_dance_user_fn_reset_t) (void);
typedef struct
{
@@ -31,18 +32,37 @@ typedef struct
uint16_t kc1;
uint16_t kc2;
} pair;
- qk_tap_dance_user_fn_t fn;
+ struct {
+ qk_tap_dance_user_fn_t regular;
+ qk_tap_dance_user_fn_t anyway;
+ qk_tap_dance_user_fn_reset_t reset;
+ } fn;
};
} qk_tap_dance_action_t;
#define ACTION_TAP_DANCE_DOUBLE(kc1, kc2) { \
- .type = QK_TAP_DANCE_TYPE_PAIR, \
- .pair = { kc1, kc2 } \
+ .type = QK_TAP_DANCE_TYPE_PAIR, \
+ .pair = { kc1, kc2 } \
}
#define ACTION_TAP_DANCE_FN(user_fn) { \
.type = QK_TAP_DANCE_TYPE_FN, \
- .fn = user_fn \
+ .fn = { user_fn, NULL, NULL } \
+ }
+
+#define ACTION_TAP_DANCE_FN_ANYWAY(user_fn, user_fn_anyway) { \
+ .type = QK_TAP_DANCE_TYPE_FN, \
+ .fn = { user_fn, user_fn_anyway, NULL } \
+ }
+
+#define ACTION_TAP_DANCE_FN_RESET(user_fn, user_fn_reset) { \
+ .type = QK_TAP_DANCE_TYPE_FN, \
+ .fn = { user_fn, NULL, user_fn_reset } \
+ }
+
+#define ACTION_TAP_DANCE_FN_ANYWAY_RESET(user_fn, user_fn_anyway, user_fn_reset) { \
+ .type = QK_TAP_DANCE_TYPE_FN, \
+ .fn = { user_fn, user_fn_anyway, user_fn_reset } \
}
extern const qk_tap_dance_action_t tap_dance_actions[];