]> git.donarmstrong.com Git - qmk_firmware.git/blob - keyboards/rgbkb/sol/keymaps/brianweyer/keymap.c
[Keyboard] Create RGBKB Folder (#5858)
[qmk_firmware.git] / keyboards / rgbkb / sol / keymaps / brianweyer / keymap.c
1 #include QMK_KEYBOARD_H
2 #ifdef PROTOCOL_LUFA
3 #include "lufa.h"
4 #include "split_util.h"
5 #endif
6
7 extern keymap_config_t keymap_config;
8
9 #ifdef RGBLIGHT_ENABLE
10 //Following line allows macro to read current RGB settings
11 extern rgblight_config_t rgblight_config;
12 #endif
13
14 // Each layer gets a name for readability, which is then used in the keymap matrix below.
15 // The underscores don't mean anything - you can have a layer called STUFF or any other name.
16 // Layer names don't all need to be of the same length, obviously, and you can also skip them
17 // entirely and just use numbers.
18 enum layer_number {
19     _QWERTY = 0,
20     _FN,
21     _ADJ
22 };
23
24 enum custom_keycodes {
25   QWERTY = SAFE_RANGE,
26   FN,
27   ADJ,
28   RGBRST
29 };
30
31
32 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
33   /* QWERTY
34    * ,------------------------------------------------.  ,------------------------------------------------.
35    * |   `  |   1  |   2  |   3  |   4  |   5  |   -  |  |   =  |   6  |   7  |   8  |   9  |   0  | Bspc |
36    * |------+------+------+------+------+------|------|  |------|------+------+------+------+------+------|
37    * |  Tab |   Q  |   W  |   E  |   R  |   T  |   [  |  |   ]  |   Y  |   U  |   I  |   O  |   P  |   \  |
38    * |------+------+------+------+------+------|------|  |------|------+------+------+------+------+------|
39    * |  Esc |   A  |   S  |   D  |   F  |   G  |      |  |      |   H  |   J  |   K  |   L  |   ;  |   '  |
40    * |------+------+------+------+------+------+------|  |------+------+------+------+------+------+------|
41    * | Shift|   Z  |   X  |   C  |   V  |   B  |      |  |      |   N  |   M  |   ,  |   .  |   /  | Shift|
42    * |------+------+------+------+------+------+------|  |------+------+------+------+------+------+------|
43    * | Ctrl |  Alt |  FN  | LGui |  RGB |  Spc |  Del |  | Bspc |  Spc |  Adj | LGui |  FN  |  Alt | Ctrl |
44    * |------+------+------+------+------+------+------|  |------+------+------+------+------+------+------|
45    *                                    |  Spc |  Ent |  |  Ent |  Spc |
46    *                                    `-------------'  `-------------'
47    */
48   [_QWERTY] = LAYOUT_kc( \
49   //,--------+--------+--------+--------+--------+--------+--+--------+.   ,--------+--+--------+--------+--------+--------+--------+--------+
50           GRV,       1,       2,       3,       4,       5,       MINS,          EQL,          6,       7,       8,       9,       0,    BSPC,
51   //|--------+--------+--------+--------+--------+--------+--+--------|    |--------+--+--------+--------+--------+--------+--------+--------|
52           TAB,       Q,       W,       E,       R,       T,       LBRC,         RBRC,          Y,       U,       I,       O,       P,    BSLS,
53   //|--------+--------+--------+--------+--------+--------+--+--------|    |--------+--+--------+--------+--------+--------+--------+--------|
54           ESC,       A,       S,       D,       F,       G,    _______,      _______,          H,       J,       K,       L,    SCLN,    QUOT,
55   //|--------+--------+--------+--------+--------+--------+--+--------|    |--------+--+--------+--------+--------+--------+--------+--------|
56          LSPO,       Z,       X,       C,       V,       B,    _______,      _______,          N,       M,    COMM,     DOT,    SLSH,    RSPC,
57   //|--------+--------+--------+--------+--------+--------+--+--------|    |--------+--+--------+--------+--------+--------+--------+--------|
58          LCTL,    LALT,      FN,    LGUI, RGB_MOD,        SPC,     DEL,         BSPC,        SPC,     ADJ,    LGUI,      FN,    LALT,    LCTL,
59   //|--------+--------+--------+--------+--------+--+--------+--------|    |--------+--+--------+--------+--------+--------+--------+--------|
60                                                           SPC,     ENT,          ENT,        SPC
61   //                                                |--------+--------|    |--------+-----------+
62       ),
63
64   /* FN
65    * ,------------------------------------------------.  ,------------------------------------------------.
66    * |  F1  |  F2  |  F3  |  F4  |  F5  |  F6  |      |  |      |  F7  |  F8  |  F9  |  F10 |  F11 |  F12 |
67    * |------+------+------+------+------+------|------|  |------|------+------+------+------+------+------|
68    * |      |      |      |  Up  |      |      |      |  |      |      |      |      |      |      |      |
69    * |------+------+------+------+------+------|------|  |------|------+------+------+------+------+------|
70    * |      |      | Left | Down | Right|      |      |  |      | Play | Next | Mute | V-Up |V-Down|      |
71    * |------+------+------+------+------+------+------|  |------+------+------+------+------+------+------|
72    * |      |      |      |      |      |      |      |  |      |      |      |      |      |      |      |
73    * |------+------+------+------+------+------+------|  |------+------+------+------+------+------+------|
74    * |      |      |      |      |      |      |      |  |      |      |      |      |      |      |      |
75    * |------+------+------+------+------+------+------|  |------+------+------+------+------+------+------|
76    *                                    |      |      |  |      |      |
77    *                                    `-------------'  `-------------'
78    */
79   [_FN] = LAYOUT_kc( \
80   //,--------+--------+--------+--------+--------+--------+--+--------+.   ,--------+--+--------+--------+--------+--------+--------+--------+
81            F1,      F2,      F3,      F4,      F5,      F6,    _______,      _______,         F7,      F8,      F9,     F10,     F11,     F12,
82   //|--------+--------+--------+--------+--------+--------+--+--------|    |--------+--+--------+--------+--------+--------+--------+--------|
83       _______, _______, _______,      UP, _______, _______,    _______,      _______,    _______, _______, _______, _______, _______, _______,
84   //|--------+--------+--------+--------+--------+--------+--+--------|    |--------+--+--------+--------+--------+--------+--------+--------|
85       _______, _______,    LEFT,    DOWN,    RGHT, _______,    _______,      _______,       MPLY,    MNXT,    MUTE,    VOLD,    VOLU, _______,
86   //|--------+--------+--------+--------+--------+--------+--+--------|    |--------+--+--------+--------+--------+--------+--------+--------|
87       _______, _______, _______, _______, _______, _______,    _______,      _______,    _______, _______, _______, _______, _______, _______,
88   //|--------+--------+--------+--------+--------+--------+--+--------|    |--------+--+--------+--------+--------+--------+--------+--------|
89       _______, _______, _______, _______, _______,    _______, _______,      _______,    _______, _______, _______, _______, _______, _______,
90   //|--------+--------+--------+--------+--------+--+--------+--------|    |--------+--+--------+--------+--------+--------+--------+--------|
91                                                       _______, _______,      _______,    _______
92   //                                                |--------+--------|    |--------+-----------+
93       ),
94
95   /* ADJ
96    * ,------------------------------------------------.  ,------------------------------------------------.
97    * |      |      |      |      |      |      |      |  |      |      |      |      |      |      |      |
98    * |------+------+------+------+------+------|------|  |------|------+------+------+------+------+------|
99    * |      | Sat+ | Val+ | Hue+ |Speed+|Toggle|      |  |      |      |      |      |      |      |      |
100    * |------+------+------+------+------+------|------|  |------|------+------+------+------+------+------|
101    * |      | Sat- | Val- | Hue- |Speed-|Reset |      |  |      |      |QWERTY| COLE |      |      |      |
102    * |------+------+------+------+------+------+------|  |------+------+------+------+------+------+------|
103    * |      |      |      |      |      |      |      |  |      |      |      |      |      |      |      |
104    * |------+------+------+------+------+------+------|  |------+------+------+------+------+------+------|
105    * |      |      |      |      |      |      |      |  |      |      |      |      |      |      |      |
106    * |------+------+------+------+------+------+------|  |------+------+------+------+------+------+------|
107    *                                    |      |      |  |      |      |
108    *                                    `-------------'  `-------------'
109    */
110
111   [_ADJ] =  LAYOUT( \
112   //,--------+--------+--------+--------+--------+--------+--+--------+.   ,--------+--+--------+--------+--------+--------+--------+--------+
113         RESET, _______, _______, _______, _______, _______,    _______,      _______,    _______, _______, _______, _______, _______,   RESET, \
114   //|--------+--------+--------+--------+--------+--------+--+--------|    |--------+--+--------+--------+--------+--------+--------+--------|
115       _______, RGB_SAI, RGB_VAI, RGB_HUI, RGB_SPI, RGB_TOG,    _______,      _______,    _______, _______, _______, _______, _______, _______, \
116   //|--------+--------+--------+--------+--------+--------+--+--------|    |--------+--+--------+--------+--------+--------+--------+--------|
117       _______, RGB_SAD, RGB_VAD, RGB_HUD, RGB_SPD,  RGBRST,    _______,      _______,    _______, _______, _______, _______, _______, _______, \
118   //|--------+--------+--------+--------+--------+--------+--+--------|    |--------+--+--------+--------+--------+--------+--------+--------|
119       _______, _______, _______, _______, _______, _______,    _______,      _______,    _______, _______, _______, _______, _______, _______, \
120   //|--------+--------+--------+--------+--------+--------+--+--------|    |--------+--+--------+--------+--------+--------+--------+--------|
121       _______, _______, _______, _______, _______,    _______, _______,      _______, _______,    _______, _______, _______, _______, _______, \
122   //|--------+--------+--------+--------+--------+--+--------+--------|    |--------+--------+--+--------+--------+--------+--------+--------|
123                                                       _______, _______,      _______, _______ \
124   //                                                |--------+--------|    |--------+--------+
125       )
126 };
127
128
129 // define variables for reactive RGB
130 bool TOG_STATUS = false;
131 int RGB_current_mode;
132
133 #ifdef ENCODER_ENABLE
134 void encoder_update_user(uint8_t index, bool clockwise) {
135   if (index == 0) { /* First encoder */
136     if (clockwise) {
137       tap_code(KC_VOLU);
138     } else {
139       tap_code(KC_VOLD);
140     }
141   } else if (index == 1) { /* Second encoder*/
142     if (clockwise) {
143       tap_code(KC_UP);
144     } else {
145       tap_code(KC_DOWN);
146     }
147   }
148 }
149 #endif
150
151 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
152
153   switch (keycode) {
154     case QWERTY:
155       if (record->event.pressed) {
156         set_single_persistent_default_layer(_QWERTY);
157       }
158       return false;
159       break;
160     case FN:
161       if (record->event.pressed) {
162         layer_on(_FN);
163       } else {
164         layer_off(_FN);
165       }
166       return false;
167       break;
168     case ADJ:
169         if (record->event.pressed) {
170           layer_on(_ADJ);
171         } else {
172           layer_off(_ADJ);
173         }
174         return false;
175         break;
176       //led operations - RGB mode change now updates the RGB_current_mode to allow the right RGB mode to be set after reactive keys are released
177     case RGBRST:
178       #ifdef RGBLIGHT_ENABLE
179         if (record->event.pressed) {
180           eeconfig_update_rgblight_default();
181           rgblight_enable();
182           RGB_current_mode = rgblight_config.mode;
183         }
184       #endif
185       break;
186   }
187   return true;
188 }
189
190 void matrix_init_user(void) {
191 #ifdef RGBLIGHT_ENABLE
192   RGB_current_mode = rgblight_config.mode;
193 #endif
194 }
195
196
197 // OLED Driver Logic
198 #ifdef OLED_DRIVER_ENABLE
199
200 oled_rotation_t oled_init_user(oled_rotation_t rotation) {
201   if (!is_keyboard_master())
202     return OLED_ROTATION_180;  // flip 180 for offhand
203   return rotation;
204 }
205
206 static void render_logo(void) {
207   static const char PROGMEM sol_logo[] = {
208     0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,0x90,0x91,0x92,0x93,0x94,
209     0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,0xb0,0xb1,0xb2,0xb3,0xb4,
210     0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,0xd0,0xd1,0xd2,0xd3,0xd4,0};
211
212   oled_write_P(sol_logo, false);
213 }
214
215 //assign the right code to your layers for OLED display
216 #define L_BASE 0
217 #define L_FN (1<<_FN)
218 #define L_ADJ (1<<_ADJ)
219 #define L_ADJ_TRI (L_ADJ|L_FN)
220
221 static void render_status(void) {
222   // Render to mode icon
223   static const char PROGMEM mode_logo[4][4] = {
224     {0x95,0x96,0x0a,0},
225     {0xb5,0xb6,0x0a,0},
226     {0x97,0x98,0x0a,0},
227     {0xb7,0xb8,0x0a,0} };
228
229   if (keymap_config.swap_lalt_lgui != false) {
230     oled_write_P(mode_logo[0], false);
231     oled_write_P(mode_logo[1], false);
232   } else {
233     oled_write_P(mode_logo[2], false);
234     oled_write_P(mode_logo[3], false);
235   }
236
237   // Define layers here, Have not worked out how to have text displayed for each layer. Copy down the number you see and add a case for it below
238
239   oled_write_P(PSTR("Layer: "), false);
240   switch (layer_state) {
241     case L_BASE:
242       oled_write_P(PSTR("Laser     \n"), false);
243       break;
244     case L_FN:
245       oled_write_P(PSTR("Function  \n"), false);
246       break;
247     case L_ADJ:
248     case L_ADJ_TRI:
249       oled_write_P(PSTR("Adjustment\n"), false);
250       break;
251     default:
252       oled_write_P(PSTR("Undefined \n"), false);
253   }
254
255   // Host Keyboard LED Status
256   uint8_t led_usb_state = host_keyboard_leds();
257   oled_write_P(led_usb_state & (1<<USB_LED_NUM_LOCK) ? PSTR("NUMLOCK ") : PSTR("        "), false);
258   oled_write_P(led_usb_state & (1<<USB_LED_CAPS_LOCK) ? PSTR("CAPS ") : PSTR("     "), false);
259   oled_write_P(led_usb_state & (1<<USB_LED_SCROLL_LOCK) ? PSTR("SCLK ") : PSTR("     "), false);
260 }
261
262 void oled_task_user(void) {
263   if (is_keyboard_master())
264     render_status();
265   else
266     render_logo();
267 }
268
269 #endif