From e6d96928a42f577706104549f86eb832782ba6d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20=C4=90or=C4=91evi=C4=87?= Date: Sat, 3 Nov 2018 13:43:37 +0100 Subject: [PATCH] Move song arrays into function where they're used, align preprocessor directives --- .../process_keycode/process_unicode_common.c | 80 ++++++++----------- .../process_keycode/process_unicode_common.h | 4 +- 2 files changed, 34 insertions(+), 50 deletions(-) diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c index 00bb4ee742ae..643c26a26eca 100644 --- a/quantum/process_keycode/process_unicode_common.c +++ b/quantum/process_keycode/process_unicode_common.c @@ -21,27 +21,6 @@ unicode_config_t unicode_config; static uint8_t saved_mods; -#ifdef AUDIO_ENABLE - #ifdef UNICODE_SONG_OSX - float osx_song[][2] = UNICODE_SONG_OSX; - #endif - #ifdef UNICODE_SONG_LNX - float song_lnx[][2] = UNICODE_SONG_LNX; - #endif - #ifdef UNICODE_SONG_BSD - float song_bsd[][2] = UNICODE_SONG_BSD; - #endif - #ifdef UNICODE_SONG_WINDOWS - float windows_song[][2] = UNICODE_SONG_WINDOWS; - #endif - #ifdef UNICODE_SONG_WIN_COMPOSE - float win_compose_song[][2] = UNICODE_SONG_WIN_COMPOSE; - #endif - #ifdef UNICODE_SONG_OSX_RALT - float osx_ralt_song[][2] = UNICODE_SONG_OSX_RALT; - #endif -#endif - void set_unicode_input_mode(uint8_t os_target) { unicode_config.input_mode = os_target; @@ -153,50 +132,55 @@ bool process_unicode_common(uint16_t keycode, keyrecord_t *record) { switch (keycode) { case UNICODE_MODE_OSX: set_unicode_input_mode(UC_OSX); - #if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_OSX) - PLAY_SONG(osx_song); - #endif +#if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_OSX) + static float song_osx[][2] = UNICODE_SONG_OSX; + PLAY_SONG(song_osx); +#endif break; case UNICODE_MODE_LNX: set_unicode_input_mode(UC_LNX); - #if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_LNX) - PLAY_SONG(song_lnx); - #endif +#if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_LNX) + static float song_lnx[][2] = UNICODE_SONG_LNX; + PLAY_SONG(song_lnx); +#endif break; case UNICODE_MODE_BSD: set_unicode_input_mode(UC_BSD); - #if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_BSD) - PLAY_SONG(song_bsd); - #endif +#if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_BSD) + static float song_bsd[][2] = UNICODE_SONG_BSD; + PLAY_SONG(song_bsd); +#endif break; case UNICODE_MODE_WIN: set_unicode_input_mode(UC_WIN); - #if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_WINDOWS) - PLAY_SONG(windows_song); - #endif +#if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_WIN) + static float song_win[][2] = UNICODE_SONG_WIN; + PLAY_SONG(song_win); +#endif break; case UNICODE_MODE_WINC: set_unicode_input_mode(UC_WINC); - #if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_WIN_COMPOSE) - PLAY_SONG(win_compose_song); - #endif +#if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_WINC) + static float song_winc[][2] = UNICODE_SONG_WINC; + PLAY_SONG(song_winc); +#endif break; case UNICODE_MODE_OSX_RALT: set_unicode_input_mode(UC_OSX_RALT); - #if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_OSX_RALT) - PLAY_SONG(osx_ralt_song); - #endif +#if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_OSX_RALT) + static float song_osx_ralt[][2] = UNICODE_SONG_OSX_RALT; + PLAY_SONG(song_osx_ralt); +#endif break; } } - #ifdef UNICODE_ENABLE - return process_unicode(keycode, record); - #endif - #ifdef UCIS_ENABLE - return process_ucis(keycode, record); - #endif - #ifdef UNICODEMAP_ENABLE - return process_unicode_map(keycode, record); - #endif +#if defined(UNICODE_ENABLE) + return process_unicode(keycode, record); +#elif defined(UNICODEMAP_ENABLE) + return process_unicode_map(keycode, record); +#elif defined(UCIS_ENABLE) + return process_ucis(keycode, record); +#else return true; +#endif } diff --git a/quantum/process_keycode/process_unicode_common.h b/quantum/process_keycode/process_unicode_common.h index 1beeda467e33..8fdc312eb32e 100644 --- a/quantum/process_keycode/process_unicode_common.h +++ b/quantum/process_keycode/process_unicode_common.h @@ -19,11 +19,11 @@ #include "quantum.h" #if defined(UNICODE_ENABLE) + defined(UNICODEMAP_ENABLE) + defined(UCIS_ENABLE) > 1 - #error "Cannot enable more than one unicode method (UNICODE, UNICODEMAP, UCIS) at the same time" + #error "Cannot enable more than one Unicode method (UNICODE, UNICODEMAP, UCIS) at the same time" #endif #ifndef UNICODE_TYPE_DELAY -#define UNICODE_TYPE_DELAY 10 + #define UNICODE_TYPE_DELAY 10 #endif typedef union {