diff options
author | 2016-06-30 12:38:48 -0400 | |
---|---|---|
committer | 2016-06-30 12:38:48 -0400 | |
commit | 44a5f7630f18b40b36270d49449a43cd42b802f0 (patch) | |
tree | 9d29ee26496a458bf161eeb59dab5e12d85cb3aa /quantum/process_keycode/process_tap_dance.h | |
parent | c9f509f0168f6d11e743a9d2e37964c05e45672b (diff) | |
parent | a8b55f8c858933a0f7641f7bf2dede640235aa70 (diff) | |
download | qmk_firmware-44a5f7630f18b40b36270d49449a43cd42b802f0.tar.gz |
Merge branch 'master' of https://github.com/jackhumbert/qmk_firmware
Diffstat (limited to 'quantum/process_keycode/process_tap_dance.h')
-rw-r--r-- | quantum/process_keycode/process_tap_dance.h | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/quantum/process_keycode/process_tap_dance.h b/quantum/process_keycode/process_tap_dance.h new file mode 100644 index 000000000..b9d7c7fcf --- /dev/null +++ b/quantum/process_keycode/process_tap_dance.h @@ -0,0 +1,62 @@ +#ifndef PROCESS_TAP_DANCE_H +#define PROCESS_TAP_DANCE_H + +#ifdef TAP_DANCE_ENABLE + +#include <stdbool.h> +#include <inttypes.h> + +typedef struct +{ + uint8_t count; + uint16_t keycode; + uint16_t timer; +} qk_tap_dance_state_t; + +#define TD(n) (QK_TAP_DANCE + n) + +typedef enum +{ + QK_TAP_DANCE_TYPE_PAIR, + QK_TAP_DANCE_TYPE_FN, +} qk_tap_dance_type_t; + +typedef void (*qk_tap_dance_user_fn_t) (qk_tap_dance_state_t *state); + +typedef struct +{ + qk_tap_dance_type_t type; + union { + struct { + uint16_t kc1; + uint16_t kc2; + } pair; + qk_tap_dance_user_fn_t fn; + }; +} qk_tap_dance_action_t; + +#define ACTION_TAP_DANCE_DOUBLE(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 \ + } + +extern const qk_tap_dance_action_t tap_dance_actions[]; + +/* To be used internally */ + +bool process_tap_dance(uint16_t keycode, keyrecord_t *record); +void matrix_scan_tap_dance (void); +void reset_tap_dance (qk_tap_dance_state_t *state); + +#else + +#define TD(n) KC_NO + +#endif + +#endif |