From 101a6400e08178a578919d42ce42d57f23582d7b Mon Sep 17 00:00:00 2001 From: MysterD Date: Thu, 20 Jan 2022 23:35:38 -0800 Subject: [PATCH] Added define guards around controller bind mappings --- src/pc/controller/controller_bind_mapping.c | 3 +++ src/pc/controller/controller_bind_mapping.h | 2 ++ src/pc/djui/djui_bind.c | 8 ++++++++ 3 files changed, 13 insertions(+) diff --git a/src/pc/controller/controller_bind_mapping.c b/src/pc/controller/controller_bind_mapping.c index 3f322d78d..ab058efe8 100644 --- a/src/pc/controller/controller_bind_mapping.c +++ b/src/pc/controller/controller_bind_mapping.c @@ -8,6 +8,8 @@ #include "controller_api.h" #include "controller_sdl.h" +#if defined(CAPI_SDL1) || defined(CAPI_SDL2) + static int inverted_scancode_table[512]; static SDL_Scancode bind_to_sdl_scancode[512] = { 0 }; @@ -149,3 +151,4 @@ const char* translate_bind_to_name(int bind) { #endif return name; } +#endif diff --git a/src/pc/controller/controller_bind_mapping.h b/src/pc/controller/controller_bind_mapping.h index fee0bf52e..211172e0a 100644 --- a/src/pc/controller/controller_bind_mapping.h +++ b/src/pc/controller/controller_bind_mapping.h @@ -1,8 +1,10 @@ #ifndef CONTROLLER_BIND_MAPPING_H #define CONTROLLER_BIND_MAPPING_H +#if defined(CAPI_SDL1) || defined(CAPI_SDL2) void controller_bind_init(void); int translate_sdl_scancode(int scancode); const char* translate_bind_to_name(int bind); +#endif #endif \ No newline at end of file diff --git a/src/pc/djui/djui_bind.c b/src/pc/djui/djui_bind.c index 71eda6e82..7640dd082 100644 --- a/src/pc/djui/djui_bind.c +++ b/src/pc/djui/djui_bind.c @@ -33,7 +33,11 @@ static void djui_bind_button_on_bind(struct DjuiBase* caller) { // set key bind->configKey[button->base.tag] = key; +#if defined(CAPI_SDL1) || defined(CAPI_SDL2) djui_text_set_text(button->text, translate_bind_to_name(key)); +#else + djui_text_set_text(button->text, "???"); +#endif djui_interactable_set_binding(NULL); play_sound(SOUND_MENU_CHANGE_SELECT, gDefaultSoundArgs); controller_reconfigure(); @@ -72,8 +76,12 @@ struct DjuiBind* djui_bind_create(struct DjuiBase* parent, const char* message, bind->rect = rect; for (int i = 0; i < MAX_BINDS; i++) { +#if defined(CAPI_SDL1) || defined(CAPI_SDL2) unsigned int key = configKey[i]; struct DjuiButton* button = djui_button_create(&rect->base, translate_bind_to_name(key)); +#else + struct DjuiButton* button = djui_button_create(&rect->base, "???"); +#endif djui_base_set_size_type(&button->base, DJUI_SVT_RELATIVE, DJUI_SVT_RELATIVE); djui_base_set_size(&button->base, 0.33f, 1.0f); button->base.tag = i;