keymap.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. /* Copyright 2020 Stephen J. Bush
  2. *
  3. * This program is free software: you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation, either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  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. *
  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 "muppetjones.h"
  18. #include "features/bongo_cat.h"
  19. #define LAYOUT_wrapper(...) LAYOUT(__VA_ARGS__)
  20. /*
  21. * qmk compile -kb lily58/rev1 -km muppetjones
  22. */
  23. // GACS (Lower)
  24. #define HR_LBRC LCTL_T(KC_LBRC)
  25. #define HR_RBRC LSFT_T(KC_RBRC)
  26. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  27. // clang-format off
  28. /* Colemak DH
  29. * ,-----------------------------------------. ,-----------------------------------------.
  30. * | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | BADJ |
  31. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  32. * | Tab | Q | W | F | P | B | | J | L | U | Y | ; | Bksp |
  33. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  34. * | Esc | A | R | S | T | G |-------. ,-------| M | N | E | I | O | ' |
  35. * |------+------+------+------+------+------| Raise | | Lower |------+------+------+------+------+------|
  36. * |LShift| Z | X | C | D | V |-------| |-------| K | H | , | . | / |Enter |
  37. * `-----------------------------------------/ / \ \-----------------------------------------'
  38. * | Alt | LGUI |LOWER | /Space / \Space \ |RAISE | Ctrl | RGUI |
  39. * | | | |/ / \ \ | | | |
  40. * `----------------------------' '------''--------------------'
  41. */
  42. [_CLMK_DH] = LAYOUT_wrapper(
  43. KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_CAPS, __BLANK____________________________________, KC_BSPC,
  44. KC_CAPS, __COLEMAK_MOD_DH_L1________________________, __COLEMAK_MOD_DH_R1_W_QUOT_________________, KC_BSPC,
  45. HY_ESC, __COLEMAK_MOD_DH_L2_W_GACS_________________, __COLEMAK_MOD_DH_R2_W_SCAG_________________, KC_QUOT,
  46. TD_LAYR, __COLEMAK_MOD_DH_L3_W_SFTV_________________, KC_CAPS, KC_TAB, __COLEMAK_MOD_DH_R3________________________, SC_SENT,
  47. XXXXXXX, XXXXXXX, HY_ESC, LOW_ENT, NAV_SPC, HY_BSPC, XXXXXXX, XXXXXXX
  48. ),
  49. /* QWERTY
  50. * ,-----------------------------------------. ,-----------------------------------------.
  51. * | ESC | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | ` |
  52. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  53. * | Tab | Q | W | E | R | T | | Y | U | I | O | P | - |
  54. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  55. * |LCTRL | A | S | D | F | G |-------. ,-------| H | J | K | L | ; | ' |
  56. * |------+------+------+------+------+------| [ | | ] |------+------+------+------+------+------|
  57. * |LShift| Z | X | C | V | B |-------| |-------| N | M | , | . | / |RShift|
  58. * `-----------------------------------------/ / \ \-----------------------------------------'
  59. * | LAlt | LGUI |LOWER | /Space / \Enter \ |RAISE |BackSP| RGUI |
  60. * | | | |/ / \ \ | | | |
  61. * `----------------------------' '------''--------------------'
  62. */
  63. [_QWERTY] = LAYOUT_wrapper(
  64. _______, __BLANK____________________________________, __BLANK____________________________________, _______,
  65. _______, __QWERTY_L1________________________________, __QWERTY_R1________________________________, _______,
  66. _______, __QWERTY_L2________________________________, __QWERTY_R2________________________________, _______,
  67. _______, __QWERTY_L3________________________________, _______, _______, __QWERTY_R3________________________________, _______,
  68. _______, _______, _______, _______, _______, _______, _______, _______
  69. ),
  70. [_MOUSE] = LAYOUT_wrapper(
  71. _______, __BLANK____________________________________, __BLANK____________________________________, _______,
  72. _______, __BLANK____________________________________, __BLANK____________________________________, _______,
  73. _______, __BLANK____________________________________, __BLANK____________________________________, _______,
  74. _______, __BLANK____________________________________, _______, _______, __BLANK____________________________________, _______,
  75. KC_BTN1, __BLANK____________________________________, _______, KC_BTN2
  76. ),
  77. /* LOWER
  78. * ,-----------------------------------------. ,-----------------------------------------.
  79. * | ` | | Mute | Vol- | Vol+ | | | | | | | | |
  80. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  81. * | ~ | | | ` | | ( | | ) | 7 | 8 | 9 | \ | Bksp |
  82. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  83. * | | GUI | ALT | _ | - | { |-------. ,-------| } | 4 | 5 | 6 | * | ` |
  84. * |------+------+------+------+------+------| | | |------+------+------+------+------+------|
  85. * | | | | + | = | [ |-------| |-------| ] | 1 | 2 | 3 | | |Enter |
  86. * `-----------------------------------------/ / \ \-----------------------------------------'
  87. * | | |LOWER | / / \ \ | 0 | . | = |
  88. * | | | |/ / \ \ | | | |
  89. * `----------------------------' '------''--------------------'
  90. */
  91. [_LOWER] = LAYOUT_wrapper(
  92. _______, __BLANK____________________________________, __BLANK____________________________________, _______,
  93. _______, __SYMBOLS_L1_______________________________, __NUMPAD_R1________________________________, _______,
  94. _______, __SYMBOLS_L2_______________________________, __NUMPAD_R2________________________________, KC_COMM,
  95. _______, __SYMBOLS_L3_______________________________, _______, _______, __NUMPAD_R3________________________________, KC_DOT,
  96. _______, _______, _______, _______, KC_SPC, KC_0, KC_DOT, _______
  97. ),
  98. /* RAISE
  99. * ,-----------------------------------------. ,-----------------------------------------.
  100. * | |MS_A_0|MS_A_1|MS_A_2| | | | | | | | | |
  101. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  102. * | | | | | |MS_W_U| | | | | | | |
  103. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  104. * | | GUI | ALT | CTL | SFT |MS_W_D|-------. ,-------| | Left | Down | Up |Right | |
  105. * |------+------+------+------+------+------|MS_W_L | |MS_W_R |------+------+------+------+------+------|
  106. * | | MS_L | MS_D | MS_U | MS_R | |-------| |-------| |MS_W_L|MS_W_D|MS_W_U|MS_W_R| |
  107. * `-----------------------------------------/ / \ \-----------------------------------------'
  108. * | | | MS_2 | / MS_1 / \ \ |RAISE | | |
  109. * | | | |/ / \ \ | | | |
  110. * `----------------------------' '------''--------------------'
  111. // */
  112. [_RAISE] = LAYOUT_wrapper(
  113. _______, __BLANK____________________________________, __BLANK____________________________________, _______,
  114. _______, __SYMBOLS_L1_______________________________, __NAV_R1___________________________________, _______,
  115. _______, __SYMBOLS_L2_______________________________, __NAV_R2___________________________________, _______,
  116. _______, __SYMBOLS_L3_______________________________, _______, _______, __NAV_R3___________________________________, _______,
  117. _______, _______, _______, _______, _______, _______, _______, _______
  118. ),
  119. [_NAV] = LAYOUT_wrapper(
  120. _______, __BLANK____________________________________, __BLANK____________________________________, _______,
  121. _______, __VIM_L1___________________________________, __NAV_R1___________________________________, _______,
  122. _______, __BLANK_W_GACS_____________________________, __NAV_R2___________________________________, _______,
  123. _______, __BLANK____________________________________, _______, _______, __NAV_R3___________________________________, _______,
  124. _______, _______, _______, _______, _______, _______, _______, _______
  125. ),
  126. /* ADJUST
  127. * ,-----------------------------------------. ,-----------------------------------------.
  128. * | | Reset| | | | | | Reset| | | | | |
  129. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  130. * | | | | | | | | | | | | | |
  131. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  132. * | | | | | | |-------. ,-------| | |RGB ON| HUE+ | SAT+ | VAL+ |
  133. * |------+------+------+------+------+------| | | |------+------+------+------+------+------|
  134. * | | | | | | |-------| |-------| | | MODE | HUE- | SAT- | VAL- |
  135. * `-----------------------------------------/ / \ \-----------------------------------------'
  136. * | LAlt | LGUI |LOWER | /Space / \Enter \ |RAISE |BackSP| RGUI |
  137. * | | | |/ / \ \ | | | |
  138. * `----------------------------' '------''--------------------'
  139. */
  140. [_ADJUST] = LAYOUT_wrapper(
  141. _______, __BLANK____________________________________, _______, CLMK_DH, QWERTY, _______, _______, _______,
  142. QK_BOOT, __ADJUST_L1________________________________, __MEDIA_R1_________________________________, _______,
  143. _______, __ADJUST_L2________________________________, __MEDIA_R2_________________________________, _______,
  144. _______, __ADJUST_L3________________________________, _______, _______, __MEDIA_R3_________________________________, _______,
  145. _______, _______, _______, _______, _______, _______, _______, _______
  146. )
  147. // clang-format on
  148. };
  149. // SSD1306 OLED update loop, make sure to enable OLED_DRIVER_ENABLE=yes in rules.mk
  150. #ifdef OLED_ENABLE
  151. oled_rotation_t oled_init_user(oled_rotation_t rotation) {
  152. if (!is_keyboard_master()) return OLED_ROTATION_180; // flips the display 180 degrees if offhand
  153. return rotation;
  154. }
  155. // When you add source files to SRC in rules.mk, you can use functions.
  156. const char *read_layer_state_user(void);
  157. void set_keylog(uint16_t keycode, keyrecord_t *record);
  158. const char *read_keylog(void);
  159. const char *read_keylogs(void);
  160. char layer_state_str[24];
  161. const char *read_layer_state_user(void) {
  162. // NOTE;
  163. switch (get_highest_layer(layer_state)) {
  164. case _CLMK_DH:
  165. return "Layer: Colemak";
  166. break;
  167. case _QWERTY:
  168. return "Layer: QWERTY ";
  169. break;
  170. case _MOUSE:
  171. return "Layer: Mouse ";
  172. break;
  173. case _LOWER:
  174. return "Layer: Lower ";
  175. break;
  176. case _RAISE:
  177. return "Layer: Raise ";
  178. break;
  179. case _NAV:
  180. return "Layer: Nav ";
  181. break;
  182. case _ADJUST:
  183. return "Layer: Adjust ";
  184. break;
  185. default:
  186. break;
  187. }
  188. char *layer_state_str = "Layer: Und- ";
  189. layer_state_str[10] = '0' + layer_state % 10;
  190. return layer_state_str;
  191. }
  192. bool oled_task_user(void) {
  193. if (is_keyboard_master()) {
  194. // If you want to change the display of OLED, you need to change here
  195. oled_write_ln(read_layer_state_user(), false);
  196. oled_write_ln(read_keylog(), false);
  197. oled_write_ln(read_keylogs(), false);
  198. } else {
  199. render_bongo_cat();
  200. oled_set_cursor(0, 6);
  201. oled_write_P(PSTR("WPM: "), false);
  202. oled_write(get_u8_str(get_current_wpm(), ' '), false);
  203. }
  204. return false;
  205. }
  206. #endif // OLED_DRIVER_ENABLE
  207. bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
  208. if (record->event.pressed) {
  209. #ifdef OLED_ENABLE
  210. set_keylog(keycode, record);
  211. #endif
  212. // set_timelog();
  213. }
  214. // Regular user keycode case statement
  215. switch (keycode) {
  216. default:
  217. return true;
  218. }
  219. return true;
  220. }