keymap.c 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. /* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
  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 "drashna.h"
  17. enum crkbd_keycodes { RGBRST = NEW_SAFE_RANGE };
  18. /*
  19. * The `LAYOUT_crkbd_base` macro is a template to allow the use of identical
  20. * modifiers for the default layouts (eg QWERTY, Colemak, Dvorak, etc), so
  21. * that there is no need to set them up for each layout, and modify all of
  22. * them if I want to change them. This helps to keep consistency and ease
  23. * of use. K## is a placeholder to pass through the individual keycodes
  24. */
  25. // clang-format off
  26. #define LAYOUT_split_3x6_3_wrapper(...) LAYOUT_split_3x6_3(__VA_ARGS__)
  27. #define LAYOUT_split_3x6_3_base( \
  28. K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, \
  29. K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, \
  30. K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A \
  31. ) \
  32. LAYOUT_split_3x6_3_wrapper( \
  33. KC_ESC, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, KC_MINS, \
  34. ALT_T(KC_TAB), K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, RALT_T(K1B), \
  35. OS_LSFT, CTL_T(K21), K22, K23, K24, K25, K26, K27, K28, K29, RCTL_T(K2A), OS_RSFT, \
  36. RGB_MOD, KC_SPC, BK_LWER, DL_RAIS, KC_ENT, OS_RGUI \
  37. )
  38. #define LAYOUT_split_3x6_3_base_wrapper(...) LAYOUT_split_3x6_3_base(__VA_ARGS__)
  39. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  40. [_QWERTY] = LAYOUT_split_3x6_3_base_wrapper(
  41. _________________QWERTY_L1_________________, _________________QWERTY_R1_________________,
  42. _________________QWERTY_L2_________________, _________________QWERTY_R2_________________,
  43. _________________QWERTY_L3_________________, _________________QWERTY_R3_________________
  44. ),
  45. [_COLEMAK] = LAYOUT_split_3x6_3_base_wrapper(
  46. _________________COLEMAK_L1________________, _________________COLEMAK_R1________________,
  47. _________________COLEMAK_L2________________, _________________COLEMAK_R2________________,
  48. _________________COLEMAK_L3________________, _________________COLEMAK_R3________________
  49. ),
  50. [_DVORAK] = LAYOUT_split_3x6_3_base_wrapper(
  51. _________________DVORAK_L1_________________, _________________DVORAK_R1_________________,
  52. _________________DVORAK_L2_________________, _________________DVORAK_R2_________________,
  53. _________________DVORAK_L3_________________, _________________DVORAK_R3_________________
  54. ),
  55. [_WORKMAN] = LAYOUT_split_3x6_3_base_wrapper(
  56. _________________WORKMAN_L1________________, _________________WORKMAN_R1________________,
  57. _________________WORKMAN_L2________________, _________________WORKMAN_R2________________,
  58. _________________WORKMAN_L3________________, _________________WORKMAN_R3________________
  59. ),
  60. [_NORMAN] = LAYOUT_split_3x6_3_base_wrapper(
  61. _________________NORMAN_L1_________________, _________________NORMAN_L1_________________,
  62. _________________NORMAN_L2_________________, _________________NORMAN_R2_________________,
  63. _________________NORMAN_L3_________________, _________________NORMAN_R3_________________
  64. ),
  65. [_MALTRON] = LAYOUT_split_3x6_3_base_wrapper(
  66. _________________MALTRON_L1________________, _________________MALTRON_R1________________,
  67. _________________MALTRON_L2________________, _________________MALTRON_R2________________,
  68. _________________MALTRON_L3________________, _________________MALTRON_R3________________
  69. ),
  70. [_EUCALYN] = LAYOUT_split_3x6_3_base_wrapper(
  71. _________________EUCALYN_L1________________, _________________EUCALYN_R1________________,
  72. _________________EUCALYN_L2________________, _________________EUCALYN_R2________________,
  73. _________________EUCALYN_L3________________, _________________EUCALYN_R3________________
  74. ),
  75. [_CARPLAX] = LAYOUT_split_3x6_3_base_wrapper(
  76. _____________CARPLAX_QFMLWY_L1_____________, _____________CARPLAX_QFMLWY_R1_____________,
  77. _____________CARPLAX_QFMLWY_L2_____________, _____________CARPLAX_QFMLWY_R2_____________,
  78. _____________CARPLAX_QFMLWY_L3_____________, _____________CARPLAX_QFMLWY_R3_____________
  79. ),
  80. [_LOWER] = LAYOUT_split_3x6_3_wrapper(
  81. KC_F11, _________________LOWER_L1__________________, _________________LOWER_R1__________________, KC_F11,
  82. KC_F12, _________________LOWER_L2__________________, _________________LOWER_R2__________________, KC_PIPE,
  83. _______, _________________LOWER_L3__________________, _________________LOWER_R3__________________, _______,
  84. _______, _______, _______, _______, _______, _______
  85. ),
  86. [_RAISE] = LAYOUT_split_3x6_3_wrapper( \
  87. _______, _________________RAISE_L1__________________, _________________RAISE_R1__________________, _______,
  88. _______, _________________RAISE_L2__________________, _________________RAISE_R2__________________, KC_BSLS,
  89. _______, _________________RAISE_L3__________________, _________________RAISE_R3__________________, _______,
  90. _______, _______, _______, _______, _______, _______
  91. ),
  92. [_ADJUST] = LAYOUT_split_3x6_3_wrapper( \
  93. KC_MAKE, _________________ADJUST_L1_________________, _________________ADJUST_R1_________________, KC_RESET,
  94. VRSN, _________________ADJUST_L2_________________, _________________ADJUST_R2_________________, EEP_RST,
  95. MG_NKRO, _________________ADJUST_L3_________________, _________________ADJUST_R3_________________, RGB_IDL,
  96. HPT_TOG, KC_NUKE, _______, _______, TG_MODS, HPT_FBK
  97. )
  98. };
  99. // clang-format on
  100. #ifdef OLED_DRIVER_ENABLE
  101. oled_rotation_t oled_init_user(oled_rotation_t rotation) {
  102. return OLED_ROTATION_270;
  103. }
  104. #endif
  105. #ifdef TAPPING_TERM_PER_KEY
  106. uint16_t get_tapping_term(uint16_t keycode, keyrecord_t *record) {
  107. switch (keycode) {
  108. case ALT_T(KC_A):
  109. return TAPPING_TERM + 100;
  110. default:
  111. return TAPPING_TERM;
  112. }
  113. }
  114. #endif
  115. void matrix_slave_scan_user(void) {
  116. #ifdef RGB_MATRIX_ENABLE
  117. rgb_matrix_task();
  118. #endif
  119. }
  120. #ifdef RGB_MATRIX_ENABLE
  121. void suspend_power_down_keymap(void) { rgb_matrix_set_suspend_state(true); }
  122. void suspend_wakeup_init_keymap(void) { rgb_matrix_set_suspend_state(false); }
  123. void check_default_layer(uint8_t mode, uint8_t type, uint8_t led_min, uint8_t led_max) {
  124. switch (get_highest_layer(default_layer_state)) {
  125. case _QWERTY:
  126. rgb_matrix_layer_helper(HSV_CYAN, mode, rgb_matrix_config.speed, type, led_min, led_max);
  127. break;
  128. case _COLEMAK:
  129. rgb_matrix_layer_helper(HSV_MAGENTA, mode, rgb_matrix_config.speed, type, led_min, led_max);
  130. break;
  131. case _DVORAK:
  132. rgb_matrix_layer_helper(HSV_SPRINGGREEN, mode, rgb_matrix_config.speed, type, led_min, led_max);
  133. break;
  134. case _WORKMAN:
  135. rgb_matrix_layer_helper(HSV_GOLDENROD, mode, rgb_matrix_config.speed, type, led_min, led_max);
  136. break;
  137. case _NORMAN:
  138. rgb_matrix_layer_helper(HSV_CORAL, mode, rgb_matrix_config.speed, type, led_min, led_max);
  139. break;
  140. case _MALTRON:
  141. rgb_matrix_layer_helper(HSV_YELLOW, mode, rgb_matrix_config.speed, type, led_min, led_max);
  142. break;
  143. case _EUCALYN:
  144. rgb_matrix_layer_helper(HSV_PINK, mode, rgb_matrix_config.speed, type, led_min, led_max);
  145. break;
  146. case _CARPLAX:
  147. rgb_matrix_layer_helper(HSV_BLUE, mode, rgb_matrix_config.speed, type, led_min, led_max);
  148. break;
  149. }
  150. }
  151. void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
  152. if (userspace_config.rgb_layer_change) {
  153. switch (get_highest_layer(layer_state)) {
  154. case _GAMEPAD:
  155. rgb_matrix_layer_helper(HSV_ORANGE, 0, rgb_matrix_config.speed, LED_FLAG_UNDERGLOW, led_min, led_max);
  156. break;
  157. case _DIABLO:
  158. rgb_matrix_layer_helper(HSV_RED, 0, rgb_matrix_config.speed, LED_FLAG_UNDERGLOW, led_min, led_max);
  159. break;
  160. case _RAISE:
  161. rgb_matrix_layer_helper(HSV_YELLOW, 0, rgb_matrix_config.speed, LED_FLAG_UNDERGLOW, led_min, led_max);
  162. break;
  163. case _LOWER:
  164. rgb_matrix_layer_helper(HSV_GREEN, 0, rgb_matrix_config.speed, LED_FLAG_UNDERGLOW, led_min, led_max);
  165. break;
  166. case _ADJUST:
  167. rgb_matrix_layer_helper(HSV_RED, 0, rgb_matrix_config.speed, LED_FLAG_UNDERGLOW, led_min, led_max);
  168. break;
  169. default: {
  170. check_default_layer(0, LED_FLAG_UNDERGLOW, led_min, led_max);
  171. break;
  172. }
  173. }
  174. check_default_layer(0, LED_FLAG_MODIFIER, led_min, led_max);
  175. }
  176. }
  177. #endif