From 0357b6c922032e41ffa2d2a8bc9e2420dae3f291 Mon Sep 17 00:00:00 2001 From: Nikos Chantziaras Date: Tue, 21 Dec 2021 01:03:35 +0200 Subject: [PATCH] Add on-screen statistics toggle hotkey (#13381) * Add on-screen statistics toggle hotkey * CHANGES.md: Add technical statistics hotkey --- CHANGES.md | 1 + command.h | 3 +++ config.def.keybinds.h | 21 +++++++++++++++++++++ configuration.c | 1 + input/input_defines.h | 1 + intl/msg_hash_us.c | 4 ++++ intl/msg_hash_us.h | 8 ++++++++ menu/cbs/menu_cbs_sublabel.c | 4 ++++ msg_hash.h | 2 ++ retroarch.c | 3 +++ retroarch.cfg | 3 +++ runloop.c | 2 ++ 12 files changed, 53 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 8936832a99..6815560853 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,6 @@ # Future - LINUX: Added support for Linux GameMode (https://github.com/FeralInteractive/gamemode), which can be toggled on/off in the Power Management or Latency settings menus. +- Added a hotkey toggle for the on-screen technical statistics. # 1.9.14 - ANDROID/PLAYSTORE: Implement MANAGE_EXTERNAL_STORAGE permission diff --git a/command.h b/command.h index 0bb46d32dc..7740260595 100644 --- a/command.h +++ b/command.h @@ -119,6 +119,8 @@ enum event_command CMD_EVENT_AUDIO_MUTE_TOGGLE, /* Toggles FPS counter. */ CMD_EVENT_FPS_TOGGLE, + /* Toggles statistics display. */ + CMD_EVENT_STATISTICS_TOGGLE, /* Toggle ping counter. */ CMD_EVENT_NETPLAY_PING_TOGGLE, /* Gathers diagnostic info about the system and RetroArch configuration, then sends it to our servers. */ @@ -461,6 +463,7 @@ static const struct cmd_map map[] = { { "MUTE", RARCH_MUTE }, { "OSK", RARCH_OSK }, { "FPS_TOGGLE", RARCH_FPS_TOGGLE }, + { "STATISTICS_TOGGLE", RARCH_STATISTICS_TOGGLE }, { "SEND_DEBUG_INFO", RARCH_SEND_DEBUG_INFO }, { "NETPLAY_HOST_TOGGLE", RARCH_NETPLAY_HOST_TOGGLE }, { "NETPLAY_GAME_WATCH", RARCH_NETPLAY_GAME_WATCH }, diff --git a/config.def.keybinds.h b/config.def.keybinds.h index cd7de7a8cc..b7494d796f 100644 --- a/config.def.keybinds.h +++ b/config.def.keybinds.h @@ -451,6 +451,13 @@ static const struct retro_keybind retro_keybinds_1[] = { RARCH_FPS_TOGGLE, NO_BTN, NO_BTN, 0, true }, + { + NULL, NULL, + AXIS_NONE, AXIS_NONE, AXIS_NONE, + MENU_ENUM_LABEL_VALUE_INPUT_META_STATISTICS_TOGGLE, RETROK_UNKNOWN, + RARCH_STATISTICS_TOGGLE, NO_BTN, NO_BTN, 0, + true + }, { NULL, NULL, AXIS_NONE, AXIS_NONE, AXIS_NONE, @@ -1026,6 +1033,13 @@ static const struct retro_keybind retro_keybinds_1[] = { RARCH_FPS_TOGGLE, NO_BTN, NO_BTN, 0, true }, + { + NULL, NULL, + AXIS_NONE, AXIS_NONE, AXIS_NONE, + MENU_ENUM_LABEL_VALUE_INPUT_META_STATISTICS_TOGGLE, RETROK_UNKNOWN, + RARCH_STATISTICS_TOGGLE, NO_BTN, NO_BTN, 0, + true + }, { NULL, NULL, AXIS_NONE, AXIS_NONE, AXIS_NONE, @@ -1611,6 +1625,13 @@ static const struct retro_keybind retro_keybinds_1[] = { RARCH_FPS_TOGGLE, NO_BTN, NO_BTN, 0, true }, + { + NULL, NULL, + AXIS_NONE, AXIS_NONE, AXIS_NONE, + MENU_ENUM_LABEL_VALUE_INPUT_META_STATISTICS_TOGGLE, RETROK_UNKNOWN, + RARCH_STATISTICS_TOGGLE, NO_BTN, NO_BTN, 0, + true + }, { NULL, NULL, AXIS_NONE, AXIS_NONE, AXIS_NONE, diff --git a/configuration.c b/configuration.c index 83d8a02c18..fe8dd6a973 100644 --- a/configuration.c +++ b/configuration.c @@ -333,6 +333,7 @@ const struct input_bind_map input_config_bind_map[RARCH_BIND_LIST_END_NULL] = { DECLARE_META_BIND(2, audio_mute, RARCH_MUTE, MENU_ENUM_LABEL_VALUE_INPUT_META_MUTE), DECLARE_META_BIND(2, osk_toggle, RARCH_OSK, MENU_ENUM_LABEL_VALUE_INPUT_META_OSK), DECLARE_META_BIND(2, fps_toggle, RARCH_FPS_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_FPS_TOGGLE), + DECLARE_META_BIND(2, toggle_statistics, RARCH_STATISTICS_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_STATISTICS_TOGGLE), DECLARE_META_BIND(2, netplay_ping_toggle, RARCH_NETPLAY_PING_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_PING_TOGGLE), DECLARE_META_BIND(2, send_debug_info, RARCH_SEND_DEBUG_INFO, MENU_ENUM_LABEL_VALUE_INPUT_META_SEND_DEBUG_INFO), DECLARE_META_BIND(2, netplay_host_toggle, RARCH_NETPLAY_HOST_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_HOST_TOGGLE), diff --git a/input/input_defines.h b/input/input_defines.h index e31c049a0a..bbce8fa514 100644 --- a/input/input_defines.h +++ b/input/input_defines.h @@ -99,6 +99,7 @@ enum RARCH_MUTE, RARCH_OSK, RARCH_FPS_TOGGLE, + RARCH_STATISTICS_TOGGLE, RARCH_NETPLAY_PING_TOGGLE, RARCH_SEND_DEBUG_INFO, RARCH_NETPLAY_HOST_TOGGLE, diff --git a/intl/msg_hash_us.c b/intl/msg_hash_us.c index f34f26236f..74d88b577b 100644 --- a/intl/msg_hash_us.c +++ b/intl/msg_hash_us.c @@ -109,6 +109,10 @@ int msg_hash_get_help_us_enum(enum msg_hash_enums msg, char *s, size_t len) snprintf(s, len, "Toggles frames per second counter."); break; + case RARCH_STATISTICS_TOGGLE: + snprintf(s, len, + "Toggles display of technical statistics."); + break; case RARCH_SEND_DEBUG_INFO: snprintf(s, len, "Sends diagnostic info about your device and RetroArch configuration to our servers for analysis."); diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 9b9b83ad70..56b06c0241 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -2666,6 +2666,14 @@ MSG_HASH( MENU_ENUM_SUBLABEL_INPUT_META_FPS_TOGGLE, "Switches 'frames per second' status indicator on/off." ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_INPUT_META_STATISTICS_TOGGLE, + "Show Technical Statistics (Toggle)" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_INPUT_META_STATISTICS_TOGGLE, + "Switches the display of on-screen technical statistics on/off." + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_PING_TOGGLE, "Show Netplay Ping (Toggle)" diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index 471ed644da..dba1a8b868 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -288,6 +288,7 @@ DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_meta_screenshot, ME DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_meta_mute, MENU_ENUM_SUBLABEL_INPUT_META_MUTE) DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_meta_osk, MENU_ENUM_SUBLABEL_INPUT_META_OSK) DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_meta_fps_toggle, MENU_ENUM_SUBLABEL_INPUT_META_FPS_TOGGLE) +DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_meta_statistics_toggle, MENU_ENUM_SUBLABEL_INPUT_META_STATISTICS_TOGGLE) DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_meta_netplay_ping_toggle, MENU_ENUM_SUBLABEL_INPUT_META_NETPLAY_PING_TOGGLE) DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_meta_send_debug_info, MENU_ENUM_SUBLABEL_INPUT_META_SEND_DEBUG_INFO) DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_meta_netplay_host_toggle, MENU_ENUM_SUBLABEL_INPUT_META_NETPLAY_HOST_TOGGLE) @@ -1883,6 +1884,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs, case RARCH_FPS_TOGGLE: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_input_meta_fps_toggle); return 0; + case RARCH_STATISTICS_TOGGLE: + BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_input_meta_statistics_toggle); + return 0; case RARCH_NETPLAY_PING_TOGGLE: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_input_meta_netplay_ping_toggle); return 0; diff --git a/msg_hash.h b/msg_hash.h index ea4360299d..66b751964a 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -880,6 +880,7 @@ enum msg_hash_enums MENU_ENUM_LABEL_VALUE_INPUT_META_MUTE, MENU_ENUM_LABEL_VALUE_INPUT_META_OSK, MENU_ENUM_LABEL_VALUE_INPUT_META_FPS_TOGGLE, + MENU_ENUM_LABEL_VALUE_INPUT_META_STATISTICS_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_PING_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_SEND_DEBUG_INFO, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_HOST_TOGGLE, @@ -940,6 +941,7 @@ enum msg_hash_enums MENU_ENUM_SUBLABEL_INPUT_META_MUTE, MENU_ENUM_SUBLABEL_INPUT_META_OSK, MENU_ENUM_SUBLABEL_INPUT_META_FPS_TOGGLE, + MENU_ENUM_SUBLABEL_INPUT_META_STATISTICS_TOGGLE, MENU_ENUM_SUBLABEL_INPUT_META_NETPLAY_PING_TOGGLE, MENU_ENUM_SUBLABEL_INPUT_META_SEND_DEBUG_INFO, MENU_ENUM_SUBLABEL_INPUT_META_NETPLAY_HOST_TOGGLE, diff --git a/retroarch.c b/retroarch.c index 92f7fc2cd4..b654c0b85d 100644 --- a/retroarch.c +++ b/retroarch.c @@ -2106,6 +2106,9 @@ bool command_event(enum event_command cmd, void *data) case CMD_EVENT_FPS_TOGGLE: settings->bools.video_fps_show = !(settings->bools.video_fps_show); break; + case CMD_EVENT_STATISTICS_TOGGLE: + settings->bools.video_statistics_show = !(settings->bools.video_statistics_show); + break; case CMD_EVENT_OVERLAY_NEXT: /* Switch to the next available overlay screen. */ #ifdef HAVE_OVERLAY diff --git a/retroarch.cfg b/retroarch.cfg index 45b729b727..c1a1f3b9c8 100644 --- a/retroarch.cfg +++ b/retroarch.cfg @@ -639,6 +639,9 @@ # Toggles menu. # input_menu_toggle = f1 +# Toggles display of on-screen technical statistics. +# input_toggle_statistics = + # RetroPad button combination to toggle menu # 0: None # 1: Down + Y + L1 + R1 diff --git a/runloop.c b/runloop.c index 3f6a28f9ac..731766e95c 100644 --- a/runloop.c +++ b/runloop.c @@ -6827,6 +6827,8 @@ static enum runloop_state_enum runloop_check_state( /* Check if we have pressed the FPS toggle button */ HOTKEY_CHECK(RARCH_FPS_TOGGLE, CMD_EVENT_FPS_TOGGLE, true, NULL); + HOTKEY_CHECK(RARCH_STATISTICS_TOGGLE, CMD_EVENT_STATISTICS_TOGGLE, true, NULL); + /* Check if we have pressed the netplay host toggle button */ HOTKEY_CHECK(RARCH_NETPLAY_HOST_TOGGLE, CMD_EVENT_NETPLAY_HOST_TOGGLE, true, NULL);