mirror of
https://github.com/libretro/RetroArch
synced 2025-04-10 15:45:19 +00:00
Refactor remaining toggle functions
This commit is contained in:
parent
61fd8b38dc
commit
0245be3193
@ -243,10 +243,8 @@ static int menu_setting_start_pressed(unsigned type,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int menu_setting_toggle_pressed(unsigned type,
|
static int menu_setting_toggle_pressed(unsigned type,
|
||||||
const char *dir, const char *label,
|
const char *label, unsigned action)
|
||||||
unsigned action)
|
|
||||||
{
|
{
|
||||||
struct retro_perf_counter **counters = NULL;
|
|
||||||
menu_file_list_cbs_t *cbs = (menu_file_list_cbs_t*)
|
menu_file_list_cbs_t *cbs = (menu_file_list_cbs_t*)
|
||||||
file_list_get_actiondata_at_offset(driver.menu->selection_buf,
|
file_list_get_actiondata_at_offset(driver.menu->selection_buf,
|
||||||
driver.menu->selection_ptr);
|
driver.menu->selection_ptr);
|
||||||
@ -254,23 +252,6 @@ static int menu_setting_toggle_pressed(unsigned type,
|
|||||||
if (cbs && cbs->action_toggle)
|
if (cbs && cbs->action_toggle)
|
||||||
return cbs->action_toggle(type, label, action);
|
return cbs->action_toggle(type, label, action);
|
||||||
|
|
||||||
if (type >= MENU_SETTINGS_PERF_COUNTERS_BEGIN &&
|
|
||||||
type <= MENU_SETTINGS_PERF_COUNTERS_END)
|
|
||||||
{
|
|
||||||
counters = (struct retro_perf_counter**)perf_counters_rarch;
|
|
||||||
return menu_common_setting_set_perf(type, action, counters,
|
|
||||||
type - MENU_SETTINGS_PERF_COUNTERS_BEGIN);
|
|
||||||
}
|
|
||||||
else if (type >= MENU_SETTINGS_LIBRETRO_PERF_COUNTERS_BEGIN &&
|
|
||||||
type <= MENU_SETTINGS_LIBRETRO_PERF_COUNTERS_END)
|
|
||||||
{
|
|
||||||
counters = (struct retro_perf_counter**)perf_counters_libretro;
|
|
||||||
return menu_common_setting_set_perf(type, action, counters,
|
|
||||||
type - MENU_SETTINGS_LIBRETRO_PERF_COUNTERS_BEGIN);
|
|
||||||
}
|
|
||||||
else if (driver.menu_ctx && driver.menu_ctx->backend)
|
|
||||||
return menu_action_setting_set(type, label, action);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,7 +306,7 @@ static int menu_settings_iterate(unsigned action)
|
|||||||
case MENU_ACTION_LEFT:
|
case MENU_ACTION_LEFT:
|
||||||
case MENU_ACTION_RIGHT:
|
case MENU_ACTION_RIGHT:
|
||||||
{
|
{
|
||||||
int ret = menu_setting_toggle_pressed(type, path, label, action);
|
int ret = menu_setting_toggle_pressed(type, label, action);
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -500,15 +500,3 @@ unsigned menu_common_type_is(const char *label, unsigned type)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int menu_common_setting_set_perf(unsigned setting, unsigned action,
|
|
||||||
struct retro_perf_counter **counters, unsigned offset)
|
|
||||||
{
|
|
||||||
if (counters[offset] && action == MENU_ACTION_START)
|
|
||||||
{
|
|
||||||
counters[offset]->total = 0;
|
|
||||||
counters[offset]->call_cnt = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
@ -30,7 +30,6 @@
|
|||||||
#include "../../playlist.h"
|
#include "../../playlist.h"
|
||||||
#include "../../input/input_common.h"
|
#include "../../input/input_common.h"
|
||||||
#include "../../input/keyboard_line.h"
|
#include "../../input/keyboard_line.h"
|
||||||
#include "../../performance.h"
|
|
||||||
#include "../../gfx/shader/shader_context.h"
|
#include "../../gfx/shader/shader_context.h"
|
||||||
|
|
||||||
#ifdef HAVE_RGUI
|
#ifdef HAVE_RGUI
|
||||||
@ -155,9 +154,6 @@ void menu_update_system_info(menu_handle_t *menu, bool *load_no_content);
|
|||||||
|
|
||||||
unsigned menu_common_type_is(const char *label, unsigned type);
|
unsigned menu_common_type_is(const char *label, unsigned type);
|
||||||
|
|
||||||
int menu_common_setting_set_perf(unsigned setting, unsigned action,
|
|
||||||
struct retro_perf_counter **counters, unsigned offset);
|
|
||||||
|
|
||||||
void apply_deferred_settings(void);
|
void apply_deferred_settings(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include "menu_action.h"
|
#include "menu_action.h"
|
||||||
#include "../../settings_data.h"
|
#include "../../settings_data.h"
|
||||||
#include "../../file_ext.h"
|
#include "../../file_ext.h"
|
||||||
|
#include "../../performance.h"
|
||||||
|
|
||||||
static void entries_refresh(file_list_t *list)
|
static void entries_refresh(file_list_t *list)
|
||||||
{
|
{
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include "backend/menu_backend.h"
|
#include "backend/menu_backend.h"
|
||||||
|
|
||||||
#include "../../config.def.h"
|
#include "../../config.def.h"
|
||||||
|
#include "../../performance.h"
|
||||||
|
|
||||||
static void common_load_content(void)
|
static void common_load_content(void)
|
||||||
{
|
{
|
||||||
@ -587,6 +588,42 @@ static int action_ok_help(const char *path,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int performance_counters_core_toggle(unsigned type, const char *label,
|
||||||
|
unsigned action)
|
||||||
|
{
|
||||||
|
struct retro_perf_counter **counters = (struct retro_perf_counter**)
|
||||||
|
perf_counters_libretro;
|
||||||
|
unsigned offset = type - MENU_SETTINGS_LIBRETRO_PERF_COUNTERS_BEGIN;
|
||||||
|
|
||||||
|
(void)label;
|
||||||
|
|
||||||
|
if (counters[offset] && action == MENU_ACTION_START)
|
||||||
|
{
|
||||||
|
counters[offset]->total = 0;
|
||||||
|
counters[offset]->call_cnt = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int performance_counters_frontend_toggle(unsigned type, const char *label,
|
||||||
|
unsigned action)
|
||||||
|
{
|
||||||
|
struct retro_perf_counter **counters = (struct retro_perf_counter**)
|
||||||
|
perf_counters_rarch;
|
||||||
|
unsigned offset = type - MENU_SETTINGS_PERF_COUNTERS_BEGIN;
|
||||||
|
|
||||||
|
(void)label;
|
||||||
|
|
||||||
|
if (counters[offset] && action == MENU_ACTION_START)
|
||||||
|
{
|
||||||
|
counters[offset]->total = 0;
|
||||||
|
counters[offset]->call_cnt = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int core_setting_toggle(unsigned type, const char *label,
|
static int core_setting_toggle(unsigned type, const char *label,
|
||||||
unsigned action)
|
unsigned action)
|
||||||
{
|
{
|
||||||
@ -756,7 +793,7 @@ static void menu_entries_cbs_init_bind_toggle(menu_file_list_cbs_t *cbs,
|
|||||||
if (!cbs)
|
if (!cbs)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
cbs->action_toggle = NULL;
|
cbs->action_toggle = menu_action_setting_set;
|
||||||
|
|
||||||
if ((menu_common_type_is(label, type) == MENU_SETTINGS_SHADER_OPTIONS) ||
|
if ((menu_common_type_is(label, type) == MENU_SETTINGS_SHADER_OPTIONS) ||
|
||||||
!strcmp(label, "video_shader_parameters") ||
|
!strcmp(label, "video_shader_parameters") ||
|
||||||
@ -765,6 +802,12 @@ static void menu_entries_cbs_init_bind_toggle(menu_file_list_cbs_t *cbs,
|
|||||||
cbs->action_toggle = menu_shader_manager_setting_toggle;
|
cbs->action_toggle = menu_shader_manager_setting_toggle;
|
||||||
else if ((type >= MENU_SETTINGS_CORE_OPTION_START))
|
else if ((type >= MENU_SETTINGS_CORE_OPTION_START))
|
||||||
cbs->action_toggle = core_setting_toggle;
|
cbs->action_toggle = core_setting_toggle;
|
||||||
|
else if (type >= MENU_SETTINGS_PERF_COUNTERS_BEGIN &&
|
||||||
|
type <= MENU_SETTINGS_PERF_COUNTERS_END)
|
||||||
|
cbs->action_toggle = performance_counters_frontend_toggle;
|
||||||
|
else if (type >= MENU_SETTINGS_LIBRETRO_PERF_COUNTERS_BEGIN &&
|
||||||
|
type <= MENU_SETTINGS_LIBRETRO_PERF_COUNTERS_END)
|
||||||
|
cbs->action_toggle = performance_counters_core_toggle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void menu_entries_cbs_init(void *data,
|
void menu_entries_cbs_init(void *data,
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "menu_action.h"
|
#include "menu_action.h"
|
||||||
#include "../../input/keyboard_line.h"
|
#include "../../input/keyboard_line.h"
|
||||||
#include "menu_input_line_cb.h"
|
#include "menu_input_line_cb.h"
|
||||||
|
#include "../../performance.h"
|
||||||
#include "../../settings_data.h"
|
#include "../../settings_data.h"
|
||||||
|
|
||||||
void menu_key_start_line(void *data, const char *label,
|
void menu_key_start_line(void *data, const char *label,
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include "dynamic.h"
|
#include "dynamic.h"
|
||||||
#include "compat/strl.h"
|
#include "compat/strl.h"
|
||||||
#include "screenshot.h"
|
#include "screenshot.h"
|
||||||
|
#include "performance.h"
|
||||||
#include "cheats.h"
|
#include "cheats.h"
|
||||||
#include "compat/getopt_rarch.h"
|
#include "compat/getopt_rarch.h"
|
||||||
#include "compat/posix_string.h"
|
#include "compat/posix_string.h"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user