Skip to content

Commit

Permalink
Generalize Tap Dance Layer functions (qmk#6629)
Browse files Browse the repository at this point in the history
* made tapdance dual_role general

* updated original dual_role functionality

* added toggling layer example

* Fix dual role and add alias

* Update docs about new layer tap dances

* Fix up based on feedback
  • Loading branch information
drashna committed Oct 5, 2019
1 parent a5d07e9 commit 23efa97
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion quantum/process_keycode/process_tap_dance.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void qk_tap_dance_dual_role_finished(qk_tap_dance_state_t *state, void *user_dat
if (state->count == 1) {
register_code16(pair->kc);
} else if (state->count == 2) {
layer_move(pair->layer);
pair->layer_function(pair->layer);
}
}

Expand Down
10 changes: 9 additions & 1 deletion quantum/process_keycode/process_tap_dance.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,19 @@ typedef struct {
typedef struct {
uint16_t kc;
uint8_t layer;
void (*layer_function)(uint8_t);
} qk_tap_dance_dual_role_t;

# define ACTION_TAP_DANCE_DOUBLE(kc1, kc2) \
{ .fn = {qk_tap_dance_pair_on_each_tap, 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 = {qk_tap_dance_dual_role_on_each_tap, qk_tap_dance_dual_role_finished, qk_tap_dance_dual_role_reset}, .user_data = (void *)&((qk_tap_dance_dual_role_t){kc, layer}), }
{ .fn = { qk_tap_dance_dual_role_on_each_tap, qk_tap_dance_dual_role_finished, qk_tap_dance_dual_role_reset }, .user_data = (void *)&((qk_tap_dance_dual_role_t) { kc, layer, layer_move }), }

# define ACTION_TAP_DANCE_TOGGLE_LAYER(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, layer_invert }), }

# define ACTION_TAP_DANCE_LAYER_MOVE(kc, layer) ACTION_TAP_DANCE_DUAL_ROLE(kc, layer)

# define ACTION_TAP_DANCE_FN(user_fn) \
{ .fn = {NULL, user_fn, NULL}, .user_data = NULL, }
Expand All @@ -73,6 +79,8 @@ typedef struct {
# define ACTION_TAP_DANCE_FN_ADVANCED_TIME(user_fn_on_each_tap, user_fn_on_dance_finished, user_fn_on_dance_reset, tap_specific_tapping_term) \
{ .fn = {user_fn_on_each_tap, user_fn_on_dance_finished, user_fn_on_dance_reset}, .user_data = NULL, .custom_tapping_term = tap_specific_tapping_term, }



extern qk_tap_dance_action_t tap_dance_actions[];

/* To be used internally */
Expand Down

0 comments on commit 23efa97

Please sign in to comment.