You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

178 lines
8.5 KiB

  1. /*
  2. Copyright 2019 @foostan
  3. Copyright 2020 Drashna Jaelre <@drashna>
  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. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. #include QMK_KEYBOARD_H
  16. #include <stdio.h>
  17. #define KC_SFTTB LSFT_T(KC_TAB)
  18. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  19. [0] = LAYOUT_split_3x6_3(
  20. //,-----------------------------------------------------. ,-----------------------------------------------------.
  21. KC_ESC, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC,
  22. //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
  23. KC_SFTTB, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT,
  24. //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
  25. KC_LCTL, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT,
  26. //|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------|
  27. KC_LALT, MO(1), KC_SPC, KC_ENT, MO(2), KC_RGUI
  28. //`--------------------------' `--------------------------'
  29. ),
  30. [1] = LAYOUT_split_3x6_3(
  31. //,-----------------------------------------------------. ,-----------------------------------------------------.
  32. _______, KC_PGUP, KC_UP, KC_PGDN, XXXXXXX, XXXXXXX, XXXXXXX, KC_7, KC_8, KC_9, KC_0, KC_DEL,
  33. //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
  34. _______, KC_LEFT, KC_DOWN, KC_RGHT, XXXXXXX, XXXXXXX, KC_HOME, KC_4, KC_5, KC_6, XXXXXXX, XXXXXXX,
  35. //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
  36. _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_END, KC_1, KC_2, KC_3, XXXXXXX, _______,
  37. //|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------|
  38. _______, _______, _______, _______, MO(3), _______
  39. //`--------------------------' `--------------------------'
  40. ),
  41. [2] = LAYOUT_split_3x6_3(
  42. //,-----------------------------------------------------. ,-----------------------------------------------------.
  43. _______, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_DEL,
  44. //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
  45. _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_MINS, KC_EQL, KC_LCBR, KC_RCBR, KC_PIPE, KC_GRV,
  46. //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
  47. _______, XXXXXXX, KC_MUTE, KC_VOLD, KC_VOLU, XXXXXXX, KC_UNDS, KC_PLUS, KC_LBRC, KC_RBRC, KC_BSLS, KC_TILD,
  48. //|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------|
  49. _______, MO(3), _______, _______, _______, _______
  50. //`--------------------------' `--------------------------'
  51. ),
  52. [3] = LAYOUT_split_3x6_3(
  53. //,-----------------------------------------------------. ,-----------------------------------------------------.
  54. QK_BOOT, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6,
  55. //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
  56. RGB_TOG, RGB_HUI, RGB_SAI, RGB_VAI, XXXXXXX, XXXXXXX, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12,
  57. //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
  58. RGB_MOD, RGB_HUD, RGB_SAD, RGB_VAD, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_RSFT,
  59. //|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------|
  60. _______, _______, _______, _______, _______, _______
  61. //`--------------------------' `--------------------------'
  62. )
  63. };
  64. #ifdef OLED_DRIVER_ENABLE
  65. oled_rotation_t oled_init_user(oled_rotation_t rotation) {
  66. if (!is_keyboard_master()) {
  67. return OLED_ROTATION_180; // flips the display 180 degrees if offhand
  68. }
  69. return rotation;
  70. }
  71. #define L_BASE 0
  72. #define L_LOWER 2
  73. #define L_RAISE 4
  74. #define L_ADJUST 8
  75. void oled_render_layer_state(void) {
  76. oled_write_P(PSTR("Layer: "), false);
  77. switch (layer_state) {
  78. case L_BASE:
  79. oled_write_ln_P(PSTR("Spike"), false);
  80. break;
  81. case L_LOWER:
  82. oled_write_ln_P(PSTR("Jet"), false);
  83. break;
  84. case L_RAISE:
  85. oled_write_ln_P(PSTR("Faye"), false);
  86. break;
  87. case L_ADJUST:
  88. case L_ADJUST|L_LOWER:
  89. case L_ADJUST|L_RAISE:
  90. case L_ADJUST|L_LOWER|L_RAISE:
  91. oled_write_ln_P(PSTR("Ed"), false);
  92. break;
  93. }
  94. }
  95. char keylog_str[24] = {};
  96. const char code_to_name[60] = {
  97. ' ', ' ', ' ', ' ', 'a', 'b', 'c', 'd', 'e', 'f',
  98. 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
  99. 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
  100. '1', '2', '3', '4', '5', '6', '7', '8', '9', '0',
  101. 'R', 'E', 'B', 'T', '_', '-', '=', '[', ']', '\\',
  102. '#', ';', '\'', '`', ',', '.', '/', ' ', ' ', ' '};
  103. void set_keylog(uint16_t keycode, keyrecord_t *record) {
  104. char name = ' ';
  105. if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) ||
  106. (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX)) { keycode = keycode & 0xFF; }
  107. if (keycode < 60) {
  108. name = code_to_name[keycode];
  109. }
  110. // update keylog
  111. snprintf(keylog_str, sizeof(keylog_str), "%dx%d, k%2d : %c",
  112. record->event.key.row, record->event.key.col,
  113. keycode, name);
  114. }
  115. void oled_render_keylog(void) {
  116. oled_write(keylog_str, false);
  117. }
  118. void render_bootmagic_status(bool status) {
  119. /* Show Ctrl-Gui Swap options */
  120. static const char PROGMEM logo[][2][3] = {
  121. {{0x97, 0x98, 0}, {0xb7, 0xb8, 0}},
  122. {{0x95, 0x96, 0}, {0xb5, 0xb6, 0}},
  123. };
  124. if (status) {
  125. oled_write_ln_P(logo[0][0], false);
  126. oled_write_ln_P(logo[0][1], false);
  127. } else {
  128. oled_write_ln_P(logo[1][0], false);
  129. oled_write_ln_P(logo[1][1], false);
  130. }
  131. }
  132. void oled_render_logo(void) {
  133. static const char PROGMEM crkbd_logo[] = {
  134. 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94,
  135. 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4,
  136. 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4,
  137. 0};
  138. oled_write_P(crkbd_logo, false);
  139. }
  140. bool oled_task_user(void) {
  141. if (is_keyboard_master()) {
  142. oled_render_layer_state();
  143. oled_render_keylog();
  144. } else {
  145. oled_render_logo();
  146. }
  147. return false;
  148. }
  149. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  150. if (record->event.pressed) {
  151. set_keylog(keycode, record);
  152. }
  153. return true;
  154. }
  155. #endif // OLED_DRIVER_ENABLE