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.

199 lines
9.2 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. // INSTRUCTIONS
  16. // install qmk: python3 -m pip install --user qmk (https://docs.qmk.fm/#/newbs_getting_started)
  17. // clone repo https://github.com/qmk/qmk_firmware into ~/qmk_firmware
  18. // copy this file into ~/qmk_firmware/keyboards/crkbd/keymaps/default/keymap.c
  19. // copy qmk.ini into ~/
  20. //
  21. // compile the keymap:
  22. // > qmk compile -kb crkbd -km default
  23. //
  24. // once keyboard connected, execute:
  25. // > qmk flash
  26. //
  27. // or if previous doesn't work, use:
  28. // > qmk flash -kb crkbd -km default
  29. //
  30. // and lately it needs the '-bl dfu' too:
  31. // > qmk flash -bl dfu -kb crkbd -km default
  32. //
  33. // If the right side does not work or acts as it were the left side, in
  34. // keyboards/crkbd/keymaps/default/config.h add:
  35. // #define SPLIT_USB_DETECT
  36. //
  37. // and to change the part that has the usb connected:
  38. // #define MASTER_RIGHT
  39. #include QMK_KEYBOARD_H
  40. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  41. [0] = LAYOUT_split_3x6_3(
  42. //,-----------------------------------------------------. ,-----------------------------------------------------.
  43. KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC,
  44. //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
  45. KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT,
  46. //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
  47. KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT,
  48. //|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------|
  49. KC_LGUI, MO(1), KC_SPC, KC_ENT, MO(2), KC_RALT
  50. //`--------------------------' `--------------------------'
  51. ),
  52. [1] = LAYOUT_split_3x6_3(
  53. //,-----------------------------------------------------. ,-----------------------------------------------------.
  54. KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL,
  55. //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
  56. KC_LCTL,KC_MUTE,KC_VOLD,KC_VOLU, XXXXXXX, XXXXXXX, KC_LEFT, KC_DOWN, KC_UP,KC_RIGHT, XXXXXXX, XXXXXXX,
  57. //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
  58. KC_LSFT, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
  59. //|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------|
  60. KC_LGUI, _______, KC_SPC, KC_ENT, MO(3), KC_RALT
  61. //`--------------------------' `--------------------------'
  62. ),
  63. [2] = LAYOUT_split_3x6_3(
  64. //,-----------------------------------------------------. ,-----------------------------------------------------.
  65. KC_ESC, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_DEL,
  66. //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
  67. KC_LCTL, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS, KC_GRV,
  68. //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
  69. KC_LSFT, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, KC_TILD,
  70. //|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------|
  71. KC_LGUI, MO(3), KC_SPC, KC_ENT, _______, KC_RALT
  72. //`--------------------------' `--------------------------'
  73. ),
  74. [3] = LAYOUT_split_3x6_3(
  75. //,-----------------------------------------------------. ,-----------------------------------------------------.
  76. QK_RBT, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11,
  77. //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
  78. RGB_TOG, RGB_HUI, RGB_SAI, RGB_VAI, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_F12,
  79. //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
  80. RGB_MOD, RGB_HUD, RGB_SAD, RGB_VAD, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
  81. //|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------|
  82. KC_LGUI, _______, KC_SPC, KC_ENT, _______, KC_RALT
  83. //`--------------------------' `--------------------------'
  84. )
  85. };
  86. #ifdef OLED_DRIVER_ENABLE
  87. oled_rotation_t oled_init_user(oled_rotation_t rotation) {
  88. if (!is_master) {
  89. return OLED_ROTATION_180; // flips the display 180 degrees if offhand
  90. }
  91. return rotation;
  92. }
  93. #define L_BASE 0
  94. #define L_LOWER 2
  95. #define L_RAISE 4
  96. #define L_ADJUST 8
  97. void oled_render_layer_state(void) {
  98. oled_write_P(PSTR("Layer: "), false);
  99. switch (layer_state) {
  100. case L_BASE:
  101. oled_write_ln_P(PSTR("Default"), false);
  102. break;
  103. case L_LOWER:
  104. oled_write_ln_P(PSTR("Lower"), false);
  105. break;
  106. case L_RAISE:
  107. oled_write_ln_P(PSTR("Raise"), false);
  108. break;
  109. case L_ADJUST:
  110. case L_ADJUST|L_LOWER:
  111. case L_ADJUST|L_RAISE:
  112. case L_ADJUST|L_LOWER|L_RAISE:
  113. oled_write_ln_P(PSTR("Adjust"), false);
  114. break;
  115. }
  116. }
  117. char keylog_str[24] = {};
  118. const char code_to_name[60] = {
  119. ' ', ' ', ' ', ' ', 'a', 'b', 'c', 'd', 'e', 'f',
  120. 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
  121. 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
  122. '1', '2', '3', '4', '5', '6', '7', '8', '9', '0',
  123. 'R', 'E', 'B', 'T', '_', '-', '=', '[', ']', '\\',
  124. '#', ';', '\'', '`', ',', '.', '/', ' ', ' ', ' '};
  125. void set_keylog(uint16_t keycode, keyrecord_t *record) {
  126. char name = ' ';
  127. if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) ||
  128. (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX)) { keycode = keycode & 0xFF; }
  129. if (keycode < 60) {
  130. name = code_to_name[keycode];
  131. }
  132. // update keylog
  133. snprintf(keylog_str, sizeof(keylog_str), "%dx%d, k%2d : %c",
  134. record->event.key.row, record->event.key.col,
  135. keycode, name);
  136. }
  137. void oled_render_keylog(void) {
  138. oled_write(keylog_str, false);
  139. }
  140. void render_bootmagic_status(bool status) {
  141. /* Show Ctrl-Gui Swap options */
  142. static const char PROGMEM logo[][2][3] = {
  143. {{0x97, 0x98, 0}, {0xb7, 0xb8, 0}},
  144. {{0x95, 0x96, 0}, {0xb5, 0xb6, 0}},
  145. };
  146. if (status) {
  147. oled_write_ln_P(logo[0][0], false);
  148. oled_write_ln_P(logo[0][1], false);
  149. } else {
  150. oled_write_ln_P(logo[1][0], false);
  151. oled_write_ln_P(logo[1][1], false);
  152. }
  153. }
  154. void oled_render_logo(void) {
  155. static const char PROGMEM crkbd_logo[] = {
  156. 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94,
  157. 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4,
  158. 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4,
  159. 0};
  160. oled_write_P(crkbd_logo, false);
  161. }
  162. void oled_task_user(void) {
  163. if (is_master) {
  164. oled_render_layer_state();
  165. oled_render_keylog();
  166. } else {
  167. oled_render_logo();
  168. }
  169. }
  170. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  171. if (record->event.pressed) {
  172. set_keylog(keycode, record);
  173. }
  174. return true;
  175. }
  176. #endif // OLED_DRIVER_ENABLE