Cleaned up layer indexing

Simplified russian symbol switching
master
Mark 2022-02-07 20:36:12 -08:00
parent 84d6be3da6
commit 3ea82795a8
Signed by: Mark
GPG Key ID: AD62BB059C2AAEE4
2 changed files with 50 additions and 51 deletions

View File

@ -13,8 +13,7 @@ enum custom_keycodes {
ST_MACRO_0, ST_MACRO_0,
ST_MACRO_1, ST_MACRO_1,
RU_LAYER, RU_LAYER,
EN_LAYER, EN_LAYER
RU_SYMBOL,
}; };
enum tap_dance_codes { enum tap_dance_codes {
@ -24,7 +23,8 @@ enum tap_dance_codes {
// Assemble key and LED maps // Assemble key and LED maps
enum layer_indices { enum layer_indices {
LAYER_MAIN_IDX, LAYER_MAIN_IDX = 0,
LAYER_RUSSIAN_IDX,
LAYER_COLEMAK_IDX, LAYER_COLEMAK_IDX,
LAYER_NUMPAD_IDX, LAYER_NUMPAD_IDX,
LAYER_SYMBOLS_IDX, LAYER_SYMBOLS_IDX,
@ -33,10 +33,24 @@ enum layer_indices {
LAYER_NAVIGATE_IDX, LAYER_NAVIGATE_IDX,
LAYER_DESKTOP_IDX, LAYER_DESKTOP_IDX,
LAYER_KEYBOARD_IDX, LAYER_KEYBOARD_IDX,
LAYER_RUSSIAN_IDX
};
enum led_indices {
// We have seperate indexes for LEDs because
// some layers may not need an led map.
// This saves memory by avoiding extra empty led maps.
LAYER_COLEMAK_LEDS_IDX = 0,
LAYER_RUSSIAN_LEDS_IDX,
LAYER_NUMPAD_LEDS_IDX,
LAYER_SYMBOLS_LEDS_IDX,
LAYER_ARROWS_LEDS_IDX,
LAYER_FKEYS_LEDS_IDX,
LAYER_NAVIGATE_LEDS_IDX,
LAYER_DESKTOP_LEDS_IDX
}; };
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[LAYER_MAIN_IDX] = LAYER_MAIN, [LAYER_MAIN_IDX] = LAYER_MAIN,
[LAYER_RUSSIAN_IDX] = LAYER_RUSSIAN,
[LAYER_COLEMAK_IDX] = LAYER_COLEMAK, [LAYER_COLEMAK_IDX] = LAYER_COLEMAK,
[LAYER_NUMPAD_IDX] = LAYER_NUMPAD, [LAYER_NUMPAD_IDX] = LAYER_NUMPAD,
[LAYER_SYMBOLS_IDX] = LAYER_SYMBOLS, [LAYER_SYMBOLS_IDX] = LAYER_SYMBOLS,
@ -44,21 +58,19 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[LAYER_FKEYS_IDX] = LAYER_FKEYS, [LAYER_FKEYS_IDX] = LAYER_FKEYS,
[LAYER_NAVIGATE_IDX] = LAYER_NAVIGATE, [LAYER_NAVIGATE_IDX] = LAYER_NAVIGATE,
[LAYER_DESKTOP_IDX] = LAYER_DESKTOP, [LAYER_DESKTOP_IDX] = LAYER_DESKTOP,
[LAYER_KEYBOARD_IDX] = LAYER_KEYBOARD, [LAYER_KEYBOARD_IDX] = LAYER_KEYBOARD
[LAYER_RUSSIAN_IDX] = LAYER_RUSSIAN
}; };
const uint8_t PROGMEM ledmap[][DRIVER_LED_TOTAL][3] = { const uint8_t PROGMEM ledmap[][DRIVER_LED_TOTAL][3] = {
[LAYER_COLEMAK_IDX] = LAYER_COLEMAK_LEDS, [LAYER_COLEMAK_LEDS_IDX] = LAYER_COLEMAK_LEDS,
[LAYER_NUMPAD_IDX] = LAYER_NUMPAD_LEDS, [LAYER_RUSSIAN_LEDS_IDX] = LAYER_RUSSIAN_LEDS,
[LAYER_SYMBOLS_IDX] = LAYER_SYMBOLS_LEDS, [LAYER_NUMPAD_LEDS_IDX] = LAYER_NUMPAD_LEDS,
[LAYER_ARROWS_IDX] = LAYER_ARROWS_LEDS, [LAYER_SYMBOLS_LEDS_IDX] = LAYER_SYMBOLS_LEDS,
[LAYER_FKEYS_IDX] = LAYER_FKEYS_LEDS, [LAYER_ARROWS_LEDS_IDX] = LAYER_ARROWS_LEDS,
[LAYER_NAVIGATE_IDX] = LAYER_NAVIGATE_LEDS, [LAYER_FKEYS_LEDS_IDX] = LAYER_FKEYS_LEDS,
[LAYER_DESKTOP_IDX] = LAYER_DESKTOP_LEDS, [LAYER_NAVIGATE_LEDS_IDX] = LAYER_NAVIGATE_LEDS,
[LAYER_RUSSIAN_IDX] = LAYER_RUSSIAN_LEDS [LAYER_DESKTOP_LEDS_IDX] = LAYER_DESKTOP_LEDS
}; };
extern bool g_suspend_state; extern bool g_suspend_state;
extern rgb_config_t rgb_matrix_config; extern rgb_config_t rgb_matrix_config;
@ -91,32 +103,29 @@ void rgb_matrix_indicators_user(void) {
} }
switch (biton32(layer_state)) { switch (biton32(layer_state)) {
case 1: case LAYER_COLEMAK_IDX:
set_layer_color(1); set_layer_color(LAYER_COLEMAK_LEDS_IDX);
break; break;
case 2: case LAYER_RUSSIAN_IDX:
set_layer_color(2); set_layer_color(LAYER_RUSSIAN_LEDS_IDX);
break; break;
case 3: case LAYER_NUMPAD_IDX:
set_layer_color(3); set_layer_color(LAYER_NUMPAD_LEDS_IDX);
break; break;
case 4: case LAYER_SYMBOLS_IDX:
set_layer_color(4); set_layer_color(LAYER_SYMBOLS_LEDS_IDX);
break; break;
case 5: case LAYER_ARROWS_IDX:
set_layer_color(5); set_layer_color(LAYER_ARROWS_LEDS_IDX);
break; break;
case 6: case LAYER_FKEYS_IDX:
set_layer_color(6); set_layer_color(LAYER_FKEYS_LEDS_IDX);
break; break;
case 7: case LAYER_NAVIGATE_IDX:
set_layer_color(7); set_layer_color(LAYER_NAVIGATE_LEDS_IDX);
break; break;
case 9: case LAYER_DESKTOP_IDX:
set_layer_color(9); set_layer_color(LAYER_DESKTOP_LEDS_IDX);
break;
case 10:
set_layer_color(10);
break; break;
default: default:
if (rgb_matrix_get_flags() == LED_FLAG_NONE) { if (rgb_matrix_get_flags() == LED_FLAG_NONE) {
@ -145,24 +154,14 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
case RU_LAYER: case RU_LAYER:
if (record->event.pressed) { if (record->event.pressed) {
SEND_STRING(SS_LGUI(SS_LSFT(SS_LCTL(SS_TAP(X_9))))); SEND_STRING(SS_LGUI(SS_LSFT(SS_LCTL(SS_TAP(X_9)))));
layer_move(9); layer_move(LAYER_RUSSIAN_IDX);
} }
break; break;
case EN_LAYER: case EN_LAYER:
if (record->event.pressed) { if (record->event.pressed) {
SEND_STRING(SS_LGUI(SS_LSFT(SS_LCTL(SS_TAP(X_0))))); SEND_STRING(SS_LGUI(SS_LSFT(SS_LCTL(SS_TAP(X_0)))));
layer_move(0); layer_move(LAYER_MAIN_IDX);
}
break;
case RU_SYMBOL:
if (record->event.pressed) {
SEND_STRING(SS_LGUI(SS_LSFT(SS_LCTL(SS_TAP(X_0)))));
layer_on(LAYER_SYMBOLS_IDX);
} else {
SEND_STRING(SS_LGUI(SS_LSFT(SS_LCTL(SS_TAP(X_9)))));
layer_off(LAYER_SYMBOLS_IDX);
} }
break; break;

View File

@ -13,11 +13,11 @@
KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT,\ KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT,\
\ \
\ \
KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, RU_NUM, RU_RUBL, KC_TRANSPARENT,\ KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, RU_NUM, RU_RUBL, KC_TRANSPARENT,\
RU_SOFT, RU_U, RU_YU, RU_I, RU_O, RU_SHCH, KC_TRANSPARENT,\ RU_SOFT, RU_U, RU_YU, RU_I, RU_O, RU_SHCH, KC_TRANSPARENT,\
RU_HA, RU_ZHE, RU_KA, RU_SYMBOL, RU_EL, KC_TRANSPARENT,\ RU_HA, RU_ZHE, RU_KA, MO(LAYER_SYMBOLS_IDX), RU_EL, KC_TRANSPARENT,\
RU_HARD, RU_EN, RU_EM, RU_PE, RU_YERU, RU_SHTI, KC_TRANSPARENT,\ RU_HARD, RU_EN, RU_EM, RU_PE, RU_YERU, RU_SHTI, KC_TRANSPARENT,\
KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT,\ KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT,\
\ \
KC_TRANSPARENT, EN_LAYER,\ KC_TRANSPARENT, EN_LAYER,\
KC_TRANSPARENT,\ KC_TRANSPARENT,\