mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-01-06 23:51:17 +00:00
Added define guards around controller bind mappings
This commit is contained in:
parent
f45ae4a115
commit
101a6400e0
3 changed files with 13 additions and 0 deletions
|
@ -8,6 +8,8 @@
|
||||||
#include "controller_api.h"
|
#include "controller_api.h"
|
||||||
#include "controller_sdl.h"
|
#include "controller_sdl.h"
|
||||||
|
|
||||||
|
#if defined(CAPI_SDL1) || defined(CAPI_SDL2)
|
||||||
|
|
||||||
static int inverted_scancode_table[512];
|
static int inverted_scancode_table[512];
|
||||||
static SDL_Scancode bind_to_sdl_scancode[512] = { 0 };
|
static SDL_Scancode bind_to_sdl_scancode[512] = { 0 };
|
||||||
|
|
||||||
|
@ -149,3 +151,4 @@ const char* translate_bind_to_name(int bind) {
|
||||||
#endif
|
#endif
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
#ifndef CONTROLLER_BIND_MAPPING_H
|
#ifndef CONTROLLER_BIND_MAPPING_H
|
||||||
#define CONTROLLER_BIND_MAPPING_H
|
#define CONTROLLER_BIND_MAPPING_H
|
||||||
|
|
||||||
|
#if defined(CAPI_SDL1) || defined(CAPI_SDL2)
|
||||||
void controller_bind_init(void);
|
void controller_bind_init(void);
|
||||||
int translate_sdl_scancode(int scancode);
|
int translate_sdl_scancode(int scancode);
|
||||||
const char* translate_bind_to_name(int bind);
|
const char* translate_bind_to_name(int bind);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -33,7 +33,11 @@ static void djui_bind_button_on_bind(struct DjuiBase* caller) {
|
||||||
|
|
||||||
// set key
|
// set key
|
||||||
bind->configKey[button->base.tag] = 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));
|
djui_text_set_text(button->text, translate_bind_to_name(key));
|
||||||
|
#else
|
||||||
|
djui_text_set_text(button->text, "???");
|
||||||
|
#endif
|
||||||
djui_interactable_set_binding(NULL);
|
djui_interactable_set_binding(NULL);
|
||||||
play_sound(SOUND_MENU_CHANGE_SELECT, gDefaultSoundArgs);
|
play_sound(SOUND_MENU_CHANGE_SELECT, gDefaultSoundArgs);
|
||||||
controller_reconfigure();
|
controller_reconfigure();
|
||||||
|
@ -72,8 +76,12 @@ struct DjuiBind* djui_bind_create(struct DjuiBase* parent, const char* message,
|
||||||
bind->rect = rect;
|
bind->rect = rect;
|
||||||
|
|
||||||
for (int i = 0; i < MAX_BINDS; i++) {
|
for (int i = 0; i < MAX_BINDS; i++) {
|
||||||
|
#if defined(CAPI_SDL1) || defined(CAPI_SDL2)
|
||||||
unsigned int key = configKey[i];
|
unsigned int key = configKey[i];
|
||||||
struct DjuiButton* button = djui_button_create(&rect->base, translate_bind_to_name(key));
|
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_type(&button->base, DJUI_SVT_RELATIVE, DJUI_SVT_RELATIVE);
|
||||||
djui_base_set_size(&button->base, 0.33f, 1.0f);
|
djui_base_set_size(&button->base, 0.33f, 1.0f);
|
||||||
button->base.tag = i;
|
button->base.tag = i;
|
||||||
|
|
Loading…
Reference in a new issue