Qt: Turbo (Hold) Hotkey binding

Fixes #5538
Acts as a temporary flip-flop switch while held that either enables turbo while held or disables turbo while held if you've already toggled turbo.

Default bind is Keyboard/Period but happy to make this unbound if preferred.
This commit is contained in:
Christian Murphy 2022-06-19 19:32:50 +01:00 committed by lightningterror
parent 1d39488061
commit 4ee92fc637
2 changed files with 13 additions and 2 deletions

View File

@ -306,6 +306,7 @@ void PAD::SetDefaultConfig(SettingsInterface& si)
si.SetStringValue("Hotkeys", "TogglePause", "Keyboard/Space"); si.SetStringValue("Hotkeys", "TogglePause", "Keyboard/Space");
si.SetStringValue("Hotkeys", "ToggleSlowMotion", "Keyboard/Shift & Keyboard/Backtab"); si.SetStringValue("Hotkeys", "ToggleSlowMotion", "Keyboard/Shift & Keyboard/Backtab");
si.SetStringValue("Hotkeys", "ToggleTurbo", "Keyboard/Tab"); si.SetStringValue("Hotkeys", "ToggleTurbo", "Keyboard/Tab");
si.SetStringValue("Hotkeys", "HoldTurbo", "Keyboard/Period");
} }
void PAD::Update() void PAD::Update()

View File

@ -134,6 +134,7 @@ static u32 s_active_no_interlacing_patches = 0;
static s32 s_current_save_slot = 1; static s32 s_current_save_slot = 1;
static u32 s_frame_advance_count = 0; static u32 s_frame_advance_count = 0;
static u32 s_mxcsr_saved; static u32 s_mxcsr_saved;
static std::optional<LimiterModeType> s_limiter_mode_prior_to_hold_interaction;
bool VMManager::PerformEarlyHardwareChecks(const char** error) bool VMManager::PerformEarlyHardwareChecks(const char** error)
{ {
@ -1005,6 +1006,8 @@ void VMManager::Shutdown(bool save_resume_state)
s_active_game_fixes = 0; s_active_game_fixes = 0;
s_active_widescreen_patches = 0; s_active_widescreen_patches = 0;
s_active_no_interlacing_patches = 0; s_active_no_interlacing_patches = 0;
s_limiter_mode_prior_to_hold_interaction.reset();
UpdateGameSettingsLayer(); UpdateGameSettingsLayer();
std::string().swap(s_elf_override); std::string().swap(s_elf_override);
@ -1044,6 +1047,7 @@ void VMManager::Reset()
s_active_game_fixes = 0; s_active_game_fixes = 0;
s_active_widescreen_patches = 0; s_active_widescreen_patches = 0;
s_active_no_interlacing_patches = 0; s_active_no_interlacing_patches = 0;
s_limiter_mode_prior_to_hold_interaction.reset();
SysClearExecutionCache(); SysClearExecutionCache();
memBindConditionalHandlers(); memBindConditionalHandlers();
@ -1707,12 +1711,18 @@ DEFINE_HOTKEY("ToggleFrameLimit", "System", "Toggle Frame Limit", [](bool presse
} }
}) })
DEFINE_HOTKEY("ToggleTurbo", "System", "Toggle Turbo", [](bool pressed) { DEFINE_HOTKEY("ToggleTurbo", "System", "Toggle Turbo", [](bool pressed) {
if (!pressed) if (pressed && !s_limiter_mode_prior_to_hold_interaction.has_value())
{ {
VMManager::SetLimiterMode((EmuConfig.LimiterMode != LimiterModeType::Turbo) ? s_limiter_mode_prior_to_hold_interaction = VMManager::GetLimiterMode();
VMManager::SetLimiterMode((s_limiter_mode_prior_to_hold_interaction.value() != LimiterModeType::Turbo) ?
LimiterModeType::Turbo : LimiterModeType::Turbo :
LimiterModeType::Nominal); LimiterModeType::Nominal);
} }
else if (!pressed && s_limiter_mode_prior_to_hold_interaction.has_value())
{
VMManager::SetLimiterMode(s_limiter_mode_prior_to_hold_interaction.value());
s_limiter_mode_prior_to_hold_interaction.reset();
}
}) })
DEFINE_HOTKEY("ToggleSlowMotion", "System", "Toggle Slow Motion", [](bool pressed) { DEFINE_HOTKEY("ToggleSlowMotion", "System", "Toggle Slow Motion", [](bool pressed) {
if (!pressed) if (!pressed)