diff --git a/keymap/keymap.c b/keymap/keymap.c index c599a71..45f6b18 100644 --- a/keymap/keymap.c +++ b/keymap/keymap.c @@ -16,6 +16,13 @@ enum alt_keycodes { DBG_KBD, //DEBUG Toggle Keyboard Prints DBG_MOU, //DEBUG Toggle Mouse Prints MD_BOOT, //Restart into bootloader after hold timeout + ALT_END +}; + +enum ashe_keycodes { + AD_WIND = ALT_END, + AD_UASH, + AD_LASH, }; const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { @@ -33,7 +40,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_DEL, \ KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_HOME, \ KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_END, \ - KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(_FL), KC_LEFT, KC_DOWN, KC_RGHT \ + KC_LCTL, AD_WIND, KC_LALT, KC_SPC, KC_RALT, MO(_FL), KC_LEFT, KC_DOWN, KC_RGHT \ ), [_GAME_LAYER] = LAYOUT_65_ansi_blocker( KC_ESC, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \ @@ -63,6 +70,13 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { _______, RGB_TOG, _______, _______, _______, MD_BOOT, NK_TOGG, DBG_TOG, _______, _______, RCTL(KC_SLSH), _______, KC_PGUP, KC_VOLD, \ KC_NLCK, _______, _______, KC_MEDIA_PLAY_PAUSE, _______, MO(_FL), RCTL(KC_LEFT), KC_PGDN, RCTL(KC_RGHT) \ ), + [_WIN_LAYER] = LAYOUT_65_ansi_blocker( + KC_ESC, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \ + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \ + _______, AD_UASH, AD_LASH, _______, _______, _______, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, _______, _______, _______, _______, \ + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \ + _______, _______, _______, _______, _______, _______, _______, _______, _______ \ + ), [_TALI_LAYER] = LAYOUT( XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \ XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \ @@ -119,6 +133,20 @@ const uint8_t PROGMEM ledmap[][DRIVER_LED_TOTAL][3] = { C_MODI, C_MODI, C_MODI, C_MODI, C_MODI, C_MODI, C_MODI, C_MODI, C_MODI, C_MODI, C_MODI, C_MODI, C_MODI, C_MODI, C_MODI, C_MODI, C_MODI }, + [_WIN_LAYER] = { + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, C_PRIM, C_PRIM, C_PRIM, C_PRIM, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, C_PRIM, _______, + _______, _______, _______, _______, _______, _______, C_PRIM, C_PRIM, C_PRIM, + //UnderGlow + C_TAL3, C_TAL3, C_TAL3, C_TAL3, C_TAL3, C_TAL3, C_TAL3, C_TAL3, C_TAL3, C_TAL3, C_TAL3, C_TAL3, C_TAL3, C_TAL3, C_TAL3, + C_TAL3, C_TAL3, + C_TAL3, C_TAL3, + C_TAL3, C_TAL3, + C_TAL3, C_TAL3, + C_TAL3, C_TAL3, C_TAL3, C_TAL3, C_TAL3, C_TAL3, C_TAL3, C_TAL3, C_TAL3, C_TAL3, C_TAL3, C_TAL3, C_TAL3, C_TAL3, C_TAL3 + }, [_TALI_LAYER] = { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, @@ -228,7 +256,43 @@ void keyboard_post_init_user(void) { bool process_record_user(uint16_t keycode, keyrecord_t *record) { static uint32_t key_timer; + static bool gui_disable_tap; + // Enable / disable WIN_LAYER + if (keycode == AD_WIND) { + if (record->event.pressed) { + key_timer = timer_read32(); + gui_disable_tap = false; + layer_on(_WIN_LAYER); + } else { + layer_off(_WIN_LAYER); + + if (!gui_disable_tap && timer_elapsed32(key_timer) < 500) { + tap_code(KC_LGUI); + } + } + + return false; + } + + // Special handling of transparent keys in win layer + if (IS_LAYER_ON(_WIN_LAYER)) { + gui_disable_tap = true; + + const keypos_t key = record->event.key; + const uint16_t keymap_value = keymaps[_WIN_LAYER][key.row][key.col]; + + if (keymap_value == KC_TRNS) { + if(!record->event.pressed) { + register_code(KC_LGUI); + tap_code(keycode); + unregister_code(KC_LGUI); + } + return false; + } + } + + // Whenever not in Win layer, or win non-trans keys switch (keycode) { case KC_GESC: if (record->event.pressed && MODS_CTRL) { @@ -248,6 +312,50 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { } return true; + case AD_UASH: + if(record->event.pressed) { + bool numlock_enabled = host_keyboard_led_state().num_lock; + if (!numlock_enabled) { + register_code(KC_NUMLOCK); + unregister_code(KC_NUMLOCK); + } + + register_code(KC_LALT); + tap_code(KC_KP_0); + tap_code(KC_KP_1); + tap_code(KC_KP_9); + tap_code(KC_KP_8); + unregister_code(KC_LALT); + + if (!numlock_enabled) { + register_code(KC_NUMLOCK); + unregister_code(KC_NUMLOCK); + } + } + return false; + + case AD_LASH: + if(record->event.pressed) { + bool numlock_enabled = host_keyboard_led_state().num_lock; + if (!numlock_enabled) { + register_code(KC_NUMLOCK); + unregister_code(KC_NUMLOCK); + } + + register_code(KC_LALT); + tap_code(KC_KP_0); + tap_code(KC_KP_2); + tap_code(KC_KP_3); + tap_code(KC_KP_0); + unregister_code(KC_LALT); + + if (!numlock_enabled) { + register_code(KC_NUMLOCK); + unregister_code(KC_NUMLOCK); + } + } + return false; + case U_T_AUTO: if (record->event.pressed && MODS_SHIFT && MODS_CTRL) { TOGGLE_FLAG_AND_PRINT(usb_extra_manual, "USB extra port manual mode"); @@ -317,115 +425,6 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { break; //Process all other keycodes normally } - if (keycode == KC_LGUI) { - if (record->event.pressed && !gui_key_down) { - gui_key_down = true; - } else if (!record->event.pressed && gui_key_down) { - if (gui_combo_pressed) { - unregister_code(KC_LGUI); - } else if (!gui_disable_tap) { - tap_code(KC_LGUI); - } - - gui_key_down = false; - gui_combo_pressed = false; - gui_disable_tap = false; - } - return false; - } - - if (!gui_key_down){ - return true; - } - - // Vim keys - if(!gui_combo_pressed) { - bool target_skipped = false; - uint16_t target = 0; - - if(keycode == KC_H){ - target = KC_LEFT; - } - - if(keycode == KC_J){ - target = KC_DOWN; - } - - if(keycode == KC_K){ - target = KC_UP; - } - - if(keycode == KC_L){ - target = KC_RIGHT; - } - - if(keycode == KC_A){ - if(record->event.pressed) { - bool numlock_enabled = host_keyboard_led_state().num_lock; - if (!numlock_enabled) { - register_code(KC_NUMLOCK); - unregister_code(KC_NUMLOCK); - } - - register_code(KC_LALT); - tap_code(KC_KP_0); - tap_code(KC_KP_1); - tap_code(KC_KP_9); - tap_code(KC_KP_8); - unregister_code(KC_LALT); - - if (!numlock_enabled) { - register_code(KC_NUMLOCK); - unregister_code(KC_NUMLOCK); - } - } - target_skipped = true; - } - - if(keycode == KC_S){ - if(record->event.pressed) { - bool numlock_enabled = host_keyboard_led_state().num_lock; - if (!numlock_enabled) { - register_code(KC_NUMLOCK); - unregister_code(KC_NUMLOCK); - } - - register_code(KC_LALT); - tap_code(KC_KP_0); - tap_code(KC_KP_2); - tap_code(KC_KP_3); - tap_code(KC_KP_0); - unregister_code(KC_LALT); - - if (!numlock_enabled) { - register_code(KC_NUMLOCK); - unregister_code(KC_NUMLOCK); - } - } - target_skipped = true; - } - - if (target != 0) { - if(record->event.pressed) { - register_code(target); - gui_disable_tap = true; - } else { - unregister_code(target); - } - return false; - } - - if (target_skipped) { - gui_disable_tap = true; - return false; - } - } - - if(!gui_combo_pressed) { - gui_combo_pressed = true; - register_code(KC_LGUI); - } - return true; } diff --git a/keymap/keymap.h b/keymap/keymap.h index 6fef0af..77ce809 100644 --- a/keymap/keymap.h +++ b/keymap/keymap.h @@ -14,6 +14,7 @@ enum layout_names { _UNB_W_LAY, _UNB_W_LAY_2, _FUNCTION_LAYER, + _WIN_LAYER, _TALI_LAYER, _TALI_LAYER2, _TALI_LAYER3, @@ -21,8 +22,4 @@ enum layout_names { extern bool g_suspend_state; extern rgb_config_t rgb_matrix_config; -bool disable_layer_color; - -bool gui_key_down; -bool gui_combo_pressed; -bool gui_disable_tap; \ No newline at end of file +bool disable_layer_color; \ No newline at end of file