diff --git a/console/rarch_console_input.c b/console/rarch_console_input.c index 778aa5fdfb..7592013fea 100644 --- a/console/rarch_console_input.c +++ b/console/rarch_console_input.c @@ -48,12 +48,6 @@ char rarch_default_libretro_keybind_name_lut[RARCH_FIRST_META_KEY][32] = { "RetroPad Button R3", /* RETRO_DEVICE_ID_JOYPAD_R3 */ }; -char rarch_dpad_emulation_name_lut[KEYBIND_DEFAULT][32] = { - "None", /* DPAD_EMULATION_NONE */ - "Left Stick", /* DPAD_EMULATION_LSTICK */ - "Right Stick", /* DPAD_EMULATION_RSTICK */ -}; - extern const struct platform_bind platform_keys[]; extern const unsigned int platform_keys_size; diff --git a/console/rarch_console_input.h b/console/rarch_console_input.h index 3ea735ec21..14249ee450 100644 --- a/console/rarch_console_input.h +++ b/console/rarch_console_input.h @@ -28,7 +28,6 @@ enum keybind_set_id }; extern char rarch_default_libretro_keybind_name_lut[RARCH_FIRST_META_KEY][32]; -extern char rarch_dpad_emulation_name_lut[KEYBIND_DEFAULT][32]; const char *rarch_input_find_platform_key_label(uint64_t joykey); void rarch_input_set_default_keybinds(unsigned player); diff --git a/frontend/menu/menu_settings.c b/frontend/menu/menu_settings.c index 145d823eec..c7069a21ab 100644 --- a/frontend/menu/menu_settings.c +++ b/frontend/menu/menu_settings.c @@ -299,6 +299,6 @@ void menu_settings_create_menu_item_label(char * str, unsigned setting, size_t s break; case S_LBL_REWIND_GRANULARITY: snprintf(str, size, "Rewind granularity: %d", g_settings.rewind_granularity); - break; + break; } } diff --git a/frontend/menu/rgui.c b/frontend/menu/rgui.c index a77602614e..47e6eed5bf 100644 --- a/frontend/menu/rgui.c +++ b/frontend/menu/rgui.c @@ -514,7 +514,18 @@ static void render_text(rgui_handle_t *rgui) #endif #ifdef RARCH_CONSOLE case RGUI_SETTINGS_BIND_DPAD_EMULATION: - snprintf(type_str, sizeof(type_str), "%s", rarch_dpad_emulation_name_lut[g_settings.input.dpad_emulation[port]]); + switch(g_settings.input.dpad_emulation[port]) + { + case DPAD_EMULATION_NONE: + snprintf(type_str, sizeof(type_str), "None"); + break; + case DPAD_EMULATION_LSTICK: + snprintf(type_str, sizeof(type_str), "Left Stick"); + break; + case DPAD_EMULATION_RSTICK: + snprintf(type_str, sizeof(type_str), "Right Stick"); + break; + } break; case RGUI_SETTINGS_BIND_UP: case RGUI_SETTINGS_BIND_DOWN: diff --git a/frontend/menu/rmenu.c b/frontend/menu/rmenu.c index 934b18a88f..3a27b4e9ff 100644 --- a/frontend/menu/rmenu.c +++ b/frontend/menu/rmenu.c @@ -569,8 +569,21 @@ static void populate_setting_item(void *data, unsigned input) break; case SETTING_DPAD_EMULATION: snprintf(current_item->text, sizeof(current_item->text), "D-Pad Emulation"); - snprintf(current_item->comment, sizeof(current_item->comment), "[%s] from Controller %d is mapped to D-pad.", rarch_dpad_emulation_name_lut[g_settings.input.dpad_emulation[currently_selected_controller_menu]], currently_selected_controller_menu+1); - snprintf(current_item->setting_text, sizeof(current_item->setting_text), "%s", rarch_dpad_emulation_name_lut[g_settings.input.dpad_emulation[currently_selected_controller_menu]]); + switch(g_settings.input.dpad_emulation[currently_selected_controller_menu]) + { + case DPAD_EMULATION_NONE: + snprintf(current_item->comment, sizeof(current_item->comment), "[%s] from Controller %d is mapped to D-pad.", "None", currently_selected_controller_menu+1); + snprintf(current_item->setting_text, sizeof(current_item->setting_text), "None"); + break; + case DPAD_EMULATION_LSTICK: + snprintf(current_item->comment, sizeof(current_item->comment), "[%s] from Controller %d is mapped to D-pad.", "Left Stick", currently_selected_controller_menu+1); + snprintf(current_item->setting_text, sizeof(current_item->setting_text), "Left Stick"); + break; + case DPAD_EMULATION_RSTICK: + snprintf(current_item->comment, sizeof(current_item->comment), "[%s] from Controller %d is mapped to D-pad.", "Right Stick", currently_selected_controller_menu+1); + snprintf(current_item->setting_text, sizeof(current_item->setting_text), "Right Stick"); + break; + } break; case SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_B: case SETTING_CONTROLS_RETRO_DEVICE_ID_JOYPAD_Y: diff --git a/frontend/menu/rmenu_xui.cpp b/frontend/menu/rmenu_xui.cpp index bff600316e..65f39a89b0 100644 --- a/frontend/menu/rmenu_xui.cpp +++ b/frontend/menu/rmenu_xui.cpp @@ -381,6 +381,22 @@ HRESULT CRetroArchFileBrowser::OnNotifyPress( HXUIOBJ hObjPressed, BOOL& bHandle return 0; } +static void set_dpad_emulation_label(unsigned port, char *str, size_t sizeof_str) +{ + switch(g_settings.input.dpad_emulation[port]) + { + case DPAD_EMULATION_NONE: + snprintf(str, sizeof_str, "D-Pad Emulation: None"); + break; + case DPAD_EMULATION_LSTICK: + snprintf(str, sizeof_str, "D-Pad Emulation: Left Stick"); + break; + case DPAD_EMULATION_RSTICK: + snprintf(str, sizeof_str, "D-Pad Emulation: Right Stick"); + break; + } +} + HRESULT CRetroArchControls::OnInit(XUIMessageInit * pInitData, BOOL& bHandled) { unsigned i; @@ -403,7 +419,7 @@ HRESULT CRetroArchControls::OnInit(XUIMessageInit * pInitData, BOOL& bHandled) m_controlslist.SetText(i, strw_buffer); } - snprintf(buttons[0], sizeof(buttons[0]), "D-Pad Emulation: %s", rarch_dpad_emulation_name_lut[g_settings.input.dpad_emulation[controlno]]); + set_dpad_emulation_label(controlno, buttons[0], sizeof(buttons[0])); convert_char_to_wchar(strw_buffer, buttons[0], sizeof(strw_buffer)); m_controlslist.SetText(SETTING_CONTROLS_DPAD_EMULATION, strw_buffer); m_controlslist.SetText(SETTING_CONTROLS_DEFAULT_ALL, L"Reset all buttons to default"); @@ -489,7 +505,8 @@ HRESULT CRetroArchControls::OnControlNavigate( break; } - snprintf(button, sizeof(button), "D-Pad Emulation: %s", rarch_dpad_emulation_name_lut[g_settings.input.dpad_emulation[controlno]]); + set_dpad_emulation_label(controlno, button, sizeof(button)); + convert_char_to_wchar(strw_buffer, button, sizeof(strw_buffer)); m_controlslist.SetText(SETTING_CONTROLS_DPAD_EMULATION, strw_buffer); m_controlslist.SetText(SETTING_CONTROLS_DEFAULT_ALL, L"Reset all buttons to default"); @@ -534,7 +551,8 @@ HRESULT CRetroArchControls::OnNotifyPress( HXUIOBJ hObjPressed, int & bHandled } } - snprintf(buttons[current_index], sizeof(buttons[current_index]), "D-Pad Emulation: %s", rarch_dpad_emulation_name_lut[g_settings.input.dpad_emulation[controlno]]); + set_dpad_emulation_label(controlno, buttons[current_index], sizeof(buttons[curent_index])); + convert_char_to_wchar(strw_buffer, buttons[current_index], sizeof(strw_buffer)); m_controlslist.SetText(SETTING_CONTROLS_DPAD_EMULATION, strw_buffer); m_controlslist.SetText(SETTING_CONTROLS_DEFAULT_ALL, L"Reset all buttons to default");