keymap.c 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  1. #include QMK_KEYBOARD_H
  2. #include "bootloader.h"
  3. #ifdef PROTOCOL_LUFA
  4. #include "lufa.h"
  5. #include "split_util.h"
  6. #endif
  7. #ifdef AUDIO_ENABLE
  8. #include "audio.h"
  9. #endif
  10. #ifdef SSD1306OLED
  11. #include "ssd1306.h"
  12. #endif
  13. extern keymap_config_t keymap_config;
  14. #ifdef RGBLIGHT_ENABLE
  15. //Following line allows macro to read current RGB settings
  16. extern rgblight_config_t rgblight_config;
  17. #endif
  18. extern uint8_t is_master;
  19. // Each layer gets a name for readability, which is then used in the keymap matrix below.
  20. // The underscores don't mean anything - you can have a layer called STUFF or any other name.
  21. // Layer names don't all need to be of the same length, obviously, and you can also skip them
  22. // entirely and just use numbers.
  23. #define _QWERTY 0
  24. #define _COLEMAK 1
  25. #define _DVORAK 2
  26. #define _LOWER 3
  27. #define _RAISE 4
  28. #define _ADJUST 6
  29. enum custom_keycodes {
  30. QWERTY = SAFE_RANGE,
  31. COLEMAK,
  32. DVORAK,
  33. LOWER,
  34. RAISE,
  35. ADJUST,
  36. BACKLIT,
  37. EISU,
  38. KANA,
  39. RGBRST
  40. };
  41. enum macro_keycodes {
  42. KC_SAMPLEMACRO,
  43. };
  44. // Fillers to make layering more clear
  45. #define _______ KC_TRNS
  46. #define XXXXXXX KC_NO
  47. //Macros
  48. #define M_SAMPLE M(KC_SAMPLEMACRO)
  49. #if HELIX_ROWS == 5
  50. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  51. /* Qwerty
  52. * ,-----------------------------------------. ,-----------------------------------------.
  53. * | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | Del |
  54. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  55. * | Tab | Q | W | E | R | T | | Y | U | I | O | P | Bksp |
  56. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  57. * | Ctrl | A | S | D | F | G | | H | J | K | L | ; | ' |
  58. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  59. * | Shift| Z | X | C | V | B | [ | ] | N | M | , | . | / |Enter |
  60. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  61. * |Adjust| Esc | Alt | GUI | EISU |Lower |Space |Space |Raise | KANA | Left | Down | Up |Right |
  62. * `-------------------------------------------------------------------------------------------------'
  63. */
  64. [_QWERTY] = LAYOUT( \
  65. KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL, \
  66. KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, \
  67. KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, \
  68. KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_LBRC, KC_RBRC, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , \
  69. ADJUST, KC_ESC, KC_LALT, KC_LGUI, EISU, LOWER, KC_SPC, KC_SPC, RAISE, KANA, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
  70. ),
  71. /* Colemak
  72. * ,-----------------------------------------. ,-----------------------------------------.
  73. * | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | Del |
  74. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  75. * | Tab | Q | W | F | P | G | | J | L | U | Y | ; | Bksp |
  76. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  77. * | Ctrl | A | R | S | T | D | | H | N | E | I | O | ' |
  78. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  79. * | Shift| Z | X | C | V | B | [ | ] | K | M | , | . | / |Enter |
  80. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  81. * |Adjust| Esc | Alt | GUI | EISU |Lower |Space |Space |Raise | KANA | Left | Down | Up |Right |
  82. * `-------------------------------------------------------------------------------------------------'
  83. */
  84. [_COLEMAK] = LAYOUT( \
  85. KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL, \
  86. KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC, \
  87. KC_LCTL, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT, \
  88. KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_LBRC, KC_RBRC, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , \
  89. ADJUST, KC_ESC, KC_LALT, KC_LGUI, EISU, LOWER, KC_SPC, KC_SPC, RAISE, KANA, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
  90. ),
  91. /* Dvorak
  92. * ,-----------------------------------------. ,-----------------------------------------.
  93. * | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | Bksp |
  94. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  95. * | Tab | ' | , | . | P | Y | | F | G | C | R | L | Del |
  96. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  97. * | Ctrl | A | O | E | U | I | | D | H | T | N | S | / |
  98. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  99. * | Shift| ; | Q | J | K | X | [ | ] | B | M | W | V | Z |Enter |
  100. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  101. * |Adjust| Esc | Alt | GUI | EISU |Lower |Space |Space |Raise | KANA | Left | Down | Up |Right |
  102. * `-------------------------------------------------------------------------------------------------'
  103. */
  104. [_DVORAK] = LAYOUT( \
  105. KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \
  106. KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_DEL, \
  107. KC_LCTL, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_SLSH, \
  108. KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_LBRC, KC_RBRC, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_ENT , \
  109. ADJUST, KC_ESC, KC_LALT, KC_LGUI, EISU, LOWER, KC_SPC, KC_SPC, RAISE, KANA, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
  110. ),
  111. /* Lower
  112. * ,-----------------------------------------. ,-----------------------------------------.
  113. * | ~ | ! | @ | # | $ | % | | ^ | & | * | ( | ) | |
  114. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  115. * | ~ | ! | @ | # | $ | % | | ^ | & | * | ( | ) | |
  116. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  117. * | | F1 | F2 | F3 | F4 | F5 | | F6 | _ | + | { | } | | |
  118. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  119. * | | F7 | F8 | F9 | F10 | F11 | ( | ) | F12 | | | Home | End | |
  120. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  121. * | | | | | | | | | | | Next | Vol- | Vol+ | Play |
  122. * `-------------------------------------------------------------------------------------------------'
  123. */
  124. [_LOWER] = LAYOUT( \
  125. KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, _______, \
  126. KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, _______, \
  127. _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, \
  128. _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_LPRN, KC_RPRN, KC_F12, _______, _______, KC_HOME, KC_END, _______, \
  129. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
  130. ),
  131. /* Raise
  132. * ,-----------------------------------------. ,-----------------------------------------.
  133. * | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | Bksp |
  134. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  135. * | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | Del |
  136. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  137. * | | F1 | F2 | F3 | F4 | F5 | | F6 | - | = | [ | ] | \ |
  138. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  139. * | | F7 | F8 | F9 | F10 | F11 | | | F12 | | |PageDn|PageUp| |
  140. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  141. * | | | | | | | | | | | Next | Vol- | Vol+ | Play |
  142. * `-------------------------------------------------------------------------------------------------'
  143. */
  144. [_RAISE] = LAYOUT( \
  145. KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \
  146. KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL, \
  147. _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS, \
  148. _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, _______, _______, KC_F12, _______, _______, KC_PGDN, KC_PGUP, _______, \
  149. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
  150. ),
  151. /* Adjust (Lower + Raise)
  152. * ,-----------------------------------------. ,-----------------------------------------.
  153. * | F1 | F2 | F3 | F4 | F5 | F6 | | F7 | F8 | F9 | F10 | F11 | F12 |
  154. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  155. * | | Reset|RGBRST| | | | | | | | | | Del |
  156. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  157. * | | | |Aud on|Audoff| Mac | | Win |Qwerty|Colemk|Dvorak| | |
  158. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  159. * | | | | | | | | | | |RGB ON| HUE+ | SAT+ | VAL+ |
  160. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  161. * | | | | | | | | | | | MODE | HUE- | SAT- | VAL- |
  162. * `-------------------------------------------------------------------------------------------------'
  163. */
  164. [_ADJUST] = LAYOUT( \
  165. KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, \
  166. _______, RESET, RGBRST, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL, \
  167. _______, _______, _______, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, _______, _______, \
  168. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_TOG, RGB_HUI, RGB_SAI, RGB_VAI, \
  169. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_SMOD,RGB_HUD, RGB_SAD, RGB_VAD \
  170. )
  171. };
  172. #elif HELIX_ROWS == 4
  173. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  174. /* Qwerty
  175. * ,-----------------------------------------. ,-----------------------------------------.
  176. * | Tab | Q | W | E | R | T | | Y | U | I | O | P | Bksp |
  177. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  178. * | Ctrl | A | S | D | F | G | | H | J | K | L | ; | ' |
  179. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  180. * | Shift| Z | X | C | V | B | | N | M | , | . | / |Enter |
  181. * |------+------+------+------+------+------+-------------+------+------+------+------+------+------|
  182. * |Adjust| Esc | Alt | GUI | EISU |Lower |Space |Space |Raise | KANA | Left | Down | Up |Right |
  183. * `-------------------------------------------------------------------------------------------------'
  184. */
  185. [_QWERTY] = LAYOUT( \
  186. KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, \
  187. KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, \
  188. KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , \
  189. ADJUST, KC_ESC, KC_LALT, KC_LGUI, EISU, LOWER, KC_SPC, KC_SPC, RAISE, KANA, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
  190. ),
  191. /* Colemak
  192. * ,-----------------------------------------. ,-----------------------------------------.
  193. * | Tab | Q | W | F | P | G | | J | L | U | Y | ; | Bksp |
  194. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  195. * | Ctrl | A | R | S | T | D | | H | N | E | I | O | ' |
  196. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  197. * | Shift| Z | X | C | V | B | | K | M | , | . | / |Enter |
  198. * |------+------+------+------+------+------+-------------+------+------+------+------+------+------|
  199. * |Adjust| Esc | Alt | GUI | EISU |Lower |Space |Space |Raise | KANA | Left | Down | Up |Right |
  200. * `-------------------------------------------------------------------------------------------------'
  201. */
  202. [_COLEMAK] = LAYOUT( \
  203. KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC, \
  204. KC_LCTL, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT, \
  205. KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , \
  206. ADJUST, KC_ESC, KC_LALT, KC_LGUI, EISU, LOWER, KC_SPC, KC_SPC, RAISE, KANA, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
  207. ),
  208. /* Dvorak
  209. * ,-----------------------------------------. ,-----------------------------------------.
  210. * | Tab | ' | , | . | P | Y | | F | G | C | R | L | Del |
  211. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  212. * | Ctrl | A | O | E | U | I | | D | H | T | N | S | / |
  213. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  214. * | Shift| ; | Q | J | K | X | | B | M | W | V | Z |Enter |
  215. * |------+------+------+------+------+------+-------------+------+------+------+------+------+------|
  216. * |Adjust| Esc | Alt | GUI | EISU |Lower |Space |Space |Raise | KANA | Left | Down | Up |Right |
  217. * `-------------------------------------------------------------------------------------------------'
  218. */
  219. [_DVORAK] = LAYOUT( \
  220. KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_DEL, \
  221. KC_LCTL, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_SLSH, \
  222. KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_ENT , \
  223. ADJUST, KC_ESC, KC_LALT, KC_LGUI, EISU, LOWER, KC_SPC, KC_SPC, RAISE, KANA, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
  224. ),
  225. /* Lower
  226. * ,-----------------------------------------. ,-----------------------------------------.
  227. * | ~ | ! | @ | # | $ | % | | ^ | & | * | ( | ) | |
  228. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  229. * | | F1 | F2 | F3 | F4 | F5 | | F6 | _ | + | { | } | | |
  230. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  231. * | | F7 | F8 | F9 | F10 | F11 | | F12 | | | Home | End | |
  232. * |------+------+------+------+------+------+-------------+------+------+------+------+------+------|
  233. * | | | | | | | | | | | Next | Vol- | Vol+ | Play |
  234. * `-------------------------------------------------------------------------------------------------'
  235. */
  236. [_LOWER] = LAYOUT( \
  237. KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, _______, \
  238. _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, \
  239. _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, KC_HOME, KC_END, _______, \
  240. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
  241. ),
  242. /* Raise
  243. * ,-----------------------------------------. ,-----------------------------------------.
  244. * | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | Del |
  245. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  246. * | | F1 | F2 | F3 | F4 | F5 | | F6 | - | = | [ | ] | \ |
  247. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  248. * | | F7 | F8 | F9 | F10 | F11 | | F12 | | |PageDn|PageUp| |
  249. * |------+------+------+------+------+------+-------------+------+------+------+------+------+------|
  250. * | | | | | | | | | | | Next | Vol- | Vol+ | Play |
  251. * `-------------------------------------------------------------------------------------------------'
  252. */
  253. [_RAISE] = LAYOUT( \
  254. KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL, \
  255. _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS, \
  256. _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, KC_PGDN, KC_PGUP, _______, \
  257. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
  258. ),
  259. /* Adjust (Lower + Raise)
  260. * ,-----------------------------------------. ,-----------------------------------------.
  261. * | | Reset| | | | | | | | | | | Del |
  262. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  263. * | | | |Aud on|Audoff| Mac | | Win |Qwerty|Colemk|Dvorak| | |
  264. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  265. * | | | | | | | | | |RGB ON| HUE+ | SAT+ | VAL+ |
  266. * |------+------+------+------+------+------+-------------+------+------+------+------+------+------|
  267. * | | | | | | | | | | | MODE | HUE- | SAT- | VAL- |
  268. * `-------------------------------------------------------------------------------------------------'
  269. */
  270. [_ADJUST] = LAYOUT( \
  271. _______, RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL, \
  272. _______, _______, _______, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, _______, _______, \
  273. _______, _______, _______, _______, _______, _______, _______, _______, RGB_TOG, RGB_HUI, RGB_SAI, RGB_VAI, \
  274. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_SMOD,RGB_HUD, RGB_SAD, RGB_VAD \
  275. )
  276. };
  277. #else
  278. #error "undefined keymaps"
  279. #endif
  280. #ifdef AUDIO_ENABLE
  281. float tone_qwerty[][2] = SONG(QWERTY_SOUND);
  282. float tone_dvorak[][2] = SONG(DVORAK_SOUND);
  283. float tone_colemak[][2] = SONG(COLEMAK_SOUND);
  284. float tone_plover[][2] = SONG(PLOVER_SOUND);
  285. float tone_plover_gb[][2] = SONG(PLOVER_GOODBYE_SOUND);
  286. float music_scale[][2] = SONG(MUSIC_SCALE_SOUND);
  287. #endif
  288. // define variables for reactive RGB
  289. bool TOG_STATUS = false;
  290. int RGB_current_mode;
  291. void persistent_default_layer_set(uint16_t default_layer) {
  292. eeconfig_update_default_layer(default_layer);
  293. default_layer_set(default_layer);
  294. }
  295. // Setting ADJUST layer RGB back to default
  296. void update_tri_layer_RGB(uint8_t layer1, uint8_t layer2, uint8_t layer3) {
  297. if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) {
  298. #ifdef RGBLIGHT_ENABLE
  299. //rgblight_mode(RGB_current_mode);
  300. #endif
  301. layer_on(layer3);
  302. } else {
  303. layer_off(layer3);
  304. }
  305. }
  306. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  307. switch (keycode) {
  308. case QWERTY:
  309. if (record->event.pressed) {
  310. #ifdef AUDIO_ENABLE
  311. PLAY_SONG(tone_qwerty);
  312. #endif
  313. persistent_default_layer_set(1UL<<_QWERTY);
  314. }
  315. return false;
  316. break;
  317. case COLEMAK:
  318. if (record->event.pressed) {
  319. #ifdef AUDIO_ENABLE
  320. PLAY_SONG(tone_colemak);
  321. #endif
  322. persistent_default_layer_set(1UL<<_COLEMAK);
  323. }
  324. return false;
  325. break;
  326. case DVORAK:
  327. if (record->event.pressed) {
  328. #ifdef AUDIO_ENABLE
  329. PLAY_SONG(tone_dvorak);
  330. #endif
  331. persistent_default_layer_set(1UL<<_DVORAK);
  332. }
  333. return false;
  334. break;
  335. case LOWER:
  336. if (record->event.pressed) {
  337. //not sure how to have keyboard check mode and set it to a variable, so my work around
  338. //uses another variable that would be set to true after the first time a reactive key is pressed.
  339. if (TOG_STATUS) { //TOG_STATUS checks is another reactive key currently pressed, only changes RGB mode if returns false
  340. } else {
  341. TOG_STATUS = !TOG_STATUS;
  342. #ifdef RGBLIGHT_ENABLE
  343. //rgblight_mode(16);
  344. #endif
  345. }
  346. layer_on(_LOWER);
  347. update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
  348. } else {
  349. #ifdef RGBLIGHT_ENABLE
  350. //rgblight_mode(RGB_current_mode); // revert RGB to initial mode prior to RGB mode change
  351. #endif
  352. TOG_STATUS = false;
  353. layer_off(_LOWER);
  354. update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
  355. }
  356. return false;
  357. break;
  358. case RAISE:
  359. if (record->event.pressed) {
  360. //not sure how to have keyboard check mode and set it to a variable, so my work around
  361. //uses another variable that would be set to true after the first time a reactive key is pressed.
  362. if (TOG_STATUS) { //TOG_STATUS checks is another reactive key currently pressed, only changes RGB mode if returns false
  363. } else {
  364. TOG_STATUS = !TOG_STATUS;
  365. #ifdef RGBLIGHT_ENABLE
  366. //rgblight_mode(15);
  367. #endif
  368. }
  369. layer_on(_RAISE);
  370. update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
  371. } else {
  372. #ifdef RGBLIGHT_ENABLE
  373. //rgblight_mode(RGB_current_mode); // revert RGB to initial mode prior to RGB mode change
  374. #endif
  375. layer_off(_RAISE);
  376. TOG_STATUS = false;
  377. update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
  378. }
  379. return false;
  380. break;
  381. case ADJUST:
  382. if (record->event.pressed) {
  383. layer_on(_ADJUST);
  384. } else {
  385. layer_off(_ADJUST);
  386. }
  387. return false;
  388. break;
  389. //led operations - RGB mode change now updates the RGB_current_mode to allow the right RGB mode to be set after reactive keys are released
  390. case RGB_MOD:
  391. #ifdef RGBLIGHT_ENABLE
  392. if (record->event.pressed) {
  393. rgblight_mode(RGB_current_mode);
  394. rgblight_step();
  395. RGB_current_mode = rgblight_config.mode;
  396. }
  397. #endif
  398. return false;
  399. break;
  400. case EISU:
  401. if (record->event.pressed) {
  402. if(keymap_config.swap_lalt_lgui==false){
  403. register_code(KC_LANG2);
  404. }else{
  405. SEND_STRING(SS_LALT("`"));
  406. }
  407. } else {
  408. unregister_code(KC_LANG2);
  409. }
  410. return false;
  411. break;
  412. case KANA:
  413. if (record->event.pressed) {
  414. if(keymap_config.swap_lalt_lgui==false){
  415. register_code(KC_LANG1);
  416. }else{
  417. SEND_STRING(SS_LALT("`"));
  418. }
  419. } else {
  420. unregister_code(KC_LANG1);
  421. }
  422. return false;
  423. break;
  424. case RGBRST:
  425. #ifdef RGBLIGHT_ENABLE
  426. if (record->event.pressed) {
  427. eeconfig_update_rgblight_default();
  428. rgblight_enable();
  429. RGB_current_mode = rgblight_config.mode;
  430. }
  431. #endif
  432. break;
  433. }
  434. return true;
  435. }
  436. void matrix_init_user(void) {
  437. #ifdef AUDIO_ENABLE
  438. startup_user();
  439. #endif
  440. #ifdef RGBLIGHT_ENABLE
  441. RGB_current_mode = rgblight_config.mode;
  442. #endif
  443. //SSD1306 OLED init, make sure to add #define SSD1306OLED in config.h
  444. #ifdef SSD1306OLED
  445. iota_gfx_init(!has_usb()); // turns on the display
  446. #endif
  447. }
  448. #ifdef AUDIO_ENABLE
  449. void startup_user()
  450. {
  451. _delay_ms(20); // gets rid of tick
  452. }
  453. void shutdown_user()
  454. {
  455. _delay_ms(150);
  456. stop_all_notes();
  457. }
  458. void music_on_user(void)
  459. {
  460. music_scale_user();
  461. }
  462. void music_scale_user(void)
  463. {
  464. PLAY_SONG(music_scale);
  465. }
  466. #endif
  467. //SSD1306 OLED update loop, make sure to add #define SSD1306OLED in config.h
  468. #ifdef SSD1306OLED
  469. void matrix_scan_user(void) {
  470. static int scan_count = 0;
  471. if( scan_count == 2 ) {
  472. rgblight_enable();
  473. rgblight_mode(35);
  474. }
  475. if( scan_count < 3 ) scan_count ++;
  476. iota_gfx_task(); // this is what updates the display continuously
  477. }
  478. void matrix_update(struct CharacterMatrix *dest,
  479. const struct CharacterMatrix *source) {
  480. if (memcmp(dest->display, source->display, sizeof(dest->display))) {
  481. memcpy(dest->display, source->display, sizeof(dest->display));
  482. dest->dirty = true;
  483. }
  484. }
  485. //assign the right code to your layers for OLED display
  486. #define L_BASE 0
  487. #define L_LOWER 8
  488. #define L_RAISE 16
  489. #define L_FNLAYER 64
  490. #define L_NUMLAY 128
  491. #define L_NLOWER 136
  492. #define L_NFNLAYER 192
  493. #define L_MOUSECURSOR 256
  494. #define L_ADJUST 65536
  495. #define L_ADJUST_TRI 65560
  496. static void render_logo(struct CharacterMatrix *matrix) {
  497. static char logo[]={
  498. 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,0x90,0x91,0x92,0x93,0x94,
  499. 0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,0xb0,0xb1,0xb2,0xb3,0xb4,
  500. 0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,0xd0,0xd1,0xd2,0xd3,0xd4,
  501. 0};
  502. matrix_write(matrix, logo);
  503. //matrix_write_P(&matrix, PSTR(" Split keyboard kit"));
  504. }
  505. void render_status(struct CharacterMatrix *matrix) {
  506. // Render to mode icon
  507. static char logo[][2][3]={{{0x95,0x96,0},{0xb5,0xb6,0}},{{0x97,0x98,0},{0xb7,0xb8,0}}};
  508. if(keymap_config.swap_lalt_lgui==false){
  509. matrix_write(matrix, logo[0][0]);
  510. matrix_write_P(matrix, PSTR("\n"));
  511. matrix_write(matrix, logo[0][1]);
  512. }else{
  513. matrix_write(matrix, logo[1][0]);
  514. matrix_write_P(matrix, PSTR("\n"));
  515. matrix_write(matrix, logo[1][1]);
  516. }
  517. // Define layers here, Have not worked out how to have text displayed for each layer. Copy down the number you see and add a case for it below
  518. char buf[40];
  519. snprintf(buf,sizeof(buf), "Undef-%ld", layer_state);
  520. matrix_write_P(matrix, PSTR("\nLayer: "));
  521. switch (layer_state) {
  522. case L_BASE:
  523. matrix_write_P(matrix, PSTR("Default"));
  524. break;
  525. case L_RAISE:
  526. matrix_write_P(matrix, PSTR("Raise"));
  527. break;
  528. case L_LOWER:
  529. matrix_write_P(matrix, PSTR("Lower"));
  530. break;
  531. case L_ADJUST:
  532. case L_ADJUST_TRI:
  533. matrix_write_P(matrix, PSTR("Adjust"));
  534. break;
  535. default:
  536. matrix_write(matrix, buf);
  537. }
  538. // Host Keyboard LED Status
  539. char led[40];
  540. snprintf(led, sizeof(led), "\n%s %s %s",
  541. (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) ? "NUMLOCK" : " ",
  542. (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) ? "CAPS" : " ",
  543. (host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK)) ? "SCLK" : " ");
  544. matrix_write(matrix, led);
  545. }
  546. void iota_gfx_task_user(void) {
  547. struct CharacterMatrix matrix;
  548. #if DEBUG_TO_SCREEN
  549. if (debug_enable) {
  550. return;
  551. }
  552. #endif
  553. matrix_clear(&matrix);
  554. if(is_master){
  555. render_status(&matrix);
  556. }else{
  557. render_logo(&matrix);
  558. }
  559. matrix_update(&display, &matrix);
  560. }
  561. #endif