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.

166 lines
7.1 KiB

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