2019-01-14 17:09:47 +00:00
|
|
|
|
#include QMK_KEYBOARD_H
|
|
|
|
|
#include "konstantin.h"
|
|
|
|
|
|
|
|
|
|
enum layers_keymap {
|
2020-05-16 06:36:08 +00:00
|
|
|
|
L_RCTRL = LAYERS_KEYMAP,
|
2019-01-14 17:09:47 +00:00
|
|
|
|
};
|
|
|
|
|
|
2021-09-19 18:47:40 +00:00
|
|
|
|
enum keycodes_keymap {
|
|
|
|
|
RCTRL = RANGE_KEYMAP,
|
|
|
|
|
};
|
2019-09-03 15:42:05 +00:00
|
|
|
|
|
2021-09-19 18:47:40 +00:00
|
|
|
|
static inline void reset_light(void) {
|
|
|
|
|
rgblight_mode(RGBLIGHT_MODE_RAINBOW_SWIRL);
|
|
|
|
|
rgblight_sethsv(MODERN_DOLCH_RED);
|
2019-09-03 15:42:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-09-05 03:38:54 +00:00
|
|
|
|
static inline void fn_light(void) {
|
2019-09-03 15:42:05 +00:00
|
|
|
|
rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT);
|
|
|
|
|
rgblight_sethsv_noeeprom(modern_dolch_red.h, modern_dolch_red.s, rgblight_get_val());
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-05 03:38:54 +00:00
|
|
|
|
static inline void caps_light(void) {
|
2019-09-03 15:42:05 +00:00
|
|
|
|
rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT);
|
|
|
|
|
rgblight_sethsv_noeeprom(modern_dolch_cyan.h, modern_dolch_cyan.s, rgblight_get_val());
|
2019-01-14 17:09:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-09-05 03:38:54 +00:00
|
|
|
|
static inline void restore_light(void) {
|
2019-09-03 15:42:05 +00:00
|
|
|
|
rgblight_config_t saved = { .raw = eeconfig_read_rgblight() };
|
|
|
|
|
rgblight_mode_noeeprom(saved.mode);
|
2021-09-19 18:47:40 +00:00
|
|
|
|
rgblight_sethsv_noeeprom(saved.hue, saved.sat, saved.val);
|
2019-09-03 15:42:05 +00:00
|
|
|
|
}
|
2019-07-25 19:31:40 +00:00
|
|
|
|
|
2021-09-19 18:47:40 +00:00
|
|
|
|
static bool last_checked_layer;
|
|
|
|
|
|
|
|
|
|
static void check_light_layer(layer_state_t state) {
|
2019-07-25 19:31:40 +00:00
|
|
|
|
if (IS_LAYER_ON_STATE(state, L_FN)) {
|
2019-09-03 15:42:05 +00:00
|
|
|
|
fn_light();
|
2023-02-06 02:36:09 +00:00
|
|
|
|
} else if (host_keyboard_led_state().caps_lock) {
|
2019-09-03 15:42:05 +00:00
|
|
|
|
caps_light();
|
2019-07-25 19:31:40 +00:00
|
|
|
|
} else {
|
2019-09-03 15:42:05 +00:00
|
|
|
|
restore_light();
|
2019-07-25 19:31:40 +00:00
|
|
|
|
}
|
2021-09-19 18:47:40 +00:00
|
|
|
|
last_checked_layer = true;
|
2019-07-25 19:31:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-07-06 08:48:02 +00:00
|
|
|
|
static void check_light_led(led_t led_state) {
|
|
|
|
|
if (led_state.caps_lock) {
|
2019-09-03 15:42:05 +00:00
|
|
|
|
caps_light();
|
|
|
|
|
} else if (IS_LAYER_ON(L_FN)) {
|
|
|
|
|
fn_light();
|
2019-07-25 19:31:40 +00:00
|
|
|
|
} else {
|
2019-09-03 15:42:05 +00:00
|
|
|
|
restore_light();
|
2019-07-25 19:31:40 +00:00
|
|
|
|
}
|
2021-09-19 18:47:40 +00:00
|
|
|
|
last_checked_layer = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void inline check_light(void) {
|
|
|
|
|
last_checked_layer
|
|
|
|
|
? check_light_layer(layer_state)
|
2023-07-06 08:48:02 +00:00
|
|
|
|
: check_light_led(host_keyboard_led_state());
|
2021-09-19 18:47:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void eeconfig_init_keymap(void) {
|
|
|
|
|
reset_light();
|
2019-07-25 19:31:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-09-03 15:42:05 +00:00
|
|
|
|
static bool skip_led = false;
|
|
|
|
|
|
2021-09-19 18:47:40 +00:00
|
|
|
|
layer_state_t layer_state_set_keymap(layer_state_t state) {
|
|
|
|
|
static layer_state_t prev_state = L_BASE;
|
2019-07-25 19:31:40 +00:00
|
|
|
|
if (IS_LAYER_ON_STATE(state, L_FN) != IS_LAYER_ON_STATE(prev_state, L_FN)) {
|
2019-09-03 15:42:05 +00:00
|
|
|
|
check_light_layer(state); // Fn state changed since last time
|
|
|
|
|
skip_led = IS_LAYER_ON_STATE(state, L_FN);
|
|
|
|
|
// led_set_keymap will be called automatically after this
|
2019-07-25 19:31:40 +00:00
|
|
|
|
}
|
|
|
|
|
return prev_state = state;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void led_set_keymap(uint8_t usb_led) {
|
2019-09-03 15:42:05 +00:00
|
|
|
|
if (skip_led) {
|
|
|
|
|
skip_led = false;
|
|
|
|
|
return; // Skip calls triggered by the Fn layer turning on
|
|
|
|
|
}
|
|
|
|
|
check_light_led(usb_led);
|
2019-07-25 19:31:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-09-19 18:47:40 +00:00
|
|
|
|
bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
|
|
|
|
|
switch (keycode) {
|
|
|
|
|
case RGB_TOG ... RGB_SPD:
|
|
|
|
|
if (record->event.pressed) {
|
|
|
|
|
// Shift+Toggle = reset RGB
|
|
|
|
|
if (keycode == RGB_TOG && get_mods() & MOD_MASK_SHIFT) {
|
|
|
|
|
reset_light();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
restore_light();
|
|
|
|
|
} else {
|
|
|
|
|
check_light();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
// Combined RCtrl and layer
|
|
|
|
|
// Cannot use LM(L_RCTRL, MOD_RCTL) because it sends LCtrl instead of RCtrl
|
|
|
|
|
case RCTRL:
|
|
|
|
|
if (record->event.pressed) {
|
2022-10-16 13:14:40 +00:00
|
|
|
|
register_code(KC_RCTL);
|
2021-09-19 18:47:40 +00:00
|
|
|
|
layer_on(L_RCTRL);
|
|
|
|
|
} else {
|
2022-10-16 13:14:40 +00:00
|
|
|
|
unregister_code(KC_RCTL);
|
2021-09-19 18:47:40 +00:00
|
|
|
|
layer_off(L_RCTRL);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-14 17:09:47 +00:00
|
|
|
|
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
2019-05-06 15:41:45 +00:00
|
|
|
|
/* Base layer
|
|
|
|
|
* ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐
|
|
|
|
|
* │Esc│ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 0 │ - │ = │ \ │ ` │
|
|
|
|
|
* ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┤
|
|
|
|
|
* │ Tab │ Q │ W │ E │ R │ T │ Y │ U │ I │ O │ P │ [ │ ] │Bspc │
|
|
|
|
|
* ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤
|
|
|
|
|
* │LCtCps│ A │ S │ D │ F │ G │ H │ J │ K │ L │ ; │ ' │ Enter │
|
|
|
|
|
* ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────┬───┤
|
2019-09-03 15:42:05 +00:00
|
|
|
|
* │LShiftFn│ Z │ X │ C │ V │ B │ N │ M │ , │ . │ / │RShift│FnF│
|
2019-05-06 15:41:45 +00:00
|
|
|
|
* └─────┬──┴┬──┴──┬┴───┴───┴───┴───┴───┴───┴──┬┴───┴┬───┬─┴───┘
|
|
|
|
|
* │LGu│LAlt │ Space │RAlGu│RCt│
|
|
|
|
|
* └───┴─────┴───────────────────────────┴─────┴───┘
|
|
|
|
|
*/
|
|
|
|
|
[L_BASE] = LAYOUT(
|
|
|
|
|
KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSLS, KC_GRV,
|
|
|
|
|
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_BSPC,
|
|
|
|
|
LCT_CPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT,
|
|
|
|
|
LSFT_FN, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, FN_FNLK,
|
2019-09-03 15:42:05 +00:00
|
|
|
|
XXXXXXX, KC_LGUI, KC_LALT, KC_SPC, RAL_RGU, RCTRL, XXXXXXX
|
2019-05-06 15:41:45 +00:00
|
|
|
|
),
|
2019-01-14 17:09:47 +00:00
|
|
|
|
|
2019-09-05 03:38:54 +00:00
|
|
|
|
/* Fn layer
|
2019-05-06 15:41:45 +00:00
|
|
|
|
* ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐
|
|
|
|
|
* │ │F1 │F2 │F3 │F4 │F5 │F6 │F7 │F8 │F9 │F10│F11│F12│PSc│Ins│
|
|
|
|
|
* ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┤
|
2019-09-03 15:42:05 +00:00
|
|
|
|
* │ │Hom│ ↑ │End│PgU│ │ │ │ │M1 │M↑ │М2 │M3 │ Del │
|
2019-05-06 15:41:45 +00:00
|
|
|
|
* ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤
|
2019-09-03 15:42:05 +00:00
|
|
|
|
* │ │ ← │ ↓ │ → │PgD│ │ │ │ │M← │M↓ │M→ │ │
|
2019-05-06 15:41:45 +00:00
|
|
|
|
* ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────┬───┤
|
2019-09-03 15:42:05 +00:00
|
|
|
|
* │ │Mut│Vo-│Vo+│Ply│Prv│Nxt│App│MW↑│M4 │М5 │ │ │
|
2019-05-06 15:41:45 +00:00
|
|
|
|
* └─────┬──┴┬──┴──┬┴───┴───┴───┴───┴───┴───┴──┬┴───┴┬───┬─┴───┘
|
|
|
|
|
* │ │ │ MW↓ │MAcl2│ │
|
|
|
|
|
* └───┴─────┴───────────────────────────┴─────┴───┘
|
|
|
|
|
*/
|
|
|
|
|
[L_FN] = LAYOUT(
|
|
|
|
|
_______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_PSCR, KC_INS,
|
2019-09-03 15:42:05 +00:00
|
|
|
|
_______, KC_HOME, KC_UP, KC_END, KC_PGUP, _______, _______, _______, _______, KC_BTN1, KC_MS_U, KC_BTN2, KC_BTN3, KC_DEL,
|
|
|
|
|
_______, KC_LEFT, KC_DOWN, KC_RGHT, KC_PGDN, _______, _______, _______, _______, KC_MS_L, KC_MS_D, KC_MS_R, _______,
|
|
|
|
|
_______, KC_MUTE, KC_VOLD, KC_VOLU, KC_MPLY, KC_MPRV, KC_MNXT, KC_APP, KC_WH_U, KC_BTN4, KC_BTN5, _______, _______,
|
2019-10-02 23:46:27 +00:00
|
|
|
|
XXXXXXX, _______, _______, KC_WH_D, KC_ACL2, _______, XXXXXXX
|
2019-05-06 15:41:45 +00:00
|
|
|
|
),
|
2019-01-14 17:09:47 +00:00
|
|
|
|
|
2019-05-06 15:41:45 +00:00
|
|
|
|
/* RCtrl layer
|
|
|
|
|
* ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐
|
|
|
|
|
* │ │ │ │ │ │ │ │ │ │ │ │ │ │ │Clr│
|
|
|
|
|
* ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┤
|
|
|
|
|
* │ │Top│Mv↑│Btm│TPr│ │ │ │ │ │ │ │ │DelNx│
|
|
|
|
|
* ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤
|
|
|
|
|
* │ │Mv←│Mv↓│Mv→│TNx│ │ │ │ │ │ │ │ │
|
|
|
|
|
* ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────┬───┤
|
2019-09-03 15:42:05 +00:00
|
|
|
|
* │ │RTg│RV-│RV+│RMd│ │ │ │ │ │ │ │ │
|
2019-05-06 15:41:45 +00:00
|
|
|
|
* └─────┬──┴┬──┴──┬┴───┴───┴───┴───┴───┴───┴──┬┴───┴┬───┬─┴───┘
|
2021-09-19 18:47:40 +00:00
|
|
|
|
* │DPR│DstNA│ │RGui │ │
|
2019-05-06 15:41:45 +00:00
|
|
|
|
* └───┴─────┴───────────────────────────┴─────┴───┘
|
|
|
|
|
*/
|
|
|
|
|
[L_RCTRL] = LAYOUT(
|
|
|
|
|
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, CLEAR,
|
|
|
|
|
_______, TOP, MV_UP, BOTTOM, TAB_PRV, _______, _______, _______, _______, _______, _______, _______, _______, DEL_NXT,
|
|
|
|
|
_______, MV_LEFT, MV_DOWN, MV_RGHT, TAB_NXT, _______, _______, _______, _______, _______, _______, _______, _______,
|
2019-09-03 15:42:05 +00:00
|
|
|
|
_______, RGB_TOG, RGB_VAD, RGB_VAI, RGB_MOD, _______, _______, _______, _______, _______, _______, _______, _______,
|
2021-09-19 18:47:40 +00:00
|
|
|
|
XXXXXXX, DST_P_R, DST_N_A, _______, KC_RGUI, _______, XXXXXXX
|
2019-05-06 15:41:45 +00:00
|
|
|
|
),
|
2019-01-14 17:09:47 +00:00
|
|
|
|
};
|