]> git.donarmstrong.com Git - qmk_firmware.git/blob - keyboards/staryu/keymaps/default/keymap.c
Refactor staryu to current standards and enable support for backlight keycodes (...
[qmk_firmware.git] / keyboards / staryu / keymaps / default / keymap.c
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               KC_MS_U,  TO(_LAYER4),
56 /* ├─────────┼─────────┼─────────┤ */
57     KC_MS_L,  KC_MS_D,  KC_MS_R
58 /* └─────────┴─────────┴─────────┘ */
59   ),
60
61   [_LAYER4] = LAYOUT(
62 /* ┌─────────┬─────────┬─────────┐ */
63               XXXXXXX,  TO(_LAYER0),
64 /* ├─────────┼─────────┼─────────┤ */
65     RGB_TOG,  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_white();
82 }
83
84 uint32_t layer_state_set_user(uint32_t state) {
85   switch (biton32(state)) {
86     case _LAYER1:
87         rgblight_sethsv_noeeprom_cyan();
88         break;
89     case _LAYER2:
90         rgblight_sethsv_noeeprom_magenta();
91         break;
92     case _LAYER3:
93         rgblight_sethsv_noeeprom_red();
94         break;
95     case _LAYER4:
96         rgblight_sethsv_noeeprom_orange();
97         break;
98     case _LAYER0:
99     default: //  for any other layers, or the default layer
100         rgblight_sethsv_noeeprom_white();
101         break;
102     }
103   return state;
104 }