From fc1d55301107be52f27727acfec74c833d613074 Mon Sep 17 00:00:00 2001 From: HorrorTroll Date: Sun, 10 Jul 2022 17:37:30 +0700 Subject: [PATCH] Updated more changes --- keyboards/feker/ik75/config.h | 18 +- keyboards/feker/ik75/ik75.c | 4 +- keyboards/feker/ik75/keymaps/default/keymap.c | 154 +++++++++++++++--- keyboards/feker/ik75/keymaps/via/keymap.c | 154 +++++++++++++++--- 4 files changed, 270 insertions(+), 60 deletions(-) diff --git a/keyboards/feker/ik75/config.h b/keyboards/feker/ik75/config.h index dec13cc5005a..1e39757b47ea 100644 --- a/keyboards/feker/ik75/config.h +++ b/keyboards/feker/ik75/config.h @@ -49,15 +49,21 @@ /* Change larger keys per scan for elite gaming */ #define QMK_KEYS_PER_SCAN 12 -/* Encoder pins */ -#define ENCODERS_PAD_A { C6 } -#define ENCODERS_PAD_B { C7 } +#ifdef ENCODER_ENABLE + /* Encoder pins */ + #define ENCODERS_PAD_A { C6 } + #define ENCODERS_PAD_B { C7 } + + /* Encoder config */ + #define ENCODER_RESOLUTION 2 +#endif #ifdef RGB_MATRIX_ENABLE #define DRIVER_LED_TOTAL (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL) #define RGB_MATRIX_MAXIMUM_BRIGHTNESS 200 #define RGB_MATRIX_STARTUP_VAL RGB_MATRIX_MAXIMUM_BRIGHTNESS #define RGB_MATRIX_KEYPRESSES + #define RGB_MATRIX_FRAMEBUFFER_EFFECTS /* RGB Matrix config */ #define DRIVER_ADDR_1 0b1011111 @@ -94,8 +100,12 @@ #define ENABLE_RGB_MATRIX_HUE_PENDULUM #define ENABLE_RGB_MATRIX_HUE_WAVE #define ENABLE_RGB_MATRIX_PIXEL_RAIN + #define ENABLE_RGB_MATRIX_PIXEL_FLOW #define ENABLE_RGB_MATRIX_PIXEL_FRACTAL -// enabled only of RGB_MATRIX_KEYPRESSES or RGB_MATRIX_KEYRELEASES is defined + + #define ENABLE_RGB_MATRIX_TYPING_HEATMAP + #define ENABLE_RGB_MATRIX_DIGITAL_RAIN + #define ENABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE #define ENABLE_RGB_MATRIX_SOLID_REACTIVE #define ENABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE diff --git a/keyboards/feker/ik75/ik75.c b/keyboards/feker/ik75/ik75.c index 8aff4df04590..c91d26579387 100644 --- a/keyboards/feker/ik75/ik75.c +++ b/keyboards/feker/ik75/ik75.c @@ -172,7 +172,7 @@ led_config_t g_led_config = { { }, { {0 , 15}, {14 , 15}, {29 , 15}, {43 , 15}, {58 , 15}, {72 , 15}, {87 , 15}, {101, 15}, {116, 15}, {130, 15}, {145, 15}, {159, 15}, {173, 15}, {195, 15}, {38 , 61}, {92 , 61}, {4 , 26}, {22 , 26}, {36 , 26}, {51 , 26}, {65 , 26}, {79 , 26}, {94 , 26}, {108, 26}, {123, 26}, {137, 26}, {152, 26}, {166, 26}, {181, 26}, {199, 26}, {173, 61}, {159, 61}, - {5 , 38}, {25 , 38}, {40 , 38}, {54 , 38}, {69 , 38}, {83 , 38}, {98 , 38}, {112, 38}, {126, 38}, {141, 38}, {155, 38}, {170, 38}, {193, 38}, {206, 52}, {0 , 29}, {145, 61}, + {5 , 38}, {25 , 38}, {40 , 38}, {54 , 38}, {69 , 38}, {83 , 38}, {98 , 38}, {112, 38}, {126, 38}, {141, 38}, {155, 38}, {170, 38}, {193, 38}, {206, 52}, {0 , 0}, {145, 61}, {9 , 49}, {33 , 49}, {47 , 49}, {61 , 49}, {76 , 49}, {90 , 49}, {105, 49}, {119, 49}, {134, 49}, {148, 49}, {163, 49}, {182, 49}, {191, 64}, {206, 64}, {220, 64}, {14 , 0}, {28 , 0}, {53 , 0}, {63 , 0}, {74 , 0}, {88 , 0}, {102, 0}, {116, 0}, {130, 0}, {144, 0}, {158, 0}, {172, 0}, {189, 0}, {210, 0}, {224, 0}, {224, 11}, {0 , 0}, {18 , 0}, {33 , 0}, {47 , 0}, {61 , 0}, {79 , 0}, {94 , 0}, {108, 0}, {123, 0}, {141, 0}, {155, 0}, {170, 0}, {184, 0}, {202, 0}, {2 , 61}, {20 , 61}, @@ -185,7 +185,7 @@ led_config_t g_led_config = { { 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, - 2, 2, 2, 2, 2, 2, 4, 4, 4, 8, 4, 4, 2, 2, 2, 2, + 2, 2, 2, 2, 1, 1, 4, 4, 4, 8, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 } }; #endif diff --git a/keyboards/feker/ik75/keymaps/default/keymap.c b/keyboards/feker/ik75/keymaps/default/keymap.c index 158199fd4368..8ff7aecaeb6e 100644 --- a/keyboards/feker/ik75/keymaps/default/keymap.c +++ b/keyboards/feker/ik75/keymaps/default/keymap.c @@ -29,6 +29,22 @@ enum layer_names { _FN2 }; +enum user_rgb_mode { + RGB_MODE_ALL, + RGB_MODE_KEYLIGHT, + RGB_MODE_UNDERGLOW, + RGB_MODE_NONE, +}; + +typedef union { + uint32_t raw; + struct { + uint8_t rgb_mode :8; + }; +} user_config_t; + +user_config_t user_config; + // enum layer_keycodes { }; const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { @@ -67,7 +83,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { */ /* Row: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */ [_BASE] = LAYOUT( - KC_ESC, 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_DEL, _______, KC_MUTE, _______, + KC_ESC, 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_DEL, KC_VOLD, KC_MUTE, KC_VOLU, KC_GRV, 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_BSPC, KC_INS, 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_END, 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_PGUP, @@ -77,29 +93,29 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { /* ┌───┐┌───┬───┬───┬───┐┌───┬───┬───┬───┐┌───┬───┬───┬───┐┌───┐ ┌───┐ - │Fn1││Mcm│Hom│Cal│Sel││Prv│Nxt│Ply│Stp││Mut│VoD│VoU│Mai││ │ │ │ + │Fn1││Mcm│Hom│Cal│Sel││Prv│Nxt│Ply│Stp││Mut│VoD│VoU│Mai││ │ │Tog│ └───┘└───┴───┴───┴───┘└───┴───┴───┴───┘└───┴───┴───┴───┘└───┘ └───┘ ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐ ┌───┐ │ │ │ │ │ │ │ │ │ │ │ │Spd│Spi│ │ │Mod│ ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤ ├───┤ - │ │ │ │ │ │ │ │ │Scr│ │ │ │ │ │ │Hui│ + │ │ │ │ │ │ │ │ │ │ │Prt│ │ │ │ │Hui│ ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤ ├───┤ - │ │ │ │ │ │ │ │ │ │ │ │ │ │ │Sai│ + │ │ │Scr│ │ │ │ │ │ │ │ │ │ │ │Sai│ ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────┬───┘ ├───┤ - │ │ │ │ │ │ │NKO│ │ │ │ │ │┌───┐│Sad│ + │ │ │ │ │ │ │Num│ │ │ │ │ │┌───┐│Sad│ ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬─────┘│Vai│└───┘ - │ │ │ │ │ │ │ ┌───┼───┼───┐ + │ │GTog│ │ │ │ │ ┌───┼───┼───┐ └────┴────┴────┴────────────────────────┴────┴────┘ │ │Vad│ │ └───┴───┴───┘ */ - /* Row: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */ + /* Row: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */ [_FN] = LAYOUT( - MO(_FN1), KC_MYCM, KC_WHOM, KC_CALC, KC_SLCT, KC_MPRV, KC_MNXT, KC_MPLY, KC_MSTP, KC_MUTE, KC_VOLD, KC_VOLU, KC_MAIL, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_SPD, RGB_SPI, _______, RGB_MOD, - _______, _______, _______, _______, _______, _______, _______, _______, KC_SCRL, _______, _______, _______, _______, _______, RGB_HUI, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_SAI, - _______, _______, _______, _______, _______, _______, NK_TOGG, _______, _______, _______, _______, _______, RGB_VAI, RGB_SAD, - _______, _______, _______, _______, _______, _______, _______, _______, RGB_VAD, _______ + QK_BOOT, KC_MYCM, KC_WHOM, KC_CALC, KC_SLCT, KC_MPRV, KC_MNXT, KC_MPLY, KC_MSTP, KC_MUTE, KC_VOLD, KC_VOLU, KC_MAIL, _______, _______, RGB_TOG, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_SPD, RGB_SPI, _______, RGB_MOD, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_PSCR, _______, _______, _______, RGB_HUI, + _______, _______, KC_SCRL, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_SAI, + _______, _______, _______, _______, _______, _______, KC_NUM, _______, _______, _______, _______, _______, RGB_VAI, RGB_SAD, + _______, GUI_TOG, _______, _______, _______, _______, _______, _______, RGB_VAD, _______ ), /* @@ -119,14 +135,14 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { └────┴────┴────┴────────────────────────┴────┴────┘ │ │ │ │ └───┴───┴───┘ */ - /* Row: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */ + /* Row: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */ [_FN1] = LAYOUT( - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, QK_BOOT, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ ), /* @@ -146,17 +162,101 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { └────┴────┴────┴────────────────────────┴────┴────┘ │ │ │ │ └───┴───┴───┘ */ - /* Row: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */ + /* Row: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */ [_FN2] = LAYOUT( - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ ), }; +void keyboard_post_init_user(void) { + user_config.raw = eeconfig_read_user(); + switch (user_config.rgb_mode) { + case RGB_MODE_ALL: + rgb_matrix_set_flags(LED_FLAG_ALL); + rgb_matrix_enable_noeeprom(); + break; + case RGB_MODE_KEYLIGHT: + rgb_matrix_set_flags(LED_FLAG_KEYLIGHT | LED_FLAG_MODIFIER | LED_FLAG_INDICATOR); + rgb_matrix_set_color_all(0, 0, 0); + break; + case RGB_MODE_UNDERGLOW: + rgb_matrix_set_flags(LED_FLAG_UNDERGLOW); + rgb_matrix_set_color_all(0, 0, 0); + break; + case RGB_MODE_NONE: + rgb_matrix_set_flags(LED_FLAG_NONE); + rgb_matrix_set_color_all(0, 0, 0); + break; + } +} + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + case RGB_TOG: + if (record->event.pressed) { + switch (rgb_matrix_get_flags()) { + case LED_FLAG_ALL: { + rgb_matrix_set_flags(LED_FLAG_KEYLIGHT | LED_FLAG_MODIFIER | LED_FLAG_INDICATOR); + rgb_matrix_set_color_all(0, 0, 0); + user_config.rgb_mode = RGB_MODE_KEYLIGHT; + } + break; + case (LED_FLAG_KEYLIGHT | LED_FLAG_MODIFIER | LED_FLAG_INDICATOR): { + rgb_matrix_set_flags(LED_FLAG_UNDERGLOW); + rgb_matrix_set_color_all(0, 0, 0); + user_config.rgb_mode = RGB_MODE_UNDERGLOW; + } + break; + case (LED_FLAG_UNDERGLOW): { + rgb_matrix_set_flags(LED_FLAG_NONE); + rgb_matrix_set_color_all(0, 0, 0); + user_config.rgb_mode = RGB_MODE_NONE; + } + break; + default: { + rgb_matrix_set_flags(LED_FLAG_ALL); + rgb_matrix_enable_noeeprom(); + user_config.rgb_mode = RGB_MODE_ALL; + } + break; + } + eeconfig_update_user(user_config.raw); + } + return false; + } + + return true; +} + +void rgb_matrix_indicators_user(void) { + rgb_matrix_set_color(46, 0, 0, 0); + rgb_matrix_set_color(104, 0, 0, 0); + + uint8_t red = host_keyboard_led_state().caps_lock ? 255 : 0; + uint8_t green = host_keyboard_led_state().scroll_lock ? 255 : 0; + uint8_t blue = keymap_config.no_gui ? 255 : 0; + + + if ((rgb_matrix_get_flags() & LED_FLAG_KEYLIGHT)) { + if (host_keyboard_led_state().num_lock) { + rgb_matrix_set_color(46, 255, 0, 0); + } + rgb_matrix_set_color(104, red, green, blue); + } else { + if (host_keyboard_led_state().num_lock) { + rgb_matrix_set_color(46, 255, 0, 0); + } else { + rgb_matrix_set_color(46, 0, 0, 0); + } + rgb_matrix_set_color(104, red, green, blue); + } +} + #ifdef ENCODER_MAP_ENABLE const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][2] = { [_BASE] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU) }, diff --git a/keyboards/feker/ik75/keymaps/via/keymap.c b/keyboards/feker/ik75/keymaps/via/keymap.c index 716b1564c759..29e3f1ae6620 100644 --- a/keyboards/feker/ik75/keymaps/via/keymap.c +++ b/keyboards/feker/ik75/keymaps/via/keymap.c @@ -29,6 +29,22 @@ enum layer_names { _FN2 }; +enum user_rgb_mode { + RGB_MODE_ALL, + RGB_MODE_KEYLIGHT, + RGB_MODE_UNDERGLOW, + RGB_MODE_NONE, +}; + +typedef union { + uint32_t raw; + struct { + uint8_t rgb_mode :8; + }; +} user_config_t; + +user_config_t user_config; + // enum layer_keycodes { }; const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { @@ -77,29 +93,29 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { /* ┌───┐┌───┬───┬───┬───┐┌───┬───┬───┬───┐┌───┬───┬───┬───┐┌───┐ ┌───┐ - │Fn1││Mcm│Hom│Cal│Sel││Prv│Nxt│Ply│Stp││Mut│VoD│VoU│Mai││ │ │ │ + │Fn1││Mcm│Hom│Cal│Sel││Prv│Nxt│Ply│Stp││Mut│VoD│VoU│Mai││ │ │Tog│ └───┘└───┴───┴───┴───┘└───┴───┴───┴───┘└───┴───┴───┴───┘└───┘ └───┘ ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐ ┌───┐ │ │ │ │ │ │ │ │ │ │ │ │Spd│Spi│ │ │Mod│ ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤ ├───┤ - │ │ │ │ │ │ │ │ │Scr│ │ │ │ │ │ │Hui│ + │ │ │ │ │ │ │ │ │ │ │Prt│ │ │ │ │Hui│ ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤ ├───┤ - │ │ │ │ │ │ │ │ │ │ │ │ │ │ │Sai│ + │ │ │Scr│ │ │ │ │ │ │ │ │ │ │ │Sai│ ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────┬───┘ ├───┤ - │ │ │ │ │ │ │NKO│ │ │ │ │ │┌───┐│Sad│ + │ │ │ │ │ │ │Num│ │ │ │ │ │┌───┐│Sad│ ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬─────┘│Vai│└───┘ - │ │ │ │ │ │ │ ┌───┼───┼───┐ + │ │GTog│ │ │ │ │ ┌───┼───┼───┐ └────┴────┴────┴────────────────────────┴────┴────┘ │ │Vad│ │ └───┴───┴───┘ */ - /* Row: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */ + /* Row: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */ [_FN] = LAYOUT( - MO(_FN1), KC_MYCM, KC_WHOM, KC_CALC, KC_SLCT, KC_MPRV, KC_MNXT, KC_MPLY, KC_MSTP, KC_MUTE, KC_VOLD, KC_VOLU, KC_MAIL, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_SPD, RGB_SPI, _______, RGB_MOD, - _______, _______, _______, _______, _______, _______, _______, _______, KC_SCRL, _______, _______, _______, _______, _______, RGB_HUI, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_SAI, - _______, _______, _______, _______, _______, _______, NK_TOGG, _______, _______, _______, _______, _______, RGB_VAI, RGB_SAD, - _______, _______, _______, _______, _______, _______, _______, _______, RGB_VAD, _______ + QK_BOOT, KC_MYCM, KC_WHOM, KC_CALC, KC_SLCT, KC_MPRV, KC_MNXT, KC_MPLY, KC_MSTP, KC_MUTE, KC_VOLD, KC_VOLU, KC_MAIL, _______, _______, RGB_TOG, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_SPD, RGB_SPI, _______, RGB_MOD, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_PSCR, _______, _______, _______, RGB_HUI, + _______, _______, KC_SCRL, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_SAI, + _______, _______, _______, _______, _______, _______, KC_NUM, _______, _______, _______, _______, _______, RGB_VAI, RGB_SAD, + _______, GUI_TOG, _______, _______, _______, _______, _______, _______, RGB_VAD, _______ ), /* @@ -119,14 +135,14 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { └────┴────┴────┴────────────────────────┴────┴────┘ │ │ │ │ └───┴───┴───┘ */ - /* Row: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */ + /* Row: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */ [_FN1] = LAYOUT( - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, QK_BOOT, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ ), /* @@ -146,17 +162,101 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { └────┴────┴────┴────────────────────────┴────┴────┘ │ │ │ │ └───┴───┴───┘ */ - /* Row: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */ + /* Row: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */ [_FN2] = LAYOUT( - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ ), }; +void keyboard_post_init_user(void) { + user_config.raw = eeconfig_read_user(); + switch (user_config.rgb_mode) { + case RGB_MODE_ALL: + rgb_matrix_set_flags(LED_FLAG_ALL); + rgb_matrix_enable_noeeprom(); + break; + case RGB_MODE_KEYLIGHT: + rgb_matrix_set_flags(LED_FLAG_KEYLIGHT | LED_FLAG_MODIFIER | LED_FLAG_INDICATOR); + rgb_matrix_set_color_all(0, 0, 0); + break; + case RGB_MODE_UNDERGLOW: + rgb_matrix_set_flags(LED_FLAG_UNDERGLOW); + rgb_matrix_set_color_all(0, 0, 0); + break; + case RGB_MODE_NONE: + rgb_matrix_set_flags(LED_FLAG_NONE); + rgb_matrix_set_color_all(0, 0, 0); + break; + } +} + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + case RGB_TOG: + if (record->event.pressed) { + switch (rgb_matrix_get_flags()) { + case LED_FLAG_ALL: { + rgb_matrix_set_flags(LED_FLAG_KEYLIGHT | LED_FLAG_MODIFIER | LED_FLAG_INDICATOR); + rgb_matrix_set_color_all(0, 0, 0); + user_config.rgb_mode = RGB_MODE_KEYLIGHT; + } + break; + case (LED_FLAG_KEYLIGHT | LED_FLAG_MODIFIER | LED_FLAG_INDICATOR): { + rgb_matrix_set_flags(LED_FLAG_UNDERGLOW); + rgb_matrix_set_color_all(0, 0, 0); + user_config.rgb_mode = RGB_MODE_UNDERGLOW; + } + break; + case (LED_FLAG_UNDERGLOW): { + rgb_matrix_set_flags(LED_FLAG_NONE); + rgb_matrix_set_color_all(0, 0, 0); + user_config.rgb_mode = RGB_MODE_NONE; + } + break; + default: { + rgb_matrix_set_flags(LED_FLAG_ALL); + rgb_matrix_enable_noeeprom(); + user_config.rgb_mode = RGB_MODE_ALL; + } + break; + } + eeconfig_update_user(user_config.raw); + } + return false; + } + + return true; +} + +void rgb_matrix_indicators_user(void) { + rgb_matrix_set_color(46, 0, 0, 0); + rgb_matrix_set_color(104, 0, 0, 0); + + uint8_t red = host_keyboard_led_state().caps_lock ? 255 : 0; + uint8_t green = host_keyboard_led_state().scroll_lock ? 255 : 0; + uint8_t blue = keymap_config.no_gui ? 255 : 0; + + + if ((rgb_matrix_get_flags() & LED_FLAG_KEYLIGHT)) { + if (host_keyboard_led_state().num_lock) { + rgb_matrix_set_color(46, 255, 0, 0); + } + rgb_matrix_set_color(104, red, green, blue); + } else { + if (host_keyboard_led_state().num_lock) { + rgb_matrix_set_color(46, 255, 0, 0); + } else { + rgb_matrix_set_color(46, 0, 0, 0); + } + rgb_matrix_set_color(104, red, green, blue); + } +} + #ifdef ENCODER_ENABLE #define ENCODERS 3 @@ -196,4 +296,4 @@ bool encoder_update_user(uint8_t index, bool clockwise) { encoder_action_register(index, clockwise); return false; } -#endif \ No newline at end of file +#endif