diff options
author | Konstantin Đorđević <vomindoraan@gmail.com> | 2019-02-18 06:08:52 +0100 |
---|---|---|
committer | Konstantin Đorđević <vomindoraan@gmail.com> | 2019-03-02 15:15:59 +0100 |
commit | 6a088f7ff6b6e001fdac46252d75863b7611fd0d (patch) | |
tree | 7df9676d6be4b6aa2d89b4dcc0477098b0ed9d07 | |
parent | 14908f86fb97bb7ddc269515a48e681799baccf3 (diff) |
Add blank lines, prefer explicit initialization
-rw-r--r-- | keyboards/melody96/keymaps/konstantin/keymap.c | 2 | ||||
-rw-r--r-- | users/konstantin/tap_dance.c | 9 |
2 files changed, 9 insertions, 2 deletions
diff --git a/keyboards/melody96/keymaps/konstantin/keymap.c b/keyboards/melody96/keymaps/konstantin/keymap.c index c8b6edb3d6..de1b67e98b 100644 --- a/keyboards/melody96/keymaps/konstantin/keymap.c +++ b/keyboards/melody96/keymaps/konstantin/keymap.c @@ -3,7 +3,7 @@ static const hsv_t *colors[] = { &GODSPEED_BLUE, &GODSPEED_YELLOW }; static size_t cnum = sizeof colors / sizeof *colors; -static size_t cidx; +static size_t cidx = 0; void eeconfig_init_keymap(void) { rgblight_sethsv(colors[cidx]->h, colors[cidx]->s, colors[cidx]->v); diff --git a/users/konstantin/tap_dance.c b/users/konstantin/tap_dance.c index 377a0889fe..c01b29bd53 100644 --- a/users/konstantin/tap_dance.c +++ b/users/konstantin/tap_dance.c @@ -8,6 +8,7 @@ void td_double_mods_each(qk_tap_dance_state_t *state, void *user_data) { qk_tap_dance_pair_t *data = (qk_tap_dance_pair_t *)user_data; + // Single tap → mod1, double tap → mod2, triple tap etc. → mod1+mod2 if (state->count == 1 || state->count == 3) { register_code(data->kc1); @@ -21,6 +22,7 @@ void td_double_mods_each(qk_tap_dance_state_t *state, void *user_data) { void td_double_mods_reset(qk_tap_dance_state_t *state, void *user_data) { qk_tap_dance_pair_t *data = (qk_tap_dance_pair_t *)user_data; + if (state->count == 1 || state->count >= 3) { unregister_code(data->kc1); } @@ -36,6 +38,7 @@ void td_double_mods_reset(qk_tap_dance_state_t *state, void *user_data) { void td_mod_layer_each(qk_tap_dance_state_t *state, void *user_data) { qk_tap_dance_dual_role_t *data = (qk_tap_dance_dual_role_t *)user_data; + // Single tap → mod, double tap → layer, triple tap etc. → mod+layer if (state->count == 1 || state->count == 3) { register_code(data->kc); @@ -49,6 +52,7 @@ void td_mod_layer_each(qk_tap_dance_state_t *state, void *user_data) { void td_mod_layer_reset(qk_tap_dance_state_t *state, void *user_data) { qk_tap_dance_dual_role_t *data = (qk_tap_dance_dual_role_t *)user_data; + if (state->count == 1 || state->count >= 3) { unregister_code(data->kc); } @@ -59,7 +63,7 @@ void td_mod_layer_reset(qk_tap_dance_state_t *state, void *user_data) { #define ACTION_TAP_DANCE_LAYER_MOD(layer, mod) { \ .fn = { td_layer_mod_each, NULL, td_layer_mod_reset }, \ - .user_data = &(qk_tap_dance_layer_mod_t){ layer, mod }, \ + .user_data = &(qk_tap_dance_layer_mod_t){ layer, mod, 0, 0 }, \ } typedef struct { @@ -75,6 +79,7 @@ void td_layer_mod_each(qk_tap_dance_state_t *state, void *user_data) { data->layer_on = IS_LAYER_ON(data->layer); data->started = true; } + // Single tap → layer, double tap → mod, triple tap etc. → layer+mod if (state->count == 1 || state->count == 3) { layer_on(data->layer); @@ -88,12 +93,14 @@ void td_layer_mod_each(qk_tap_dance_state_t *state, void *user_data) { void td_layer_mod_reset(qk_tap_dance_state_t *state, void *user_data) { qk_tap_dance_layer_mod_t *data = (qk_tap_dance_layer_mod_t *)user_data; + if ((state->count == 1 || state->count >= 3) && !data->layer_on) { layer_off(data->layer); } if (state->count >= 2) { unregister_code(data->kc); } + data->started = false; } |