keymap.c 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673
  1. /* Copyright 2021 Aric Crosson Bouwers
  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. #include "muse.h"
  18. #include "features/select_word.h"
  19. #include "features/caps_word.h"
  20. // using the Word Selection QMK Macro by Pascal Getreuer, found here: https://getreuer.info/posts/keyboards/select-word/index.html
  21. // THANKS Pascal for such amazing functionality!!
  22. // Each layer gets a name for readability, which is then used in the keymap matrix below.
  23. // The underscores don't mean anything - you can have a layer called STUFF or any other name.
  24. // Layer names don't all need to be of the same length, obviously, and you can also skip them
  25. // entirely and just use numbers.
  26. #define _QWERTY 0
  27. #define _COLEMAK_VCP 1
  28. #define _LOWER 2
  29. #define _RAISE 3
  30. #define _NUMPAD 4
  31. #define _FN 5
  32. #define _ADJUST 6
  33. #define _GAMING 7
  34. #define MICMUTE LALT(KC_M)
  35. #define DESKTR LGUI(LCTL(KC_RGHT)) // move one virtual desktop to the right
  36. #define DESKTL LGUI(LCTL(KC_LEFT)) // move one virtual desktop to the left
  37. #define MTLCTL_F9 MT(MOD_LCTL, KC_F9)
  38. #define MTLSFT_F10 MT(MOD_LSFT, KC_F10)
  39. #define MTLALT_F11 MT(MOD_LALT, KC_F11)
  40. #define MTLGUI_Z MT(MOD_LGUI, KC_Z)
  41. #define MTLALT_PL MT(MOD_LALT, KC_MPLY)
  42. #define MTLALT_NXT MT(MOD_LALT, KC_MNXT)
  43. #define MTENTER MT(MOD_LCTL, KC_ENT)
  44. #define MTRSFTBSLS MT(MOD_RSFT, KC_BSLS)
  45. #define MTRCTLQUO MT(MOD_RCTL, KC_QUOT)
  46. #define MTTAB MT(MOD_LCTL | MOD_LGUI | MOD_LALT, KC_TAB)
  47. #define LTESC LT(_FN, KC_ESC)
  48. #define MTPLAY MT(MOD_RALT, KC_MPLY)
  49. #define KC_COPY LCTL(KC_C)
  50. #define KC_CUT LCTL(KC_X)
  51. #define KC_PASTE LCTL(KC_V)
  52. #define KC_WINPASTE LGUI(KC_V)
  53. #define KC_PTXT LCTL(LSFT(KC_V))
  54. #define KC_UNDO LCTL(KC_Z)
  55. #define KC_REDO LCTL(KC_Y)
  56. enum planck_keycodes {
  57. QWERTY = SAFE_RANGE,
  58. COLEMAK_VCP,
  59. LOWER,
  60. RAISE,
  61. FN,
  62. ADJUST,
  63. NUMPAD,
  64. GAMING,
  65. EXT_NUM,
  66. EXT_GAMING,
  67. SELWORD,
  68. BRACES,
  69. BRACES2,
  70. ARROW,
  71. ALT_TAB
  72. };
  73. // Define a type for as many tap dance states as you need
  74. typedef enum {
  75. TD_NONE,
  76. TD_UNKNOWN,
  77. TD_SINGLE_TAP,
  78. TD_SINGLE_HOLD,
  79. TD_DOUBLE_TAP
  80. } td_state_t;
  81. typedef struct {
  82. bool is_press_action;
  83. td_state_t state;
  84. } td_tap_t;
  85. // Our custom tap dance keys; add any other tap dance keys to this enum
  86. enum {
  87. UNDS_LOWER,
  88. PLAY_RAISE
  89. };
  90. // Declare the functions to be used with your tap dance key(s)
  91. // Function associated with all tap dances
  92. td_state_t cur_dance(tap_dance_state_t *state);
  93. // Functions associated with individual tap dances
  94. void usl_finished(tap_dance_state_t *state, void *user_data);
  95. void usl_reset(tap_dance_state_t *state, void *user_data);
  96. /* ----------------------------------------------------------------------------------------------------------------------------- */
  97. // This is a completely modified layout that stikes a balance between muscle memory for keys, where I was coming from a standard
  98. // Qwerty keyboard, and efficiency gained by using layers. I've switched tab and esc because it's more natural to me this way, and
  99. // added layer switch on hold functionality for each key. Enter has moved to the key beside LOWER, to allow usage while still having
  100. // the right hand on the mouse.
  101. // Lower incorporates a numpad on the right side, and all of the symbols included on the left. There is logic for the symbols needed for
  102. // calculators and math are located around the numpad, and coding symbols are placed in easy to remember spots.
  103. // CAPS has moved to the Fn layer, and a few additional shortcut modifiers like CTRL_ALT_UP and DOWN for adding additional cursors in VSCode.
  104. // Play/Pause has a prime spot on the base layer, and the Fn version skips to next track
  105. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  106. /* MIT Layout (QWERTY)
  107. *
  108. * ,------------------------------------------------------------------------.
  109. * |FN,Esc| q | w | e | r | t | y | u | i | o | p |Bsp |
  110. * |------------------------------------------------------------------------|
  111. |CSW,Tab| a | s | d | f | g | h | j | k | l | ; |Ctl,'|
  112. * |------------------------------------------------------------------------|
  113. * |Shift |Win,z| x | c | v | b | n | m | , | . | / |Sft,\|
  114. * |------------------------------------------------------------------------|
  115. * | | | |Ctl,Ent|LOWER| Space |RAISE|Alt,Play| | | |
  116. * `------------------------------------------------------------------------'
  117. */
  118. [_QWERTY] = LAYOUT_planck_grid( /* QWERTY */
  119. LTESC, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC,
  120. MTTAB, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, MTRCTLQUO,
  121. KC_LSFT, MTLGUI_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, MTRSFTBSLS,
  122. KC_NO, KC_NO, KC_NO, MTENTER, TD(UNDS_LOWER), KC_SPC, KC_SPC, MO(3), MTLALT_PL, KC_NO, KC_NO, KC_NO
  123. ),
  124. /* MIT Layout (COLEMAK_VCP)
  125. *
  126. * ,------------------------------------------------------------------------.
  127. * |FN,ESC| q | w | f | d | b | j | l | u | y | ; | Bsp |
  128. * |------------------------------------------------------------------------|
  129. |CSW,Tab| a | r | s | t | g | m | n | e | i | o |Ctl,'|
  130. * |------------------------------------------------------------------------|
  131. * |Shift |Win,z| x | v | c | p | k | h | , | . | / |Sft,\|
  132. * |------------------------------------------------------------------------|
  133. * | | | |Ctl,Ent|LWR,_| Space |RAISE|Alt,Play| | | |
  134. * `------------------------------------------------------------------------'
  135. */
  136. [_COLEMAK_VCP] = LAYOUT_planck_grid( /* COLEMAK_VCP */
  137. LTESC, KC_Q, KC_W, KC_F, KC_D, KC_B, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC,
  138. MTTAB, KC_A, KC_R, KC_S, KC_T, KC_G, KC_M, KC_N, KC_E, KC_I, KC_O, MTRCTLQUO,
  139. KC_LSFT, MTLGUI_Z, KC_X, KC_V, KC_C, KC_P, KC_K, KC_H, KC_COMM, KC_DOT, KC_SLSH, MTRSFTBSLS,
  140. KC_NO, KC_NO, KC_NO, MTENTER, TD(UNDS_LOWER), KC_SPC, KC_SPC, MO(3), MTLALT_PL, KC_NO, KC_NO, KC_NO
  141. ),
  142. /* MIT Layout (RAISE)
  143. *
  144. * ,----------------------------------------------------------------------------.
  145. * | ~ | ! | | | | | | Cut | Undo| Redo|P2TXT| Bsp |
  146. * |----------------------------------------------------------------------------|
  147. * | |Menu | | | | |ARROW |SELWORD|Copy|Paste|WinPst| " |
  148. * |----------------------------------------------------------------------------|
  149. * | |Vol+ |Vol- | Mute| | |Braces|Braces2| < | > | ? | ! |
  150. * |----------------------------------------------------------------------------|
  151. * | | | | |Adjust| | | | | | |
  152. * `----------------------------------------------------------------------------'
  153. */
  154. [_RAISE] = LAYOUT_planck_grid( /* RAISE */
  155. KC_TILD, KC_EXLM, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_CUT, KC_UNDO, KC_REDO, KC_PTXT, KC_BSPC,
  156. KC_TRNS, KC_APP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, ARROW, SELWORD, KC_COPY, KC_PASTE, KC_WINPASTE, KC_DQUO,
  157. KC_TRNS, KC_VOLU, KC_VOLD, KC_MUTE, KC_TRNS, KC_TRNS, BRACES, BRACES2, KC_LABK, KC_RABK, KC_QUES, KC_EXLM,
  158. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, MO(6), KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_NO, KC_NO
  159. ),
  160. /* MIT Layout (LOWER)
  161. * XZ
  162. * ,-----------------------------------------------------------------------.
  163. * | ` | ! | # | $ | < | > | : | 7 | 8 | 9 | = | Bsp |
  164. * |-----------------------------------------------------------------------|
  165. * | ' | _ | ^ | % | ( | ) | M | 4 | 5 | 6 | - | + |
  166. * |-----------------------------------------------------------------------|
  167. * |Shift| | | & | " | { | } | @ | 1 | 2 | 3 | / | * |
  168. * |-----------------------------------------------------------------------|
  169. * | | | | | | |MO(6),0| . | | | |
  170. * `-----------------------------------------------------------------------'
  171. */
  172. [_LOWER] = LAYOUT_planck_grid( /* LOWER */
  173. KC_GRV, KC_EXLM, KC_HASH, KC_DLR, KC_LABK, KC_RABK, KC_COLN, KC_P7, KC_P8, KC_P9, KC_EQL, KC_BSPC,
  174. KC_QUOT, KC_UNDS, KC_CIRC, KC_PERC, KC_LPRN, KC_RPRN, KC_M, KC_P4, KC_P5, KC_P6, KC_PMNS, KC_PPLS,
  175. KC_TRNS, KC_PIPE, KC_AMPR, KC_DQUO, KC_LCBR, KC_RCBR, KC_AT, KC_P1, KC_P2, KC_P3, KC_PSLS, KC_PAST,
  176. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_P0, KC_PDOT, KC_NO, KC_NO, KC_NO
  177. ),
  178. /* MIT Layout (GAMING)
  179. *.
  180. * ,-----------------------------------------------------------------------.
  181. * |ESC,`| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 |EXIT GAMING|
  182. * |-----------------------------------------------------------------------|
  183. * | TAB | Q | W | E | R | T | I | 4 | 5 | 6 | - | + |
  184. * |-----------------------------------------------------------------------|
  185. * |Shift| A | S | D | F | G | K | 1 | 2 | 3 | / | * |
  186. * |-----------------------------------------------------------------------|
  187. * | | | | Ctl | Alt | SPACE | 0 | . | | | |
  188. * `-----------------------------------------------------------------------'
  189. */
  190. [_GAMING] = LAYOUT_planck_grid( /* GAMING */
  191. QK_GESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_P8, KC_9, KC_0, EXT_GAMING,
  192. KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_I, KC_P4, KC_P5, KC_P6, KC_PMNS, KC_PPLS,
  193. KC_LSFT, KC_A, KC_S, KC_D, KC_F, KC_G, KC_K, KC_P1, KC_P2, KC_P3, KC_PSLS, KC_PAST,
  194. KC_NO, KC_NO, KC_NO, KC_LCTL, KC_LALT, KC_SPC, KC_SPC, KC_P0, KC_PDOT, KC_NO, KC_NO, KC_NO
  195. ),
  196. /* MIT Layout (FN)
  197. *
  198. * ,----------------------------------------------------------------------------.
  199. * | |Ctl,F9 |Sft,F10|Alt,F11| F12 |MyComp|Calc |home | up | end |PrtScr| Del |
  200. * |-----------------------------------------------------------------------------|
  201. * | | F5 | F6 | F7 | F8 |DeskL |DeskR |left | down |right|ScrLck| CAPS|
  202. * |-----------------------------------------------------------------------------|
  203. * | | F1 | F2 | F3 | F4 |ALT_TAB|MicM |pgup |LCA_dn| pgdn|Pse/Brk| Ins|
  204. * |-----------------------------------------------------------------------------|
  205. * | | | | | | | |Alt,MNext| | | |
  206. * `-----------------------------------------------------------------------------'
  207. */
  208. [_FN] = LAYOUT_planck_grid( /* FUNCTION */
  209. KC_TRNS, MTLCTL_F9, MTLSFT_F10, MTLALT_F11, KC_F12, KC_MYCM, KC_CALC, KC_HOME, KC_UP, KC_END, KC_PSCR, KC_DEL,
  210. KC_TRNS, KC_F5, KC_F6, KC_F7, KC_F8, DESKTL, DESKTR, KC_LEFT, KC_DOWN, KC_RGHT, KC_SCRL, KC_CAPS,
  211. KC_TRNS, KC_F1, KC_F2, KC_F3, KC_F4, ALT_TAB, MICMUTE, KC_PGUP, LCA(KC_DOWN), KC_PGDN, KC_PAUSE, KC_INS,
  212. KC_NO, KC_NO, KC_NO, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, MTLALT_NXT, KC_NO, KC_NO, KC_NO
  213. ),
  214. /* MIT Layout (ADJUST)
  215. *
  216. * ,-----------------------------------------------------------------------------.
  217. * |RGBtog|Ms3 | Ms2 |MsUp | Ms1 | Hue+| Hue- | Sat+| Sat- |Brt+ |Brt- | Boot |
  218. * |-----------------------------------------------------------------------------|
  219. * |RGBMod| MWL | MsL |MDn |MsR |GAMING| |AU_ON|AU_OFF|MU_ON|MU_OF| Debug|
  220. * |-----------------------------------------------------------------------------|
  221. * | |MWLft|MWUp |NWDn |NWRght|QWERTY|CMK_VCP|MI_ON|MI_OF | | |MU_Mod|
  222. * |-----------------------------------------------------------------------------|
  223. * | | | |SLEEP| | | | | | | |
  224. * `-----------------------------------------------------------------------------'
  225. */
  226. [_ADJUST] = LAYOUT_planck_grid( /* ADJUST LAYER */
  227. RGB_TOG, KC_BTN3, KC_BTN2, KC_MS_U, KC_BTN1, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, QK_BOOT,
  228. RGB_MOD, KC_NO, KC_MS_L, KC_MS_D, KC_MS_R, GAMING, KC_NO, AU_ON, AU_OFF, MU_ON, MU_OFF, DB_TOGG,
  229. KC_TRNS, KC_WH_L, KC_WH_U, KC_WH_D, KC_WH_R, QWERTY, COLEMAK_VCP, MI_ON, MI_OFF, KC_TRNS, KC_TRNS, MU_NEXT,
  230. KC_NO, KC_NO, KC_NO, KC_SLEP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_NO, KC_NO
  231. )
  232. };
  233. #ifdef AUDIO_ENABLE
  234. float layerswitch_song[][2] = SONG(PLANCK_SOUND);
  235. float tone_startup[][2] = SONG(STARTUP_SOUND);
  236. float tone_qwerty[][2] = SONG(QWERTY_SOUND);
  237. float tone_COLEMAK_VCP[][2] = SONG(COLEMAK_SOUND);
  238. float music_scale[][2] = SONG(MUSIC_SCALE_SOUND);
  239. float tone_goodbye[][2] = SONG(GOODBYE_SOUND);
  240. #endif
  241. bool is_alt_tab_active = false;
  242. layer_state_t layer_state_set_user(layer_state_t state) {
  243. static bool is_this_layer_on = false;
  244. if (layer_state_cmp(state, 4) != is_this_layer_on) {
  245. is_this_layer_on = layer_state_cmp(state, 4);
  246. if (is_this_layer_on) {
  247. PLAY_SONG(layerswitch_song);
  248. }
  249. else {
  250. stop_all_notes();
  251. }
  252. }
  253. if (is_alt_tab_active) {
  254. unregister_code(KC_LALT);
  255. is_alt_tab_active = false;
  256. }
  257. return state;
  258. switch (get_highest_layer(state)) {
  259. case _ADJUST:
  260. rgblight_setrgb (0xFF, 0x00, 0x00);
  261. break;
  262. case _LOWER:
  263. rgblight_setrgb (0x00, 0x00, 0xFF);
  264. break;
  265. case _NUMPAD:
  266. rgblight_setrgb (0x00, 0x00, 0xFF);
  267. break;
  268. case _RAISE:
  269. rgblight_setrgb (0x7A, 0x00, 0xFF);
  270. break;
  271. case _FN:
  272. rgblight_setrgb (0x00, 0xFF, 0x00);
  273. break;
  274. default: // for any other layers, or the default layer
  275. rgblight_setrgb (0xFF, 0xFF, 0xFF);
  276. break;
  277. }
  278. return state;
  279. }
  280. // void dance_media (tap_dance_state_t *state, void *user_data)
  281. // if (state->count == 1) {
  282. // tap_code(KC_MPLY);
  283. // } else if (state->count == 2) {
  284. // tap_code (KC_MNXT);
  285. // } else if (state->count == 3) {
  286. // tap_code(KC_MPRV);
  287. // } else {
  288. // reset_tap_dance (state);
  289. // }
  290. // }
  291. // tap_dance_action_t tap_dance_actions[] = {
  292. // [0] = ACTION_TAP_DANCE_FN (dance_media),
  293. // };
  294. // Determine the current tap dance state
  295. td_state_t cur_dance(tap_dance_state_t *state) {
  296. if (state->interrupted) return TD_SINGLE_HOLD;
  297. if (state->count == 1) {
  298. if (!state->pressed) return TD_SINGLE_TAP;
  299. else return TD_SINGLE_HOLD;
  300. } else if (state->count == 2) return TD_DOUBLE_TAP;
  301. else return TD_UNKNOWN;
  302. }
  303. // Initialize tap structure associated with example tap dance key
  304. static td_tap_t usl_tap_state = {
  305. .is_press_action = true,
  306. .state = TD_NONE
  307. };
  308. // Functions that control what our tap dance key does
  309. void usl_finished(tap_dance_state_t *state, void *user_data) {
  310. usl_tap_state.state = cur_dance(state);
  311. switch (usl_tap_state.state) {
  312. case TD_SINGLE_TAP:
  313. tap_code16(KC_UNDS);
  314. break;
  315. case TD_SINGLE_HOLD:
  316. layer_on(_LOWER);
  317. // update_tri_layer(_LOWER, _RAISE, _ADJUST);
  318. break;
  319. case TD_DOUBLE_TAP:
  320. // Check to see if the layer is already set
  321. if (layer_state_is(_LOWER)) {
  322. // If already set, then switch it off
  323. layer_off(_LOWER);
  324. #ifdef AUDIO_ENABLE
  325. PLAY_SONG(tone_goodbye);
  326. #endif
  327. } else {
  328. // If not already set, then switch the layer on
  329. layer_on(_LOWER);
  330. #ifdef AUDIO_ENABLE
  331. PLAY_SONG(layerswitch_song);
  332. #endif
  333. }
  334. break;
  335. default:
  336. break;
  337. }
  338. }
  339. void usl_reset(tap_dance_state_t *state, void *user_data) {
  340. // If the key was held down and now is released then switch off the layer
  341. if (usl_tap_state.state == TD_SINGLE_HOLD) {
  342. layer_off(_LOWER);
  343. // update_tri_layer(_LOWER, _RAISE, _ADJUST);
  344. }
  345. usl_tap_state.state = TD_NONE;
  346. }
  347. // Associate our tap dance key with its functionality
  348. tap_dance_action_t tap_dance_actions[] = {
  349. [UNDS_LOWER] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, usl_finished, usl_reset)
  350. };
  351. uint16_t get_tapping_term(uint16_t keycode, keyrecord_t *record) {
  352. switch (keycode) {
  353. case TD(UNDS_LOWER):
  354. return 175;
  355. default:
  356. return TAPPING_TERM;
  357. }
  358. }
  359. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  360. if (!process_select_word(keycode, record, SELWORD)) { return false; }
  361. if (!process_caps_word(keycode, record)) { return false; }
  362. const uint8_t mods = get_mods();
  363. const uint8_t oneshot_mods = get_oneshot_mods();
  364. switch (keycode) {
  365. case QWERTY:
  366. if (record->event.pressed) {
  367. set_single_persistent_default_layer(_QWERTY);
  368. }
  369. return false;
  370. break;
  371. case KC_CAPS:
  372. if (record->event.pressed) {
  373. #ifdef AUDIO_ENABLE
  374. PLAY_SONG(tone_qwerty);
  375. #endif
  376. register_code(KC_CAPS);
  377. }
  378. return false;
  379. break;
  380. case GAMING:
  381. if (record->event.pressed) {
  382. layer_off(_RAISE);
  383. layer_off(_LOWER);
  384. layer_off(_ADJUST);
  385. layer_on(_GAMING);
  386. #ifdef AUDIO_ENABLE
  387. PLAY_SONG(layerswitch_song);
  388. #endif
  389. }
  390. return false;
  391. break;
  392. case EXT_GAMING:
  393. if (record->event.pressed) {
  394. layer_off(_GAMING);
  395. #ifdef AUDIO_ENABLE
  396. PLAY_SONG(tone_goodbye);
  397. #endif
  398. }
  399. return false;
  400. break;
  401. case COLEMAK_VCP:
  402. if (record->event.pressed) {
  403. set_single_persistent_default_layer(_COLEMAK_VCP);
  404. }
  405. return false;
  406. break;
  407. case BRACES: // Types (), or {}, and puts cursor between braces.
  408. if (record->event.pressed) {
  409. clear_mods(); // Temporarily disable mods.
  410. clear_oneshot_mods();
  411. if ((mods | oneshot_mods) & MOD_MASK_SHIFT) {
  412. SEND_STRING("{}");
  413. } else {
  414. SEND_STRING("<>");
  415. }
  416. tap_code(KC_LEFT); // Move cursor between braces.
  417. set_mods(mods); // Restore mods.
  418. }
  419. return false;
  420. case BRACES2: // Types [], or <>, and puts cursor between braces.
  421. if (record->event.pressed) {
  422. clear_mods(); // Temporarily disable mods.
  423. clear_oneshot_mods();
  424. if ((mods | oneshot_mods) & MOD_MASK_SHIFT) {
  425. SEND_STRING("()");
  426. } else {
  427. SEND_STRING("[]");
  428. }
  429. tap_code(KC_LEFT); // Move cursor between braces.
  430. set_mods(mods); // Restore mods.
  431. }
  432. return false;
  433. case ARROW: // Arrow macro, types -> or =>.
  434. if (record->event.pressed) {
  435. if ((mods | oneshot_mods) & MOD_MASK_SHIFT) { // Is shift held?
  436. del_mods(MOD_MASK_SHIFT); // Temporarily delete shift.
  437. del_oneshot_mods(MOD_MASK_SHIFT);
  438. SEND_STRING("->");
  439. set_mods(mods); // Restore mods.
  440. } else {
  441. SEND_STRING("=>");
  442. }
  443. }
  444. return false;
  445. case ALT_TAB: // super alt tab macro
  446. if (record->event.pressed) {
  447. if (!is_alt_tab_active) {
  448. is_alt_tab_active = true;
  449. register_code(KC_LALT);
  450. }
  451. register_code(KC_TAB);
  452. } else {
  453. unregister_code(KC_TAB);
  454. }
  455. return false;
  456. break;
  457. }
  458. return true;
  459. }
  460. enum combo_events {
  461. EM_EMAIL,
  462. EM_WORK_EMAIL,
  463. HTML_P,
  464. HTML_TITLE,
  465. HTML_DIV,
  466. HTML_HTML,
  467. HTML_HEAD,
  468. HTML_BODY,
  469. HTML_FOOTER,
  470. HTML_A_HREF,
  471. HTML_IMG,
  472. CSS_STYLE,
  473. HTML_GENERIC_TAG,
  474. CTLRGHT,
  475. CTLLEFT,
  476. COMBO_LENGTH
  477. };
  478. uint16_t COMBO_LEN = COMBO_LENGTH; // remove the COMBO_COUNT define and use this instead!
  479. const uint16_t PROGMEM email_combo[] = {KC_E, KC_M, COMBO_END};
  480. const uint16_t PROGMEM email_work_combo[] = {KC_E, KC_K, COMBO_END};
  481. const uint16_t PROGMEM html_p_combo[] = {KC_P, KC_DOT, COMBO_END};
  482. const uint16_t PROGMEM html_title_combo[] = {KC_T, KC_DOT, COMBO_END};
  483. const uint16_t PROGMEM html_div_combo[] = {KC_D, KC_DOT, COMBO_END};
  484. const uint16_t PROGMEM html_html_combo[] = {KC_Q, KC_DOT, COMBO_END};
  485. const uint16_t PROGMEM html_head_combo[] = {KC_W, KC_DOT, COMBO_END};
  486. const uint16_t PROGMEM html_body_combo[] = {KC_R, KC_DOT, COMBO_END};
  487. const uint16_t PROGMEM html_footer_combo[] = {KC_X, KC_DOT, COMBO_END};
  488. const uint16_t PROGMEM html_a_href_combo[] = {KC_A, KC_DOT, COMBO_END};
  489. const uint16_t PROGMEM html_img_combo[] = {KC_F, KC_DOT, COMBO_END};
  490. const uint16_t PROGMEM css_style_combo[] = {KC_S, KC_DOT, COMBO_END};
  491. const uint16_t PROGMEM html_generic_tag_combo[] = {KC_G, KC_DOT, COMBO_END};
  492. const uint16_t PROGMEM ctrrght_combo[] = {KC_RGHT, KC_DOWN, COMBO_END};
  493. const uint16_t PROGMEM ctrleft_combo[] = {KC_LEFT, KC_DOWN, COMBO_END};
  494. // const uint8_t combo_mods = get_mods();
  495. // const uint8_t combo_oneshot_mods = get_oneshot_mods();
  496. combo_t key_combos[] = {
  497. [EM_EMAIL] = COMBO_ACTION(email_combo),
  498. [EM_WORK_EMAIL] = COMBO_ACTION(email_work_combo),
  499. [HTML_P] = COMBO_ACTION(html_p_combo),
  500. [HTML_TITLE] = COMBO_ACTION(html_title_combo),
  501. [HTML_DIV] = COMBO_ACTION(html_div_combo),
  502. [HTML_HTML] = COMBO_ACTION(html_html_combo),
  503. [HTML_HEAD] = COMBO_ACTION(html_head_combo),
  504. [HTML_BODY] = COMBO_ACTION(html_body_combo),
  505. [HTML_FOOTER] = COMBO_ACTION(html_footer_combo),
  506. [HTML_A_HREF] = COMBO_ACTION(html_a_href_combo),
  507. [HTML_IMG] = COMBO_ACTION(html_img_combo),
  508. [CSS_STYLE] = COMBO_ACTION(css_style_combo),
  509. [HTML_GENERIC_TAG] = COMBO_ACTION(html_generic_tag_combo),
  510. [CTLRGHT] = COMBO_ACTION(ctrrght_combo),
  511. [CTLLEFT] = COMBO_ACTION(ctrleft_combo),
  512. };
  513. /* COMBO_ACTION(x) is same as COMBO(x, KC_NO) */
  514. void process_combo_event(uint16_t combo_index, bool pressed) {
  515. switch(combo_index) {
  516. case EM_EMAIL:
  517. if (pressed) {
  518. SEND_STRING("aricbouwers@outlook.com");
  519. }
  520. break;
  521. case EM_WORK_EMAIL:
  522. if (pressed) {
  523. SEND_STRING("acrossonbouwers@rjc.ca");
  524. }
  525. break;
  526. case HTML_DIV:
  527. if (pressed) {
  528. SEND_STRING("<div></div>");
  529. for (int i = 0; i < 6; i++) {
  530. tap_code16(KC_LEFT);
  531. }
  532. }
  533. break;
  534. case HTML_P:
  535. if (pressed) {
  536. SEND_STRING("<p></p>");
  537. for (int i = 0; i < 4; i++) {
  538. tap_code16(KC_LEFT);
  539. }
  540. }
  541. break;
  542. case HTML_TITLE:
  543. if (pressed) {
  544. SEND_STRING("<title></title>");
  545. for (int i = 0; i < 8; i++) {
  546. tap_code16(KC_LEFT);
  547. }
  548. }
  549. break;
  550. case CSS_STYLE:
  551. if (pressed) {
  552. SEND_STRING("<style></style>");
  553. for (int i = 0; i < 8; i++) {
  554. tap_code16(KC_LEFT);
  555. }
  556. }
  557. break;
  558. case HTML_HTML:
  559. if (pressed) {
  560. SEND_STRING("<html lang=\"en\"></html>");
  561. for (int i = 0; i < 7; i++) {
  562. tap_code16(KC_LEFT);
  563. }
  564. }
  565. break;
  566. case HTML_HEAD:
  567. if (pressed) {
  568. SEND_STRING("<head></head>");
  569. for (int i = 0; i < 7; i++) {
  570. tap_code16(KC_LEFT);
  571. }
  572. }
  573. break;
  574. case HTML_BODY:
  575. if (pressed) {
  576. SEND_STRING("<body></body>");
  577. for (int i = 0; i < 7; i++) {
  578. tap_code16(KC_LEFT);
  579. }
  580. }
  581. break;
  582. case HTML_FOOTER:
  583. if (pressed) {
  584. SEND_STRING("<footer></footer>");
  585. for (int i = 0; i < 9; i++) {
  586. tap_code16(KC_LEFT);
  587. }
  588. }
  589. break;
  590. case HTML_A_HREF:
  591. if (pressed) {
  592. SEND_STRING("<a href=\"link_goes_here\">name_of_link_goes_here</a>");
  593. tap_code16(KC_HOME);
  594. for (int i = 0; i < 10; i++) {
  595. tap_code16(KC_RGHT);
  596. }
  597. }
  598. break;
  599. case HTML_IMG:
  600. if (pressed) {
  601. SEND_STRING("<img src=\"image_source_or_link_goes_here\" alt=\"name_if_cant_load\" width=\"num_pixels\" height=\"num_pixels\">");
  602. tap_code16(KC_HOME);
  603. for (int i = 0; i < 11; i++) {
  604. tap_code16(KC_RGHT);
  605. }
  606. }
  607. break;
  608. case HTML_GENERIC_TAG:
  609. if (pressed) {
  610. SEND_STRING("<TAG></TAG>");
  611. tap_code16(KC_ESC);
  612. for (int i = 0; i < 9; i++) {
  613. tap_code16(KC_LEFT);
  614. }
  615. tap_code16(LCTL(KC_D));
  616. tap_code16(LCTL(KC_D));
  617. tap_code16(KC_BSPC);
  618. }
  619. break;
  620. case CTLLEFT:
  621. if (pressed) {
  622. tap_code16(C(KC_LEFT));
  623. }
  624. break;
  625. case CTLRGHT:
  626. if (pressed) {
  627. tap_code16(C(KC_RGHT));
  628. }
  629. break;
  630. }
  631. }