mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-01-20 18:02:12 +00:00
(Menu) Cut down on some code duplication
This commit is contained in:
parent
94955eb3b5
commit
e5ec7d0fda
@ -146,6 +146,7 @@ unsigned menu_event(input_bits_t *p_input, input_bits_t *p_trigger_input)
|
||||
/* Used for key repeat */
|
||||
static float delay_timer = 0.0f;
|
||||
static float delay_count = 0.0f;
|
||||
static unsigned ok_old = 0;
|
||||
unsigned ret = MENU_ACTION_NOOP;
|
||||
static bool initial_held = true;
|
||||
static bool first_held = false;
|
||||
@ -154,14 +155,14 @@ unsigned menu_event(input_bits_t *p_input, input_bits_t *p_trigger_input)
|
||||
size_t new_scroll_accel = 0;
|
||||
menu_input_t *menu_input = NULL;
|
||||
settings_t *settings = config_get_ptr();
|
||||
static unsigned ok_old = 0;
|
||||
bool swap_ok_cancel_btns = settings->bools.input_menu_swap_ok_cancel_buttons;
|
||||
bool input_swap_override =
|
||||
input_autoconfigure_get_swap_override();
|
||||
unsigned menu_ok_btn = (!input_swap_override &&
|
||||
settings->bools.input_menu_swap_ok_cancel_buttons) ?
|
||||
swap_ok_cancel_btns) ?
|
||||
RETRO_DEVICE_ID_JOYPAD_B : RETRO_DEVICE_ID_JOYPAD_A;
|
||||
unsigned menu_cancel_btn = (!input_swap_override &&
|
||||
settings->bools.input_menu_swap_ok_cancel_buttons) ?
|
||||
swap_ok_cancel_btns) ?
|
||||
RETRO_DEVICE_ID_JOYPAD_A : RETRO_DEVICE_ID_JOYPAD_B;
|
||||
unsigned ok_current = BIT256_GET_PTR(p_input,
|
||||
menu_ok_btn );
|
||||
|
@ -213,6 +213,22 @@ bool menu_shader_manager_set_preset(void *data,
|
||||
return true;
|
||||
}
|
||||
|
||||
static const char *shader_get_preset_extension(unsigned type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case RARCH_SHADER_GLSL:
|
||||
return file_path_str(FILE_PATH_GLSLP_EXTENSION);
|
||||
case RARCH_SHADER_SLANG:
|
||||
return file_path_str(FILE_PATH_SLANGP_EXTENSION);
|
||||
case RARCH_SHADER_HLSL:
|
||||
case RARCH_SHADER_CG:
|
||||
return file_path_str(FILE_PATH_CGP_EXTENSION);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* menu_shader_manager_save_preset:
|
||||
* @basename : basename of preset
|
||||
@ -256,24 +272,9 @@ bool menu_shader_manager_save_preset(
|
||||
&& !strstr(basename,
|
||||
file_path_str(FILE_PATH_SLANGP_EXTENSION)))
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case RARCH_SHADER_GLSL:
|
||||
strlcat(buffer,
|
||||
file_path_str(FILE_PATH_GLSLP_EXTENSION),
|
||||
sizeof(buffer));
|
||||
break;
|
||||
case RARCH_SHADER_SLANG:
|
||||
strlcat(buffer,
|
||||
file_path_str(FILE_PATH_SLANGP_EXTENSION),
|
||||
sizeof(buffer));
|
||||
break;
|
||||
case RARCH_SHADER_CG:
|
||||
strlcat(buffer,
|
||||
file_path_str(FILE_PATH_CGP_EXTENSION),
|
||||
sizeof(buffer));
|
||||
break;
|
||||
}
|
||||
const char *preset_ext = shader_get_preset_extension(type);
|
||||
if (!string_is_empty(preset_ext))
|
||||
strlcat(buffer, preset_ext, sizeof(buffer));
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -287,36 +288,25 @@ bool menu_shader_manager_save_preset(
|
||||
const char *config_path = path_get(RARCH_PATH_CONFIG);
|
||||
/* In a multi-config setting, we can't have
|
||||
* conflicts on menu.cgp/menu.glslp. */
|
||||
const char *preset_ext = NULL;
|
||||
const char *preset_ext = shader_get_preset_extension(type);
|
||||
|
||||
switch (type)
|
||||
if (!string_is_empty(preset_ext))
|
||||
{
|
||||
case RARCH_SHADER_GLSL:
|
||||
preset_ext = file_path_str(FILE_PATH_GLSLP_EXTENSION);
|
||||
break;
|
||||
case RARCH_SHADER_SLANG:
|
||||
preset_ext = file_path_str(FILE_PATH_SLANGP_EXTENSION);
|
||||
break;
|
||||
case RARCH_SHADER_HLSL:
|
||||
case RARCH_SHADER_CG:
|
||||
preset_ext = file_path_str(FILE_PATH_CGP_EXTENSION);
|
||||
break;
|
||||
}
|
||||
|
||||
if (config_path)
|
||||
{
|
||||
fill_pathname_base_ext(default_preset,
|
||||
config_path,
|
||||
preset_ext,
|
||||
sizeof(default_preset));
|
||||
}
|
||||
else
|
||||
{
|
||||
strlcpy(default_preset, "menu",
|
||||
sizeof(default_preset));
|
||||
strlcat(default_preset,
|
||||
preset_ext,
|
||||
sizeof(default_preset));
|
||||
if (config_path)
|
||||
{
|
||||
fill_pathname_base_ext(default_preset,
|
||||
config_path,
|
||||
preset_ext,
|
||||
sizeof(default_preset));
|
||||
}
|
||||
else
|
||||
{
|
||||
strlcpy(default_preset, "menu",
|
||||
sizeof(default_preset));
|
||||
strlcat(default_preset,
|
||||
preset_ext,
|
||||
sizeof(default_preset));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -328,7 +318,6 @@ bool menu_shader_manager_save_preset(
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
|
||||
if (!path_is_empty(RARCH_PATH_CONFIG))
|
||||
fill_pathname_basedir(
|
||||
config_directory,
|
||||
|
Loading…
x
Reference in New Issue
Block a user