keymap.c 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. /* Copyright 2020 Hybrid
  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. enum layers {
  18. _MAIN = 0,
  19. _LY1,
  20. _LY2,
  21. };
  22. enum {
  23. TD_A,
  24. TD_E,
  25. TD_I,
  26. TD_O,
  27. TD_U,
  28. TD_SLASH,
  29. TD_UNDER,
  30. TD_OP_ACCOL,
  31. TD_CL_ACCOL,
  32. TD_QUESTION,
  33. TD_CEDILLE,
  34. TD_DOT,
  35. };
  36. void dance_a_accent (qk_tap_dance_state_t *state, void *user_data) {
  37. if (state->count == 2) {
  38. tap_code (KC_0);
  39. }
  40. else {
  41. tap_code (KC_Q);
  42. }
  43. }
  44. void dance_e_accent (qk_tap_dance_state_t *state, void *user_data) {
  45. if (state->count == 2) {
  46. tap_code (KC_2);
  47. }
  48. else if (state->count == 3) {
  49. tap_code (KC_7);
  50. }
  51. else {
  52. tap_code (KC_E);
  53. }
  54. }
  55. void dance_i_accent (qk_tap_dance_state_t *state, void *user_data) {
  56. if (state->count == 2) {
  57. tap_code (KC_NUM_LOCK);
  58. register_code (KC_LALT);
  59. tap_code (KC_P0);
  60. tap_code (KC_P2);
  61. tap_code (KC_P3);
  62. tap_code (KC_P8);
  63. unregister_code (KC_LALT);
  64. tap_code (KC_NUM_LOCK);
  65. }
  66. else {
  67. tap_code (KC_I);
  68. }
  69. }
  70. void dance_o_accent (qk_tap_dance_state_t *state, void *user_data) {
  71. if (state->count == 2) {
  72. tap_code (KC_NUM_LOCK);
  73. register_code (KC_LALT);
  74. tap_code (KC_P0);
  75. tap_code (KC_P2);
  76. tap_code (KC_P4);
  77. tap_code (KC_P4);
  78. unregister_code (KC_LALT);
  79. tap_code (KC_NUM_LOCK);
  80. }
  81. else {
  82. tap_code (KC_O);
  83. }
  84. }
  85. void dance_u_accent (qk_tap_dance_state_t *state, void *user_data) {
  86. if (state->count == 2) {
  87. tap_code (KC_NUM_LOCK);
  88. register_code (KC_LALT);
  89. tap_code (KC_P0);
  90. tap_code (KC_P2);
  91. tap_code (KC_P4);
  92. tap_code (KC_P9);
  93. unregister_code (KC_LALT);
  94. tap_code (KC_NUM_LOCK);
  95. }
  96. else {
  97. tap_code (KC_U);
  98. }
  99. }
  100. void dance_slash (qk_tap_dance_state_t *state, void *user_data) {
  101. if (state->count == 2) {
  102. tap_code (KC_NUM_LOCK);
  103. register_code (KC_LALT);
  104. tap_code (KC_P0);
  105. tap_code (KC_P9);
  106. tap_code (KC_P2);
  107. unregister_code (KC_LALT);
  108. tap_code (KC_NUM_LOCK);
  109. }
  110. else {
  111. tap_code (KC_PSLS);
  112. }
  113. }
  114. void dance_under (qk_tap_dance_state_t *state, void *user_data) {
  115. if (state->count == 2) {
  116. tap_code (KC_NUM_LOCK);
  117. register_code (KC_LALT);
  118. tap_code (KC_P0);
  119. tap_code (KC_P9);
  120. tap_code (KC_P5);
  121. unregister_code (KC_LALT);
  122. tap_code (KC_NUM_LOCK);
  123. }
  124. else {
  125. tap_code (KC_6);
  126. }
  127. }
  128. void dance_open_accol (qk_tap_dance_state_t *state, void *user_data) {
  129. if (state->count == 2) {
  130. tap_code (KC_NUM_LOCK);
  131. register_code (KC_LALT);
  132. tap_code (KC_P0);
  133. tap_code (KC_P1);
  134. tap_code (KC_P2);
  135. tap_code (KC_P3);
  136. unregister_code (KC_LALT);
  137. tap_code (KC_NUM_LOCK);
  138. }
  139. else if (state->count == 3) {
  140. tap_code (KC_NUM_LOCK);
  141. register_code (KC_LALT);
  142. tap_code (KC_P0);
  143. tap_code (KC_P9);
  144. tap_code (KC_P1);
  145. unregister_code (KC_LALT);
  146. tap_code (KC_NUM_LOCK);
  147. }
  148. else {
  149. tap_code (KC_5);
  150. }
  151. }
  152. void dance_close_accol (qk_tap_dance_state_t *state, void *user_data) {
  153. if (state->count == 2) {
  154. tap_code (KC_NUM_LOCK);
  155. register_code (KC_LALT);
  156. tap_code (KC_P0);
  157. tap_code (KC_P1);
  158. tap_code (KC_P2);
  159. tap_code (KC_P5);
  160. unregister_code (KC_LALT);
  161. tap_code (KC_NUM_LOCK);
  162. }
  163. else if (state->count == 3) {
  164. tap_code (KC_NUM_LOCK);
  165. register_code (KC_LALT);
  166. tap_code (KC_P0);
  167. tap_code (KC_P9);
  168. tap_code (KC_P3);
  169. unregister_code (KC_LALT);
  170. tap_code (KC_NUM_LOCK);
  171. }
  172. else {
  173. tap_code (KC_MINS);
  174. }
  175. }
  176. void dance_question (qk_tap_dance_state_t *state, void *user_data) {
  177. if (state->count == 2) {
  178. tap_code (KC_NUM_LOCK);
  179. register_code (KC_LALT);
  180. tap_code (KC_P0);
  181. tap_code (KC_P0);
  182. tap_code (KC_P3);
  183. tap_code (KC_P3);
  184. unregister_code (KC_LALT);
  185. tap_code (KC_NUM_LOCK);
  186. }
  187. else {
  188. tap_code (KC_NUM_LOCK);
  189. register_code (KC_LALT);
  190. tap_code (KC_P0);
  191. tap_code (KC_P0);
  192. tap_code (KC_P6);
  193. tap_code (KC_P3);
  194. unregister_code (KC_LALT);
  195. tap_code (KC_NUM_LOCK);
  196. }
  197. }
  198. void dance_cedille (qk_tap_dance_state_t *state, void *user_data) {
  199. if (state->count == 2) {
  200. tap_code (KC_9);
  201. }
  202. else {
  203. tap_code (KC_C);
  204. }
  205. }
  206. void dance_dot (qk_tap_dance_state_t *state, void *user_data) {
  207. if (state->count == 2) {
  208. tap_code (KC_NUM_LOCK);
  209. register_code (KC_LALT);
  210. tap_code (KC_P0);
  211. tap_code (KC_P4);
  212. tap_code (KC_P4);
  213. unregister_code (KC_LALT);
  214. tap_code (KC_NUM_LOCK);
  215. }
  216. else {
  217. tap_code (KC_NUM_LOCK);
  218. register_code (KC_LALT);
  219. tap_code (KC_P0);
  220. tap_code (KC_P4);
  221. tap_code (KC_P6);
  222. unregister_code (KC_LALT);
  223. tap_code (KC_NUM_LOCK);
  224. }
  225. }
  226. qk_tap_dance_action_t tap_dance_actions[] = {
  227. [TD_A] = ACTION_TAP_DANCE_FN(dance_a_accent),
  228. [TD_E] = ACTION_TAP_DANCE_FN(dance_e_accent),
  229. [TD_I] = ACTION_TAP_DANCE_FN(dance_i_accent),
  230. [TD_O] = ACTION_TAP_DANCE_FN(dance_o_accent),
  231. [TD_U] = ACTION_TAP_DANCE_FN(dance_u_accent),
  232. [TD_SLASH] = ACTION_TAP_DANCE_FN(dance_slash),
  233. [TD_UNDER] = ACTION_TAP_DANCE_FN(dance_under),
  234. [TD_OP_ACCOL] = ACTION_TAP_DANCE_FN(dance_open_accol),
  235. [TD_CL_ACCOL] = ACTION_TAP_DANCE_FN(dance_close_accol),
  236. [TD_QUESTION] = ACTION_TAP_DANCE_FN(dance_question),
  237. [TD_CEDILLE] = ACTION_TAP_DANCE_FN(dance_cedille),
  238. [TD_DOT] = ACTION_TAP_DANCE_FN(dance_dot),
  239. };
  240. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  241. // red led layout
  242. [_MAIN] = LAYOUT_ortho_5x15(
  243. KC_ESC, KC_RBRC, KC_1, KC_2, KC_3, KC_4, KC_5, TD(TD_DOT), KC_6, KC_7, KC_8, KC_9, KC_0, DF(_LY1), KC_NO,
  244. KC_TAB, TD(TD_A), KC_W, TD(TD_E), KC_R, KC_T, KC_Y, KC_ENT, TD(TD_U), TD(TD_I), TD(TD_O), KC_P, KC_NO, TD(TD_OP_ACCOL), TD(TD_CL_ACCOL),
  245. KC_PGUP, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_ENT, KC_J, KC_K, KC_L, KC_SCLN, KC_UP, KC_NO, KC_NO,
  246. KC_PGDN, KC_Z, KC_X, TD(TD_CEDILLE), KC_V, KC_B, KC_N, KC_DOT, TD(TD_QUESTION), TD(TD_UNDER), TD(TD_SLASH), KC_LEFT, KC_DOWN, KC_RGHT, KC_NO,
  247. KC_NO, KC_NO, KC_LALT, KC_LCTL, KC_LSFT, KC_SPC, KC_HOME, KC_LGUI, KC_END, KC_BSPC, KC_RALT, KC_DEL, KC_PMNS, KC_NO, MO(1)
  248. ),
  249. // green led layout
  250. [_LY1] = LAYOUT_ortho_5x15(
  251. KC_ESC, RGB_TOG, RGB_RMOD, RGB_M_P, RGB_M_B, RGB_M_SW, RGB_M_K, RGB_M_G, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, DF(_LY2), DF(_MAIN),
  252. DB_TOGG, KC_PSCR, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_NUM, KC_PSLS, KC_PAST, KC_PMNS,
  253. QK_BOOT, KC_NO, KC_S, KC_D, KC_F, KC_G, KC_Z, KC_J, KC_K, KC_L, KC_M, KC_P7, KC_P8, KC_P9, KC_PPLS, KC_LSFT,
  254. KC_NO, KC_X, KC_C, KC_V, KC_B, KC_N, KC_COMM, KC_SCLN, KC_NO, KC_NO, KC_P4, KC_P5, KC_P6, KC_PEQL, KC_LCBR,
  255. KC_NO, KC_NO, KC_NO, KC_SPC, KC_SPC, KC_SPC, KC_TRNS, KC_NO, KC_TRNS, KC_P0, KC_P1, KC_P2, KC_P3, KC_TRNS
  256. ),
  257. // blue led layout
  258. [_LY2] = LAYOUT_ortho_5x15(
  259. KC_MPRV, KC_MNXT, KC_NO, KC_NO, KC_NO, BL_ON, BL_OFF, KC_NO, KC_NO, KC_NO, RGB_TOG, RGB_RMOD, RGB_MOD, KC_NO, DF(_LY1),
  260. KC_VOLD, KC_VOLU, KC_NO, KC_NO, KC_NO, BL_TOGG, BL_STEP, KC_NO, KC_NO, KC_NO, KC_NO, RGB_HUD, RGB_HUI, RGB_M_P, RGB_M_B,
  261. KC_MPLY, KC_MSTP, KC_MUTE, KC_NO, KC_NO, BL_DEC, BL_INC, KC_NO, KC_NO, KC_NO, KC_NO, RGB_SAD, RGB_SAI, RGB_M_R, RGB_M_SW,
  262. KC_MRWD, KC_MFFD, KC_NO, KC_NO, KC_NO, BL_BRTG, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, RGB_VAD, RGB_VAI, RGB_M_SN, RGB_M_K,
  263. KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_TRNS, KC_TRNS, KC_TRNS, KC_NO, KC_NO, RGB_SPD, RGB_SPI, RGB_M_X, RGB_M_G
  264. )
  265. };
  266. //Define layer colors
  267. #define rgblight_setrgb_user_MAIN() rgblight_sethsv(HSV_RED)
  268. #define rgblight_setrgb_user_LY1() rgblight_sethsv(HSV_GREEN)
  269. #define rgblight_setrgb_user_LY2() rgblight_sethsv(HSV_BLUE)
  270. void matrix_init_user(void) {
  271. rgblight_enable();
  272. rgblight_mode(1);
  273. rgblight_setrgb_user_MAIN();
  274. }
  275. //Set a color based on the layer
  276. layer_state_t layer_state_set_user(layer_state_t state) {
  277. switch (get_highest_layer(state)) {
  278. case _LY1:
  279. rgblight_setrgb_user_LY1();
  280. break;
  281. case _LY2:
  282. rgblight_setrgb_user_LY2();
  283. break;
  284. default:
  285. rgblight_setrgb_user_MAIN();
  286. break;
  287. }
  288. return state;
  289. }