From cb1935aaff0fed118954996fc7afb722b6ed21be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20=C4=90or=C4=91evi=C4=87?= Date: Mon, 6 May 2019 17:41:45 +0200 Subject: [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 --- users/konstantin/konstantin.c | 120 ++++++++++++++---------------- users/konstantin/konstantin.h | 60 ++++++++------- users/konstantin/rgb.h | 12 +-- users/konstantin/rules.mk | 13 ++-- users/konstantin/tap_dance.c | 166 +++++++++++++++++++++--------------------- users/konstantin/tap_dance.h | 14 ++-- users/konstantin/unicode.c | 2 +- users/konstantin/unicode.h | 20 ++--- 8 files changed, 203 insertions(+), 204 deletions(-) (limited to 'users/konstantin') diff --git a/users/konstantin/konstantin.c b/users/konstantin/konstantin.c index 753742fa78..9e3caca414 100644 --- a/users/konstantin/konstantin.c +++ b/users/konstantin/konstantin.c @@ -4,107 +4,99 @@ __attribute__((weak)) void keyboard_pre_init_keymap(void) {} void keyboard_pre_init_user(void) { - keyboard_pre_init_keymap(); + keyboard_pre_init_keymap(); } __attribute__((weak)) void eeconfig_init_keymap(void) {} void eeconfig_init_user(void) { - eeconfig_init_keymap(); + eeconfig_init_keymap(); } __attribute__((weak)) void keyboard_post_init_keymap(void) {} void keyboard_post_init_user(void) { - keyboard_post_init_keymap(); + keyboard_post_init_keymap(); } __attribute__((weak)) bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { - return true; + return true; } bool process_record_user(uint16_t keycode, keyrecord_t *record) { - if (!process_record_keymap(keycode, record)) { - return false; - } - -#ifdef LAYER_NUMPAD - void toggle_numpad(void) { - layer_invert(L_NUMPAD); - bool numpad = IS_LAYER_ON(L_NUMPAD), num_lock = IS_HOST_LED_ON(USB_LED_NUM_LOCK); - if (num_lock != numpad) { - tap_code(KC_NLCK); // Toggle Num Lock to match layer state + if (!process_record_keymap(keycode, record)) { + return false; } - } -#endif - switch (keycode) { - case CLEAR: - if (record->event.pressed) { - SEND_STRING(SS_LCTRL("a") SS_TAP(X_DELETE)); - } - return false; + switch (keycode) { + case CLEAR: + if (record->event.pressed) { + SEND_STRING(SS_LCTRL("a") SS_TAP(X_DELETE)); + } + return false; - case DST_P_R: - (record->event.pressed ? register_code16 : unregister_code16)( - (get_mods() & DST_MOD_MASK) ? DST_REM : DST_PRV - ); - return false; + case DST_P_R: + (record->event.pressed ? register_code16 : unregister_code16)( + (get_mods() & DST_MOD_MASK) ? DST_REM : DST_PRV + ); + return false; - case DST_N_A: - (record->event.pressed ? register_code16 : unregister_code16)( - (get_mods() & DST_MOD_MASK) ? DST_ADD : DST_NXT - ); - return false; + case DST_N_A: + (record->event.pressed ? register_code16 : unregister_code16)( + (get_mods() & DST_MOD_MASK) ? DST_ADD : DST_NXT + ); + return false; #ifdef LAYER_FN - static bool fn_lock; - - case FN_FNLK: - if (record->event.pressed && record->tap.count == TAPPING_TOGGLE) { - fn_lock = !IS_LAYER_ON(L_FN); // Fn layer will be toggled after this - } - return true; -#endif + static bool fn_lock; -#ifdef LAYER_NUMPAD - case NUMPAD: - if (record->event.pressed) { - toggle_numpad(); - } - return false; + case FN_FNLK: + if (record->event.pressed && record->tap.count == TAPPING_TOGGLE) { + fn_lock = !IS_LAYER_ON(L_FN); // Fn layer will be toggled after this + } + return true; #endif - case KC_ESC: - if (record->event.pressed) { -#ifdef LAYER_NUMPAD - if (IS_LAYER_ON(L_NUMPAD)) { - toggle_numpad(); - return false; - } + case KC_ESC: + if (record->event.pressed) { +#ifdef LAYER_NUMPAD // Disable Numpad layer before Fn layer + if (IS_LAYER_ON(L_NUMPAD)) { + layer_off(L_NUMPAD); + return false; + } #endif #ifdef LAYER_FN - if (IS_LAYER_ON(L_FN) && fn_lock) { - layer_off(L_FN); - return fn_lock = false; - } + if (IS_LAYER_ON(L_FN) && fn_lock) { + layer_off(L_FN); + return fn_lock = false; + } #endif - } - return true; + } + return true; - default: - return true; - } + default: + return true; + } } __attribute__((weak)) uint32_t layer_state_set_keymap(uint32_t state) { - return state; + return state; } uint32_t layer_state_set_user(uint32_t state) { - return layer_state_set_keymap(state); + state = layer_state_set_keymap(state); + +#ifdef LAYER_NUMPAD + bool numpad = state & 1UL<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), }; diff --git a/users/konstantin/tap_dance.h b/users/konstantin/tap_dance.h index ad7c04cb7f..13d682a603 100644 --- a/users/konstantin/tap_dance.h +++ b/users/konstantin/tap_dance.h @@ -13,13 +13,13 @@ #define FN_RCTL TD(TD_FN_RCTL) enum tap_dance { - TD_DST_A_R, + TD_DST_A_R, - TD_RAL_LAL, - TD_RAL_RGU, - TD_RCT_RSF, + TD_RAL_LAL, + TD_RAL_RGU, + TD_RCT_RSF, - TD_LSFT_FN, - TD_RCTL_FN, - TD_FN_RCTL, + TD_LSFT_FN, + TD_RCTL_FN, + TD_FN_RCTL, }; diff --git a/users/konstantin/unicode.c b/users/konstantin/unicode.c index 144c0aaf75..8ef5aaa1ec 100644 --- a/users/konstantin/unicode.c +++ b/users/konstantin/unicode.c @@ -2,6 +2,6 @@ #ifdef UNICODEMAP_ENABLE const uint32_t PROGMEM unicode_map[] = { - FOREACH_UNICODE(UCM_ENTRY) + FOREACH_UNICODE(UCM_ENTRY) }; #endif diff --git a/users/konstantin/unicode.h b/users/konstantin/unicode.h index c8eddabb71..b2616d120b 100644 --- a/users/konstantin/unicode.h +++ b/users/konstantin/unicode.h @@ -3,13 +3,13 @@ #include "quantum.h" #define FOREACH_UNICODE(M) \ - M(COMMA, 0x002C) \ - M(L_PAREN, 0x0028) \ - M(R_PAREN, 0x0029) \ - M(EQUALS, 0x003D) \ - M(TIMES, 0x00D7) \ - M(DIVIDE, 0x00F7) \ - M(MINUS, 0x2212) + M(COMMA, 0x002C) \ + M(L_PAREN, 0x0028) \ + M(R_PAREN, 0x0029) \ + M(EQUALS, 0x003D) \ + M(TIMES, 0x00D7) \ + M(DIVIDE, 0x00F7) \ + M(MINUS, 0x2212) #define UC_KEYCODE(name, code) name = UC(code), @@ -19,16 +19,16 @@ #if defined(UNICODE_ENABLE) enum unicode_keycodes { - FOREACH_UNICODE(UC_KEYCODE) + FOREACH_UNICODE(UC_KEYCODE) }; #elif defined(UNICODEMAP_ENABLE) enum unicode_names { - FOREACH_UNICODE(UCM_NAME) + FOREACH_UNICODE(UCM_NAME) }; extern const uint32_t PROGMEM unicode_map[]; enum unicode_keycodes { - FOREACH_UNICODE(UCM_KEYCODE) + FOREACH_UNICODE(UCM_KEYCODE) }; #endif -- cgit v1.2.3