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.

220 lines
9.5 KiB

  1. /*
  2. Copyright 2019 @foostan
  3. Copyright 2020 Drashna Jaelre <@drashna>
  4. Copyright 2022 Elliott Claus <@emdashii>
  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. #include <stdio.h>
  18. #include "ocean_dream.h"
  19. // Ocean Dream
  20. //# ifdef OCEAN_DREAM_ENABLE
  21. //render_stars();
  22. // is_calm = (record->event.pressed) ? true : false;
  23. //# endif
  24. // Left-hand home row mods
  25. #define HOME_A LGUI_T(KC_A)
  26. #define HOME_S LALT_T(KC_S)
  27. #define HOME_D LSFT_T(KC_D)
  28. #define HOME_F LCTL_T(KC_F)
  29. // Right-hand home row mods
  30. #define HOME_J RCTL_T(KC_J)
  31. #define HOME_K RSFT_T(KC_K)
  32. #define HOME_L LALT_T(KC_L)
  33. #define HOME_SCLN RGUI_T(KC_SCLN)
  34. // Special Space Keys
  35. #define LYR1SPC LT(1, KC_SPC)
  36. #define LYR2SPC LT(2, KC_SPC)
  37. #define CTRLSPC LCTL_T(KC_SPC)
  38. #define CTRLSFT C(KC_LSFT)
  39. #define TABLGUI LGUI_T(KC_TAB)
  40. //OSM(MOD_LSFT) One Shot Modifer Shift Key
  41. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  42. [0] = LAYOUT_split_3x6_3(
  43. //,-----------------------------------------------------. ,-----------------------------------------------------.
  44. KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC,
  45. //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
  46. TO(2), HOME_A, HOME_S, HOME_D, HOME_F, KC_G, KC_H, HOME_J, HOME_K, HOME_L, HOME_SCLN, KC_QUOT,
  47. //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
  48. KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ESC,
  49. //|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------|
  50. KC_DEL, LYR1SPC, OSL(1), TO(0), LYR2SPC, KC_ENT
  51. //`--------------------------' `--------------------------'
  52. ),
  53. [1] = LAYOUT_split_3x6_3(
  54. //,-----------------------------------------------------. ,-----------------------------------------------------.
  55. KC_TAB, KC_CIRC, KC_HASH, KC_LPRN, KC_RPRN, KC_DLR, KC_BSLS, KC_P7, KC_P8, KC_P9, KC_PPLS, KC_BSPC,
  56. //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
  57. TO(2), KC_EXLM, KC_AT, KC_LCBR, KC_RCBR, KC_EQL, KC_SLSH, KC_P4, KC_P5, KC_P6, KC_PMNS, KC_UNDS,
  58. //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
  59. KC_LSFT, KC_GRV, KC_PERC, KC_LBRC, KC_RBRC, KC_AMPR, KC_PAST, KC_P1, KC_P2, KC_P3, KC_PDOT, KC_ENT,
  60. //|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------|
  61. KC_LGUI, CTRLSPC, TO(1), TO(0), LYR2SPC, KC_P0
  62. //`--------------------------' `--------------------------'
  63. ),
  64. [2] = LAYOUT_split_3x6_3(
  65. //,-----------------------------------------------------. ,-----------------------------------------------------.
  66. TABLGUI, KC_INS, KC_HOME, KC_UP, KC_END, KC_PGUP, KC_ESC, KC_F7, KC_F8, KC_F9, KC_F10, KC_BSPC,
  67. //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
  68. TO(0), C(KC_A), KC_LEFT, KC_DOWN, KC_RGHT, KC_PGDN, KC_LALT, KC_F4, KC_F5, KC_F6, KC_F11, KC_DEL,
  69. //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
  70. KC_LSFT, C(KC_Z), C(KC_X), C(KC_C), C(KC_V), KC_LGUI, TO(3), KC_F1, KC_F2, KC_F3, KC_F12, KC_ENT,
  71. //|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------|
  72. KC_LALT, CTRLSPC, CTRLSFT, TO(0), CTRLSPC, KC_ENT
  73. //`--------------------------' `--------------------------'
  74. ),
  75. [3] = LAYOUT_split_3x6_3(
  76. //,-----------------------------------------------------. ,-----------------------------------------------------.
  77. KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_F1, KC_F2, KC_F4, KC_F11, RESET, KC_ESC,
  78. //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
  79. KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_X, KC_Z, KC_L, KC_C, KC_BRIU,
  80. //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
  81. KC_LSFT, KC_1, KC_2, KC_3, KC_4, KC_B, KC_5, KC_6, KC_7, KC_8, KC_9, KC_BRID,
  82. //|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------|
  83. KC_F3, KC_SPC, KC_F5, TO(0), KC_NUM, KC_ENT
  84. //`--------------------------' `--------------------------'
  85. )
  86. };
  87. #ifdef OLED_ENABLE
  88. oled_rotation_t oled_init_user(oled_rotation_t rotation) {
  89. if (!is_keyboard_master()) {
  90. return OLED_ROTATION_270; // flips the display 180 degrees if offhand
  91. }
  92. return rotation;
  93. }
  94. #define L_BASE 0
  95. #define L_LOWER 2
  96. #define L_RAISE 4
  97. #define L_ADJUST 8
  98. void oled_render_layer_state(void) {
  99. oled_write_P(PSTR("\nLayer: "), false);
  100. switch (get_highest_layer(layer_state|default_layer_state)) {
  101. case L_BASE:
  102. oled_write_ln_P(PSTR("QWERTY"), false);
  103. break;
  104. case L_LOWER:
  105. oled_write_ln_P(PSTR("Numpad"), false);
  106. break;
  107. case L_RAISE:
  108. oled_write_ln_P(PSTR("Nav"), false);
  109. break;
  110. case L_ADJUST:
  111. oled_write_ln_P(PSTR("Minecraft"), false);
  112. break;
  113. default:
  114. oled_write_ln_P(PSTR("Default"), false);
  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. bool oled_task_user(void) {
  163. if (is_keyboard_master()) {
  164. oled_render_layer_state();
  165. oled_render_keylog();
  166. } else {
  167. //oled_render_logo();
  168. if (is_oled_on()) render_stars();
  169. }
  170. return false;
  171. }
  172. //bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  173. // if (record->event.pressed) {
  174. // set_keylog(keycode, record);
  175. // }
  176. // return true;
  177. //}
  178. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  179. switch (keycode) {
  180. case KC_LCTL:
  181. case KC_RCTL:
  182. #ifdef OCEAN_DREAM_ENABLE
  183. is_calm = (record->event.pressed) ? true : false;
  184. #endif
  185. break;
  186. }
  187. return true;
  188. }
  189. #endif // OLED_ENABLE