diff options
author | Jack Humbert <jack.humb@gmail.com> | 2017-07-20 23:57:11 -0400 |
---|---|---|
committer | Jack Humbert <jack.humb@gmail.com> | 2017-07-23 14:59:29 -0400 |
commit | 6a3c66776cb10888b24400526241b46deeb051a8 (patch) | |
tree | 7604aafe7087d9ab40aa0bb6bc603975e31d7e2e /quantum/quantum.c | |
parent | 8edb67b08242f2ab641d7e658a0a7adb579bbae2 (diff) |
clean-up planck and preonic keymaps, move audio stuff around
Diffstat (limited to 'quantum/quantum.c')
-rw-r--r-- | quantum/quantum.c | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/quantum/quantum.c b/quantum/quantum.c index 36e586d316..31a6fc7133 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<<default_layer); + default_layer_set(1U<<default_layer); +} + void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3) { if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) { layer_on(layer3); @@ -571,6 +613,9 @@ void matrix_init_quantum() { #ifdef BACKLIGHT_ENABLE backlight_init_ports(); #endif + #ifdef AUDIO_ENABLE + audio_init(); + #endif matrix_init_kb(); } |