1 #include QMK_KEYBOARD_H
2 #include "bootloader.h"
5 #include "split_util.h"
14 extern keymap_config_t keymap_config;
16 #ifdef RGBLIGHT_ENABLE
17 //Following line allows macro to read current RGB settings
18 extern rgblight_config_t rgblight_config;
21 extern uint8_t is_master;
23 // Each layer gets a name for readability, which is then used in the keymap matrix below.
24 // The underscores don't mean anything - you can have a layer called STUFF or any other name.
25 // Layer names don't all need to be of the same length, obviously, and you can also skip them
26 // entirely and just use numbers.
36 enum custom_keycodes {
54 #define M_SAMPLE M(KC_SAMPLEMACRO)
56 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
59 * ,-----------------------------------------. ,-----------------------------------------.
60 * | Tab | Q | W | E | R | T | | Y | U | I | O | P | Bksp |
61 * |------+------+------+------+------+------| |------+------+------+------+------+------|
62 * | Ctrl | A | S | D | F | G | | H | J | K | L | ; | ' |
63 * |------+------+------+------+------+------| |------+------+------+------+------+------|
64 * | Shift| Z | X | C | V | B | | N | M | , | . | / |Enter |
65 * |------+------+------+------+------+------+-------------+------+------+------+------+------+------|
66 * |Adjust| Esc | Alt | GUI | EISU |Lower |Space |Space |Raise | KANA | Left | Down | Up |Right |
67 * `-------------------------------------------------------------------------------------------------'
71 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, \
72 KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, \
73 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , \
74 ADJUST, KC_ESC, KC_LALT, KC_LGUI, EISU, LOWER, KC_SPC, KC_SPC, RAISE, KANA, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
77 * ,-----------------------------------------. ,-----------------------------------------.
78 * | Tab | Q | W | F | P | G | | J | L | U | Y | ; | Bksp |
79 * |------+------+------+------+------+------| |------+------+------+------+------+------|
80 * | Ctrl | A | R | S | T | D | | H | N | E | I | O | ' |
81 * |------+------+------+------+------+------| |------+------+------+------+------+------|
82 * | Shift| Z | X | C | V | B | | K | M | , | . | / |Enter |
83 * |------+------+------+------+------+------+-------------+------+------+------+------+------+------|
84 * |Adjust| Esc | Alt | GUI | EISU |Lower |Space |Space |Raise | KANA | Left | Down | Up |Right |
85 * `-------------------------------------------------------------------------------------------------'
87 [_COLEMAK] = LAYOUT( \
88 KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC, \
89 KC_LCTL, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT, \
90 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , \
91 ADJUST, KC_ESC, KC_LALT, KC_LGUI, EISU, LOWER, KC_SPC, KC_SPC, RAISE, KANA, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
95 * ,-----------------------------------------. ,-----------------------------------------.
96 * | Tab | ' | , | . | P | Y | | F | G | C | R | L | Bksp |
97 * |------+------+------+------+------+------| |------+------+------+------+------+------|
98 * | Ctrl | A | O | E | U | I | | D | H | T | N | S | / |
99 * |------+------+------+------+------+------| |------+------+------+------+------+------|
100 * | Shift| ; | Q | J | K | X | | B | M | W | V | Z |Enter |
101 * |------+------+------+------+------+------+-------------+------+------+------+------+------+------|
102 * |Adjust| Esc | Alt | GUI | EISU |Lower |Space |Space |Raise | KANA | Left | Down | Up |Right |
103 * `-------------------------------------------------------------------------------------------------'
105 [_DVORAK] = LAYOUT( \
106 KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_BSPC, \
107 KC_LCTL, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_SLSH, \
108 KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_ENT , \
109 ADJUST, KC_ESC, KC_LALT, KC_LGUI, EISU, LOWER, KC_SPC, KC_SPC, RAISE, KANA, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
113 * ,-----------------------------------------. ,-----------------------------------------.
114 * | ~ | ! | @ | # | $ | % | | ^ | & | * | ( | ) | Del |
115 * |------+------+------+------+------+------| |------+------+------+------+------+------|
116 * | | F1 | F2 | F3 | F4 | F5 | | F6 | _ | + | { | } | | |
117 * |------+------+------+------+------+------| |------+------+------+------+------+------|
118 * | | F7 | F8 | F9 | F10 | F11 | | F12 | | PrSc | Home | End | |
119 * |------+------+------+------+------+------+-------------+------+------+------+------+------+------|
120 * | | | | | | | | | | | Next | Vol- | Vol+ | Play |
121 * `-------------------------------------------------------------------------------------------------'
124 KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_DEL, \
125 _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, \
126 _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, KC_PSCR, KC_HOME, KC_END, _______, \
127 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
131 * ,-----------------------------------------. ,-----------------------------------------.
132 * | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | Del |
133 * |------+------+------+------+------+------| |------+------+------+------+------+------|
134 * | | F1 | F2 | F3 | F4 | F5 | | F6 | - | = | [ | ] | \ |
135 * |------+------+------+------+------+------| |------+------+------+------+------+------|
136 * | | F7 | F8 | F9 | F10 | F11 | | F12 | | PrSc |PageDn|PageUp| |
137 * |------+------+------+------+------+------+-------------+------+------+------+------+------+------|
138 * | | | | | | | | | | | Next | Vol- | Vol+ | Play |
139 * `-------------------------------------------------------------------------------------------------'
142 KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL, \
143 _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS, \
144 _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, KC_PSCR, KC_PGDN, KC_PGUP, _______, \
145 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
148 /* Adjust (Lower + Raise)
149 * ,-----------------------------------------. ,-----------------------------------------.
150 * | | Reset| | | | | | | | | | | |
151 * |------+------+------+------+------+------| |------+------+------+------+------+------|
152 * | |Aud on|Audoff|MU TOG|MU MOD| Mac | | Win |Qwerty|Colemk|Dvorak| | |
153 * |------+------+------+------+------+------| |------+------+------+------+------+------|
154 * | |CK TOG|CK RST| CK UP|CK DWN| | | | |RGB ON| HUE+ | SAT+ | VAL+ |
155 * |------+------+------+------+------+------+-------------+------+------+------+------+------+------|
156 * | | | | | | | | | | | MODE | HUE- | SAT- | VAL- |
157 * `-------------------------------------------------------------------------------------------------'
159 [_ADJUST] = LAYOUT( \
160 _______, RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
161 _______, AU_ON, AU_OFF, MU_TOG, MU_MOD, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, _______, _______, \
162 _______, CK_TOGG, CK_RST, CK_UP, CK_DOWN, _______, _______, _______, RGB_TOG, RGB_HUI, RGB_SAI, RGB_VAI, \
163 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_MOD, RGB_HUD, RGB_SAD, RGB_VAD \
171 float tone_qwerty[][2] = SONG(QWERTY_SOUND);
172 float tone_dvorak[][2] = SONG(DVORAK_SOUND);
173 float tone_colemak[][2] = SONG(COLEMAK_SOUND);
174 float tone_plover[][2] = SONG(PLOVER_SOUND);
175 float tone_plover_gb[][2] = SONG(PLOVER_GOODBYE_SOUND);
176 float music_scale[][2] = SONG(MUSIC_SCALE_SOUND);
179 // define variables for reactive RGB
180 bool TOG_STATUS = false;
181 int RGB_current_mode;
183 void persistent_default_layer_set(uint16_t default_layer) {
184 eeconfig_update_default_layer(default_layer);
185 default_layer_set(default_layer);
188 // Setting ADJUST layer RGB back to default
189 void update_tri_layer_RGB(uint8_t layer1, uint8_t layer2, uint8_t layer3) {
190 if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) {
191 #ifdef RGBLIGHT_ENABLE
192 //rgblight_mode(RGB_current_mode);
200 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
203 if (record->event.pressed) {
205 PLAY_SONG(tone_qwerty);
207 persistent_default_layer_set(1UL<<_QWERTY);
212 if (record->event.pressed) {
214 PLAY_SONG(tone_colemak);
216 persistent_default_layer_set(1UL<<_COLEMAK);
221 if (record->event.pressed) {
223 PLAY_SONG(tone_dvorak);
225 persistent_default_layer_set(1UL<<_DVORAK);
230 if (record->event.pressed) {
231 //not sure how to have keyboard check mode and set it to a variable, so my work around
232 //uses another variable that would be set to true after the first time a reactive key is pressed.
233 if (TOG_STATUS) { //TOG_STATUS checks is another reactive key currently pressed, only changes RGB mode if returns false
235 TOG_STATUS = !TOG_STATUS;
236 #ifdef RGBLIGHT_ENABLE
237 //rgblight_mode(RGBLIGHT_MODE_SNAKE + 1);
241 update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
243 #ifdef RGBLIGHT_ENABLE
244 //rgblight_mode(RGB_current_mode); // revert RGB to initial mode prior to RGB mode change
248 update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
253 if (record->event.pressed) {
254 //not sure how to have keyboard check mode and set it to a variable, so my work around
255 //uses another variable that would be set to true after the first time a reactive key is pressed.
256 if (TOG_STATUS) { //TOG_STATUS checks is another reactive key currently pressed, only changes RGB mode if returns false
258 TOG_STATUS = !TOG_STATUS;
259 #ifdef RGBLIGHT_ENABLE
260 //rgblight_mode(RGBLIGHT_MODE_SNAKE);
264 update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
266 #ifdef RGBLIGHT_ENABLE
267 //rgblight_mode(RGB_current_mode); // revert RGB to initial mode prior to RGB mode change
271 update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
276 if (record->event.pressed) {
283 //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
285 #ifdef RGBLIGHT_ENABLE
286 if (record->event.pressed) {
287 rgblight_mode(RGB_current_mode);
289 RGB_current_mode = rgblight_config.mode;
295 if (record->event.pressed) {
296 if(keymap_config.swap_lalt_lgui==false){
297 register_code(KC_LANG2);
299 SEND_STRING(SS_LALT("`"));
302 unregister_code(KC_LANG2);
307 if (record->event.pressed) {
308 if(keymap_config.swap_lalt_lgui==false){
309 register_code(KC_LANG1);
311 SEND_STRING(SS_LALT("`"));
314 unregister_code(KC_LANG1);
319 #ifdef RGBLIGHT_ENABLE
320 if (record->event.pressed) {
321 eeconfig_update_rgblight_default();
323 RGB_current_mode = rgblight_config.mode;
331 void matrix_init_user(void) {
335 #ifdef RGBLIGHT_ENABLE
336 RGB_current_mode = rgblight_config.mode;
338 //SSD1306 OLED init, make sure to add #define SSD1306OLED in config.h
340 iota_gfx_init(!has_usb()); // turns on the display
349 _delay_ms(50); // gets rid of tick
358 void music_on_user(void)
363 void music_scale_user(void)
365 PLAY_SONG(music_scale);
371 //SSD1306 OLED update loop, make sure to add #define SSD1306OLED in config.h
374 void matrix_scan_user(void) {
375 iota_gfx_task(); // this is what updates the display continuously
378 void matrix_update(struct CharacterMatrix *dest,
379 const struct CharacterMatrix *source) {
380 if (memcmp(dest->display, source->display, sizeof(dest->display))) {
381 memcpy(dest->display, source->display, sizeof(dest->display));
386 //assign the right code to your layers for OLED display
388 #define L_LOWER (1<<_LOWER)
389 #define L_RAISE (1<<_RAISE)
390 #define L_ADJUST (1<<_ADJUST)
391 #define L_ADJUST_TRI (L_ADJUST|L_RAISE|L_LOWER)
393 static void render_logo(struct CharacterMatrix *matrix) {
396 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,0x90,0x91,0x92,0x93,0x94,
397 0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,0xb0,0xb1,0xb2,0xb3,0xb4,
398 0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,0xd0,0xd1,0xd2,0xd3,0xd4,
400 matrix_write(matrix, logo);
401 //matrix_write_P(&matrix, PSTR(" Split keyboard kit"));
406 void render_status(struct CharacterMatrix *matrix) {
408 // Render to mode icon
409 static char logo[][2][3]={{{0x95,0x96,0},{0xb5,0xb6,0}},{{0x97,0x98,0},{0xb7,0xb8,0}}};
410 if(keymap_config.swap_lalt_lgui==false){
411 matrix_write(matrix, logo[0][0]);
412 matrix_write_P(matrix, PSTR("\n"));
413 matrix_write(matrix, logo[0][1]);
415 matrix_write(matrix, logo[1][0]);
416 matrix_write_P(matrix, PSTR("\n"));
417 matrix_write(matrix, logo[1][1]);
420 // 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
422 snprintf(buf,sizeof(buf), "Undef-%ld", layer_state);
423 matrix_write_P(matrix, PSTR("\nLayer: "));
424 switch (layer_state) {
426 matrix_write_P(matrix, PSTR("Default"));
429 matrix_write_P(matrix, PSTR("Raise"));
432 matrix_write_P(matrix, PSTR("Lower"));
436 matrix_write_P(matrix, PSTR("Adjust"));
439 matrix_write(matrix, buf);
442 // Host Keyboard LED Status
444 snprintf(led, sizeof(led), "\n%s %s %s",
445 (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) ? "NUMLOCK" : " ",
446 (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) ? "CAPS" : " ",
447 (host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK)) ? "SCLK" : " ");
448 matrix_write(matrix, led);
452 void iota_gfx_task_user(void) {
453 struct CharacterMatrix matrix;
461 matrix_clear(&matrix);
463 render_status(&matrix);
465 render_logo(&matrix);
467 matrix_update(&display, &matrix);