diff --git a/frontend/menu/backend/menu_common_backend.c b/frontend/menu/backend/menu_common_backend.c index 38a69a2eb5..d9a5e653e1 100644 --- a/frontend/menu/backend/menu_common_backend.c +++ b/frontend/menu/backend/menu_common_backend.c @@ -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; diff --git a/frontend/menu/menu_common.c b/frontend/menu/menu_common.c index b3384b0112..6cebdaa73f 100644 --- a/frontend/menu/menu_common.c +++ b/frontend/menu/menu_common.c @@ -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; -} diff --git a/frontend/menu/menu_common.h b/frontend/menu/menu_common.h index b8753d6b50..d397f0d8bc 100644 --- a/frontend/menu/menu_common.h +++ b/frontend/menu/menu_common.h @@ -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 diff --git a/frontend/menu/menu_entries.c b/frontend/menu/menu_entries.c index 55291bd05e..025559001a 100644 --- a/frontend/menu/menu_entries.c +++ b/frontend/menu/menu_entries.c @@ -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) { diff --git a/frontend/menu/menu_entries_cbs.c b/frontend/menu/menu_entries_cbs.c index 12c98caea4..4dc5ae1f1e 100644 --- a/frontend/menu/menu_entries_cbs.c +++ b/frontend/menu/menu_entries_cbs.c @@ -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, diff --git a/frontend/menu/menu_input_line_cb.c b/frontend/menu/menu_input_line_cb.c index 390f4e80b2..ee1a27343f 100644 --- a/frontend/menu/menu_input_line_cb.c +++ b/frontend/menu/menu_input_line_cb.c @@ -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, diff --git a/retroarch.c b/retroarch.c index 5c56f5aa2a..a29db42d6c 100644 --- a/retroarch.c +++ b/retroarch.c @@ -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"