keymap.c 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. /* Copyright 2021 rookiebwoy
  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. // Layers declarations
  18. enum layers {
  19. _BL
  20. };
  21. // Tap Dance declarations
  22. enum {
  23. TD_PNCT,
  24. TD_ABC,
  25. TD_DEF,
  26. TD_GHI,
  27. TD_JKL,
  28. TD_MNO,
  29. TD_PQRS,
  30. TD_TUV,
  31. TD_WXYZ,
  32. TD_SPACE,
  33. TD_UPRCS,
  34. };
  35. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  36. /* Keymap _BL: Base Layer
  37. * ,-----------------------.
  38. * |ENTER | ↑ | BSPC |
  39. * | | | |
  40. * |-------|-------|-------|
  41. * | <- | ↓ | -> |
  42. * | | | |
  43. * |-------|-------|-------|
  44. * | 1 .,' | 2 | 3 |
  45. * |?!-:;/ | abc | def |
  46. * |-------|-------|-------|
  47. * | 4 | 5 | 6 |
  48. * | ghi | jkl | mno |
  49. * |-------|-------|-------|
  50. * | 7 | 8 | 9 |
  51. * | pqrs | tuv | wxyz |
  52. * |-------|-------|-------|
  53. * | * | 0 | CAPS |
  54. * | | space | |
  55. * `-----------------------'
  56. */
  57. [_BL] = LAYOUT(
  58. KC_ENT, KC_UP, KC_BSPC,
  59. KC_LEFT, KC_DOWN, KC_RIGHT,
  60. TD(TD_PNCT), TD(TD_ABC), TD(TD_DEF),
  61. TD(TD_GHI), TD(TD_JKL), TD(TD_MNO),
  62. TD(TD_PQRS), TD(TD_TUV), TD(TD_WXYZ),
  63. KC_PAST, TD(TD_SPACE), TD(TD_UPRCS)
  64. ),
  65. };
  66. // Tap Dance cycles
  67. void dance_1 (tap_dance_state_t *state, void *user_data) {
  68. if (state->count == 1) {
  69. if (state->interrupted || !state->pressed) return tap_code(KC_DOT);
  70. else return tap_code(KC_1);
  71. } else if (state->count == 2) {
  72. tap_code (KC_COMM);
  73. } else if (state->count == 3) {
  74. tap_code(KC_QUOT);
  75. } else if (state->count == 4) {
  76. tap_code16(KC_QUES);
  77. } else if (state->count == 5) {
  78. tap_code16(KC_EXLM);
  79. } else if (state->count == 6) {
  80. tap_code(KC_MINS);
  81. } else if (state->count == 7) {
  82. tap_code16(KC_COLN);
  83. } else if (state->count == 8) {
  84. tap_code(KC_SCLN);
  85. } else if (state->count == 9) {
  86. tap_code(KC_SLSH);
  87. } else {
  88. reset_tap_dance (state);
  89. }
  90. }
  91. void dance_2 (tap_dance_state_t *state, void *user_data) {
  92. if (state->count == 1) {
  93. if (state->interrupted || !state->pressed) return tap_code(KC_A);
  94. else return tap_code(KC_2);
  95. } else if (state->count == 2) {
  96. tap_code (KC_B);
  97. } else if (state->count == 3) {
  98. tap_code(KC_C);
  99. } else {
  100. reset_tap_dance (state);
  101. }
  102. }
  103. void dance_3 (tap_dance_state_t *state, void *user_data) {
  104. if (state->count == 1) {
  105. if (state->interrupted || !state->pressed) return tap_code(KC_D);
  106. else return tap_code(KC_3);
  107. } else if (state->count == 2) {
  108. tap_code (KC_E);
  109. } else if (state->count == 3) {
  110. tap_code(KC_F);
  111. } else {
  112. reset_tap_dance (state);
  113. }
  114. }
  115. void dance_4 (tap_dance_state_t *state, void *user_data) {
  116. if (state->count == 1) {
  117. if (state->interrupted || !state->pressed) return tap_code(KC_G);
  118. else return tap_code(KC_4);
  119. } else if (state->count == 2) {
  120. tap_code (KC_H);
  121. } else if (state->count == 3) {
  122. tap_code(KC_I);
  123. } else {
  124. reset_tap_dance (state);
  125. }
  126. }
  127. void dance_5 (tap_dance_state_t *state, void *user_data) {
  128. if (state->count == 1) {
  129. if (state->interrupted || !state->pressed) return tap_code(KC_J);
  130. else return tap_code(KC_5);
  131. } else if (state->count == 2) {
  132. tap_code (KC_K);
  133. } else if (state->count == 3) {
  134. tap_code(KC_L);
  135. } else {
  136. reset_tap_dance (state);
  137. }
  138. }
  139. void dance_6 (tap_dance_state_t *state, void *user_data) {
  140. if (state->count == 1) {
  141. if (state->interrupted || !state->pressed) return tap_code(KC_M);
  142. else return tap_code(KC_6);
  143. } else if (state->count == 2) {
  144. tap_code (KC_N);
  145. } else if (state->count == 3) {
  146. tap_code(KC_O);
  147. } else {
  148. reset_tap_dance (state);
  149. }
  150. }
  151. void dance_7 (tap_dance_state_t *state, void *user_data) {
  152. if (state->count == 1) {
  153. if (state->interrupted || !state->pressed) return tap_code(KC_P);
  154. else return tap_code(KC_7);
  155. } else if (state->count == 2) {
  156. tap_code (KC_Q);
  157. } else if (state->count == 3) {
  158. tap_code(KC_R);
  159. } else if (state->count == 4) {
  160. tap_code(KC_S);
  161. } else {
  162. reset_tap_dance (state);
  163. }
  164. }
  165. void dance_8 (tap_dance_state_t *state, void *user_data) {
  166. if (state->count == 1) {
  167. if (state->interrupted || !state->pressed) return tap_code(KC_T);
  168. else return tap_code(KC_8);
  169. } else if (state->count == 2) {
  170. tap_code (KC_U);
  171. } else if (state->count == 3) {
  172. tap_code(KC_V);
  173. } else {
  174. reset_tap_dance (state);
  175. }
  176. }
  177. void dance_9 (tap_dance_state_t *state, void *user_data) {
  178. if (state->count == 1) {
  179. if (state->interrupted || !state->pressed) return tap_code(KC_W);
  180. else return tap_code(KC_9);
  181. } else if (state->count == 2) {
  182. tap_code (KC_X);
  183. } else if (state->count == 3) {
  184. tap_code(KC_Y);
  185. } else if (state->count == 4) {
  186. tap_code(KC_Z);
  187. } else {
  188. reset_tap_dance (state);
  189. }
  190. }
  191. void dance_0 (tap_dance_state_t *state, void *user_data) {
  192. if (state->count == 1) {
  193. if (state->interrupted || !state->pressed) return tap_code(KC_SPACE);
  194. else return tap_code(KC_0);
  195. } else {
  196. reset_tap_dance (state);
  197. }
  198. }
  199. void dance_maiusc (tap_dance_state_t *state, void *user_data) {
  200. if (state->count == 1) {
  201. if (state->interrupted || !state->pressed) return set_oneshot_mods(MOD_BIT(KC_LSFT));
  202. else return tap_code(KC_CAPS);
  203. } else {
  204. reset_tap_dance (state);
  205. }
  206. }
  207. // Tap Dance actions
  208. tap_dance_action_t tap_dance_actions[] = {
  209. [TD_PNCT] = ACTION_TAP_DANCE_FN (dance_1),
  210. [TD_ABC] = ACTION_TAP_DANCE_FN (dance_2),
  211. [TD_DEF] = ACTION_TAP_DANCE_FN (dance_3),
  212. [TD_GHI] = ACTION_TAP_DANCE_FN (dance_4),
  213. [TD_JKL] = ACTION_TAP_DANCE_FN (dance_5),
  214. [TD_MNO] = ACTION_TAP_DANCE_FN (dance_6),
  215. [TD_PQRS] = ACTION_TAP_DANCE_FN (dance_7),
  216. [TD_TUV] = ACTION_TAP_DANCE_FN (dance_8),
  217. [TD_WXYZ] = ACTION_TAP_DANCE_FN (dance_9),
  218. [TD_SPACE] = ACTION_TAP_DANCE_FN (dance_0),
  219. [TD_UPRCS] = ACTION_TAP_DANCE_FN (dance_maiusc),
  220. };