mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 12:32:52 +00:00
(menu_cbs_{left|right}.c) Cut down on some code duplication
This commit is contained in:
parent
a42b59916c
commit
236a8425ec
@ -26,48 +26,34 @@
|
||||
#include "../../general.h"
|
||||
#include "../../retroarch.h"
|
||||
|
||||
|
||||
#ifdef HAVE_SHADER_MANAGER
|
||||
static void shader_action_parameter_left_common(
|
||||
struct video_shader_parameter *param,
|
||||
struct video_shader *shader)
|
||||
static int generic_shader_action_parameter_left(unsigned type, const char *label,
|
||||
bool wraparound, unsigned param_id)
|
||||
{
|
||||
if (!shader)
|
||||
return;
|
||||
#ifdef HAVE_SHADER_MANAGER
|
||||
struct video_shader *shader = video_shader_driver_get_current_shader();
|
||||
struct video_shader_parameter *param = &shader->parameters[type - param_id];
|
||||
|
||||
param->current -= param->step;
|
||||
param->current = min(max(param->minimum, param->current), param->maximum);
|
||||
}
|
||||
if (shader)
|
||||
{
|
||||
param->current -= param->step;
|
||||
param->current = min(max(param->minimum, param->current), param->maximum);
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int shader_action_parameter_left(unsigned type, const char *label,
|
||||
bool wraparound)
|
||||
{
|
||||
#ifdef HAVE_SHADER_MANAGER
|
||||
struct video_shader *shader = video_shader_driver_get_current_shader();
|
||||
struct video_shader_parameter *param =
|
||||
&shader->parameters[type - MENU_SETTINGS_SHADER_PARAMETER_0];
|
||||
|
||||
shader_action_parameter_left_common(param, shader);
|
||||
#endif
|
||||
return 0;
|
||||
return generic_shader_action_parameter_left(type, label, wraparound,
|
||||
MENU_SETTINGS_SHADER_PARAMETER_0);
|
||||
}
|
||||
|
||||
static int shader_action_parameter_preset_left(unsigned type, const char *label,
|
||||
bool wraparound)
|
||||
{
|
||||
#ifdef HAVE_SHADER_MANAGER
|
||||
struct video_shader_parameter *param = NULL;
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
struct video_shader *shader = menu ? menu->shader : NULL;
|
||||
if (!menu || !shader)
|
||||
return -1;
|
||||
|
||||
param = &shader->parameters[type - MENU_SETTINGS_SHADER_PRESET_PARAMETER_0];
|
||||
|
||||
shader_action_parameter_left_common(param, shader);
|
||||
#endif
|
||||
return 0;
|
||||
return generic_shader_action_parameter_left(type, label, wraparound,
|
||||
MENU_SETTINGS_SHADER_PRESET_PARAMETER_0);
|
||||
}
|
||||
|
||||
static int action_left_cheat(unsigned type, const char *label,
|
||||
@ -208,6 +194,7 @@ static int action_left_shader_filter_pass(unsigned type, const char *label,
|
||||
bool wraparound)
|
||||
{
|
||||
#ifdef HAVE_SHADER_MANAGER
|
||||
unsigned delta = 2;
|
||||
unsigned pass = type - MENU_SETTINGS_SHADER_PASS_FILTER_0;
|
||||
struct video_shader *shader = NULL;
|
||||
struct video_shader_pass *shader_pass = NULL;
|
||||
@ -222,11 +209,7 @@ static int action_left_shader_filter_pass(unsigned type, const char *label,
|
||||
if (!shader_pass)
|
||||
return -1;
|
||||
|
||||
{
|
||||
unsigned delta = 2;
|
||||
shader_pass->filter = ((shader_pass->filter + delta) % 3);
|
||||
|
||||
}
|
||||
shader_pass->filter = ((shader_pass->filter + delta) % 3);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
@ -27,51 +27,38 @@
|
||||
#include "../../retroarch.h"
|
||||
|
||||
|
||||
#ifdef HAVE_SHADER_MANAGER
|
||||
static void shader_action_parameter_right_common(
|
||||
struct video_shader_parameter *param,
|
||||
struct video_shader *shader)
|
||||
static int generic_shader_action_parameter_right(unsigned type, const char *label,
|
||||
bool wraparound, unsigned param_id)
|
||||
{
|
||||
driver_t * driver = driver_get_ptr();
|
||||
const ui_companion_driver_t *ui = ui_companion_get_ptr();
|
||||
#ifdef HAVE_SHADER_MANAGER
|
||||
driver_t *driver = driver_get_ptr();
|
||||
const ui_companion_driver_t *ui = ui_companion_get_ptr();
|
||||
struct video_shader *shader = video_shader_driver_get_current_shader();
|
||||
struct video_shader_parameter *param = &shader->parameters[type - param_id];
|
||||
|
||||
if (!shader)
|
||||
return;
|
||||
return -1;
|
||||
|
||||
param->current += param->step;
|
||||
param->current = min(max(param->minimum, param->current), param->maximum);
|
||||
|
||||
if (ui->notify_refresh && ui_companion_is_on_foreground())
|
||||
ui->notify_refresh(driver->ui_companion_data);
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
int shader_action_parameter_right(unsigned type, const char *label, bool wraparound)
|
||||
{
|
||||
#ifdef HAVE_SHADER_MANAGER
|
||||
struct video_shader *shader = video_shader_driver_get_current_shader();
|
||||
struct video_shader_parameter *param =
|
||||
&shader->parameters[type - MENU_SETTINGS_SHADER_PARAMETER_0];
|
||||
|
||||
shader_action_parameter_right_common(param, shader);
|
||||
#endif
|
||||
return 0;
|
||||
return generic_shader_action_parameter_right(type, label, wraparound,
|
||||
MENU_SETTINGS_SHADER_PARAMETER_0);
|
||||
}
|
||||
|
||||
int shader_action_parameter_preset_right(unsigned type, const char *label,
|
||||
bool wraparound)
|
||||
{
|
||||
#ifdef HAVE_SHADER_MANAGER
|
||||
struct video_shader_parameter *param = NULL;
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
struct video_shader *shader = menu ? menu->shader : NULL;
|
||||
if (!menu || !shader)
|
||||
return -1;
|
||||
|
||||
param = &shader->parameters[type - MENU_SETTINGS_SHADER_PRESET_PARAMETER_0];
|
||||
|
||||
shader_action_parameter_right_common(param, shader);
|
||||
#endif
|
||||
return 0;
|
||||
return generic_shader_action_parameter_right(type, label, wraparound,
|
||||
MENU_SETTINGS_SHADER_PRESET_PARAMETER_0);
|
||||
}
|
||||
|
||||
int action_right_cheat(unsigned type, const char *label,
|
||||
|
Loading…
x
Reference in New Issue
Block a user