keymap.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
  1. #include "atomic.h"
  2. #include "action_layer.h"
  3. #include "eeconfig.h"
  4. #include "led.h"
  5. #ifdef AUDIO_ENABLE
  6. #include "audio.h"
  7. #include "song_list.h"
  8. #endif
  9. #define LAYER_QWERTY 0
  10. #define LAYER_COLEMAK 1
  11. #define LAYER_DVORAK 2
  12. #define LAYER_LOWER 3
  13. #define LAYER_RAISE 4
  14. #define LAYER_ADJUST 5
  15. #define LAYER_FUNCTION 6
  16. #define LAYER_MUSIC 7
  17. #define MACRO_QWERTY 0
  18. #define MACRO_COLEMAK 1
  19. #define MACRO_DVORAK 2
  20. #define MACRO_LOWER 3
  21. #define MACRO_RAISE 4
  22. #define MACRO_FUNCTION 5
  23. #define MACRO_TIMBRE_1 6
  24. #define MACRO_TIMBRE_2 7
  25. #define MACRO_TIMBRE_3 8
  26. #define MACRO_TIMBRE_4 9
  27. #define MACRO_TEMPO_U 10
  28. #define MACRO_TEMPO_D 11
  29. #define MACRO_TONE_DEFAULT 12
  30. #define MACRO_MUSIC_ON 13
  31. #define MACRO_MUSIC_OFF 14
  32. #define MACRO_AUDIO_ON 15
  33. #define MACRO_AUDIO_OFF 16
  34. #define M_QWRTY M(MACRO_QWERTY)
  35. #define M_COLMK M(MACRO_COLEMAK)
  36. #define M_DVORK M(MACRO_DVORAK)
  37. #define M_LOWER M(MACRO_LOWER)
  38. #define M_RAISE M(MACRO_RAISE)
  39. #define M_FUNCT M(MACRO_FUNCTION)
  40. #define TIMBR_1 M(MACRO_TIMBRE_1)
  41. #define TIMBR_2 M(MACRO_TIMBRE_2)
  42. #define TIMBR_3 M(MACRO_TIMBRE_3)
  43. #define TIMBR_4 M(MACRO_TIMBRE_4)
  44. #define TMPO_UP M(MACRO_TEMPO_U)
  45. #define TMPO_DN M(MACRO_TEMPO_D)
  46. #define TMPO_DF M(MACRO_TONE_DEFAULT)
  47. #define MUS_ON M(MACRO_MUSIC_ON)
  48. #define MUS_OFF M(MACRO_MUSIC_OFF)
  49. #define AUD_OFF M(MACRO_AUDIO_OFF)
  50. #define AUD_ON M(MACRO_AUDIO_ON)
  51. #define SC_UNDO LCTL(KC_Z)
  52. #define SC_REDO LCTL(KC_Y)
  53. #define SC_CUT LCTL(KC_X)
  54. #define SC_COPY LCTL(KC_C)
  55. #define SC_PSTE LCTL(KC_V)
  56. #define SC_SELA LCTL(KC_A)
  57. #define SC_SAVE LCTL(KC_S)
  58. #define SC_OPEN LCTL(KC_O)
  59. #define SC_ACLS LALT(KC_F4)
  60. #define SC_CCLS LCTL(KC_F4)
  61. #define _______ KC_TRNS
  62. #define ___T___ KC_TRNS
  63. #define XXXXXXX KC_NO
  64. /* QWERTY
  65. * .---------------------------------------------------------------------------------------------------------------------- 2u ------------.
  66. * | ESC | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | XXXXXX . BACKSP |
  67. * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+-----------------|
  68. * | TAB | Q | W | E | R | T | Y | U | I | O | P | [ | ] | \ | DEL |
  69. * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+- 2u ------------+--------|
  70. * | CAPS | A | S | D | F | G | H | J | K | L | ; | ' | XXXXXX . ENTER | PG UP |
  71. * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+- 2u ---------------------+--------|
  72. * | LSHIFT | Z | X | C | V | B | N | M | , | . | / | XXXXXX . RSHIFT | UP | PG DN |
  73. * |--------+--------+--------+--------+--------+- 2u ------------+--------+--------+--------+--------+-----------------+--------+--------|
  74. * | LCTRL | LWIN | FN | LALT | RAISED | XXXXXX . SPACE | LOWER | RALT | HOME | END | RCTRL | LEFT | DOWN | RIGHT |
  75. * '--------------------------------------------------------------------------------------------------------------------------------------'
  76. */
  77. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  78. [LAYER_QWERTY] = { /* QWERTY */
  79. { KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, XXXXXXX },
  80. { KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_DEL },
  81. { KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, XXXXXXX, KC_PGUP },
  82. { KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, XXXXXXX, KC_UP, KC_PGDN },
  83. { KC_LCTL, KC_LGUI, M_FUNCT, KC_LALT, M_RAISE, KC_SPC, XXXXXXX, M_LOWER, KC_RALT, KC_HOME, KC_END, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT },
  84. },
  85. /* COLEMAK
  86. * .---------------------------------------------------------------------------------------------------------------------- 2u ------------.
  87. * | ESC | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | XXXXXX . BACKSP |
  88. * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+-----------------|
  89. * | TAB | Q | W | F | P | G | J | L | U | Y | ; | [ | ] | \ | DEL |
  90. * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+- 2u ------------+--------|
  91. * | CAPS | A | R | S | T | D | H | N | E | I | O | ' | XXXXXX . ENTER | PG UP |
  92. * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+- 2u ---------------------+--------|
  93. * | LSHIFT | Z | X | C | V | B | K | M | , | . | / | XXXXXX . RSHIFT | UP | PG DN |
  94. * |--------+--------+--------+--------+--------+- 2u ------------+--------+--------+--------+--------+-----------------+--------+--------|
  95. * | LCTRL | LWIN | FN | LALT | RAISED | XXXXXX . SPACE | LOWER | RALT | HOME | END | RCTRL | LEFT | DOWN | RIGHT |
  96. * '--------------------------------------------------------------------------------------------------------------------------------------'
  97. */
  98. [LAYER_COLEMAK] = { /* COLEMAK */
  99. { KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_BSPC },
  100. { KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_LBRC, KC_RBRC, KC_BSLS, KC_DEL },
  101. { KC_CAPS, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT, KC_ENT, KC_ENT, KC_PGUP },
  102. { KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_RSFT, KC_UP, KC_PGDN },
  103. { KC_LCTL, KC_LGUI, M_FUNCT, KC_LALT, M_RAISE, KC_SPC, XXXXXXX, M_LOWER, KC_RALT, KC_HOME, KC_END, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT },
  104. },
  105. /* DVORAK
  106. * .---------------------------------------------------------------------------------------------------------------------- 2u ------------.
  107. * | ESC | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | [ | ] | XXXXXX . BACKSP |
  108. * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+-----------------|
  109. * | TAB | ' | , | . | P | Y | F | G | C | R | L | / | = | \ | DEL |
  110. * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+- 2u ------------+--------|
  111. * | CAPS | A | O | E | U | I | D | H | T | N | S | - | XXXXXX . ENTER | PG UP |
  112. * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+- 2u ---------------------+--------|
  113. * | LSHIFT | ; | Q | J | K | X | B | M | W | V | Z | XXXXXX . RSHIFT | UP | PG DN |
  114. * |--------+--------+--------+--------+--------+- 2u ------------+--------+--------+--------+--------+-----------------+--------+--------|
  115. * | LCTRL | LWIN | FN | LALT | RAISED | XXXXXX . SPACE | LOWER | RALT | HOME | END | RCTRL | LEFT | DOWN | RIGHT |
  116. * '--------------------------------------------------------------------------------------------------------------------------------------'
  117. */
  118. [LAYER_DVORAK] = { /* DVORAK */
  119. { KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_LBRC, KC_RBRC, KC_BSPC, KC_BSPC },
  120. { KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_SLSH, KC_EQL, KC_BSLS, KC_DEL },
  121. { KC_CAPS, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_MINS, KC_ENT, KC_ENT, KC_PGUP },
  122. { KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_RSFT, KC_RSFT, KC_UP, KC_PGDN },
  123. { KC_LCTL, KC_LGUI, M_FUNCT, KC_LALT, M_RAISE, KC_SPC, XXXXXXX, M_LOWER, KC_RALT, KC_HOME, KC_END, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT },
  124. },
  125. [LAYER_LOWER] = { /* LOWERED */
  126. { KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, ___T___, ___T___ },
  127. { _______, _______, _______, _______, SC_CCLS, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_INS },
  128. { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, ___T___, ___T___, _______ },
  129. { _______, SC_REDO, _______, _______, _______, _______, _______, _______, _______, _______, _______, ___T___, ___T___, _______, _______ },
  130. { _______, _______, _______, _______, _______, KC_BSPC, KC_BSPC, _______, _______, _______, _______, _______, _______, _______, _______ },
  131. },
  132. [LAYER_RAISE] = { /* RAISED */
  133. { KC_TILD, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, ___T___, ___T___ },
  134. { _______, _______, _______, _______, SC_ACLS, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_INS },
  135. { _______, SC_SELA, SC_SAVE, _______, _______, _______, _______, _______, _______, _______, _______, _______, ___T___, ___T___, _______ },
  136. { _______, SC_UNDO, SC_CUT, SC_COPY, SC_PSTE, _______, _______, _______, _______, _______, _______, ___T___, ___T___, _______, _______ },
  137. { _______, _______, _______, _______, _______, ___T___, ___T___, _______, _______, _______, _______, _______, _______, _______, _______ },
  138. },
  139. [LAYER_FUNCTION] = { /* FUNCTION */
  140. { KC_NLCK, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, ___T___, ___T___ },
  141. { KC_SLCK, KC_F13, KC_F14, KC_F15, KC_F16, KC_F17, KC_F18, KC_F19, KC_F20, KC_F21, KC_F22, KC_F23, KC_F24, KC_PAUS, KC_PSCR },
  142. { KC_CAPS, KC_BTN5, KC_BTN4, KC_BTN3, KC_BTN2, KC_ACL0, KC_ACL2, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY, _______, ___T___, ___T___, KC_WH_U },
  143. { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, ___T___, ___T___, KC_MS_U, KC_WH_D },
  144. { _______, _______, _______, _______, _______, KC_BTN1, KC_BTN1, _______, _______, _______, _______, _______, KC_MS_L, KC_MS_D, KC_MS_R },
  145. },
  146. [LAYER_ADJUST] = { /* ADJUST */
  147. { _______, TIMBR_1, TIMBR_2, TIMBR_3, TIMBR_4, TMPO_UP, TMPO_DN, TMPO_DF, _______, MUS_ON, MUS_OFF, AUD_ON, AUD_OFF, ___T___, ___T___ },
  148. { _______, M_QWRTY, M_COLMK, M_DVORK, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ },
  149. { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, ___T___, ___T___, _______ },
  150. { _______, _______, _______, _______, _______, RESET, _______, _______, _______, _______, _______, ___T___, ___T___, _______, _______ },
  151. { _______, _______, _______, _______, _______, ___T___, ___T___, _______, _______, _______, _______, _______, _______, _______, _______ },
  152. },
  153. [LAYER_MUSIC] = {
  154. { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, ___T___, ___T___ },
  155. { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ },
  156. { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, ___T___, ___T___, _______ },
  157. { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, ___T___, ___T___, _______, _______ },
  158. { _______, _______, _______, _______, _______, ___T___, ___T___, _______, _______, _______, _______, _______, _______, _______, _______ },
  159. },
  160. };
  161. #ifdef AUDIO_ENABLE
  162. float tone_my_startup[][2] = SONG(ODE_TO_JOY);
  163. float tone_my_goodbye[][2] = SONG(ROCK_A_BYE_BABY);
  164. float tone_qwerty[][2] = SONG(QWERTY_SOUND);
  165. float tone_dvorak[][2] = SONG(COLEMAK_SOUND);
  166. float tone_colemak[][2] = SONG(DVORAK_SOUND);
  167. float tone_audio_on[][2] = SONG(CLOSE_ENCOUNTERS_5_NOTE);
  168. float tone_music_on[][2] = SONG(DOE_A_DEER);
  169. float tone_caps_on[][2] = SONG(CAPS_LOCK_ON_SOUND);
  170. float tone_caps_off[][2] = SONG(CAPS_LOCK_OFF_SOUND);
  171. float tone_numlk_on[][2] = SONG(NUM_LOCK_ON_SOUND);
  172. float tone_numlk_off[][2] = SONG(NUM_LOCK_OFF_SOUND);
  173. float tone_scroll_on[][2] = SONG(SCROLL_LOCK_ON_SOUND);
  174. float tone_scroll_off[][2] = SONG(SCROLL_LOCK_OFF_SOUND);
  175. #endif /* AUDIO_ENABLE */
  176. /*
  177. void update_quad_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3, uint8_t layer4, bool order)
  178. {
  179. if (order)
  180. {
  181. if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2))
  182. {
  183. layer_on(layer3);
  184. }
  185. else
  186. {
  187. layer_off(layer3);
  188. layer_off(layer4);
  189. }
  190. }
  191. else
  192. {
  193. if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2))
  194. {
  195. layer_on(layer4);
  196. }
  197. else
  198. {
  199. layer_off(layer3);
  200. layer_off(layer4);
  201. }
  202. }
  203. }
  204. */
  205. void persistant_default_layer_set(uint16_t default_layer)
  206. {
  207. eeconfig_write_default_layer(default_layer);
  208. default_layer_set(default_layer);
  209. }
  210. const uint16_t PROGMEM fn_actions[] = {
  211. };
  212. const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
  213. {
  214. // MACRODOWN only works in this function
  215. switch(id)
  216. {
  217. case MACRO_QWERTY:
  218. if (record->event.pressed)
  219. {
  220. persistant_default_layer_set(1UL<<LAYER_QWERTY);
  221. PLAY_NOTE_ARRAY(tone_qwerty, false, STACCATO);
  222. }
  223. break;
  224. case MACRO_COLEMAK:
  225. if (record->event.pressed)
  226. {
  227. persistant_default_layer_set(1UL<<LAYER_COLEMAK);
  228. PLAY_NOTE_ARRAY(tone_colemak, false, STACCATO);
  229. }
  230. break;
  231. case MACRO_DVORAK:
  232. if (record->event.pressed)
  233. {
  234. persistant_default_layer_set(1UL<<LAYER_DVORAK);
  235. PLAY_NOTE_ARRAY(tone_dvorak, false, STACCATO);
  236. }
  237. break;
  238. case MACRO_LOWER:
  239. if (record->event.pressed)
  240. {
  241. layer_on(LAYER_LOWER);
  242. update_tri_layer(LAYER_LOWER, LAYER_RAISE, LAYER_ADJUST);
  243. }
  244. else
  245. {
  246. layer_off(LAYER_LOWER);
  247. update_tri_layer(LAYER_LOWER, LAYER_RAISE, LAYER_ADJUST);
  248. }
  249. break;
  250. case MACRO_RAISE:
  251. if (record->event.pressed)
  252. {
  253. layer_on(LAYER_RAISE);
  254. update_tri_layer(LAYER_LOWER, LAYER_RAISE, LAYER_ADJUST);
  255. }
  256. else
  257. {
  258. layer_off(LAYER_RAISE);
  259. update_tri_layer(LAYER_LOWER, LAYER_RAISE, LAYER_ADJUST);
  260. }
  261. break;
  262. case MACRO_FUNCTION:
  263. if (record->event.pressed)
  264. {
  265. layer_on(LAYER_FUNCTION);
  266. }
  267. else
  268. {
  269. layer_off(LAYER_FUNCTION);
  270. }
  271. break;
  272. case MACRO_TIMBRE_1:
  273. if (record->event.pressed) set_timbre(TIMBRE_12);
  274. break;
  275. case MACRO_TIMBRE_2:
  276. if (record->event.pressed) set_timbre(TIMBRE_25);
  277. break;
  278. case MACRO_TIMBRE_3:
  279. if (record->event.pressed) set_timbre(TIMBRE_50);
  280. break;
  281. case MACRO_TIMBRE_4:
  282. if (record->event.pressed) set_timbre(TIMBRE_75);
  283. break;
  284. case MACRO_TEMPO_U:
  285. if (record->event.pressed) increase_tempo(10);
  286. break;
  287. case MACRO_TEMPO_D:
  288. if (record->event.pressed) decrease_tempo(10);
  289. break;
  290. case MACRO_TONE_DEFAULT:
  291. if (record->event.pressed)
  292. {
  293. set_timbre(TIMBRE_DEFAULT);
  294. set_tempo(TEMPO_DEFAULT);
  295. }
  296. break;
  297. case MACRO_AUDIO_OFF:
  298. if (record->event.pressed)
  299. {
  300. #ifdef AUDIO_ENABLE
  301. audio_off();
  302. #endif
  303. }
  304. break;
  305. case MACRO_AUDIO_ON:
  306. if (record->event.pressed)
  307. {
  308. #ifdef AUDIO_ENABLE
  309. audio_on();
  310. PLAY_NOTE_ARRAY(tone_audio_on, false, STACCATO);
  311. #endif
  312. }
  313. break;
  314. case MACRO_MUSIC_ON:
  315. if (record->event.pressed)
  316. {
  317. #ifdef AUDIO_ENABLE
  318. PLAY_NOTE_ARRAY(tone_music_on, false, STACCATO);
  319. layer_on(LAYER_MUSIC);
  320. #endif
  321. }
  322. break;
  323. case MACRO_MUSIC_OFF:
  324. if (record->event.pressed)
  325. {
  326. #ifdef AUDIO_ENABLE
  327. layer_off(LAYER_MUSIC);
  328. stop_all_notes();
  329. #endif
  330. }
  331. break;
  332. default:
  333. break;
  334. }
  335. return MACRO_NONE;
  336. };
  337. #ifdef AUDIO_ENABLE
  338. uint8_t starting_note = 0x0C;
  339. int offset = 7;
  340. void process_action_user(keyrecord_t *record)
  341. {
  342. if (IS_LAYER_ON(LAYER_MUSIC))
  343. {
  344. if (record->event.pressed)
  345. {
  346. play_note(((double)220.0)*pow(2.0, -4.0)*pow(2.0,(starting_note + SCALE[record->event.key.col + offset])/12.0+(MATRIX_ROWS - record->event.key.row)), 0xF);
  347. }
  348. else
  349. {
  350. stop_note(((double)220.0)*pow(2.0, -4.0)*pow(2.0,(starting_note + SCALE[record->event.key.col + offset])/12.0+(MATRIX_ROWS - record->event.key.row)));
  351. }
  352. }
  353. }
  354. void matrix_init_user(void)
  355. {
  356. init_notes();
  357. play_startup_tone();
  358. println("Matrix Init");
  359. }
  360. void led_set_user(uint8_t usb_led)
  361. {
  362. static uint8_t old_usb_led = 0;
  363. if ((usb_led & (1<<USB_LED_CAPS_LOCK)) && !(old_usb_led & (1<<USB_LED_CAPS_LOCK)))
  364. {
  365. // If CAPS LK LED is turning on...
  366. PLAY_NOTE_ARRAY(tone_caps_on, false, LEGATO);
  367. }
  368. else if (!(usb_led & (1<<USB_LED_CAPS_LOCK)) && (old_usb_led & (1<<USB_LED_CAPS_LOCK)))
  369. {
  370. // If CAPS LK LED is turning off...
  371. PLAY_NOTE_ARRAY(tone_caps_off, false, LEGATO);
  372. }
  373. else if ((usb_led & (1<<USB_LED_NUM_LOCK)) && !(old_usb_led & (1<<USB_LED_NUM_LOCK)))
  374. {
  375. // If NUM LK LED is turning on...
  376. PLAY_NOTE_ARRAY(tone_numlk_on, false, LEGATO);
  377. }
  378. else if (!(usb_led & (1<<USB_LED_NUM_LOCK)) && (old_usb_led & (1<<USB_LED_NUM_LOCK)))
  379. {
  380. // If NUM LED is turning off...
  381. PLAY_NOTE_ARRAY(tone_numlk_off, false, LEGATO);
  382. }
  383. else if ((usb_led & (1<<USB_LED_SCROLL_LOCK)) && !(old_usb_led & (1<<USB_LED_SCROLL_LOCK)))
  384. {
  385. // If SCROLL LK LED is turning on...
  386. PLAY_NOTE_ARRAY(tone_scroll_on, false, LEGATO);
  387. }
  388. else if (!(usb_led & (1<<USB_LED_SCROLL_LOCK)) && (old_usb_led & (1<<USB_LED_SCROLL_LOCK)))
  389. {
  390. // If SCROLL LED is turning off...
  391. PLAY_NOTE_ARRAY(tone_scroll_off, false, LEGATO);
  392. }
  393. old_usb_led = usb_led;
  394. }
  395. void play_startup_tone()
  396. {
  397. PLAY_NOTE_ARRAY(tone_my_startup, false, STACCATO);
  398. }
  399. void play_goodbye_tone()
  400. {
  401. PLAY_NOTE_ARRAY(tone_my_goodbye, false, STACCATO);
  402. _delay_ms(2000);
  403. }
  404. #endif /* AUDIO_ENABLE */