diff --git a/src/core/host_interface.cpp b/src/core/host_interface.cpp
index 40f83ce40..86af9b33e 100644
--- a/src/core/host_interface.cpp
+++ b/src/core/host_interface.cpp
@@ -776,6 +776,7 @@ void HostInterface::SetDefaultSettings()
m_settings.increase_timer_resolution = true;
m_settings.start_paused = false;
m_settings.save_state_on_exit = true;
+ m_settings.confim_power_off = true;
m_settings.gpu_renderer = Settings::DEFAULT_GPU_RENDERER;
m_settings.gpu_resolution_scale = 1;
diff --git a/src/core/settings.cpp b/src/core/settings.cpp
index 170638cef..b0ffbe0c7 100644
--- a/src/core/settings.cpp
+++ b/src/core/settings.cpp
@@ -14,6 +14,7 @@ void Settings::Load(SettingsInterface& si)
increase_timer_resolution = si.GetBoolValue("General", "IncreaseTimerResolution", true);
start_paused = si.GetBoolValue("General", "StartPaused", false);
save_state_on_exit = si.GetBoolValue("General", "SaveStateOnExit", true);
+ confim_power_off = si.GetBoolValue("General", "ConfirmPowerOff", true);
cpu_execution_mode = ParseCPUExecutionMode(si.GetStringValue("CPU", "ExecutionMode", "Interpreter").c_str())
.value_or(CPUExecutionMode::Interpreter);
@@ -67,6 +68,7 @@ void Settings::Save(SettingsInterface& si) const
si.SetBoolValue("General", "IncreaseTimerResolution", increase_timer_resolution);
si.SetBoolValue("General", "StartPaused", start_paused);
si.SetBoolValue("General", "SaveStateOnExit", save_state_on_exit);
+ si.SetBoolValue("General", "ConfirmPowerOff", confim_power_off);
si.SetStringValue("CPU", "ExecutionMode", GetCPUExecutionModeName(cpu_execution_mode));
diff --git a/src/core/settings.h b/src/core/settings.h
index 7546b960f..9f5e62903 100644
--- a/src/core/settings.h
+++ b/src/core/settings.h
@@ -40,6 +40,7 @@ struct Settings
bool increase_timer_resolution = true;
bool start_paused = false;
bool save_state_on_exit = true;
+ bool confim_power_off = true;
GPURenderer gpu_renderer = GPURenderer::Software;
u32 gpu_resolution_scale = 1;
diff --git a/src/duckstation-qt/consolesettingswidget.cpp b/src/duckstation-qt/consolesettingswidget.cpp
index 0a2db08d3..feb0cc768 100644
--- a/src/duckstation-qt/consolesettingswidget.cpp
+++ b/src/duckstation-qt/consolesettingswidget.cpp
@@ -28,6 +28,7 @@ ConsoleSettingsWidget::ConsoleSettingsWidget(QtHostInterface* host_interface, QW
100.0f);
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.pauseOnStart, "General/StartPaused");
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.saveStateOnExit, "General/SaveStateOnExit");
+ SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.confirmPowerOff, "General/ConfirmPowerOff");
SettingWidgetBinder::BindWidgetToEnumSetting(m_host_interface, m_ui.cpuExecutionMode, "CPU/ExecutionMode",
&Settings::ParseCPUExecutionMode, &Settings::GetCPUExecutionModeName);
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.cdromReadThread, "CDROM/ReadThread");
diff --git a/src/duckstation-qt/consolesettingswidget.ui b/src/duckstation-qt/consolesettingswidget.ui
index d6e528b9c..2f4e65ed9 100644
--- a/src/duckstation-qt/consolesettingswidget.ui
+++ b/src/duckstation-qt/consolesettingswidget.ui
@@ -160,6 +160,13 @@
+ -
+
+
+ Confirm Power Off
+
+
+
diff --git a/src/duckstation-qt/qthostinterface.cpp b/src/duckstation-qt/qthostinterface.cpp
index 79b810d75..64d1629c3 100644
--- a/src/duckstation-qt/qthostinterface.cpp
+++ b/src/duckstation-qt/qthostinterface.cpp
@@ -433,6 +433,7 @@ std::vector QtHostInterface::getHotkeyList() const
{QStringLiteral("FastForward"), QStringLiteral("Toggle Fast Forward"), QStringLiteral("General")},
{QStringLiteral("Fullscreen"), QStringLiteral("Toggle Fullscreen"), QStringLiteral("General")},
{QStringLiteral("Pause"), QStringLiteral("Toggle Pause"), QStringLiteral("General")},
+ {QStringLiteral("PowerOff"), QStringLiteral("Power Off System"), QStringLiteral("General")},
{QStringLiteral("ToggleSoftwareRendering"), QStringLiteral("Toggle Software Rendering"),
QStringLiteral("Graphics")},
{QStringLiteral("IncreaseResolutionScale"), QStringLiteral("Increase Resolution Scale"),
@@ -486,6 +487,36 @@ void QtHostInterface::updateHotkeyInputMap()
pauseSystem(!m_paused);
});
+ hk(QStringLiteral("PowerOff"), [this](bool pressed) {
+ if (!pressed && m_system)
+ {
+ if (m_settings.confim_power_off)
+ {
+ emit setFullscreenRequested(false);
+
+ QString confirmation_message = tr("Are you sure you want to stop emulation?");
+ if (m_settings.save_state_on_exit)
+ {
+ confirmation_message += "\n\n";
+ confirmation_message += tr("The current state will be saved.");
+ }
+
+ if (!messageConfirmed(confirmation_message))
+ {
+ if (m_settings.display_fullscreen)
+ emit setFullscreenRequested(true);
+ else
+ emit focusDisplayWidgetRequested();
+
+ m_system->ResetPerformanceCounters();
+ return;
+ }
+ }
+
+ powerOffSystem();
+ }
+ });
+
hk(QStringLiteral("ToggleSoftwareRendering"), [this](bool pressed) {
if (!pressed)
ToggleSoftwareRendering();
@@ -655,6 +686,9 @@ void QtHostInterface::pauseSystem(bool paused)
return;
}
+ if (!m_system)
+ return;
+
m_paused = paused;
m_audio_stream->PauseOutput(paused);
if (!paused)