From 40676d058ec74acec9357212bc8c8b5d878e29cf Mon Sep 17 00:00:00 2001 From: p4yne Date: Sat, 13 Aug 2022 22:12:31 +0200 Subject: [Keymap] adding new user (p4yne) layout with complex lighting feature… (#16085) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [Keymap] adding new user (p4yne) layout with complex lighting features (per layer, per key, per type) and usefull layers DE/US, etc. Co-authored-by: Drashna Jaelre --- .../bm65hsrgb_iso/keymaps/p4yne/config.h | 36 ++ .../bm65hsrgb_iso/keymaps/p4yne/custom_keymap.h | 71 ++++ .../bm65hsrgb_iso/keymaps/p4yne/keymap.c | 471 +++++++++++++++++++++ .../bm65hsrgb_iso/keymaps/p4yne/readme.md | 22 + .../bm65hsrgb_iso/keymaps/p4yne/rules.mk | 23 + 5 files changed, 623 insertions(+) create mode 100644 keyboards/kprepublic/bm65hsrgb_iso/keymaps/p4yne/config.h create mode 100644 keyboards/kprepublic/bm65hsrgb_iso/keymaps/p4yne/custom_keymap.h create mode 100644 keyboards/kprepublic/bm65hsrgb_iso/keymaps/p4yne/keymap.c create mode 100644 keyboards/kprepublic/bm65hsrgb_iso/keymaps/p4yne/readme.md create mode 100644 keyboards/kprepublic/bm65hsrgb_iso/keymaps/p4yne/rules.mk diff --git a/keyboards/kprepublic/bm65hsrgb_iso/keymaps/p4yne/config.h b/keyboards/kprepublic/bm65hsrgb_iso/keymaps/p4yne/config.h new file mode 100644 index 0000000000..0e06652715 --- /dev/null +++ b/keyboards/kprepublic/bm65hsrgb_iso/keymaps/p4yne/config.h @@ -0,0 +1,36 @@ +/* Copyright 2021 deadolus 2022 p4yne + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +// place overrides here + +#pragma once +#define LSPO_KEYS KC_LSFT, KC_LSFT, KC_8 +#define RSPC_KEYS KC_RSFT, KC_LSFT, KC_9 +#define LAPO_KEYS KC_LALT, KC_RALT, KC_QUOT +#define RAPC_KEYS KC_RALT, KC_RALT, KC_NUHS + +#define LEADER_TIMEOUT 1000 +#define LEADER_PER_KEY_TIMING 250 + +// control underglow +// i.e. switch it off +//#define RGBLIGHT_DEFAULT_MODE RGBLIGHT_MODE_STATIC_LIGHT +//#define RGBLIGHT_DEFAULT_HUE 0 +//#define RGBLIGHT_DEFAULT_SAT UINT8_MAX +//#define RGBLIGHT_DEFAULT_SAT 0 +//#define RGBLIGHT_DEFAULT_VAL RGBLIGHT_LIMIT_VAL +//#define RGBLIGHT_DEFAULT_VAL 0 +//#define RGBLIGHT_DEFAULT_SPD 0 diff --git a/keyboards/kprepublic/bm65hsrgb_iso/keymaps/p4yne/custom_keymap.h b/keyboards/kprepublic/bm65hsrgb_iso/keymaps/p4yne/custom_keymap.h new file mode 100644 index 0000000000..8f11e4072b --- /dev/null +++ b/keyboards/kprepublic/bm65hsrgb_iso/keymaps/p4yne/custom_keymap.h @@ -0,0 +1,71 @@ +/* Copyright 2019 ash0x0 2021 peepeetee, deadolus 2022 p4yne + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#include QMK_KEYBOARD_H + +#include "print.h" +#include +// HID has not yet been implemented for this keyboard +// #include "raw_hid.h" + +#define MILLISECONDS_IN_SECOND 1000 + +// Custom HSV values +#define C_HSV_WINERED 0, 255, 85 +#define C_HSV_DARKGOLD 36, 255, 85 +#define C_HSV_DARKBLUE 170, 255, 85 + +// Default color HSV Values (for inspiration) +// #define HSV_AZURE 132, 102, 255 +// #define HSV_BLACK 0, 0, 0 +// #define HSV_BLUE 170, 255, 255 +// #define HSV_CHARTREUSE 64, 255, 255 +// #define HSV_CORAL 11, 176, 255 +// #define HSV_CYAN 128, 255, 255 +// #define HSV_GOLD 36, 255, 255 +// #define HSV_GOLDENROD 30, 218, 218 +// #define HSV_GREEN 85, 255, 255 +// #define HSV_MAGENTA 213, 255, 255 +// #define HSV_ORANGE 28, 255, 255 +// #define HSV_PINK 234, 128, 255 +// #define HSV_PURPLE 191, 255, 255 +// #define HSV_RED 0, 255, 255 +// #define HSV_SPRINGGREEN 106, 255, 255 +// #define HSV_TEAL 128, 255, 128 +// #define HSV_TURQUOISE 123, 90, 112 +// #define HSV_WHITE 0, 0, 255 +// #define HSV_YELLOW 43, 255, 255 +// #define HSV_OFF HSV_BLACK + + +//========================================================== CONFIGURABLE DEFAULTS ========================================================== +#define RGB_DEFAULT_TIME_OUT 30 +#define RGB_FAST_MODE_TIME_OUT 3 +#define RGB_TIME_OUT_MAX 600 +#define RGB_TIME_OUT_MIN 10 +#define RGB_TIME_OUT_STEP 10 + +bool disable_layer_color; + +uint8_t dfa_state; //state for my language switching DFA + + +bool rgb_enabled_flag; // Current LED state flag. If false then LED is off. +bool rgb_time_out_enable; // Idle LED toggle enable. If false then LED will not turn off after idle timeout. +bool rgb_time_out_fast_mode_enabled; // Enable flag for RGB timeout fast mode +bool rgb_time_out_user_value; // This holds the toggle value set by user with ROUT_TG. It's necessary as RGB_TOG changes timeout enable. +uint16_t rgb_time_out_seconds; // Idle LED timeout value, in seconds not milliseconds +uint16_t rgb_time_out_saved_seconds; // The saved user config for RGB timeout period +led_flags_t rgb_time_out_saved_flag; // Store LED flag before timeout so it can be restored when LED is turned on again. diff --git a/keyboards/kprepublic/bm65hsrgb_iso/keymaps/p4yne/keymap.c b/keyboards/kprepublic/bm65hsrgb_iso/keymaps/p4yne/keymap.c new file mode 100644 index 0000000000..442111bb6e --- /dev/null +++ b/keyboards/kprepublic/bm65hsrgb_iso/keymaps/p4yne/keymap.c @@ -0,0 +1,471 @@ +/* Copyright 2019 ashlar 2021 peepeetee, deadolus 2022 p4yne + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#include QMK_KEYBOARD_H +#include "custom_keymap.h" +#include "sendstring_german.h" + +#ifdef TAP_DANCE_ENABLE +enum { + TD_HOME_END, +}; + +// Tap Dance definitions +qk_tap_dance_action_t tap_dance_actions[] = { + // tap once for home, twice for end + [TD_HOME_END] = ACTION_TAP_DANCE_DOUBLE(KC_HOME, KC_END) +}; +#endif + +// Custom layer types +enum layertypes { + LYR_SOLID, // fullsize coloring + LYR_TRANS, // used keys in layer color, lower layer shines through on unused keys + LYR_BLACK // only used key in layer color +}; + +// Defines names for use in layer keycodes and the keymap +enum layers { + _LVL0_, + _LVL1_, + _LVL2_, + _LVL3_, + _LVL4_, + _LVL5_, + _LVL6_, + _LVL7_ +}; + + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* + * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┬───┐ + * │ ` │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 0 │ - │ = │ Backsp│Hom│ + * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┼───┤ + * │ Tab │ Q │ W │ E │ R │ T │ Y │ U │ I │ O │ P │ [ │ ] │ │PgU│ + * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐ Ent├───┤ + * │ Caps │ A │ S │ D │ F │ G │ H │ J │ K │ L │ ; │ ' │ # │ │PgD│ + * ├────┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┴┬───┼───┤ + * │Shft│ \ │ Z │ X │ C │ V │ B │ N │ M │ , │ . │ / │ Shift│ ↑ │End│ + * ├────┼───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬─┬───┼───┼───┤ + * │Ctrl│GUI │Alt │ │ Alt│Ctrl│ │ ← │ ↓ │ → │ + * └────┴────┴────┴────────────────────────┴────┴────┘ └───┴───┴───┘ + */ +#ifdef TAP_DANCE_ENABLE +/* 0: ISO qwertz, SPACECADET and TAPDANCE */ +/* [_LVL0_] = LAYOUT_65_iso_blocker( + 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_BSPC, KC_DEL, + 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, TD(TD_HOME_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_NUHS, KC_ENT, KC_PGUP, + KC_LSPO, KC_NUBS, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSPC, KC_UP, KC_PGDN, + KC_LCTL, KC_LGUI, KC_LAPO, KC_SPC, KC_RAPC, MO(_LVL1_), KC_LEFT, KC_DOWN, KC_RGHT + ), + */ +/* 0: ISO DE qwertz, SPACECADET and TAPDANCE */ + [_LVL0_] = LAYOUT_65_iso_blocker( + KC_ESC, DE_1, DE_2, DE_3, DE_4, DE_5, DE_6, DE_7, DE_8, DE_9, DE_0, DE_SS, DE_ACUT, KC_BSPC, KC_DEL, + KC_TAB, DE_Q, DE_W, DE_E, DE_R, DE_T, DE_Z, DE_U, DE_I, DE_O, DE_P, DE_UDIA, DE_PLUS, TD(TD_HOME_END), + KC_CAPS, DE_A, DE_S, DE_D, DE_F, DE_G, DE_H, DE_J, DE_K, DE_L, DE_ODIA, DE_ADIA, DE_HASH, KC_ENT, KC_PGUP, + KC_LSPO, DE_LABK, DE_Y, DE_X, DE_C, DE_V, DE_B, DE_N, DE_M, DE_COMM, DE_DOT, DE_MINS, KC_RSPC, KC_UP, KC_PGDN, + KC_LCTL, KC_LGUI, KC_LAPO, KC_SPC, KC_RAPC, MO(_LVL1_), KC_LEFT, KC_DOWN, KC_RGHT + ), +#else + /* 0: ISO qwertz, SPACECADET but no TAPDANCE */ + [_LVL0_] = LAYOUT_65_iso_blocker( + 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_BSPC, KC_DEL, + 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_ENT, KC_HOME, + 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_NUHS, KC_PGUP, + KC_LSPO, KC_NUBS, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSPC, KC_UP, KC_PGDN, + KC_LCTL, KC_LGUI, KC_LAPO, KC_SPC, KC_RAPC, MO(_LVL1_), KC_LEFT, KC_DOWN, KC_RGHT + ), +#endif + /* 1: Function key, multimedia control, layer switching board and LEADER */ + [_LVL1_] = LAYOUT_65_iso_blocker( + KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, LGUI(KC_END), + S(KC_GRV), _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, LGUI(KC_PAUSE), + QK_BOOT, TO(_LVL2_), TO(_LVL3_), TO(_LVL4_), TO(_LVL5_), TO(_LVL6_), TO(_LVL7_), _______, _______, _______, KC_BRIU, _______, KC_MUTE, TO(_LVL0_), KC_VOLU, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_BRID, _______, S(KC_MUTE), KC_MPLY, KC_VOLD, + _______, _______, _______, KC_LEAD, _______, _______, KC_MPRV, KC_MSTP, KC_MNXT + ), + /* 2: Mouse layer and virtual/multiple desktop navigation */ + [_LVL2_] = LAYOUT_65_iso_blocker( + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, KC_ACL0, KC_ACL1, KC_ACL2, _______, _______, _______, KC_PGDN, KC_PGUP, KC_PSCR, KC_WH_U, _______, _______, _______, + _______, _______, KC_BTN1, KC_BTN2, _______, _______, KC_MS_L, KC_MS_D, KC_MS_U, KC_MS_R, KC_WH_D, _______, _______, TO(_LVL0_), _______, + _______, _______, _______, _______, _______, _______, _______, KC_HOME, KC_END, _______, _______, _______, _______, LCA(KC_UP), LCA(KC_E), + _______, _______, _______, _______, _______, _______, LCA(KC_LEFT), LCA(KC_DOWN), LCA(KC_RGHT) + ), +#ifdef DYNAMIC_MACRO_ENABLE + /* 3: Dynamic macro, NUMPAD and settings */ + [_LVL3_] = LAYOUT_65_iso_blocker( + _______, DM_PLY1, DM_PLY2, _______, _______, _______, _______, _______, _______, KC_NLCK, KC_PSLS, KC_PAST, KC_PMNS, _______, _______, + _______, DM_REC1, DM_REC2, _______, RGB_MOD, RGB_HUI, RGB_SAI, RGB_VAI, _______, KC_P7, KC_P8, KC_P9, KC_PMNS, _______, + _______, _______, _______, _______, RGB_RMOD, RGB_HUD, RGB_SAD, RGB_VAD, _______, KC_P4, KC_P5, KC_P6, KC_PPLS, TO(_LVL0_), _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_P1, KC_P2, KC_P3, KC_PENT, _______, _______, + _______, _______, _______, RGB_TOG, KC_0, KC_PCMM, _______, _______, _______ + ), +#else + /* 3: NUMPAD and settings */ + [_LVL3_] = LAYOUT_65_iso_blocker( + _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_NLCK, KC_PSLS, KC_PAST, KC_PMNS, _______, _______, + _______, _______, _______, _______, RGB_MOD, RGB_HUI, RGB_SAI, RGB_VAI, _______, KC_P7, KC_P8, KC_P9, KC_PMNS, _______, + _______, _______, _______, _______, RGB_RMOD, RGB_HUD, RGB_SAD, RGB_VAD, _______, KC_P4, KC_P5, KC_P6, KC_PPLS, TO(_LVL0_), _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_P1, KC_P2, KC_P3, KC_PENT, _______, _______, + _______, _______, _______, RGB_TOG, KC_0, KC_PCMM, _______, _______, _______ + ), +#endif + /* Gaming layer no TAPDANCE no SPACECADET simple QWERTZ layout for custom coloring */ + [_LVL4_] = LAYOUT_65_iso_blocker( + 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_BSPC, KC_DEL, + 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_HOME, + 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_NUHS, KC_ENT, KC_PGUP, + KC_LSFT, KC_NUBS, 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_PGDN, + KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, TO(_LVL0_), KC_LEFT, KC_DOWN, KC_RGHT + ), + /* 5: ISO qwerty DE 2 US Base Layer */ + [_LVL5_] = LAYOUT_65_iso_blocker( + KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, DE_MINS, DE_EQL, KC_BSPC, KC_DEL, + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, DE_Y, KC_U, KC_I, KC_O, KC_P, DE_LBRC, DE_RBRC, KC_HOME, + KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, DE_SCLN, DE_QUOT, DE_BSLS, KC_ENT, KC_PGUP, + MO(_LVL6_), DE_GRV, DE_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, DE_COMM, DE_DOT, DE_SLSH, MO(_LVL6_), KC_UP, KC_PGDN, + KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, TO(_LVL0_), KC_LEFT, KC_DOWN, KC_RGHT + ), + /* 6: ISO qwerty DE 2 US Shifted Layer */ + [_LVL6_] = LAYOUT_65_iso_blocker( + _______, DE_EXLM, DE_AT, DE_HASH, DE_DLR, DE_PERC, DE_CIRC, DE_AMPR, DE_ASTR, DE_LPRN, DE_RPRN, DE_UNDS, DE_PLUS, _______, _______, + _______, S(KC_Q), S(KC_W), S(KC_E), S(KC_R), S(KC_T), S(DE_Y), S(KC_U), S(KC_I), S(KC_O), S(KC_P), DE_LCBR, DE_RCBR, KC_END, + KC_CAPS, S(KC_A), S(KC_S), S(KC_D), S(KC_F), S(KC_G), S(KC_H), S(KC_J), S(KC_K), S(KC_L), DE_COLN, DE_DQUO, DE_PIPE, _______, _______, + KC_LSFT, DE_TILD, S(DE_Z), S(KC_X), S(KC_C), S(KC_V), S(KC_B), S(KC_N), S(KC_M), DE_LABK, DE_RABK, DE_QUES, KC_RSFT, _______, _______, + _______, _______, _______, _______, _______, TO(_LVL0_), _______, _______, _______ + ), +/* Led Type Lighting Layer functionally equivalent to _LVL0_ / layer 0 */ +#ifdef TAP_DANCE_ENABLE + /* 7: ISO DE qwertz, SPACECADET and TAPDANCE */ + [_LVL7_] = LAYOUT_65_iso_blocker( + KC_ESC, DE_1, DE_2, DE_3, DE_4, DE_5, DE_6, DE_7, DE_8, DE_9, DE_0, DE_SS, DE_ACUT, KC_BSPC, KC_DEL, + KC_TAB, DE_Q, DE_W, DE_E, DE_R, DE_T, DE_Z, DE_U, DE_I, DE_O, DE_P, DE_UDIA, DE_PLUS, TD(TD_HOME_END), + KC_CAPS, DE_A, DE_S, DE_D, DE_F, DE_G, DE_H, DE_J, DE_K, DE_L, DE_ODIA, DE_ADIA, DE_HASH, KC_ENT, KC_PGUP, + KC_LSPO, DE_LABK, DE_Y, DE_X, DE_C, DE_V, DE_B, DE_N, DE_M, DE_COMM, DE_DOT, DE_MINS, KC_RSPC, KC_UP, KC_PGDN, + KC_LCTL, KC_LGUI, KC_LAPO, KC_SPC, KC_RAPC, TO(_LVL0_), KC_LEFT, KC_DOWN, KC_RGHT + ), +#else + /* 7: ISO qwertz, SPACECADET but no TAPDANCE */ + [_LVL7_] = LAYOUT_65_iso_blocker( + 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_BSPC, KC_DEL, + 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_HOME, + 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_NUHS, KC_ENT, KC_PGUP, + KC_LSPO, KC_NUBS, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSPC, KC_UP, KC_PGDN, + KC_LCTL, KC_LGUI, KC_LAPO, KC_SPC, KC_RAPC, TO(_LVL0_), KC_LEFT, KC_DOWN, KC_RGHT + ), +#endif + + + /*template + [_UL] = LAYOUT_65_iso_blocker( + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, TO(0), _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______ + ) + */ +}; + + +// layer color and type +const uint8_t PROGMEM ledmap[][4] = { + // LEDs off on Layer 0 + //[_LVL0_] = {{0, 0, 0}, LYR_SOLID}, + [_LVL0_] = {C_HSV_WINERED, LYR_SOLID}, + [_LVL1_] = {HSV_RED, LYR_TRANS}, + [_LVL2_] = {HSV_MAGENTA, LYR_BLACK}, + [_LVL3_] = {HSV_PURPLE, LYR_BLACK}, + [_LVL4_] = {C_HSV_DARKGOLD, LYR_SOLID}, + [_LVL5_] = {C_HSV_DARKBLUE, LYR_SOLID}, + [_LVL6_] = {HSV_BLUE, LYR_TRANS}, + [_LVL7_] = {C_HSV_WINERED, LYR_SOLID} +}; + + +void keyboard_post_init_user(void) { + // Call the post init code. +#ifdef CONSOLE_ENABLE + debug_enable=true; + debug_matrix=true; +#endif + //rgb_matrix_set_flags(LED_FLAG_UNDERGLOW); + //rgb_matrix_set_flags(LED_FLAG_NONE); + rgb_matrix_set_flags(LED_FLAG_KEYLIGHT | LED_FLAG_MODIFIER | LED_FLAG_INDICATOR); + //rgb_matrix_mode(RGB_MATRIX_SOLID_COLOR); + //rgb_matrix_sethsv(HSV_OFF); + //rgb_matrix_mode_noeeprom(RGB_MATRIX_SOLID_COLOR); + //rgb_matrix_sethsv_noeeprom(HSV_OFF); + //rgb_matrix_set_color_all(RGB_BLACK); + rgb_matrix_enable(); +} + + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { +#ifdef CONSOLE_ENABLE + // useful for getting matrix right + uprintf("KL: kc: 0x%04X, col: %u, row: %u, pressed: %u, time: %u, interrupt: %u, count: %u\n", keycode, record->event.key.col, record->event.key.row, record->event.pressed, record->event.time, record->tap.interrupted, record->tap.count); +#endif + + 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(RGB_BLACK); + } + break; + case (LED_FLAG_KEYLIGHT | LED_FLAG_MODIFIER | LED_FLAG_INDICATOR): { + rgb_matrix_set_flags(LED_FLAG_UNDERGLOW); + rgb_matrix_set_color_all(RGB_BLACK); + } + break; + case LED_FLAG_UNDERGLOW: { + rgb_matrix_set_flags(LED_FLAG_NONE); + rgb_matrix_disable_noeeprom(); + } + break; + default: { + rgb_matrix_set_flags(LED_FLAG_ALL); + rgb_matrix_enable_noeeprom(); + } + break; + } + } + return false; + default: + return true; // Process all other keycodes normally + } +} + + +void set_led_color_by_hsv(int ledkey, uint8_t h_in, uint8_t s_in, uint8_t v_in){ + HSV hsv = { .h = h_in, .s = s_in, .v = v_in}; + RGB rgb = hsv_to_rgb(hsv); + float f = (float)rgb_matrix_config.hsv.v / UINT8_MAX; + rgb_matrix_set_color(ledkey, f * rgb.r, f * rgb.g, f * rgb.b); +} + +void set_led_color_by_layer(int layer, int ledkey){ + set_led_color_by_hsv(ledkey, pgm_read_byte(&ledmap[layer][0]), + pgm_read_byte(&ledmap[layer][1]), + pgm_read_byte(&ledmap[layer][2])); +} + +void set_ledkey_by_layer_type(int layer, int ledkey, uint16_t key){ + if (rgb_matrix_get_flags() != LED_FLAG_ALL){ + if ( key == KC_TRNS ) { + if ((pgm_read_byte(&ledmap[layer][3]) == LYR_TRANS) && (layer > 0)){ + // this key is transparent and the layer below does something + // - light it up in (lower) layer-1 specific color + set_led_color_by_layer(layer-1, ledkey); + } + if (pgm_read_byte(&ledmap[layer][3]) == LYR_BLACK){ + // this key is transparent but the lower layer is not intended + // to be used, it still works but not intended; type BLACK + set_led_color_by_hsv(ledkey, HSV_BLACK); + } + } else { + // this key does something - light it up in layer specific color + // regular key and SOLID or BLACK as layer type + set_led_color_by_layer(layer, ledkey); + } + } +} + +void set_caps_lock(int layer) { + int caps_lock_led = 30; + led_t host_leds = host_keyboard_led_state(); + if (host_leds.caps_lock) { + set_led_color_by_hsv(caps_lock_led, HSV_WHITE); + } else { + // if capslock is not pressed don't clear it, + // it might be used for displaying led pattern + if((rgb_matrix_get_flags() != LED_FLAG_ALL)) { + // or to keep the correct lighting on for the layer that use all keys + // on all other layers turn the led off, so only switch it of when + // layer is BLACK + if(pgm_read_byte(&ledmap[layer][3]) == LYR_BLACK){ + set_led_color_by_hsv(caps_lock_led, HSV_BLACK); + } + } + } +} + +void set_layer_color(int layer) { + // key specific lighting + int ledkey=0; + for (int keyindex=0; keyindex