From 6a3c66776cb10888b24400526241b46deeb051a8 Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Thu, 20 Jul 2017 23:57:11 -0400 Subject: clean-up planck and preonic keymaps, move audio stuff around --- quantum/quantum.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) (limited to 'quantum/quantum.c') diff --git a/quantum/quantum.c b/quantum/quantum.c index 36e586d31..31a6fc713 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -30,6 +30,28 @@ extern backlight_config_t backlight_config; #include "fauxclicky.h" #endif +#ifdef AUDIO_ENABLE + #ifndef GOODBYE_SONG + #define GOODBYE_SONG SONG(GOODBYE_SOUND) + #endif + #ifndef AG_NORM_SONG + #define AG_NORM_SONG SONG(AG_NORM_SOUND) + #endif + #ifndef AG_SWAP_SONG + #define AG_SWAP_SONG SONG(AG_SWAP_SOUND) + #endif + #ifndef DEFAULT_LAYER_SONGS + #define DEFAULT_LAYER_SONGS { SONG(QWERTY_SOUND), \ + SONG(COLEMAK_SOUND) \ + SONG(DVORAK_SOUND) \ + } + #endif + float goodbye_song[][2] = GOODBYE_SONG; + float ag_norm_song[][2] = AG_NORM_SONG; + float ag_swap_song[][2] = AG_SWAP_SONG; + float default_layer_songs[][16][2] = DEFAULT_LAYER_SONGS; +#endif + static void do_code16 (uint16_t code, void (*f) (uint8_t)) { switch (code) { case QK_MODS ... QK_MODS_MAX: @@ -116,9 +138,15 @@ void reset_keyboard(void) { clear_keyboard(); #if defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_ENABLE_BASIC)) music_all_notes_off(); + uint16_t timer_start = timer_read(); + PLAY_SONG(goodbye_song); shutdown_user(); -#endif + while(timer_elapsed(timer_start) < 250) + wait_ms(1); + stop_all_notes(); +#else wait_ms(250); +#endif #ifdef CATERINA_BOOTLOADER *(uint16_t *)0x0800 = 0x7777; // these two are a-star-specific #endif @@ -351,6 +379,9 @@ bool process_record_quantum(keyrecord_t *record) { case MAGIC_SWAP_ALT_GUI: keymap_config.swap_lalt_lgui = true; keymap_config.swap_ralt_rgui = true; + #ifdef AUDIO_ENABLE + PLAY_SONG(ag_swap_song); + #endif break; case MAGIC_UNSWAP_CONTROL_CAPSLOCK: keymap_config.swap_control_capslock = false; @@ -379,6 +410,9 @@ bool process_record_quantum(keyrecord_t *record) { case MAGIC_UNSWAP_ALT_GUI: keymap_config.swap_lalt_lgui = false; keymap_config.swap_ralt_rgui = false; + #ifdef AUDIO_ENABLE + PLAY_SONG(ag_norm_song); + #endif break; case MAGIC_TOGGLE_NKRO: keymap_config.nkro = !keymap_config.nkro; @@ -521,6 +555,14 @@ void send_string_with_delay(const char *str, uint8_t interval) { } } +void set_single_persistent_default_layer(uint8_t default_layer) { + #ifdef AUDIO_ENABLE + PLAY_SONG(default_layer_songs[default_layer]); + #endif + eeconfig_update_default_layer(1U<