]> git.donarmstrong.com Git - qmk_firmware.git/blob - keyboards/hadron/ver2/keymaps/default/keymap.c
Remove/migrate action_get_macro()s from default keymaps (#5625)
[qmk_firmware.git] / keyboards / hadron / ver2 / keymaps / default / keymap.c
1 #include QMK_KEYBOARD_H
2 #ifdef USE_I2C
3 #include "i2c.h"
4 #endif
5 #ifdef SSD1306OLED
6 #include "ssd1306.h"
7 #endif
8 extern keymap_config_t keymap_config;
9
10 //Following line allows macro to read current RGB settings
11 extern rgblight_config_t rgblight_config;
12
13 // Each layer gets a name for readability, which is then used in the keymap matrix below.
14 // The underscores don't mean anything - you can have a layer called STUFF or any other name.
15 // Layer names don't all need to be of the same length, obviously, and you can also skip them
16 // entirely and just use numbers.
17 #define _QWERTY 0
18 #define _COLEMAK 1
19 #define _DVORAK 2
20 #define _LOWER 3
21 #define _RAISE 4
22 #define _MOUSECURSOR 8
23 #define _ADJUST 16
24
25 enum preonic_keycodes {
26   QWERTY = SAFE_RANGE,
27   COLEMAK,
28   DVORAK,
29   LOWER,
30   RAISE,
31   BACKLIT,
32   RGBLED_TOGGLE,
33   RGBLED_STEP_MODE,
34   RGBLED_INCREASE_HUE,
35   RGBLED_DECREASE_HUE,
36   RGBLED_INCREASE_SAT,
37   RGBLED_DECREASE_SAT,
38   RGBLED_INCREASE_VAL,
39   RGBLED_DECREASE_VAL,
40   DEMOMACRO
41 };
42
43 // Custom macros
44 #define CTL_ESC     CTL_T(KC_ESC)               // Tap for Esc, hold for Ctrl
45 #define CTL_TTAB    CTL_T(KC_TAB)               // Tap for Esc, hold for Ctrl
46 #define CTL_ENT     CTL_T(KC_ENT)               // Tap for Enter, hold for Ctrl
47 #define SFT_ENT     SFT_T(KC_ENT)               // Tap for Enter, hold for Shift
48 // Requires KC_TRNS/_______ for the trigger key in the destination layer
49 #define LT_MC(kc)   LT(_MOUSECURSOR, kc)        // L-ayer T-ap M-ouse C-ursor
50 #define LT_RAI(kc)  LT(_RAISE, kc)              // L-ayer T-ap to Raise
51
52
53 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
54
55 /* Qwerty
56  * ,------+------+------+------+------+------------------------------------------------.
57  * | Esc  |  F1  |  F2  |  F3  |  F4  |  F5  |  F6  |  F7  |  F8  |  F9  |  F10 |  DEL |
58  * |------+------+------+------+------+------+------+------+------+------+------+------+--------------------.
59  * | Tab  |   Q  |   W  |   E  |   R  |   T  |   7  |   8  |   9  |   Y  |   U  |   I  |   O  |   P  | Bksp |
60  * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
61  * | CAPS |   A  |   S  |   D  |   F  |   G  |   4  |   5  |   6  |   H  |   J  |   K  |   L  | ;/Nav|  '   |
62  * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
63  * | Shift|   Z  |   X  |   C  |   V  |   B  |   1  |   2  |   3  |   N  |   M  |   ,  |   .  |   /  |Ctl/Et|
64  * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
65  * |  `   | Ctrl | Alt  | GUI  |Lower |Space |   0  |   .  |   =  |Space |Raise | Left | Down |  Up  |Right |
66  * `--------------------------------------------------------------------------------------------------------'
67  */
68 [_QWERTY] = LAYOUT(
69   KC_ESC,   KC_F1,    KC_F2,   KC_F3,   KC_F4,   KC_F5,   KC_F6,   KC_F7,   KC_F8,    KC_F9,   KC_F10,  KC_DEL,\
70   KC_TAB,   KC_Q,     KC_W,    KC_E,    KC_R,    KC_T,    KC_P7,   KC_P8,   KC_P9,    KC_Y,    KC_U,    KC_I,   KC_O,    KC_P,     KC_BSPC, \
71   KC_CAPS,  KC_A,     KC_S,    KC_D,    KC_F,    KC_G,    KC_P4,   KC_P5,   KC_P6,    KC_H,    KC_J,    KC_K,   KC_L,LT_MC(KC_SCLN), KC_QUOT, \
72   KC_LSFT,  KC_Z,     KC_X,    KC_C,    KC_V,    KC_B,    KC_P1,   KC_P2,   KC_P3,    KC_N,    KC_M,    KC_COMM,KC_DOT,  KC_SLSH,  CTL_ENT, \
73   KC_GRV,   KC_LCTRL, KC_LGUI, KC_LALT, LOWER,   KC_SPC,  KC_P0,   KC_DOT,  KC_EQL,  KC_SPC,   RAISE,   KC_LEFT,KC_DOWN, KC_UP,    KC_RGHT  \
74 ),
75
76 /* Colemak
77  * ,------+------+------+------+------+------------------------------------------------.
78  * | Esc  |  F1  |  F2  |  F3  |  F4  |  F5  |  F6  |  F7  |  F8  |  F9  |   0  |   -  |
79  * |------+------+------+------+------+------+------+------+------+------+------+------+--------------------.
80  * | Tab  |   Q  |   W  |   F  |   P  |   G  |   7  |   8  |   9  |   J  |   L  |   U  |   Y  |   ;  | Bksp |
81  * |------+------+------+------+------+-------------+------+------+------+------+------+------+------+------|
82  * | CAPS |   A  |   R  |   S  |   T  |   D  |   4  |   5  |   6  |   H  |   N  |   E  |   I  |   O  |  '   |
83  * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
84  * | Shift|   Z  |   X  |   C  |   V  |   B  |   1  |   2  |   3  |   K  |   M  |   ,  |   .  |   /  |Ctl/Et|
85  * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
86  * |   `  | Ctrl | Alt  | GUI  |Lower |Space |   0  |   .  |   =  |Space |Raise | Left | Down |  Up  |Right |
87  * `--------------------------------------------------------------------------------------------------------'
88  */
89 [_COLEMAK] = LAYOUT(
90   KC_ESC,   KC_F1,   KC_F2,   KC_F3,   KC_F4,   KC_F5,   KC_F6,   KC_F7,   KC_F8,    KC_F9,   KC_F10, KC_DEL,\
91   KC_TAB,   KC_Q,    KC_W,    KC_F,    KC_P,    KC_G,    KC_P7,   KC_P8,   KC_P9,    KC_J,    KC_L,    KC_U,    KC_Y,    KC_SCLN,  KC_BSPC, \
92   KC_LCTRL, KC_A,    KC_R,    KC_S,    KC_T,    KC_D,    KC_P4,   KC_P5,   KC_P6,    KC_H,    KC_N,    KC_E,    KC_I, LT_MC(KC_O), KC_QUOT, \
93   KC_LSFT,  KC_Z,    KC_X,    KC_C,    KC_V,    KC_B,    KC_P1,   KC_P2,   KC_P3,    KC_K,    KC_M,    KC_COMM, KC_DOT,  KC_SLSH,  CTL_ENT, \
94   KC_GRV,   KC_LCTRL, KC_LGUI, KC_LALT, LOWER,  KC_SPC,  KC_P0,   KC_DOT,  KC_EQL,   KC_SPC,  RAISE,   KC_LEFT, KC_DOWN, KC_UP,    KC_RGHT  \
95   ),
96
97 /* Dvorak
98  * ,------+------+------+------+------+------------------------------------------------.
99  * |  Esc |   1  |   2  |   3  |   4  |   5  |   6  |   7  |   8  |   9  |   0  |   -  |
100  * |------+------+------+------+------+------+------+------+------+------+------+------+--------------------.
101  * | Tab  |   "  |   ,  |   .  |   P  |   Y  |   7  |   8  |   9  |   F  |   G  |   C  |   R  |   L  | Bksp |
102  * |------+------+------+------+------+-------------+------+------+------+------+------+------+------+------|
103  * | Esc  |   A  |   O  |   E  |   U  |   I  |   4  |   5  |   6  |   D  |   H  |   T  |   N  |   S  |  /   |
104  * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
105  * | Shift|   ;  |   Q  |   J  |   K  |   X  |   1  |   2  |   3  |   B  |   M  |   W  |   V  |   Z  |Ctl/Et|
106  * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
107  * |   `  | Ctrl | Alt  | GUI  |Lower |Space |   0  |   .  |   =  |Space |Raise | Left | Down |  Up  |Right |
108  * `--------------------------------------------------------------------------------------------------------'
109  */
110 [_DVORAK] = LAYOUT(
111   KC_ESC,   KC_F1,    KC_F2,   KC_F3,   KC_F4,   KC_F5,   KC_F6,   KC_F7,   KC_F8,    KC_F9,   KC_F10, KC_DEL,\
112   KC_TAB,   KC_QUOT,  KC_COMM, KC_DOT,  KC_P,    KC_Y,    KC_P7,   KC_P8,   KC_P9,    KC_F,    KC_G,   KC_C,    KC_R,    KC_L,     KC_BSPC, \
113   KC_LCTL,  KC_A,     KC_O,    KC_E,    KC_U,    KC_I,    KC_P4,   KC_P5,   KC_P6,    KC_D,    KC_H,   KC_T,    KC_N, LT_MC(KC_S), KC_SLSH, \
114   KC_LSFT,  KC_SCLN,  KC_Q,    KC_J,    KC_K,    KC_X,    KC_P1,   KC_P2,   KC_P3,    KC_B,    KC_M,   KC_W,    KC_V,    KC_Z,     CTL_ENT, \
115   KC_GRV,   KC_LCTRL, KC_LGUI, KC_LALT, LOWER,   KC_SPC,  KC_P0,   KC_DOT,  KC_EQL,   KC_SPC,  RAISE,  KC_LEFT, KC_DOWN, KC_UP,    KC_RGHT \
116 ),
117
118 /* Lower
119  * ,------+------+------+------+------+------------------------------------------------.
120  * |   ~  |   !  |   @  |   #  |   $  |   %  |   ^  |   &  |   *  |   (  |   )  | Bksp |
121  * |------+------+------+------+------+------+------+------+------+------+------+------+--------------------.
122  * |   ~  |   !  |   @  |   #  |   $  |   %  |      |      |      |   ^  |   &  |   *  |   (  |   )  | Del  |
123  * |------+------+------+------+------+-------------+------+------+------+------+------+------+------+------|
124  * |      |  F1  |  F2  |  F3  |  F4  |  F5  |      |      |      |  F6  |   _  |   +  |   {  |   }  |  |   |
125  * |------+------+------+------+------+------|------+------+------+------+------+------+------+------+------|
126  * |      |  F7  |  F8  |  F9  |  F10 |  F11 |      |      |      |  F12 |ISO ~ |ISO | |      |      |      |
127  * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
128  * |      |      |      |      |      |      |      |      |      |      |      | Next | Vol- | Vol+ | Play |
129  * `--------------------------------------------------------------------------------------------------------'
130  */
131 [_LOWER] = LAYOUT(
132   KC_TILD, KC_EXLM, KC_AT,   KC_HASH, KC_DLR,  KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC, \
133   KC_TILD, KC_EXLM, KC_AT,   KC_HASH, KC_DLR,  KC_PERC, _______, _______, _______, KC_CIRC, KC_AMPR, KC_ASTR,  KC_LPRN, KC_RPRN, KC_DEL, \
134   _______, KC_F1,   KC_F2,   KC_F3,   KC_F4,   KC_F5,   _______, _______, _______, KC_F6,   KC_UNDS, KC_PLUS,  KC_LBRC, KC_RBRC, KC_PIPE, \
135   _______, KC_F7,   KC_F8,   KC_F9,   KC_F10,  KC_F11,  _______, _______, _______, KC_F12,S(KC_NUHS),S(KC_NUBS),_______,_______, _______, \
136   _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
137 ),
138
139 /* Raise
140  * ,------+------+------+------+------+------------------------------------------------.
141  * |  Esc |   1  |   2  |   3  |   4  |   5  |   6  |   7  |   8  |   9  |   0  |   -  |
142  * |------+------+------+------+------+------+------+------+------+------+------+------+--------------------.
143  * |   `  |   1  |   2  |   3  |   4  |   5  |      |      |      |   6  |   7  |   8  |   9  |   0  | Del  |
144  * |------+------+------+------+------+-------------+------+------+------+------+------+------+------+------|
145  * | Del  |  F1  |  F2  |  F3  |  F4  |  F5  |      |      |      |  F6  |   -  |   =  |   [  |   ]  |  \   |
146  * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
147  * |      |  F7  |  F8  |  F9  |  F10 |  F11 |      |      |      |  F12 |ISO # |ISO / |      |      |      |
148  * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
149  * |      |      |      |      |      |      |      |      |      |      |      | Next | Vol- | Vol+ | Play |
150  * `--------------------------------------------------------------------------------------------------------'
151  */
152 [_RAISE] = LAYOUT(
153   KC_GRV,  KC_1,    KC_2,    KC_3,    KC_4,    KC_5,    KC_6,    KC_7,    KC_8,    KC_9,    KC_0,    KC_BSPC, \
154   KC_GRV,  KC_1,    KC_2,    KC_3,    KC_4,    KC_5,    _______, _______, _______, KC_6,    KC_7,    KC_8,    KC_9,    KC_0,    KC_DEL, \
155   KC_DEL,  KC_F1,   KC_F2,   KC_F3,   KC_F4,   KC_F5,   _______, _______, _______, KC_F6,   KC_MINS, KC_EQL,  KC_LBRC, KC_RBRC, KC_BSLS, \
156   _______, KC_F7,   KC_F8,   KC_F9,   KC_F10,  KC_F11,  _______, _______, _______, KC_F12,  KC_NUHS, KC_NUBS, _______, _______, _______, \
157   _______, _______, _______, _______,  _______, KC_SPC, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY   \
158 ),
159
160 /* Mouse Layer (semi-col)
161  * ,------+------+------+------+------+------------------------------------------------.
162  * | ACCL0| ACCL1| ACCL2|      |      |      |      |      |      |      |      |      |
163  * |------+------+------+------+------+------+------+------+------+------+------+------+--------------------.
164  * |      |      |      |      |      |      |      |      | Home | Wh_Up| WHL_L| M_Up | WHL_R| Macro|      |
165  * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
166  * |      |      |      |      |      |      |      |      | End  | Wh_Dn| M_Lft| M_Dn | M_Rt |      |      |
167  * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
168  * |      |      |      |      |      |      |      |      |      | BTN2 | BTN3 | BTN4 | BTN5 |      |      |
169  * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
170  * |      |      |      |      |      | BTN1 |      |      |      | BTN1 |      |      |      |      |      |
171  * `--------------------------------------------------------------------------------------------------------'
172  */
173
174 [_MOUSECURSOR] = LAYOUT(
175   KC_ACL0, KC_ACL1, KC_ACL2, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
176   _______, _______, _______, _______, _______, _______, _______, _______, KC_HOME, KC_PGUP, KC_WH_L, KC_MS_U, KC_WH_R,DEMOMACRO,_______, \
177   _______, _______, _______, _______, _______, _______, _______, _______, KC_END , KC_PGDN, KC_MS_L, KC_MS_D, KC_MS_R, _______, _______, \
178   _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_BTN2, KC_BTN3, KC_BTN4, KC_BTN5, _______, _______, \
179   _______, _______, _______, _______, _______, KC_BTN1, _______, _______, _______, KC_BTN1, _______, _______, _______, _______, _______  \
180 ),
181
182 /* Adjust (Lower + Raise)
183  * ,------+------+------+------+------+------------------------------------------------.
184  * |  Esc |   1  |   2  |   3  |   4  |   5  |   6  |   7  |   8  |   9  |   0  |   -  |
185  * |------+------+------+------+------+------+------+------+------+------+------+------+--------------------.
186  * | Reset|RGB TG|RGB ST|RGBH -|RGBH +|RGBS -|RGBS +|RGBV -|RGBV +|      |      |      |      |      |  Del |
187  * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
188  * |      |      |      |Aud on|Audoff|AGnorm|      |      |      |AGswap|Qwerty|Colemk|      |      |      |
189  * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
190  * |      |Voice-|Voice+|Mus on|Musoff|      |      |      |      |      |      |      | BL + |BL ST |BL TG |
191  * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
192  * |      |      |      |      |      |      |      |      |      |      |      |      |      |      |      |
193  * `--------------------------------------------------------------------------------------------------------'
194  */
195 [_ADJUST] = LAYOUT(
196   KC_F1,   KC_F2,   KC_F3,   KC_F4,   KC_F5,   KC_F6,   KC_F7,   KC_F8,   KC_F9,   KC_F10,  KC_F11,  KC_F12, \
197   RESET,   RGB_TOG, RGB_MOD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, _______, _______, _______, _______, _______, KC_DEL, \
198   _______, _______, _______, AU_ON,   AU_OFF,  AG_NORM, _______, _______, _______, AG_SWAP, QWERTY,  COLEMAK, _______,  _______,  _______, \
199   _______, MUV_DE,  MUV_IN,  MU_ON,   MU_OFF,  MI_ON,   MI_OFF, _______, _______, _______,  _______, BL_DEC,  BL_INC,  BL_STEP, BL_TOGG, \
200   _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______\
201 )
202
203
204
205 };
206
207 // define variables for reactive RGB
208 bool RGB_INIT = false;
209 bool TOG_STATUS = false;
210 int RGB_current_mode;
211
212 void update_tri_layer_RGB(uint8_t layer1, uint8_t layer2, uint8_t layer3) {
213   if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) {
214     rgblight_mode(RGB_current_mode);
215     layer_on(layer3);
216   } else {
217     layer_off(layer3);
218   }
219 }
220
221 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
222   switch (keycode) {
223     case QWERTY:
224       if (record->event.pressed) {
225         set_single_persistent_default_layer(_QWERTY);
226       }
227       return false;
228       break;
229     case COLEMAK:
230       if (record->event.pressed) {
231         set_single_persistent_default_layer(_COLEMAK);
232       }
233       return false;
234       break;
235     case LOWER:
236       if (record->event.pressed) {
237           //not sure how to have keyboard check mode and set it to a variable, so my work around
238           //uses another variable that would be set to true after the first time a reactive key is pressed.
239         if (RGB_INIT) {} else {
240           RGB_current_mode = rgblight_config.mode;
241           RGB_INIT = true;
242         }
243         if (TOG_STATUS) { //TOG_STATUS checks is another reactive key currently pressed, only changes RGB mode if returns false
244         } else {
245           TOG_STATUS = !TOG_STATUS;
246           rgblight_mode(16);
247         }
248         layer_on(_LOWER);
249         update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
250       } else {
251         rgblight_mode(RGB_current_mode);   // revert RGB to initial mode prior to RGB mode change
252         TOG_STATUS = false;
253         layer_off(_LOWER);
254         update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
255       }
256       return false;
257       break;
258     case RAISE:
259       if (record->event.pressed) {
260         //not sure how to have keyboard check mode and set it to a variable, so my work around
261         //uses another variable that would be set to true after the first time a reactive key is pressed.
262         if (RGB_INIT) {} else {
263           RGB_current_mode = rgblight_config.mode;
264           RGB_INIT = true;
265         }
266         if (TOG_STATUS) { //TOG_STATUS checks is another reactive key currently pressed, only changes RGB mode if returns false
267         } else {
268           TOG_STATUS = !TOG_STATUS;
269           rgblight_mode(15);
270         }
271         layer_on(_RAISE);
272         update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
273       } else {
274         rgblight_mode(RGB_current_mode);  // revert RGB to initial mode prior to RGB mode change
275         layer_off(_RAISE);
276         TOG_STATUS = false;
277         update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
278       }
279       return false;
280       break;
281     case BACKLIT:
282       if (record->event.pressed) {
283         register_code(KC_RSFT);
284         #ifdef BACKLIGHT_ENABLE
285           backlight_step();
286         #endif
287       } else {
288         unregister_code(KC_RSFT);
289       }
290       return false;
291       break;
292     case RGB_MOD:
293       //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
294       if (record->event.pressed) {
295         rgblight_mode(RGB_current_mode);
296         rgblight_step();
297         RGB_current_mode = rgblight_config.mode;
298       }
299       return false;
300       break;
301     case DEMOMACRO:
302       if (record->event.pressed) {
303         SEND_STRING("hello world");
304       }
305       return false;
306       break;
307   }
308   return true;
309 }
310
311 //Functions for ver2
312 #ifdef KEYBOARD_hadron_ver2
313 #include "LUFA/Drivers/Peripheral/TWI.h"
314 void matrix_init_user(void) {
315   #ifdef USE_I2C
316     i2c_master_init();
317   #ifdef SSD1306OLED
318   // calls code for the SSD1306 OLED
319         _delay_ms(400);
320         TWI_Init(TWI_BIT_PRESCALE_1, TWI_BITLENGTH_FROM_FREQ(1, 800000));
321         iota_gfx_init();   // turns on the display
322   #endif
323   #endif
324     #ifdef AUDIO_ENABLE
325         startup_user();
326     #endif
327 }
328
329
330 void matrix_scan_user(void) {
331     #ifdef SSD1306OLED
332      iota_gfx_task();  // this is what updates the display continuously
333     #endif
334 }
335
336 void matrix_update(struct CharacterMatrix *dest,
337                           const struct CharacterMatrix *source) {
338   if (memcmp(dest->display, source->display, sizeof(dest->display))) {
339     memcpy(dest->display, source->display, sizeof(dest->display));
340     dest->dirty = true;
341   }
342 }
343 //assign the right code to your layers for OLED display
344 #define L_BASE 0
345 #define L_LOWER 8
346 #define L_RAISE 16
347 #define L_FNLAYER 64
348 #define L_NUMLAY 128
349 #define L_NLOWER 136
350 #define L_NFNLAYER 192
351 #define L_MOUSECURSOR 256
352 #define L_ADJUST 65560
353
354 void iota_gfx_task_user(void) {
355 #if DEBUG_TO_SCREEN
356   if (debug_enable) {
357     return;
358   }
359 #endif
360
361   struct CharacterMatrix matrix;
362
363   matrix_clear(&matrix);
364   matrix_write_P(&matrix, PSTR("USB: "));
365 #ifdef PROTOCOL_LUFA
366   switch (USB_DeviceState) {
367     case DEVICE_STATE_Unattached:
368       matrix_write_P(&matrix, PSTR("Unattached"));
369       break;
370     case DEVICE_STATE_Suspended:
371       matrix_write_P(&matrix, PSTR("Suspended"));
372       break;
373     case DEVICE_STATE_Configured:
374       matrix_write_P(&matrix, PSTR("Connected"));
375       break;
376     case DEVICE_STATE_Powered:
377       matrix_write_P(&matrix, PSTR("Powered"));
378       break;
379     case DEVICE_STATE_Default:
380       matrix_write_P(&matrix, PSTR("Default"));
381       break;
382     case DEVICE_STATE_Addressed:
383       matrix_write_P(&matrix, PSTR("Addressed"));
384       break;
385     default:
386       matrix_write_P(&matrix, PSTR("Invalid"));
387   }
388 #endif
389
390 // 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
391
392   char buf[40];
393   snprintf(buf,sizeof(buf), "Undef-%ld", layer_state);
394   matrix_write_P(&matrix, PSTR("\n\nLayer: "));
395     switch (layer_state) {
396         case L_BASE:
397            matrix_write_P(&matrix, PSTR("Default"));
398            break;
399         case L_RAISE:
400            matrix_write_P(&matrix, PSTR("Raise"));
401            break;
402         case L_LOWER:
403            matrix_write_P(&matrix, PSTR("Lower"));
404            break;
405         case L_ADJUST:
406            matrix_write_P(&matrix, PSTR("ADJUST"));
407            break;
408         default:
409            matrix_write(&matrix, buf);
410  }
411
412   // Host Keyboard LED Status
413   char led[40];
414     snprintf(led, sizeof(led), "\n%s  %s  %s",
415             (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) ? "NUMLOCK" : "       ",
416             (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) ? "CAPS" : "    ",
417             (host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK)) ? "SCLK" : "    ");
418   matrix_write(&matrix, led);
419   matrix_update(&display, &matrix);
420 }
421
422 #endif