keymap.c (3716B)
1 /* 2 Copyright 2018 Kenneth Aloysius 3 4 This program is free software: you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation, either version 2 of the License, or 7 (at your option) any later version. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License 15 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 #include QMK_KEYBOARD_H 18 19 enum layers { 20 _LAYER0, 21 _LAYER1, 22 _LAYER2, 23 _LAYER3, 24 _LAYER4 25 }; 26 27 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { 28 29 [_LAYER0] = LAYOUT( 30 /* ┌─────────┬─────────┬─────────┐ */ 31 KC_UP, TO(_LAYER1), 32 /* ├─────────┼─────────┼─────────┤ */ 33 KC_LEFT, KC_DOWN, KC_RIGHT 34 /* └─────────┴─────────┴─────────┘ */ 35 ), 36 37 [_LAYER1] = LAYOUT( 38 /* ┌─────────┬─────────┬─────────┐ */ 39 KC_PGUP, TO(_LAYER2), 40 /* ├─────────┼─────────┼─────────┤ */ 41 KC_HOME, KC_PGDN, KC_END 42 /* └─────────┴─────────┴─────────┘ */ 43 ), 44 45 [_LAYER2] = LAYOUT( 46 /* ┌─────────┬─────────┬─────────┐ */ 47 KC_MSEL, TO(_LAYER3), 48 /* ├─────────┼─────────┼─────────┤ */ 49 KC_MPRV, KC_MPLY, KC_MNXT 50 /* └─────────┴─────────┴─────────┘ */ 51 ), 52 53 [_LAYER3] = LAYOUT( 54 /* ┌─────────┬─────────┬─────────┐ */ 55 MS_UP, TO(_LAYER4), 56 /* ├─────────┼─────────┼─────────┤ */ 57 MS_LEFT, MS_DOWN, MS_RGHT 58 /* └─────────┴─────────┴─────────┘ */ 59 ), 60 61 [_LAYER4] = LAYOUT( 62 /* ┌─────────┬─────────┬─────────┐ */ 63 XXXXXXX, TO(_LAYER0), 64 /* ├─────────┼─────────┼─────────┤ */ 65 UG_TOGG, BL_TOGG, BL_STEP 66 /* └─────────┴─────────┴─────────┘ */ 67 ), 68 69 }; 70 71 void eeconfig_init_user(void) { 72 // use the non noeeprom versions, to write these values to EEPROM too 73 rgblight_enable(); 74 rgblight_mode(RGBLIGHT_MODE_BREATHING+1); 75 76 backlight_enable(); 77 } 78 79 void keyboard_post_init_user(void) { 80 //layer_state_set_user is not called for inital state - set it here 81 rgblight_sethsv_noeeprom(HSV_WHITE); 82 } 83 84 layer_state_t layer_state_set_user(layer_state_t state) { 85 switch (get_highest_layer(state)) { 86 case _LAYER1: 87 rgblight_sethsv_noeeprom(HSV_CYAN); 88 break; 89 case _LAYER2: 90 rgblight_sethsv_noeeprom(HSV_MAGENTA); 91 break; 92 case _LAYER3: 93 rgblight_sethsv_noeeprom(HSV_RED); 94 break; 95 case _LAYER4: 96 rgblight_sethsv_noeeprom(HSV_ORANGE); 97 break; 98 case _LAYER0: 99 default: // for any other layers, or the default layer 100 rgblight_sethsv_noeeprom(HSV_WHITE); 101 break; 102 } 103 return state; 104 }