Refactor remaining toggle functions

This commit is contained in:
twinaphex 2014-10-12 19:45:38 +02:00
parent 61fd8b38dc
commit 0245be3193
7 changed files with 49 additions and 38 deletions

View File

@ -243,10 +243,8 @@ static int menu_setting_start_pressed(unsigned type,
}
static int menu_setting_toggle_pressed(unsigned type,
const char *dir, const char *label,
unsigned action)
const char *label, unsigned action)
{
struct retro_perf_counter **counters = NULL;
menu_file_list_cbs_t *cbs = (menu_file_list_cbs_t*)
file_list_get_actiondata_at_offset(driver.menu->selection_buf,
driver.menu->selection_ptr);
@ -254,23 +252,6 @@ static int menu_setting_toggle_pressed(unsigned type,
if (cbs && cbs->action_toggle)
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;
}
@ -325,7 +306,7 @@ static int menu_settings_iterate(unsigned action)
case MENU_ACTION_LEFT:
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)
return ret;

View File

@ -500,15 +500,3 @@ unsigned menu_common_type_is(const char *label, unsigned type)
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;
}

View File

@ -30,7 +30,6 @@
#include "../../playlist.h"
#include "../../input/input_common.h"
#include "../../input/keyboard_line.h"
#include "../../performance.h"
#include "../../gfx/shader/shader_context.h"
#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);
int menu_common_setting_set_perf(unsigned setting, unsigned action,
struct retro_perf_counter **counters, unsigned offset);
void apply_deferred_settings(void);
#ifdef __cplusplus

View File

@ -18,6 +18,7 @@
#include "menu_action.h"
#include "../../settings_data.h"
#include "../../file_ext.h"
#include "../../performance.h"
static void entries_refresh(file_list_t *list)
{

View File

@ -21,6 +21,7 @@
#include "backend/menu_backend.h"
#include "../../config.def.h"
#include "../../performance.h"
static void common_load_content(void)
{
@ -587,6 +588,42 @@ static int action_ok_help(const char *path,
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,
unsigned action)
{
@ -756,7 +793,7 @@ static void menu_entries_cbs_init_bind_toggle(menu_file_list_cbs_t *cbs,
if (!cbs)
return;
cbs->action_toggle = NULL;
cbs->action_toggle = menu_action_setting_set;
if ((menu_common_type_is(label, type) == MENU_SETTINGS_SHADER_OPTIONS) ||
!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;
else if ((type >= MENU_SETTINGS_CORE_OPTION_START))
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,

View File

@ -28,6 +28,7 @@
#include "menu_action.h"
#include "../../input/keyboard_line.h"
#include "menu_input_line_cb.h"
#include "../../performance.h"
#include "../../settings_data.h"
void menu_key_start_line(void *data, const char *label,

View File

@ -29,6 +29,7 @@
#include "dynamic.h"
#include "compat/strl.h"
#include "screenshot.h"
#include "performance.h"
#include "cheats.h"
#include "compat/getopt_rarch.h"
#include "compat/posix_string.h"