keymap.c 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /* Copyright 2021 Batuhan Başerdem
  2. * <baserdem.batuhan@gmail.com> @bbaserdem
  3. *
  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. *
  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. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #include QMK_KEYBOARD_H
  18. #include "bbaserdem.h"
  19. #ifdef KEYBOARD_crkbd_rev1
  20. # include "bb-oled-extra.h"
  21. #endif // KEYBOARD_crkbd_rev1
  22. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  23. [_BASE] = LAYOUT_split_3x6_3_wrapper(
  24. BB_ENC0,_BL1_5_,_BR1_5_,BB_ENC1,
  25. _BL2_1_,_BL2_5_,_BR2_5_,_BR2_1_,
  26. _BL3_1_,_BL3_5_,_BR3_5_,_BR3_1_,
  27. _BL4_3_,_BR4_3_
  28. ),
  29. [_CHAR] = LAYOUT_split_3x6_3_wrapper(
  30. _______,_CL1_5_,_CR1_5_,_______,
  31. XXXXXXX,_CL2_5_,_CR2_5_,XXXXXXX,
  32. XXXXXXX,_CL3_5_,_CR3_5_,XXXXXXX,
  33. _CL4_3_,_CR4_3_
  34. ),
  35. [_GAME] = LAYOUT_split_3x6_3_wrapper(
  36. _______,_GA1_5_,___6___,
  37. _GA2_1_,_GA2_5_,___6___,
  38. _GA3_1_,_GA3_5_,___6___,
  39. _GA4_3_,___3___
  40. ),
  41. [_MEDI] = LAYOUT_split_3x6_3_wrapper(
  42. ___6___,_ME1_5_,_______,
  43. ___6___,_ME2_5_,xxx1xxx,
  44. ___6___,_ME3_5_,xxx1xxx,
  45. ___3___,_ME4_3_
  46. ),
  47. [_NAVI] = LAYOUT_split_3x6_3_wrapper(
  48. ___6___,_NA1_5_,_______,
  49. ___6___,_NA2_5_,xxx1xxx,
  50. ___6___,_NA3_5_,xxx1xxx,
  51. ___3___,_NA4_3_
  52. ),
  53. [_SYMB] = LAYOUT_split_3x6_3_wrapper(
  54. ___6___,_SY1_5_,_______,
  55. ___6___,_SY2_5_,xxx1xxx,
  56. ___6___,_SY3_5_,xxx1xxx,
  57. ___3___,_SY4_3_
  58. ),
  59. [_NUMB] = LAYOUT_split_3x6_3_wrapper(
  60. _______,_NU1_5_,___6___,
  61. xxx1xxx,_NU2_5_,___6___,
  62. xxx1xxx,_NU3_5_,___6___,
  63. _NU4_3_,___3___
  64. ),
  65. [_FUNC] = LAYOUT_split_3x6_3_wrapper(
  66. _______,_FU1_5_,___6___,
  67. xxx1xxx,_FU2_5_,___6___,
  68. xxx1xxx,_FU3_5_,___6___,
  69. _FU4_3_,___3___
  70. ),
  71. [_MOUS] = LAYOUT_split_3x6_3_wrapper(
  72. _______,_MO1_5_,___6___,
  73. xxx1xxx,_MO2_5_,___6___,
  74. xxx1xxx,_MO3_5_,___6___,
  75. _MO4_3_,___3___
  76. ),
  77. [_MUSI] = LAYOUT_split_3x6_3_wrapper(
  78. _MU_12_,
  79. _MU_12_,
  80. _MU_12_,
  81. _MUL_3_,_MUR_3_
  82. )
  83. };
  84. // crkbd
  85. #ifdef KEYBOARD_crkbd_rev1
  86. #ifdef AUDIO_ENABLE
  87. const uint8_t music_map[MATRIX_ROWS][MATRIX_COLS] = LAYOUT_split_3x6_3(
  88. 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
  89. 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
  90. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
  91. 0, 0, 0, 0, 0, 0
  92. );
  93. #endif // AUDIO_ENABLE
  94. void keyboard_pre_init_keymap(void) {
  95. # ifdef AUDIO_ENABLE
  96. //thank you to @sigprof for this
  97. // Set audio pins to analog mode
  98. palSetLineMode(A5, PAL_MODE_INPUT_ANALOG);
  99. palSetLineMode(B1, PAL_MODE_INPUT_ANALOG);
  100. # endif // AUDIO_ENABLE
  101. # ifdef RGB_MATRIX_ENABLE
  102. // Led locations are different on protorne; need to be fixed
  103. g_led_config = (led_config_t) { {
  104. // Logical Layout
  105. // 0 1 2 3 4 5 COLS
  106. // -LEFT ROWS
  107. // 16 17 18 19 20 21 0
  108. // 15 14 13 12 11 10 1
  109. // 04 05 06 07 08 09 2
  110. // 03 02 01 3
  111. // -Right
  112. // 21 20 19 18 17 16 4
  113. // 10 11 12 13 14 15 5
  114. // 09 08 07 06 05 04 6
  115. // 01 02 03 7
  116. { 15, 16, 17, 18, 19, 20},
  117. { 14, 13, 12, 11, 10, 9 },
  118. { 3, 4, 5, 6, 7, 8 },
  119. { NO_LED, NO_LED, NO_LED, 2, 1, 0 },
  120. { 47, 46, 45, 44, 43, 42 },
  121. { 36, 37, 38, 39, 40, 41 },
  122. { 35, 34, 33, 32, 31, 30 },
  123. { NO_LED, NO_LED, NO_LED, 27, 28, 29 }
  124. }, {
  125. // Physical Layout
  126. // LEFT RIGHT
  127. // 16 17 18 19 20 21 16 17 18 19 20 21
  128. // 24 23 22 24 23 22
  129. // 15 14 13 12 11 10 15 14 13 12 11 10
  130. // 25 27
  131. // 04 05 06 07 08 09 04 05 06 07 08 09
  132. // 26 27 25 26
  133. // 03 02 01 03 02 01
  134. { 95, 63 }, { 80, 58 }, { 60, 55 },
  135. { 0, 41 }, { 16, 42 }, { 33, 37 }, { 50, 35 }, { 68, 37 }, { 85, 39 },
  136. { 85, 21 }, { 68, 19 }, { 50, 13 }, { 33, 20 }, { 16, 24 }, { 0, 24 },
  137. { 0, 7 }, { 16, 7 }, { 33, 3 }, { 50, 0 }, { 68, 2 }, { 85, 4 },
  138. { 85, 16 }, { 50, 13 }, { 16, 20 }, { 16, 38 }, { 50, 48 }, { 85, 52 },
  139. { 164, 55 }, { 144, 58 }, { 129, 63 },
  140. { 139, 39 }, { 156, 37 }, { 174, 35 }, { 191, 37 }, { 208, 42 }, { 224, 41 },
  141. { 224, 24 }, { 208, 24 }, { 191, 20 }, { 174, 13 }, { 156, 19 }, { 139, 21 },
  142. { 139, 4 }, { 156, 2 }, { 174, 0 }, { 191, 3 }, { 208, 7 }, { 224, 7 },
  143. { 208, 20 }, { 174, 13 }, { 139, 16 }, { 139, 52 }, { 174, 48 }, { 208, 38 }
  144. }, {
  145. // (x---)8 stands for indicator
  146. // (-x--)4 stands for per-key led
  147. // (--x-)2 stands for underglow led
  148. // (---1)1 stands for modifier key
  149. 12, 12, 12,
  150. 4, 4, 5, 4, 4, 4,
  151. 4, 5, 5, 5, 5, 4,
  152. 4, 4, 4, 4, 4, 4,
  153. 10, 10, 10, 10, 10, 10,
  154. 12, 12, 12,
  155. 4, 4, 4, 5, 4, 4,
  156. 4, 5, 5, 5, 5, 4,
  157. 4, 4, 4, 4, 4, 4,
  158. 10, 10, 10, 10, 10, 10
  159. } };
  160. # endif // RGB_MATRIX_ENABLE
  161. }
  162. // Enable OPAMP1 as A5 → B1 follower
  163. #ifdef AUDIO_ENABLE
  164. void keyboard_post_init_keymap(void) {
  165. OPAMP3->CSR = OPAMP3_CSR_VMSEL_1 | OPAMP3_CSR_VMSEL_0 | OPAMP3_CSR_VPSEL_0 | OPAMP3_CSR_OPAMP3EN;
  166. }
  167. #endif // AUDIO_ENABLE
  168. #ifdef OLED_ENABLE
  169. // Flip the display on the right half
  170. oled_rotation_t oled_init_user(oled_rotation_t rotation) {
  171. if (!is_keyboard_left()) {
  172. return OLED_ROTATION_180;
  173. }
  174. return rotation;
  175. }
  176. bool oled_task_keymap(void) {
  177. if (is_keyboard_left()) {
  178. render_status_left(0, 0);
  179. } else {
  180. render_status_right(0, 0);
  181. }
  182. return false;
  183. }
  184. #endif // OLED_ENABLE
  185. #endif // KEYBOARD_crkbd_rev1