keymap.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  1. // This is the canonical layout file for the Quantum project. If you want to add another keyboard,
  2. // this is the style you want to emulate.
  3. #include "planck.h"
  4. #include "action_layer.h"
  5. #ifdef AUDIO_ENABLE
  6. #include "audio.h"
  7. #endif
  8. #include "eeconfig.h"
  9. extern keymap_config_t keymap_config;
  10. // Each layer gets a name for readability, which is then used in the keymap matrix below.
  11. // The underscores don't mean anything - you can have a layer called STUFF or any other name.
  12. // Layer names don't all need to be of the same length, obviously, and you can also skip them
  13. // entirely and just use numbers.
  14. #define _QWERTY 0
  15. #define _COLEMAK 1
  16. #define _DVORAK 2
  17. #define _LOWER 3
  18. #define _RAISE 4
  19. #define _PLOVER 5
  20. #define _TOUCHCURSOR 6
  21. #define _MOUSECURSOR 7
  22. #define _ADJUST 16
  23. // Keycodes
  24. enum planck_keycodes {
  25. QWERTY = SAFE_RANGE,
  26. COLEMAK,
  27. DVORAK,
  28. PLOVER,
  29. LOWER,
  30. RAISE,
  31. BACKLIT,
  32. EXT_PLV
  33. };
  34. enum macro_keycodes {
  35. KC_ALT_TAB,
  36. KC_CMD_TAB,
  37. KC_CTL_TAB,
  38. KC_CMD_SLSH,
  39. KC_AG_FIND,
  40. KC_AG_AGAIN,
  41. KC_AG_UNDO,
  42. KC_AG_CUT,
  43. KC_AG_COPY,
  44. KC_AG_PASTE,
  45. KC_AG_DESK_L,
  46. KC_AG_DESK_R,
  47. KC_AG_TAB_C,
  48. KC_AG_TAB_N,
  49. KC_AG_TAB_R,
  50. };
  51. // Fillers to make layering more clear
  52. #define _______ KC_TRNS
  53. #define XXXXXXX KC_NO
  54. // Custom macros
  55. #define CTL_ESC CTL_T(KC_ESC) // Tap for Esc, hold for Ctrl
  56. #define SFT_ENT SFT_T(KC_ENT) // Tap for Enter, hold for Shift
  57. #define HPR_TAB ALL_T(KC_TAB) // Tap for Tab, hold for Hyper
  58. #define GUI_SEM GUI_T(KC_SCLN) // Tap for Semicolon, hold for GUI
  59. #define ALT_QUO ALT_T(KC_QUOT) // Tap for Quote, hold for Alt
  60. // Requires KC_TRNS/_______ for the trigger key in the destination layer
  61. #define LT_TC LT(_TOUCHCURSOR, KC_SPC) // L-ayer T-ap T-ouch C-ursor
  62. #define LT_MC(kc) LT(_MOUSECURSOR, kc) // L-ayer T-ap M-ouse C-ursor
  63. #define ALT_TAB M(KC_ALT_TAB) // Macro for Alt-Tab
  64. #define CMD_TAB M(KC_CMD_TAB) // Macro for Cmd-Tab
  65. #define CTL_TAB M(KC_CTL_TAB) // Macro for Ctl-Tab
  66. #define CMD_SLSH M(KC_CMD_SLSH) // Macro for Cmd-Slash (personal shortcut to toggle iTerm2 visibility)
  67. #define AG_FIND M(KC_AG_FIND) // Macros for Cmd-[x] vs Ctrl-[x] based on current AG_NORM or AG_SWAP settings
  68. #define AG_AGAIN M(KC_AG_AGAIN)
  69. #define AG_UNDO M(KC_AG_UNDO)
  70. #define AG_CUT M(KC_AG_CUT)
  71. #define AG_COPY M(KC_AG_COPY)
  72. #define AG_PASTE M(KC_AG_PASTE)
  73. #define AG_D_L M(KC_AG_DESK_L) // For Virtual Desktop Switching: Left, and
  74. #define AG_D_R M(KC_AG_DESK_R) // Right
  75. #define AG_T_C M(KC_AG_TAB_C) // For Chrome, etc. Tab Close,
  76. #define AG_T_N M(KC_AG_TAB_N) // Tab New, and
  77. #define AG_T_R M(KC_AG_TAB_R) // Tab Reopen Closed
  78. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  79. /* Qwerty
  80. * ,-----------------------------------------------------------------------------------------.
  81. * | Hyper/Tab| Q | W | E | R | T | Y | U | I | O | P | Bksp |
  82. * |----------+------+------+------+------+-------------+------+------+------+------+--------|
  83. * | Ctrl/Esc | A | S | MC/D | F | G | H | J | K | L |GUI/; | Alt/" |
  84. * |----------+------+------+------+------+------|------+------+------+------+------+--------|
  85. * | Shift | Z | X | C | V | B | N | M | , | . | / |Sft/Ent |
  86. * |----------+------+------+------+------+------+------+------+------+------+------+--------|
  87. * | PrntScrn | RGUI | Alt | GUI |Lower | TC/Space |Raise | Next | Vol- | Vol+ | Play |
  88. * `-----------------------------------------------------------------------------------------'
  89. */
  90. [_QWERTY] = {
  91. {HPR_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC},
  92. {CTL_ESC, KC_A, KC_S, LT_MC(KC_D),KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, GUI_SEM, ALT_QUO},
  93. {KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, SFT_ENT},
  94. {KC_PSCR, KC_RGUI, KC_LALT, KC_LGUI, LOWER, LT_TC, LT_TC, RAISE, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY}
  95. },
  96. /* Colemak
  97. * ,-----------------------------------------------------------------------------------------.
  98. * | Hyper/Tab| Q | W | F | P | G | J | L | U | Y | ; | Bksp |
  99. * |----------+------+------+------+------+-------------+------+------+------+------+--------|
  100. * | Ctrl/Esc | A | R | MC/S | T | D | H | N | E | I | O | " |
  101. * |----------+------+------+------+------+------|------+------+------+------+------+--------|
  102. * | Shift | Z | X | C | V | B | K | M | , | . | / |Sft/Ent |
  103. * |----------+------+------+------+------+------+------+------+------+------+------+--------|
  104. * | PrntScrn | RGUI | Alt | GUI |Lower | TC/Space |Raise | Next | Vol- | Vol+ | Play |
  105. * `-----------------------------------------------------------------------------------------'
  106. */
  107. [_COLEMAK] = {
  108. {HPR_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC},
  109. {CTL_ESC, KC_A, KC_R, LT_MC(KC_S),KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT},
  110. {KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, SFT_ENT},
  111. {KC_PSCR, KC_RGUI, KC_LALT, KC_LGUI, LOWER, LT_TC, LT_TC, RAISE, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY}
  112. },
  113. /* Dvorak
  114. * ,-----------------------------------------------------------------------------------------.
  115. * | Hyper/Tab| " | , | . | P | Y | F | G | C | R | L | Bksp |
  116. * |----------+------+------+------+------+-------------+------+------+------+------+--------|
  117. * | Ctrl/Esc | A | O | MC/E | U | I | D | H | T | N | S | / |
  118. * |----------+------+------+------+------+------|------+------+------+------+------+--------|
  119. * | Shift | ; | Q | J | K | X | B | M | W | V | Z |Sft/Ent |
  120. * |----------+------+------+------+------+------+------+------+------+------+------+--------|
  121. * | PrntScrn | RGUI | Alt | GUI |Lower | TC/Space |Raise | Next | Vol- | Vol+ | Play |
  122. * `-----------------------------------------------------------------------------------------'
  123. */
  124. [_DVORAK] = {
  125. {HPR_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_BSPC},
  126. {CTL_ESC, KC_A, KC_O, LT_MC(KC_E),KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_SLSH},
  127. {KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, SFT_ENT},
  128. {KC_PSCR, KC_RGUI, KC_LALT, KC_LGUI, LOWER, LT_TC, LT_TC, RAISE, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY}
  129. },
  130. /* Lower
  131. * ,-----------------------------------------------------------------------------------.
  132. * | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | Bksp |
  133. * |------+------+------+------+------+-------------+------+------+------+------+------|
  134. * | [ | F1 | F2 | F3 | F4 | F5 | F6 | _ | + | { | } | | |
  135. * |------+------+------+------+------+------|------+------+------+------+------+------|
  136. * | ] | F7 | F8 | F9 | F10 | F11 | F12 | - | = | [ | ] | \ |
  137. * |------+------+------+------+------+------+------+------+------+------+------+------|
  138. * |Brite | | | | | | | Prev | Stop | Slct | Mute |
  139. * `-----------------------------------------------------------------------------------'
  140. */
  141. [_LOWER] = {
  142. {KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC},
  143. {KC_LBRC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE},
  144. {KC_RBRC, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS},
  145. {BACKLIT, _______, _______, _______, _______, _______, _______, _______, KC_MPRV, KC_MSTP, KC_MSEL, KC_MUTE}
  146. },
  147. /* Raise
  148. * ,-----------------------------------------------------------------------------------.
  149. * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp |
  150. * |------+------+------+------+------+-------------+------+------+------+------+------|
  151. * | $ | 4 | 5 | 6 | . | + | . | 4 | 5 | 6 | * | | |
  152. * |------+------+------+------+------+------|------+------+------+------+------+------|
  153. * | = | 7 | 8 | 9 | 0 | - | . | 1 | 2 | 3 | / | \ |
  154. * |------+------+------+------+------+------+------+------+------+------+------+------|
  155. * |Brite | | | | | | | Prev | Stop | Slct | Mute |
  156. * `-----------------------------------------------------------------------------------'
  157. */
  158. [_RAISE] = {
  159. {KC_0, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC},
  160. {KC_DLR, KC_4, KC_5, KC_6, KC_DOT, KC_PLUS, KC_DOT, KC_4, KC_5, KC_6, KC_ASTR, KC_PIPE},
  161. {KC_EQL, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_DOT, KC_1, KC_2, KC_3, KC_SLSH, KC_BSLS},
  162. {BACKLIT, _______, _______, _______, _______, _______, _______, _______, KC_MPRV, KC_MSTP, KC_MSEL, KC_MUTE}
  163. },
  164. /* TouchCursor layer (http://martin-stone.github.io/touchcursor/) plus personal customizations
  165. * ,-----------------------------------------------------------------------------------.
  166. * |AltTab|CmdTab|CtlTab| GUI |Shift | ~ |Insert| Home | Up | End | Bksp | |
  167. * |------+------+------+------+------+-------------+------+------+------+------+------|
  168. * | | Alt |Space |Tab_C | Find |Again | PgUp | Left | Down |Right |Desk_L|Desk_R|
  169. * |------+------+------+------+------+------|------+------+------+------+------+------|
  170. * | | Undo | Cut | Copy |Paste | ` | PgDn | Del |Tab_N |Tab_R |iTerm2| |
  171. * |------+------+------+------+------+------+------+------+------+------+------+------|
  172. * | | | | | | | | | | | |
  173. * `-----------------------------------------------------------------------------------'
  174. *
  175. * The KC_UNDO, KC_CUT, KC_COPY, KC_PASTE, KC_FIND, and KC_AGAIN keycodes don't
  176. * seem to work on Mac. Presumably they'll work under Windows.
  177. */
  178. [_TOUCHCURSOR] = {
  179. {ALT_TAB, CMD_TAB, CTL_TAB, KC_LGUI, KC_LSFT, KC_TILD, KC_INS, KC_HOME, KC_UP, KC_END, KC_BSPC, _______},
  180. {_______, KC_LALT, KC_SPC, AG_T_C, AG_FIND,AG_AGAIN, KC_PGUP, KC_LEFT, KC_DOWN, KC_RGHT, AG_D_L, AG_D_R },
  181. {_______, AG_UNDO, AG_CUT, AG_COPY, AG_PASTE,KC_GRV, KC_PGDN, KC_DEL, AG_T_N, AG_T_R, CMD_SLSH,_______},
  182. {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______}
  183. },
  184. /* Mouse Layer
  185. * ,-----------------------------------------------------------------------------------.
  186. * | | |ACCL0 | | | | |WHL_L | Up |WHL_R | BTN2 | |
  187. * |------+------+------+------+------+-------------+------+------+------+------+------|
  188. * | |ACCL2 | BTN2 | | BTN1 |ACCL1 |WHL_Up| Left | Down |Right | BTN4 | BTN5 |
  189. * |------+------+------+------+------+------|------+------+------+------+------+------|
  190. * | | | | | BTN3 | |WHL_Dn| BTN1 | | | BTN3 | |
  191. * |------+------+------+------+------+------+------+------+------+------+------+------|
  192. * | | | | | | | | | | | |
  193. * `-----------------------------------------------------------------------------------'
  194. */
  195. [_MOUSECURSOR] = {
  196. {_______, _______, KC_ACL0, _______, _______, _______, _______, KC_WH_L, KC_MS_U, KC_WH_R, KC_BTN2, _______},
  197. {_______, KC_ACL2, KC_BTN2, _______, KC_BTN1, KC_ACL1, KC_WH_U, KC_MS_L, KC_MS_D, KC_MS_R, KC_BTN4, KC_BTN5},
  198. {_______, _______, _______, _______, KC_BTN3, _______, KC_WH_D, KC_BTN1, _______, _______, KC_BTN3, _______},
  199. {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______}
  200. },
  201. /* Plover layer (http://opensteno.org)
  202. * ,-----------------------------------------------------------------------------------.
  203. * | # | # | # | # | # | # | # | # | # | # | # | # |
  204. * |------+------+------+------+------+-------------+------+------+------+------+------|
  205. * | | S | T | P | H | * | * | F | P | L | T | D |
  206. * |------+------+------+------+------+------|------+------+------+------+------+------|
  207. * |TogOut| S | K | W | R | * | * | R | B | G | S | Z |
  208. * |------+------+------+------+------+------+------+------+------+------+------+------|
  209. * | Exit | | | A | O | | E | U | | | |
  210. * `-----------------------------------------------------------------------------------'
  211. */
  212. [_PLOVER] = {
  213. {KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1 },
  214. {XXXXXXX, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC},
  215. {XXXXXXX, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT},
  216. {EXT_PLV, XXXXXXX, XXXXXXX, KC_C, KC_V, XXXXXXX, XXXXXXX, KC_N, KC_M, XXXXXXX, XXXXXXX, XXXXXXX}
  217. },
  218. /* Adjust (Lower + Raise)
  219. * ,-----------------------------------------------------------------------------------.
  220. * | | | | | | | | | | | | Del |
  221. * |------+------+------+------+------+-------------+------+------+------+------+------|
  222. * | | | |Aud on|Audoff|AGnorm|AGswap|Qwerty|Colemk|Dvorak|Plover| |
  223. * |------+------+------+------+------+------|------+------+------+------+------+------|
  224. * | |Voice-|Voice+|Mus on|Musoff|MIDIon|MIDIof| | | | | |
  225. * |------+------+------+------+------+------+------+------+------+------+------+------|
  226. * | | | | | | | | | | |Reset |
  227. * `-----------------------------------------------------------------------------------'
  228. */
  229. [_ADJUST] = {
  230. {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL},
  231. {_______, _______, _______, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, PLOVER, _______},
  232. {_______, MUV_DE, MUV_IN, MU_ON, MU_OFF, MI_ON, MI_OFF, _______, _______, _______, _______, _______},
  233. {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RESET}
  234. }
  235. };
  236. #ifdef AUDIO_ENABLE
  237. float tone_startup[][2] = SONG(STARTUP_SOUND);
  238. float tone_qwerty[][2] = SONG(QWERTY_SOUND);
  239. float tone_dvorak[][2] = SONG(DVORAK_SOUND);
  240. float tone_colemak[][2] = SONG(COLEMAK_SOUND);
  241. float tone_plover[][2] = SONG(PLOVER_SOUND);
  242. float tone_plover_gb[][2] = SONG(PLOVER_GOODBYE_SOUND);
  243. float music_scale[][2] = SONG(MUSIC_SCALE_SOUND);
  244. float tone_goodbye[][2] = SONG(GOODBYE_SOUND);
  245. #endif
  246. void persistent_default_layer_set(uint16_t default_layer) {
  247. eeconfig_update_default_layer(default_layer);
  248. default_layer_set(default_layer);
  249. }
  250. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  251. switch (keycode) {
  252. case QWERTY:
  253. if (record->event.pressed) {
  254. #ifdef AUDIO_ENABLE
  255. PLAY_SONG(tone_qwerty);
  256. #endif
  257. default_layer_set(1UL<<_QWERTY);
  258. }
  259. return false;
  260. break;
  261. case COLEMAK:
  262. if (record->event.pressed) {
  263. #ifdef AUDIO_ENABLE
  264. PLAY_SONG(tone_colemak);
  265. #endif
  266. default_layer_set(1UL<<_COLEMAK);
  267. }
  268. return false;
  269. break;
  270. case DVORAK:
  271. if (record->event.pressed) {
  272. #ifdef AUDIO_ENABLE
  273. PLAY_SONG(tone_dvorak);
  274. #endif
  275. default_layer_set(1UL<<_DVORAK);
  276. }
  277. return false;
  278. break;
  279. case LOWER:
  280. if (record->event.pressed) {
  281. layer_on(_LOWER);
  282. update_tri_layer(_LOWER, _RAISE, _ADJUST);
  283. } else {
  284. layer_off(_LOWER);
  285. update_tri_layer(_LOWER, _RAISE, _ADJUST);
  286. }
  287. return false;
  288. break;
  289. case RAISE:
  290. if (record->event.pressed) {
  291. layer_on(_RAISE);
  292. update_tri_layer(_LOWER, _RAISE, _ADJUST);
  293. } else {
  294. layer_off(_RAISE);
  295. update_tri_layer(_LOWER, _RAISE, _ADJUST);
  296. }
  297. return false;
  298. break;
  299. case BACKLIT:
  300. if (record->event.pressed) {
  301. register_code(KC_RSFT);
  302. #ifdef BACKLIGHT_ENABLE
  303. backlight_step();
  304. #endif
  305. } else {
  306. unregister_code(KC_RSFT);
  307. }
  308. return false;
  309. break;
  310. case PLOVER:
  311. if (record->event.pressed) {
  312. #ifdef AUDIO_ENABLE
  313. stop_all_notes();
  314. PLAY_SONG(tone_plover);
  315. #endif
  316. layer_off(_RAISE);
  317. layer_off(_LOWER);
  318. layer_off(_ADJUST);
  319. layer_on(_PLOVER);
  320. if (!eeconfig_is_enabled()) {
  321. eeconfig_init();
  322. }
  323. keymap_config.raw = eeconfig_read_keymap();
  324. keymap_config.nkro = 1;
  325. eeconfig_update_keymap(keymap_config.raw);
  326. }
  327. return false;
  328. break;
  329. case EXT_PLV:
  330. if (record->event.pressed) {
  331. #ifdef AUDIO_ENABLE
  332. PLAY_SONG(tone_plover_gb);
  333. #endif
  334. layer_off(_PLOVER);
  335. }
  336. return false;
  337. break;
  338. }
  339. return true;
  340. }
  341. /*
  342. * Macro definition
  343. */
  344. const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
  345. {
  346. if (!eeconfig_is_enabled()) {
  347. eeconfig_init();
  348. }
  349. bool use_cmd = true; // Use, for example, Cmd-Tab, Cmd-C, Cmd-V, etc.
  350. // Compare to MAGIC_SWAP_ALT_GUI and MAGIC_UNSWAP_ALT_GUI configs, set in:
  351. // quantum/quantum.c
  352. if(keymap_config.swap_lalt_lgui == 1 && keymap_config.swap_ralt_rgui == 1) {
  353. use_cmd = false; // ... or, Alt-Tab, Ctrl-C, Ctrl-V, etc.
  354. }
  355. switch (id) {
  356. case KC_ALT_TAB:
  357. if(use_cmd) { return (record->event.pressed ? MACRO( D(LALT), D(TAB), END ) : MACRO( U(TAB), END )); }
  358. else { return (record->event.pressed ? MACRO( D(LGUI), D(TAB), END ) : MACRO( U(TAB), END )); }
  359. case KC_CMD_TAB:
  360. if(use_cmd) { return (record->event.pressed ? MACRO( D(LGUI), D(TAB), END ) : MACRO( U(TAB), END )); }
  361. else { return (record->event.pressed ? MACRO( D(LALT), D(TAB), END ) : MACRO( U(TAB), END )); }
  362. case KC_CTL_TAB:
  363. return (record->event.pressed ? MACRO( D(LCTRL), D(TAB), END ) : MACRO( U(TAB), END ));
  364. case KC_CMD_SLSH:
  365. return (record->event.pressed ? MACRO( D(LGUI), D(SLSH),END ) : MACRO( U(SLSH),END ));
  366. case KC_AG_FIND:
  367. return use_cmd ? MACRODOWN( D(LGUI), T(F), END ) : MACRODOWN( D(LCTRL), T(F), END );
  368. case KC_AG_AGAIN:
  369. return use_cmd ? MACRODOWN( D(LGUI), T(G), END ) : MACRODOWN( D(LCTRL), T(G), END );
  370. case KC_AG_UNDO:
  371. return use_cmd ? MACRODOWN( D(LGUI), T(Z), END ) : MACRODOWN( D(LCTRL), T(Z), END );
  372. case KC_AG_CUT:
  373. return use_cmd ? MACRODOWN( D(LGUI), T(X), END ) : MACRODOWN( D(LCTRL), T(X), END );
  374. case KC_AG_COPY:
  375. return use_cmd ? MACRODOWN( D(LGUI), T(C), END ) : MACRODOWN( D(LCTRL), T(C), END );
  376. case KC_AG_PASTE:
  377. return use_cmd ? MACRODOWN( D(LGUI), T(V), END ) : MACRODOWN( D(LCTRL), T(V), END );
  378. case KC_AG_DESK_L:
  379. return use_cmd ? MACRODOWN( D(LGUI), D(LCTRL), T(SCLN), END ) : MACRODOWN( D(LALT), D(LCTRL), T(SCLN), END );
  380. case KC_AG_DESK_R:
  381. return use_cmd ? MACRODOWN( D(LGUI), D(LCTRL), T(QUOT), END ) : MACRODOWN( D(LALT), D(LCTRL), T(QUOT), END );
  382. case KC_AG_TAB_C:
  383. return use_cmd ? MACRODOWN( D(LGUI), T(W), END ) : MACRODOWN( D(LCTRL), T(W), END );
  384. case KC_AG_TAB_N:
  385. return use_cmd ? MACRODOWN( D(LGUI), T(T), END ) : MACRODOWN( D(LCTRL), T(T), END );
  386. case KC_AG_TAB_R:
  387. return use_cmd ? MACRODOWN( D(LGUI), D(LSHIFT), T(T), END ) : MACRODOWN( D(LCTRL), D(LSHIFT), T(T), END );
  388. }
  389. return MACRO_NONE;
  390. }
  391. void matrix_init_user(void) {
  392. #ifdef AUDIO_ENABLE
  393. startup_user();
  394. #endif
  395. }
  396. #ifdef AUDIO_ENABLE
  397. void startup_user()
  398. {
  399. _delay_ms(20); // gets rid of tick
  400. PLAY_SONG(tone_startup);
  401. }
  402. void shutdown_user()
  403. {
  404. PLAY_SONG(tone_goodbye);
  405. _delay_ms(150);
  406. stop_all_notes();
  407. }
  408. void music_on_user(void)
  409. {
  410. music_scale_user();
  411. }
  412. void music_scale_user(void)
  413. {
  414. PLAY_SONG(music_scale);
  415. }
  416. #endif