diff --git a/command.c b/command.c index 5eaccec478..983bd8aae2 100644 --- a/command.c +++ b/command.c @@ -220,6 +220,7 @@ static const struct cmd_map map[] = { { "SCREENSHOT", RARCH_SCREENSHOT }, { "MUTE", RARCH_MUTE }, { "OSK", RARCH_OSK }, + { "FPS_TOGGLE", RARCH_FPS_TOGGLE }, { "NETPLAY_GAME_WATCH", RARCH_NETPLAY_GAME_WATCH }, { "VOLUME_UP", RARCH_VOLUME_UP }, { "VOLUME_DOWN", RARCH_VOLUME_DOWN }, @@ -2187,6 +2188,12 @@ TODO: Add a setting for these tweaks */ RARCH_LOG("%s\n", msg); } break; + case CMD_EVENT_FPS_TOGGLE: + { + settings_t *settings = config_get_ptr(); + settings->bools.video_fps_show = !(settings->bools.video_fps_show); + } + break; case CMD_EVENT_OVERLAY_DEINIT: #ifdef HAVE_OVERLAY input_overlay_free(overlay_ptr); diff --git a/command.h b/command.h index 134504cadb..7659ea605a 100644 --- a/command.h +++ b/command.h @@ -85,6 +85,8 @@ enum event_command CMD_EVENT_AUDIO_START, /* Mutes audio. */ CMD_EVENT_AUDIO_MUTE_TOGGLE, + /* Toggles FPS counter. */ + CMD_EVENT_FPS_TOGGLE, /* Initializes overlay. */ CMD_EVENT_OVERLAY_INIT, /* Deinitializes overlay. */ diff --git a/config.def.keybinds.h b/config.def.keybinds.h index 169cc7b5fc..c2994122a3 100644 --- a/config.def.keybinds.h +++ b/config.def.keybinds.h @@ -87,6 +87,7 @@ static const struct retro_keybind retro_keybinds_1[] = { { true, RARCH_SCREENSHOT, MENU_ENUM_LABEL_VALUE_INPUT_META_SCREENSHOT, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, { true, RARCH_MUTE, MENU_ENUM_LABEL_VALUE_INPUT_META_MUTE, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, { true, RARCH_OSK, MENU_ENUM_LABEL_VALUE_INPUT_META_OSK, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_FPS_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_FPS_TOGGLE, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, { true, RARCH_NETPLAY_GAME_WATCH, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_GAME_WATCH, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, { true, RARCH_ENABLE_HOTKEY, MENU_ENUM_LABEL_VALUE_INPUT_META_ENABLE_HOTKEY, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, { true, RARCH_VOLUME_UP, MENU_ENUM_LABEL_VALUE_INPUT_META_VOLUME_UP, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, @@ -165,6 +166,7 @@ static const struct retro_keybind retro_keybinds_1[] = { { true, RARCH_SCREENSHOT, MENU_ENUM_LABEL_VALUE_INPUT_META_SCREENSHOT, RETROK_F8, NO_BTN, NO_BTN, 0, AXIS_NONE }, { true, RARCH_MUTE, MENU_ENUM_LABEL_VALUE_INPUT_META_MUTE, RETROK_F9, NO_BTN, NO_BTN, 0, AXIS_NONE }, { true, RARCH_OSK, MENU_ENUM_LABEL_VALUE_INPUT_META_OSK, RETROK_F12, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_FPS_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_FPS_TOGGLE, RETROK_F3, NO_BTN, NO_BTN, 0, AXIS_NONE }, { true, RARCH_NETPLAY_GAME_WATCH, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_GAME_WATCH, RETROK_i, NO_BTN, NO_BTN, 0, AXIS_NONE }, { true, RARCH_ENABLE_HOTKEY, MENU_ENUM_LABEL_VALUE_INPUT_META_ENABLE_HOTKEY, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, { true, RARCH_VOLUME_UP, MENU_ENUM_LABEL_VALUE_INPUT_META_VOLUME_UP, RETROK_KP_PLUS, NO_BTN, NO_BTN, 0, AXIS_NONE }, diff --git a/input/input_defines.h b/input/input_defines.h index ea52a3c890..891d850bdd 100644 --- a/input/input_defines.h +++ b/input/input_defines.h @@ -97,6 +97,7 @@ enum RARCH_SCREENSHOT, RARCH_MUTE, RARCH_OSK, + RARCH_FPS_TOGGLE, RARCH_NETPLAY_GAME_WATCH, RARCH_ENABLE_HOTKEY, RARCH_VOLUME_UP, diff --git a/input/input_driver.c b/input/input_driver.c index 7261a4ca27..2e0c055fb9 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -343,6 +343,7 @@ const struct input_bind_map input_config_bind_map[RARCH_BIND_LIST_END_NULL] = { DECLARE_META_BIND(2, screenshot, RARCH_SCREENSHOT, MENU_ENUM_LABEL_VALUE_INPUT_META_SCREENSHOT), 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, netplay_game_watch, RARCH_NETPLAY_GAME_WATCH, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_GAME_WATCH), DECLARE_META_BIND(2, enable_hotkey, RARCH_ENABLE_HOTKEY, MENU_ENUM_LABEL_VALUE_INPUT_META_ENABLE_HOTKEY), DECLARE_META_BIND(2, volume_up, RARCH_VOLUME_UP, MENU_ENUM_LABEL_VALUE_INPUT_META_VOLUME_UP), diff --git a/intl/msg_hash_us.c b/intl/msg_hash_us.c index e2d5c9c970..6f46d28063 100644 --- a/intl/msg_hash_us.c +++ b/intl/msg_hash_us.c @@ -104,6 +104,10 @@ int menu_hash_get_help_us_enum(enum msg_hash_enums msg, char *s, size_t len) snprintf(s, len, "Toggles onscreen keyboard."); break; + case RARCH_FPS_TOGGLE: + snprintf(s, len, + "Toggles frames per second counter."); + break; case RARCH_NETPLAY_GAME_WATCH: snprintf(s, len, "Netplay toggle play/spectate mode."); diff --git a/msg_hash.h b/msg_hash.h index 5c4e151916..b1565e79a0 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -671,6 +671,7 @@ enum msg_hash_enums MENU_ENUM_LABEL_VALUE_INPUT_META_SCREENSHOT, 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_NETPLAY_GAME_WATCH, MENU_ENUM_LABEL_VALUE_INPUT_META_ENABLE_HOTKEY, MENU_ENUM_LABEL_VALUE_INPUT_META_VOLUME_UP, diff --git a/retroarch.c b/retroarch.c index 7671fe20a8..ba30250af1 100644 --- a/retroarch.c +++ b/retroarch.c @@ -2930,6 +2930,18 @@ static enum runloop_state runloop_check_state( old_pressed = pressed; } + /* Check FPS toggle */ + { + static bool old_pressed = false; + bool pressed = BIT256_GET( + current_input, RARCH_FPS_TOGGLE); + + if (pressed && !old_pressed) + command_event(CMD_EVENT_FPS_TOGGLE, NULL); + + old_pressed = pressed; + } + /* Check recording toggle */ { static bool old_pressed = false;