diff options
author | Konstantin Đorđević <vomindoraan@gmail.com> | 2019-05-06 17:41:45 +0200 |
---|---|---|
committer | Drashna Jaelre <drashna@live.com> | 2019-05-06 08:41:45 -0700 |
commit | cb1935aaff0fed118954996fc7afb722b6ed21be (patch) | |
tree | 753712b2dff56ca41675a99af8f3ffcaf58b85b9 /users/konstantin/tap_dance.c | |
parent | 8a9c90ad78305a1d76663fcb973a1a2ae7177297 (diff) | |
download | qmk_firmware-cb1935aaff0fed118954996fc7afb722b6ed21be.tar.gz qmk_firmware-cb1935aaff0fed118954996fc7afb722b6ed21be.zip |
[Keymap] Update personal userspace and keymaps (now with 4 spaces!) (#5774)
* Add FnLk to Melody96 bottom row
* Update conditional in userspace makefile
Thanks @drashna
* Add F keys to Melody96 Fn layer
* Add FN_ESC alias to userspace
* Update KBD6X keymap
* Fix RGB_MATRIX_ENABLE constant name in #if
* Remove trailing \ from LAYOUT macro calls
* Set RGB mode on EEPROM reset in KBD6X
* Swap right and middle mouse buttons in KBD6X
* Rearrange RGB controls in KBD6X
* Update keycode aliases, replace CLEAR with DEL_NXT in KBD6X
Add Clear to KBD6X as RCtrl+`
* Convert code to 4 space indents
* Tweak RCTRL layer functionality
* Replace NUMPAD custom keycode with layer state logic
* Update RGB_MATRIX_ENABLE check
Co-Authored-By: vomindoraan <vomindoraan@gmail.com>
Diffstat (limited to 'users/konstantin/tap_dance.c')
-rw-r--r-- | users/konstantin/tap_dance.c | 166 |
1 files changed, 83 insertions, 83 deletions
diff --git a/users/konstantin/tap_dance.c b/users/konstantin/tap_dance.c index 0b405939b3..fa43288ce7 100644 --- a/users/konstantin/tap_dance.c +++ b/users/konstantin/tap_dance.c @@ -1,117 +1,117 @@ #include "tap_dance.h" #include "konstantin.h" -#define ACTION_TAP_DANCE_DOUBLE_MOD(mod1, mod2) { \ - .fn = { td_double_mod_each, NULL, td_double_mod_reset }, \ - .user_data = &(qk_tap_dance_pair_t){ mod1, mod2 }, \ - } +#define ACTION_TAP_DANCE_DOUBLE_MOD(mod1, mod2) { \ + .fn = { td_double_mod_each, NULL, td_double_mod_reset }, \ + .user_data = &(qk_tap_dance_pair_t){ mod1, mod2 }, \ + } void td_double_mod_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); - } else if (state->count == 2) { - unregister_code(data->kc1); - register_code(data->kc2); - } - // Prevent tap dance from sending the mods as weak mods - state->weak_mods &= ~(MOD_BIT(data->kc1) | MOD_BIT(data->kc2)); + 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); + } else if (state->count == 2) { + unregister_code(data->kc1); + register_code(data->kc2); + } + // Prevent tap dance from sending the mods as weak mods + state->weak_mods &= ~(MOD_BIT(data->kc1) | MOD_BIT(data->kc2)); } void td_double_mod_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); - } - if (state->count >= 2) { - unregister_code(data->kc2); - } + qk_tap_dance_pair_t *data = (qk_tap_dance_pair_t *)user_data; + + if (state->count == 1 || state->count >= 3) { + unregister_code(data->kc1); + } + if (state->count >= 2) { + unregister_code(data->kc2); + } } -#define ACTION_TAP_DANCE_MOD_LAYER(mod, layer) { \ - .fn = { td_mod_layer_each, NULL, td_mod_layer_reset }, \ - .user_data = &(qk_tap_dance_dual_role_t){ mod, layer }, \ - } +#define ACTION_TAP_DANCE_MOD_LAYER(mod, layer) { \ + .fn = { td_mod_layer_each, NULL, td_mod_layer_reset }, \ + .user_data = &(qk_tap_dance_dual_role_t){ mod, layer }, \ + } 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); - } else if (state->count == 2) { - unregister_code(data->kc); - // Prevent tap dance from sending the mod as a weak mod - state->weak_mods &= ~MOD_BIT(data->kc); - layer_on(data->layer); - } + 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); + } else if (state->count == 2) { + unregister_code(data->kc); + // Prevent tap dance from sending the mod as a weak mod + state->weak_mods &= ~MOD_BIT(data->kc); + layer_on(data->layer); + } } 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); - } - if (state->count >= 2) { - layer_off(data->layer); - } + 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); + } + if (state->count >= 2) { + layer_off(data->layer); + } } -#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, 0, 0 }, \ - } +#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, 0, 0 }, \ + } typedef struct { - uint8_t layer; - uint16_t kc; - bool layer_on; // Layer state when tap dance started - bool started; + uint8_t layer; + uint16_t kc; + bool layer_on; // Layer state when tap dance started + bool started; } qk_tap_dance_layer_mod_t; void td_layer_mod_each(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 (!data->started) { - 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); - } else if (state->count == 2) { - if (!data->layer_on) { - layer_off(data->layer); + qk_tap_dance_layer_mod_t *data = (qk_tap_dance_layer_mod_t *)user_data; + if (!data->started) { + 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); + } else if (state->count == 2) { + if (!data->layer_on) { + layer_off(data->layer); + } + register_code(data->kc); } - register_code(data->kc); - } } 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; + 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); - } + 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; + data->started = false; } qk_tap_dance_action_t tap_dance_actions[] = { - [TD_DST_A_R] = ACTION_TAP_DANCE_DOUBLE(DST_ADD, DST_REM), + [TD_DST_A_R] = ACTION_TAP_DANCE_DOUBLE(DST_ADD, DST_REM), - [TD_RAL_LAL] = ACTION_TAP_DANCE_DOUBLE_MOD(KC_RALT, KC_LALT), - [TD_RAL_RGU] = ACTION_TAP_DANCE_DOUBLE_MOD(KC_RALT, KC_RGUI), - [TD_RCT_RSF] = ACTION_TAP_DANCE_DOUBLE_MOD(KC_RCTL, KC_RSFT), + [TD_RAL_LAL] = ACTION_TAP_DANCE_DOUBLE_MOD(KC_RALT, KC_LALT), + [TD_RAL_RGU] = ACTION_TAP_DANCE_DOUBLE_MOD(KC_RALT, KC_RGUI), + [TD_RCT_RSF] = ACTION_TAP_DANCE_DOUBLE_MOD(KC_RCTL, KC_RSFT), - [TD_LSFT_FN] = ACTION_TAP_DANCE_MOD_LAYER(KC_LSFT, L_FN), - [TD_RCTL_FN] = ACTION_TAP_DANCE_MOD_LAYER(KC_RCTL, L_FN), - [TD_FN_RCTL] = ACTION_TAP_DANCE_LAYER_MOD(L_FN, KC_RCTL), + [TD_LSFT_FN] = ACTION_TAP_DANCE_MOD_LAYER(KC_LSFT, L_FN), + [TD_RCTL_FN] = ACTION_TAP_DANCE_MOD_LAYER(KC_RCTL, L_FN), + [TD_FN_RCTL] = ACTION_TAP_DANCE_LAYER_MOD(L_FN, KC_RCTL), }; |