1 #pragma message "You may need to add LAYOUT_planck_grid to your keymap layers - see default for an example"
3 #include "action_layer.h"
10 #include "song_list.h"
13 enum keyboard_layers {
21 enum keyboard_macros {
40 MACRO_BREATH_SPEED_INC,
41 MACRO_BREATH_SPEED_DEC,
64 #define M_QWRTY M(MACRO_QWERTY)
65 #define M_UPPER M(MACRO_UPPER)
66 #define M_LOWER M(MACRO_LOWER)
67 #define M_FUNCT M(MACRO_FUNCTION)
68 #define M_MOUSE M(MACRO_MOUSE)
69 #define TIMBR_1 M(MACRO_TIMBRE_1)
70 #define TIMBR_2 M(MACRO_TIMBRE_2)
71 #define TIMBR_3 M(MACRO_TIMBRE_3)
72 #define TIMBR_4 M(MACRO_TIMBRE_4)
73 #define TMPO_UP M(MACRO_TEMPO_U)
74 #define TMPO_DN M(MACRO_TEMPO_D)
75 #define TMPO_DF M(MACRO_TONE_DEFAULT)
76 #define M_BACKL M(MACRO_BACKLIGHT)
77 #define M_BRTOG M(MACRO_BREATH_TOGGLE)
78 #define M_BSPDU M(MACRO_BREATH_SPEED_INC)
79 #define M_BSPDD M(MACRO_BREATH_SPEED_DEC)
80 #define M_BDFLT M(MACRO_BREATH_DEFAULT)
81 #define M_MS_UL M(MACRO_MOUSE_MOVE_UL)
82 #define M_MS_UR M(MACRO_MOUSE_MOVE_UR)
83 #define M_MS_DL M(MACRO_MOUSE_MOVE_DL)
84 #define M_MS_DR M(MACRO_MOUSE_MOVE_DR)
85 #define M_HELP1 M(MACRO_HELP_1)
86 #define M_HELP2 M(MACRO_HELP_2)
87 #define M_HELP3 M(MACRO_HELP_3)
88 #define M_HELP4 M(MACRO_HELP_4)
89 #define M_HELP5 M(MACRO_HELP_5)
90 #define M_HELP6 M(MACRO_HELP_6)
91 #define M_HELP7 M(MACRO_HELP_7)
92 #define M_HELP8 M(MACRO_HELP_8)
93 #define M_HELP9 M(MACRO_HELP_9)
94 #define MY_MACRO M(MACRO_MINE)
95 //#define M_SHENT M(MACRO_SHENT)
98 #define VC_UP M(MACRO_INC_VOICE)
99 #define VC_DOWN M(MACRO_DEC_VOICE)
102 #define SC_UNDO LCTL(KC_Z)
103 #define SC_REDO LCTL(KC_Y)
104 #define SC_CUT LCTL(KC_X)
105 #define SC_COPY LCTL(KC_C)
106 #define SC_PSTE LCTL(KC_V)
107 #define SC_SELA LCTL(KC_A)
108 #define SC_SAVE LCTL(KC_S)
109 #define SC_OPEN LCTL(KC_O)
110 #define SC_ACLS LALT(KC_F4)
111 #define SC_CCLS LCTL(KC_F4)
113 #define TG_NKRO MAGIC_TOGGLE_NKRO
114 #define OS_SHFT KC_FN0
116 #define _______ KC_TRNS
117 #define XXXXXXX KC_NO
118 #define ________________ _______, _______
119 #define XXXXXXXXXXXXXXXX XXXXXXX, XXXXXXX
122 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
124 /* LAYER = LAYER_QWERTY
125 .-----------------------------------------------------------------------------------------------------------.
126 | ESC | Q | W | E | R | T | Y | U | I | O | P | BACKSP |
127 |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
128 | TAB | A | S | D | F | G | H | J | K | L | ; | ' |
129 |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
130 | LSHIFT | Z | X | C | V | B | N | M | , | . | UP | SH/ENT |
131 |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
132 | LCTRL | LWIN | FN | LALT | LOWER | SPACE | SPACE | UPPER | MENU | LEFT | DOWN | RIGHT |
133 '-----------------------------------------------------------------------------------------------------------'
136 { KC_ESC , KC_Q , KC_W , KC_E , KC_R , KC_T , KC_Y , KC_U , KC_I , KC_O , KC_P , KC_BSPC },
137 { KC_TAB , KC_A , KC_S , KC_D , KC_F , KC_G , KC_H , KC_J , KC_K , KC_L , KC_SCLN, KC_QUOT },
138 { KC_LSFT, KC_Z , KC_X , KC_C , KC_V , KC_B , KC_N , KC_M , KC_COMM, KC_DOT , KC_UP , KC_SFTENT /*M_SHENT*/ },
139 { KC_LCTL, KC_LGUI, M_FUNCT, KC_LALT, M_LOWER, KC_SPC , KC_SPC , M_UPPER, KC_APP , KC_LEFT, KC_DOWN, KC_RGHT }
141 /* LAYER = LAYER_UPPER
142 .-----------------------------------------------------------------------------------------------------------.
143 | PRINT | F1 | F2 | F3 | F4 | NUM LK | KP / | KP 7 | KP 8 | KP 9 | KP - | DEL |
144 |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
145 | PAUSE | F5 | F6 | F7 | F8 | SCR LK | KP * | KP 4 | KP 5 | KP 6 | KP + | HOME |
146 |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
147 | ______ | F9 | F10 | F11 | F12 | PAUSE | KP 0 | KP 1 | KP 2 | KP 3 | KP ENT | END |
148 |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
149 | ______ | ______ | ______ | ______ | LOWER | KP 0 | KP 0 | ______ | RALT | KP 0 | KP ENT | RTCTRL |
150 '-----------------------------------------------------------------------------------------------------------'
153 { KC_PSCR, KC_F1 , KC_F2 , KC_F3 , KC_F4 , KC_NLCK, KC_PSLS, KC_KP_7, KC_KP_8, KC_KP_9, KC_PMNS, KC_DEL },
154 { KC_PAUS, KC_F5 , KC_F6 , KC_F7 , KC_F8 , KC_SLCK, KC_PAST, KC_KP_4, KC_KP_5, KC_KP_6, KC_PPLS, KC_HOME },
155 { _______, KC_F9 , KC_F10 , KC_F11 , KC_F12 , KC_PAUS, KC_KP_0, KC_KP_1, KC_KP_2, KC_KP_3, KC_PENT, KC_END },
156 { _______, _______, _______, _______, M_LOWER, KC_KP_0, KC_KP_0, _______, KC_KP_0, KC_PDOT, KC_PENT, KC_RCTL }
158 /* LAYER = LAYER_LOWER
159 .-----------------------------------------------------------------------------------------------------------.
160 | ______ | $ | { | [ | ( | % | # | ) | ] | } | @ | PG UP |
161 |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
162 | ______ | ^ | * | + | - | / | \ | _ | ' | " | ` | PG DN |
163 |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
164 | ______ | | | & | ! | ~ | ; | : | = | < | > | ? | HOME |
165 |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
166 | ______ | ______ | ______ | ______ | ______ | ______ | ______ | UPPER | ______ | ______ | ______ | END |
167 '-----------------------------------------------------------------------------------------------------------'
170 { _______, KC_DLR , KC_LCBR, KC_LBRC, KC_LPRN, KC_PERC, KC_HASH, KC_RPRN, KC_RBRC, KC_RCBR, KC_AT , KC_PGUP },
171 { _______, KC_CIRC, KC_ASTR, KC_PLUS, KC_MINS, KC_SLSH, KC_BSLS, KC_UNDS, KC_QUOT, KC_DQT , KC_GRV , KC_PGDN },
172 { _______, KC_PIPE, KC_AMPR, KC_EXLM, KC_TILD, KC_SCLN, KC_COLN, KC_EQL , KC_LT , KC_GT , KC_QUES, KC_HOME },
173 { _______, _______, _______, _______, _______, _______, _______, M_UPPER, _______, _______, _______, KC_END }
175 /* LAYER = LAYER_FUNCTION
176 .-----------------------------------------------------------------------------------------------------------.
177 | XXXXXX | F13 | F14 | F15 | F16 | NUM LK | XXXXXX | XXXXXX | XXXXXX | XXXXXX | XXXXXX | XXXXXX |
178 |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
179 | XXXXXX | F17 | F18 | F19 | F20 | SCR LK | XXXXXX | XXXXXX | XXXXXX | XXXXXX | XXXXXX | XXXXXX |
180 |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
181 | ______ | F21 | F22 | F23 | F24 | CAP LK | XXXXXX | XXXXXX | XXXXXX | XXXXXX | VOL UP | MUTE |
182 |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
183 | ______ | ______ | FN | ______ | ______ | PLAY | PLAY | ______ | ______ | PREV | VOL DN | NEXT |
184 '-----------------------------------------------------------------------------------------------------------'
187 { XXXXXXX, KC_F13 , KC_F14 , KC_F15 , KC_F16 , KC_NLCK, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX },
188 { XXXXXXX, KC_F17 , KC_F18 , KC_F19 , KC_F20 , KC_SLCK, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX },
189 { _______, KC_F21 , KC_F22 , KC_F23 , KC_F24 , KC_CAPS, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_VOLU, KC_MUTE },
190 { _______, _______, M_FUNCT, _______, _______, KC_MPLY, KC_MPLY, _______, _______, KC_MPRV, KC_VOLD, KC_MNXT }
192 /* LAYER = LAYER_MOUSE
193 .-----------------------------------------------------------------------------------------------------------.
194 | ESC | XXXXXX | XXXXXX | XXXXXX | XXXXXX | XXXXXX | XXXXXX | MS UL | MS U | MS UR | MS WHL | MS WHR |
195 |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
196 | XXXXXX | MS BT5 | MS BT4 | MS BT3 | MS BT2 | XXXXXX | XXXXXX | MS L | XXXXXX | MS R | XXXXXX | MS WHU |
197 |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
198 | ______ | XXXXXX | XXXXXX | XXXXXX | XXXXXX | XXXXXX | XXXXXX | MS DL | MS D | MS DR | MS U | MS WHD |
199 |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
200 | ______ | ______ | ______ | ______ | ______ | MS BT1 | MS BT1 | ______ | ______ | MS L | MS D | MS R |
201 '-----------------------------------------------------------------------------------------------------------'
204 { KC_ESC , XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, M_MS_UL, KC_MS_U, M_MS_UR, KC_WH_L, KC_WH_R },
205 { XXXXXXX, KC_BTN5, KC_BTN4, KC_BTN3, KC_BTN2, XXXXXXX, XXXXXXX, KC_MS_L, XXXXXXX, KC_MS_R, XXXXXXX, KC_WH_U },
206 { _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, M_MS_DL, KC_MS_D, M_MS_DR, KC_MS_U, KC_WH_D },
207 { _______, _______, _______, _______, _______, KC_BTN1, KC_BTN1, _______, _______, KC_MS_L, KC_MS_D, KC_MS_R }
209 /* LAYER = LAYER_ADJUST
210 .-----------------------------------------------------------------------------------------------------------.
211 | XXXXXX | HELP 1 | HELP 2 | HELP 3 | HELP 4 | HELP 5 | HELP 6 | HELP 7 | HELP 8 | HELP 9 | MUSIC | AUDIO |
212 |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
213 | XXXXXX | BRTOG | BRSPD+ | BRSPD- | BRDFLT | XXXXXX | XXXXXX | XXXXXX | XXXXXX | XXXXXX | XXXXXX | XXXXXX |
214 |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
215 | XXXXXX | QWERTY | XXXXXX | XXXXXX | BACKLT | RESET | XXXXXX | MOUSE | XXXXXX | XXXXXX | VOICE+ | MACRO |
216 |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
217 | XXXXXX | XXXXXX | XXXXXX | XXXXXX | LOWER | XXXXXX | XXXXXX | UPPER | XXXXXX | TEMPO- | VOICE- | TEMPO+ |
218 '-----------------------------------------------------------------------------------------------------------'
221 { XXXXXXX, M_HELP1, M_HELP2, M_HELP3, M_HELP4, M_HELP5, M_HELP6, M_HELP7, M_HELP8, M_HELP9, MU_TOG , AU_TOG },
222 { XXXXXXX, M_BRTOG, M_BSPDU, M_BSPDD, M_BDFLT, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX },
223 { XXXXXXX, M_QWRTY, XXXXXXX, XXXXXXX, M_BACKL, RESET , XXXXXXX, M_MOUSE, XXXXXXX, XXXXXXX, MUV_IN , MY_MACRO},
224 { XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, M_LOWER, XXXXXXX, XXXXXXX, M_UPPER, XXXXXXX, TMPO_DN, MUV_DE , TMPO_UP }
231 float tone_my_startup[][2] = SONG(QWERTY_SOUND);
232 float tone_my_goodbye[][2] = SONG(QWERTY_SOUND);
234 float tone_audio_on[][2] = SONG(CLOSE_ENCOUNTERS_5_NOTE);
235 float tone_music_on[][2] = SONG(DOE_A_DEER);
236 float tone_caps_on[][2] = SONG(CAPS_LOCK_ON_SOUND);
237 float tone_caps_off[][2] = SONG(CAPS_LOCK_OFF_SOUND);
238 float tone_numlk_on[][2] = SONG(NUM_LOCK_ON_SOUND);
239 float tone_numlk_off[][2] = SONG(NUM_LOCK_OFF_SOUND);
240 float tone_scroll_on[][2] = SONG(SCROLL_LOCK_ON_SOUND);
241 float tone_scroll_off[][2] = SONG(SCROLL_LOCK_OFF_SOUND);
242 float music_scale[][2] = SONG(MUSIC_SCALE_SOUND);
244 #endif /* AUDIO_ENABLE */
246 void persistant_default_layer_set(uint16_t default_layer)
248 eeconfig_update_default_layer(default_layer);
249 default_layer_set(default_layer);
252 const uint16_t PROGMEM fn_actions[] = {
253 [0] = ACTION_MODS_ONESHOT(MOD_RSFT),
256 const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
259 // MACRODOWN only works in this function
264 if (record->event.pressed)
271 if (record->event.pressed)
278 if (record->event.pressed)
285 if (record->event.pressed)
292 if (record->event.pressed)
299 if (record->event.pressed)
306 if (record->event.pressed)
313 if (record->event.pressed)
320 if (record->event.pressed)
326 case MACRO_BREATH_TOGGLE:
327 if (record->event.pressed)
329 #ifdef BACKLIGHT_BREATHING
335 case MACRO_BREATH_SPEED_INC:
336 if (record->event.pressed)
338 #ifdef BACKLIGHT_BREATHING
339 breathing_period_inc();
344 case MACRO_BREATH_SPEED_DEC:
345 if (record->event.pressed)
347 #ifdef BACKLIGHT_BREATHING
348 breathing_period_dec();
353 case MACRO_BREATH_DEFAULT:
354 if (record->event.pressed)
356 #ifdef BACKLIGHT_BREATHING
357 breathing_period_default();
363 if (record->event.pressed)
365 persistant_default_layer_set(1UL<<LAYER_QWERTY);
370 if (record->event.pressed)
372 layer_on(LAYER_UPPER);
373 #ifdef BACKLIGHT_BREATHING
374 breathing_period_set(2);
377 update_tri_layer(LAYER_LOWER, LAYER_UPPER, LAYER_ADJUST);
381 layer_off(LAYER_UPPER);
382 update_tri_layer(LAYER_LOWER, LAYER_UPPER, LAYER_ADJUST);
387 if (record->event.pressed)
389 layer_on(LAYER_LOWER);
390 #ifdef BACKLIGHT_BREATHING
391 breathing_period_set(2);
394 update_tri_layer(LAYER_LOWER, LAYER_UPPER, LAYER_ADJUST);
398 layer_off(LAYER_LOWER);
399 update_tri_layer(LAYER_LOWER, LAYER_UPPER, LAYER_ADJUST);
404 if (record->event.pressed)
406 #ifdef BACKLIGHT_BREATHING
407 breathing_period_set(3);
410 layer_on(LAYER_FUNCTION);
414 #ifdef BACKLIGHT_BREATHING
415 breathing_period_set(1);
416 breathing_self_disable();
418 layer_off(LAYER_FUNCTION);
423 if(record->event.pressed)
425 return MACRO( I(03), T(R), T(O), T(O), T(T), W(10), T(TAB), W(10), T(T), T(O), T(O), T(R), T(ENTER), END );
431 if (record->event.pressed)
433 start = timer_read();
434 return MACRO( D(LSHIFT), END );
438 if (timer_elapsed(start) > 100)
440 return MACRO( U(LSHIFT), END);
444 return MACRO( U(LSHIFT), T(ENTER), END);
451 #ifdef BACKLIGHT_ENABLE
452 case MACRO_BACKLIGHT:
453 if (record->event.pressed)
459 #ifdef MOUSEKEY_ENABLE
462 if (record->event.pressed)
464 layer_invert(LAYER_MOUSE);
468 case MACRO_MOUSE_MOVE_UL:
469 if (record->event.pressed)
471 mousekey_on(KC_MS_UP);
472 mousekey_on(KC_MS_LEFT);
476 mousekey_off(KC_MS_UP);
477 mousekey_off(KC_MS_LEFT);
481 case MACRO_MOUSE_MOVE_UR:
482 if (record->event.pressed)
484 mousekey_on(KC_MS_UP);
485 mousekey_on(KC_MS_RIGHT);
489 mousekey_off(KC_MS_UP);
490 mousekey_off(KC_MS_RIGHT);
494 case MACRO_MOUSE_MOVE_DL:
495 if (record->event.pressed)
497 mousekey_on(KC_MS_DOWN);
498 mousekey_on(KC_MS_LEFT);
502 mousekey_off(KC_MS_DOWN);
503 mousekey_off(KC_MS_LEFT);
507 case MACRO_MOUSE_MOVE_DR:
508 if (record->event.pressed)
510 mousekey_on(KC_MS_DOWN);
511 mousekey_on(KC_MS_RIGHT);
515 mousekey_off(KC_MS_DOWN);
516 mousekey_off(KC_MS_RIGHT);
520 #endif /* MOUSEKEY_ENABLE */
525 if (record->event.pressed) set_timbre(TIMBRE_12);
529 if (record->event.pressed) set_timbre(TIMBRE_25);
533 if (record->event.pressed) set_timbre(TIMBRE_50);
537 if (record->event.pressed) set_timbre(TIMBRE_75);
541 if (record->event.pressed) increase_tempo(10);
545 if (record->event.pressed) decrease_tempo(10);
548 case MACRO_TONE_DEFAULT:
549 if (record->event.pressed)
551 set_timbre(TIMBRE_DEFAULT);
552 set_tempo(TEMPO_DEFAULT);
556 #endif /* AUDIO_ENABLE */
569 void matrix_init_user(void)
571 set_voice(default_voice);
573 println("Matrix Init");
576 void led_set_user(uint8_t usb_led)
578 static uint8_t old_usb_led = 0;
580 _delay_ms(10); // gets rid of tick
582 if ((usb_led & (1<<USB_LED_CAPS_LOCK)) && !(old_usb_led & (1<<USB_LED_CAPS_LOCK)))
584 // If CAPS LK LED is turning on...
585 PLAY_SONG(tone_caps_on);
587 else if (!(usb_led & (1<<USB_LED_CAPS_LOCK)) && (old_usb_led & (1<<USB_LED_CAPS_LOCK)))
589 // If CAPS LK LED is turning off...
590 PLAY_SONG(tone_caps_off);
592 else if ((usb_led & (1<<USB_LED_NUM_LOCK)) && !(old_usb_led & (1<<USB_LED_NUM_LOCK)))
594 // If NUM LK LED is turning on...
595 PLAY_SONG(tone_numlk_on);
597 else if (!(usb_led & (1<<USB_LED_NUM_LOCK)) && (old_usb_led & (1<<USB_LED_NUM_LOCK)))
599 // If NUM LED is turning off...
600 PLAY_SONG(tone_numlk_off);
602 else if ((usb_led & (1<<USB_LED_SCROLL_LOCK)) && !(old_usb_led & (1<<USB_LED_SCROLL_LOCK)))
604 // If SCROLL LK LED is turning on...
605 PLAY_SONG(tone_scroll_on);
607 else if (!(usb_led & (1<<USB_LED_SCROLL_LOCK)) && (old_usb_led & (1<<USB_LED_SCROLL_LOCK)))
609 // If SCROLL LED is turning off...
610 PLAY_SONG(tone_scroll_off);
612 old_usb_led = usb_led;
618 _delay_ms(10); // gets rid of tick
619 PLAY_SONG(tone_my_startup);
624 PLAY_SONG(tone_my_goodbye);
629 void audio_on_user(void)
631 PLAY_SONG(tone_audio_on);
634 void music_on_user(void)
636 PLAY_SONG(tone_music_on);
639 void music_scale_user(void)
641 PLAY_SONG(music_scale);
644 #endif /* AUDIO_ENABLE */