Added define guards around controller bind mappings

This commit is contained in:
MysterD 2022-01-20 23:35:38 -08:00
parent f45ae4a115
commit 101a6400e0
3 changed files with 13 additions and 0 deletions

View file

@ -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

View file

@ -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

View file

@ -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;