mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-23 14:25:37 +00:00
Qt: Add turbo speed setting
This commit is contained in:
parent
d73fedcef1
commit
54f5563321
|
@ -472,6 +472,7 @@ void HostInterface::SetDefaultSettings(SettingsInterface& si)
|
||||||
|
|
||||||
si.SetFloatValue("Main", "EmulationSpeed", 1.0f);
|
si.SetFloatValue("Main", "EmulationSpeed", 1.0f);
|
||||||
si.SetFloatValue("Main", "FastForwardSpeed", 0.0f);
|
si.SetFloatValue("Main", "FastForwardSpeed", 0.0f);
|
||||||
|
si.SetFloatValue("Main", "TurboSpeed", 0.0f);
|
||||||
si.SetBoolValue("Main", "IncreaseTimerResolution", true);
|
si.SetBoolValue("Main", "IncreaseTimerResolution", true);
|
||||||
si.SetBoolValue("Main", "StartPaused", false);
|
si.SetBoolValue("Main", "StartPaused", false);
|
||||||
si.SetBoolValue("Main", "StartFullscreen", false);
|
si.SetBoolValue("Main", "StartFullscreen", false);
|
||||||
|
|
|
@ -111,6 +111,7 @@ void Settings::Load(SettingsInterface& si)
|
||||||
|
|
||||||
emulation_speed = si.GetFloatValue("Main", "EmulationSpeed", 1.0f);
|
emulation_speed = si.GetFloatValue("Main", "EmulationSpeed", 1.0f);
|
||||||
fast_forward_speed = si.GetFloatValue("Main", "FastForwardSpeed", 0.0f);
|
fast_forward_speed = si.GetFloatValue("Main", "FastForwardSpeed", 0.0f);
|
||||||
|
turbo_speed = si.GetFloatValue("Main", "TurboSpeed", 0.0f);
|
||||||
increase_timer_resolution = si.GetBoolValue("Main", "IncreaseTimerResolution", true);
|
increase_timer_resolution = si.GetBoolValue("Main", "IncreaseTimerResolution", true);
|
||||||
start_paused = si.GetBoolValue("Main", "StartPaused", false);
|
start_paused = si.GetBoolValue("Main", "StartPaused", false);
|
||||||
start_fullscreen = si.GetBoolValue("Main", "StartFullscreen", false);
|
start_fullscreen = si.GetBoolValue("Main", "StartFullscreen", false);
|
||||||
|
@ -281,6 +282,7 @@ void Settings::Save(SettingsInterface& si) const
|
||||||
|
|
||||||
si.SetFloatValue("Main", "EmulationSpeed", emulation_speed);
|
si.SetFloatValue("Main", "EmulationSpeed", emulation_speed);
|
||||||
si.SetFloatValue("Main", "FastForwardSpeed", fast_forward_speed);
|
si.SetFloatValue("Main", "FastForwardSpeed", fast_forward_speed);
|
||||||
|
si.SetFloatValue("Main", "TurboSpeed", turbo_speed);
|
||||||
si.SetBoolValue("Main", "IncreaseTimerResolution", increase_timer_resolution);
|
si.SetBoolValue("Main", "IncreaseTimerResolution", increase_timer_resolution);
|
||||||
si.SetBoolValue("Main", "StartPaused", start_paused);
|
si.SetBoolValue("Main", "StartPaused", start_paused);
|
||||||
si.SetBoolValue("Main", "StartFullscreen", start_fullscreen);
|
si.SetBoolValue("Main", "StartFullscreen", start_fullscreen);
|
||||||
|
|
|
@ -81,6 +81,7 @@ struct Settings
|
||||||
|
|
||||||
float emulation_speed = 1.0f;
|
float emulation_speed = 1.0f;
|
||||||
float fast_forward_speed = 0.0f;
|
float fast_forward_speed = 0.0f;
|
||||||
|
float turbo_speed = 0.0f;
|
||||||
bool increase_timer_resolution = true;
|
bool increase_timer_resolution = true;
|
||||||
bool start_paused = false;
|
bool start_paused = false;
|
||||||
bool start_fullscreen = false;
|
bool start_fullscreen = false;
|
||||||
|
|
|
@ -40,7 +40,7 @@ GeneralSettingsWidget::GeneralSettingsWidget(QtHostInterface* host_interface, QW
|
||||||
|
|
||||||
QtUtils::FillComboBoxWithEmulationSpeeds(m_ui.emulationSpeed);
|
QtUtils::FillComboBoxWithEmulationSpeeds(m_ui.emulationSpeed);
|
||||||
const int emulation_speed_index =
|
const int emulation_speed_index =
|
||||||
m_ui.emulationSpeed->findData(QVariant(m_host_interface->GetFloatSettingValue("Main", "EmulationSpeed")));
|
m_ui.emulationSpeed->findData(QVariant(m_host_interface->GetFloatSettingValue("Main", "EmulationSpeed", 1.0f)));
|
||||||
if (emulation_speed_index >= 0)
|
if (emulation_speed_index >= 0)
|
||||||
m_ui.emulationSpeed->setCurrentIndex(emulation_speed_index);
|
m_ui.emulationSpeed->setCurrentIndex(emulation_speed_index);
|
||||||
connect(m_ui.emulationSpeed, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
|
connect(m_ui.emulationSpeed, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
|
||||||
|
@ -48,11 +48,18 @@ GeneralSettingsWidget::GeneralSettingsWidget(QtHostInterface* host_interface, QW
|
||||||
|
|
||||||
QtUtils::FillComboBoxWithEmulationSpeeds(m_ui.fastForwardSpeed);
|
QtUtils::FillComboBoxWithEmulationSpeeds(m_ui.fastForwardSpeed);
|
||||||
const int fast_forward_speed_index =
|
const int fast_forward_speed_index =
|
||||||
m_ui.emulationSpeed->findData(QVariant(m_host_interface->GetFloatSettingValue("Main", "FastForwardSpeed")));
|
m_ui.fastForwardSpeed->findData(QVariant(m_host_interface->GetFloatSettingValue("Main", "FastForwardSpeed", 0.0f)));
|
||||||
if (fast_forward_speed_index >= 0)
|
if (fast_forward_speed_index >= 0)
|
||||||
m_ui.fastForwardSpeed->setCurrentIndex(fast_forward_speed_index);
|
m_ui.fastForwardSpeed->setCurrentIndex(fast_forward_speed_index);
|
||||||
connect(m_ui.fastForwardSpeed, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
|
connect(m_ui.fastForwardSpeed, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
|
||||||
&GeneralSettingsWidget::onFastForwardSpeedIndexChanged);
|
&GeneralSettingsWidget::onFastForwardSpeedIndexChanged);
|
||||||
|
QtUtils::FillComboBoxWithEmulationSpeeds(m_ui.turboSpeed);
|
||||||
|
const int turbo_speed_index =
|
||||||
|
m_ui.turboSpeed->findData(QVariant(m_host_interface->GetFloatSettingValue("Main", "TurboSpeed", 0.0f)));
|
||||||
|
if (turbo_speed_index >= 0)
|
||||||
|
m_ui.turboSpeed->setCurrentIndex(turbo_speed_index);
|
||||||
|
connect(m_ui.turboSpeed, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
|
||||||
|
&GeneralSettingsWidget::onTurboSpeedIndexChanged);
|
||||||
|
|
||||||
dialog->registerWidgetHelp(
|
dialog->registerWidgetHelp(
|
||||||
m_ui.confirmPowerOff, tr("Confirm Power Off"), tr("Checked"),
|
m_ui.confirmPowerOff, tr("Confirm Power Off"), tr("Checked"),
|
||||||
|
@ -89,8 +96,10 @@ GeneralSettingsWidget::GeneralSettingsWidget(QtHostInterface* host_interface, QW
|
||||||
"and if not, the emulator will run as fast as it can manage."));
|
"and if not, the emulator will run as fast as it can manage."));
|
||||||
dialog->registerWidgetHelp(
|
dialog->registerWidgetHelp(
|
||||||
m_ui.fastForwardSpeed, tr("Fast Forward Speed"), "100%",
|
m_ui.fastForwardSpeed, tr("Fast Forward Speed"), "100%",
|
||||||
tr(
|
tr("Sets the fast forward speed. This speed will be used when the fast forward hotkey is pressed/toggled."));
|
||||||
"Sets the fast forward (turbo) speed. This speed will be used when the fast forward hotkey is pressed/toggled."));
|
dialog->registerWidgetHelp(
|
||||||
|
m_ui.turboSpeed, tr("Turbo Speed"), "100%",
|
||||||
|
tr("Sets the turbo speed. This speed will be used when the turbo hotkey is pressed/toggled."));
|
||||||
dialog->registerWidgetHelp(m_ui.controllerBackend, tr("Controller Backend"),
|
dialog->registerWidgetHelp(m_ui.controllerBackend, tr("Controller Backend"),
|
||||||
qApp->translate("ControllerInterface", ControllerInterface::GetBackendName(
|
qApp->translate("ControllerInterface", ControllerInterface::GetBackendName(
|
||||||
ControllerInterface::GetDefaultBackend())),
|
ControllerInterface::GetDefaultBackend())),
|
||||||
|
@ -156,3 +165,11 @@ void GeneralSettingsWidget::onFastForwardSpeedIndexChanged(int index)
|
||||||
m_host_interface->SetFloatSettingValue("Main", "FastForwardSpeed", okay ? value : 0.0f);
|
m_host_interface->SetFloatSettingValue("Main", "FastForwardSpeed", okay ? value : 0.0f);
|
||||||
m_host_interface->applySettings();
|
m_host_interface->applySettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GeneralSettingsWidget::onTurboSpeedIndexChanged(int index)
|
||||||
|
{
|
||||||
|
bool okay;
|
||||||
|
const float value = m_ui.turboSpeed->currentData().toFloat(&okay);
|
||||||
|
m_host_interface->SetFloatSettingValue("Main", "TurboSpeed", okay ? value : 0.0f);
|
||||||
|
m_host_interface->applySettings();
|
||||||
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ public:
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void onEmulationSpeedIndexChanged(int index);
|
void onEmulationSpeedIndexChanged(int index);
|
||||||
void onFastForwardSpeedIndexChanged(int index);
|
void onFastForwardSpeedIndexChanged(int index);
|
||||||
|
void onTurboSpeedIndexChanged(int index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::GeneralSettingsWidget m_ui;
|
Ui::GeneralSettingsWidget m_ui;
|
||||||
|
|
|
@ -131,6 +131,16 @@
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QComboBox" name="fastForwardSpeed"/>
|
<widget class="QComboBox" name="fastForwardSpeed"/>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>Turbo Speed:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QComboBox" name="turboSpeed"/>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
@ -604,7 +604,9 @@ bool CommonHostInterface::ResumeSystemFromMostRecentState()
|
||||||
|
|
||||||
void CommonHostInterface::UpdateSpeedLimiterState()
|
void CommonHostInterface::UpdateSpeedLimiterState()
|
||||||
{
|
{
|
||||||
const float target_speed = m_fast_forward_enabled ? g_settings.fast_forward_speed : g_settings.emulation_speed;
|
const float target_speed = m_turbo_enabled ?
|
||||||
|
g_settings.turbo_speed :
|
||||||
|
(m_fast_forward_enabled ? g_settings.fast_forward_speed : g_settings.emulation_speed);
|
||||||
m_speed_limiter_enabled = (target_speed != 0.0f);
|
m_speed_limiter_enabled = (target_speed != 0.0f);
|
||||||
|
|
||||||
const bool is_non_standard_speed = (std::abs(target_speed - 1.0f) > 0.05f);
|
const bool is_non_standard_speed = (std::abs(target_speed - 1.0f) > 0.05f);
|
||||||
|
@ -1435,6 +1437,9 @@ void CommonHostInterface::RegisterGeneralHotkeys()
|
||||||
TRANSLATABLE("Hotkeys", "Fast Forward"), [this](bool pressed) {
|
TRANSLATABLE("Hotkeys", "Fast Forward"), [this](bool pressed) {
|
||||||
m_fast_forward_enabled = pressed;
|
m_fast_forward_enabled = pressed;
|
||||||
UpdateSpeedLimiterState();
|
UpdateSpeedLimiterState();
|
||||||
|
AddOSDMessage(m_fast_forward_enabled ? TranslateStdString("OSDMessage", "Fast forwarding...") :
|
||||||
|
TranslateStdString("OSDMessage", "Stopped fast forwarding."),
|
||||||
|
2.0f);
|
||||||
});
|
});
|
||||||
|
|
||||||
RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "General")), StaticString("ToggleFastForward"),
|
RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "General")), StaticString("ToggleFastForward"),
|
||||||
|
@ -1449,6 +1454,27 @@ void CommonHostInterface::RegisterGeneralHotkeys()
|
||||||
2.0f);
|
2.0f);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "General")), StaticString("Turbo"),
|
||||||
|
TRANSLATABLE("Hotkeys", "Turbo"), [this](bool pressed) {
|
||||||
|
m_turbo_enabled = pressed;
|
||||||
|
UpdateSpeedLimiterState();
|
||||||
|
AddOSDMessage(m_turbo_enabled ? TranslateStdString("OSDMessage", "Turboing...") :
|
||||||
|
TranslateStdString("OSDMessage", "Stopped turboing."),
|
||||||
|
2.0f);
|
||||||
|
});
|
||||||
|
|
||||||
|
RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "General")), StaticString("ToggleTurbo"),
|
||||||
|
StaticString(TRANSLATABLE("Hotkeys", "Toggle Turbo")), [this](bool pressed) {
|
||||||
|
if (pressed)
|
||||||
|
{
|
||||||
|
m_turbo_enabled = !m_turbo_enabled;
|
||||||
|
UpdateSpeedLimiterState();
|
||||||
|
AddOSDMessage(m_turbo_enabled ? TranslateStdString("OSDMessage", "Turboing...") :
|
||||||
|
TranslateStdString("OSDMessage", "Stopped turboing."),
|
||||||
|
2.0f);
|
||||||
|
}
|
||||||
|
});
|
||||||
#ifndef ANDROID
|
#ifndef ANDROID
|
||||||
RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "General")), StaticString("ToggleFullscreen"),
|
RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "General")), StaticString("ToggleFullscreen"),
|
||||||
StaticString(TRANSLATABLE("Hotkeys", "Toggle Fullscreen")), [this](bool pressed) {
|
StaticString(TRANSLATABLE("Hotkeys", "Toggle Fullscreen")), [this](bool pressed) {
|
||||||
|
|
|
@ -349,6 +349,7 @@ protected:
|
||||||
|
|
||||||
bool m_frame_step_request = false;
|
bool m_frame_step_request = false;
|
||||||
bool m_fast_forward_enabled = false;
|
bool m_fast_forward_enabled = false;
|
||||||
|
bool m_turbo_enabled = false;
|
||||||
bool m_timer_resolution_increased = false;
|
bool m_timer_resolution_increased = false;
|
||||||
bool m_speed_limiter_enabled = true;
|
bool m_speed_limiter_enabled = true;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue