Skip to content

Commit e6d9692

Browse files
committed
Move song arrays into function where they're used, align preprocessor directives
1 parent bcafc3b commit e6d9692

File tree

2 files changed

+34
-50
lines changed

2 files changed

+34
-50
lines changed

quantum/process_keycode/process_unicode_common.c

+32-48
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,6 @@
2121

2222
unicode_config_t unicode_config;
2323
static uint8_t saved_mods;
24-
#ifdef AUDIO_ENABLE
25-
#ifdef UNICODE_SONG_OSX
26-
float osx_song[][2] = UNICODE_SONG_OSX;
27-
#endif
28-
#ifdef UNICODE_SONG_LNX
29-
float song_lnx[][2] = UNICODE_SONG_LNX;
30-
#endif
31-
#ifdef UNICODE_SONG_BSD
32-
float song_bsd[][2] = UNICODE_SONG_BSD;
33-
#endif
34-
#ifdef UNICODE_SONG_WINDOWS
35-
float windows_song[][2] = UNICODE_SONG_WINDOWS;
36-
#endif
37-
#ifdef UNICODE_SONG_WIN_COMPOSE
38-
float win_compose_song[][2] = UNICODE_SONG_WIN_COMPOSE;
39-
#endif
40-
#ifdef UNICODE_SONG_OSX_RALT
41-
float osx_ralt_song[][2] = UNICODE_SONG_OSX_RALT;
42-
#endif
43-
#endif
44-
4524

4625
void set_unicode_input_mode(uint8_t os_target) {
4726
unicode_config.input_mode = os_target;
@@ -153,50 +132,55 @@ bool process_unicode_common(uint16_t keycode, keyrecord_t *record) {
153132
switch (keycode) {
154133
case UNICODE_MODE_OSX:
155134
set_unicode_input_mode(UC_OSX);
156-
#if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_OSX)
157-
PLAY_SONG(osx_song);
158-
#endif
135+
#if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_OSX)
136+
static float song_osx[][2] = UNICODE_SONG_OSX;
137+
PLAY_SONG(song_osx);
138+
#endif
159139
break;
160140
case UNICODE_MODE_LNX:
161141
set_unicode_input_mode(UC_LNX);
162-
#if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_LNX)
163-
PLAY_SONG(song_lnx);
164-
#endif
142+
#if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_LNX)
143+
static float song_lnx[][2] = UNICODE_SONG_LNX;
144+
PLAY_SONG(song_lnx);
145+
#endif
165146
break;
166147
case UNICODE_MODE_BSD:
167148
set_unicode_input_mode(UC_BSD);
168-
#if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_BSD)
169-
PLAY_SONG(song_bsd);
170-
#endif
149+
#if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_BSD)
150+
static float song_bsd[][2] = UNICODE_SONG_BSD;
151+
PLAY_SONG(song_bsd);
152+
#endif
171153
break;
172154
case UNICODE_MODE_WIN:
173155
set_unicode_input_mode(UC_WIN);
174-
#if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_WINDOWS)
175-
PLAY_SONG(windows_song);
176-
#endif
156+
#if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_WIN)
157+
static float song_win[][2] = UNICODE_SONG_WIN;
158+
PLAY_SONG(song_win);
159+
#endif
177160
break;
178161
case UNICODE_MODE_WINC:
179162
set_unicode_input_mode(UC_WINC);
180-
#if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_WIN_COMPOSE)
181-
PLAY_SONG(win_compose_song);
182-
#endif
163+
#if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_WINC)
164+
static float song_winc[][2] = UNICODE_SONG_WINC;
165+
PLAY_SONG(song_winc);
166+
#endif
183167
break;
184168
case UNICODE_MODE_OSX_RALT:
185169
set_unicode_input_mode(UC_OSX_RALT);
186-
#if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_OSX_RALT)
187-
PLAY_SONG(osx_ralt_song);
188-
#endif
170+
#if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_OSX_RALT)
171+
static float song_osx_ralt[][2] = UNICODE_SONG_OSX_RALT;
172+
PLAY_SONG(song_osx_ralt);
173+
#endif
189174
break;
190175
}
191176
}
192-
#ifdef UNICODE_ENABLE
193-
return process_unicode(keycode, record);
194-
#endif
195-
#ifdef UCIS_ENABLE
196-
return process_ucis(keycode, record);
197-
#endif
198-
#ifdef UNICODEMAP_ENABLE
199-
return process_unicode_map(keycode, record);
200-
#endif
177+
#if defined(UNICODE_ENABLE)
178+
return process_unicode(keycode, record);
179+
#elif defined(UNICODEMAP_ENABLE)
180+
return process_unicode_map(keycode, record);
181+
#elif defined(UCIS_ENABLE)
182+
return process_ucis(keycode, record);
183+
#else
201184
return true;
185+
#endif
202186
}

quantum/process_keycode/process_unicode_common.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
#include "quantum.h"
2020

2121
#if defined(UNICODE_ENABLE) + defined(UNICODEMAP_ENABLE) + defined(UCIS_ENABLE) > 1
22-
#error "Cannot enable more than one unicode method (UNICODE, UNICODEMAP, UCIS) at the same time"
22+
#error "Cannot enable more than one Unicode method (UNICODE, UNICODEMAP, UCIS) at the same time"
2323
#endif
2424

2525
#ifndef UNICODE_TYPE_DELAY
26-
#define UNICODE_TYPE_DELAY 10
26+
#define UNICODE_TYPE_DELAY 10
2727
#endif
2828

2929
typedef union {

0 commit comments

Comments
 (0)