diff --git a/src/platform/qt/CoreController.cpp b/src/platform/qt/CoreController.cpp index 0860e0866..8cf21da00 100644 --- a/src/platform/qt/CoreController.cpp +++ b/src/platform/qt/CoreController.cpp @@ -209,6 +209,10 @@ bool CoreController::isPaused() { return mCoreThreadIsPaused(&m_threadContext); } +bool CoreController::hasStarted() { + return mCoreThreadHasStarted(&m_threadContext); +} + mPlatform CoreController::platform() const { return m_threadContext.core->platform(m_threadContext.core); } diff --git a/src/platform/qt/CoreController.h b/src/platform/qt/CoreController.h index c426aa483..c2fb9a9e8 100644 --- a/src/platform/qt/CoreController.h +++ b/src/platform/qt/CoreController.h @@ -61,6 +61,7 @@ public: color_t* drawContext(); bool isPaused(); + bool hasStarted(); mPlatform platform() const; QSize screenDimensions() const; diff --git a/src/platform/qt/OverrideView.cpp b/src/platform/qt/OverrideView.cpp index c9e68c68c..1259761ee 100644 --- a/src/platform/qt/OverrideView.cpp +++ b/src/platform/qt/OverrideView.cpp @@ -93,13 +93,16 @@ OverrideView::OverrideView(ConfigController* config, QWidget* parent) connect(m_ui.buttonBox, &QDialogButtonBox::accepted, this, &OverrideView::saveOverride); connect(m_ui.buttonBox, &QDialogButtonBox::rejected, this, &QWidget::close); + + m_recheck.setInterval(200); + connect(&m_recheck, &QTimer::timeout, this, &OverrideView::recheck); } void OverrideView::setController(std::shared_ptr controller) { m_controller = controller; connect(controller.get(), &CoreController::started, this, &OverrideView::gameStarted); connect(controller.get(), &CoreController::stopping, this, &OverrideView::gameStopped); - updateOverrides(); + recheck(); } void OverrideView::saveOverride() { @@ -115,6 +118,17 @@ void OverrideView::saveOverride() { m_config->saveOverride(*override); } +void OverrideView::recheck() { + if (!m_controller) { + return; + } + if (m_controller->hasStarted()) { + gameStarted(); + } else { + updateOverrides(); + } +} + void OverrideView::updateOverrides() { if (!m_controller) { return; @@ -190,6 +204,7 @@ void OverrideView::gameStarted() { mCoreThread* thread = m_controller->thread(); m_ui.tabWidget->setEnabled(false); + m_recheck.start(); switch (thread->core->platform(thread->core)) { #ifdef M_CORE_GBA @@ -242,6 +257,7 @@ void OverrideView::gameStarted() { } void OverrideView::gameStopped() { + m_recheck.stop(); m_controller.reset(); m_ui.tabWidget->setEnabled(true); m_ui.savetype->setCurrentIndex(0); diff --git a/src/platform/qt/OverrideView.h b/src/platform/qt/OverrideView.h index 5a877b174..cbface71c 100644 --- a/src/platform/qt/OverrideView.h +++ b/src/platform/qt/OverrideView.h @@ -6,6 +6,7 @@ #pragma once #include +#include #include @@ -36,6 +37,7 @@ public: public slots: void saveOverride(); + void recheck(); private slots: void updateOverrides(); @@ -48,6 +50,7 @@ private: std::shared_ptr m_controller; ConfigController* m_config; bool m_savePending = false; + QTimer m_recheck; #ifdef M_CORE_GB uint32_t m_gbColors[12]{}; diff --git a/src/platform/qt/Window.cpp b/src/platform/qt/Window.cpp index 37f5e5887..7c83ca06d 100644 --- a/src/platform/qt/Window.cpp +++ b/src/platform/qt/Window.cpp @@ -1442,6 +1442,7 @@ void Window::setupMenu(QMenuBar* menubar) { connect(this, &Window::shutdown, m_overrideView.get(), &QWidget::close); } m_overrideView->show(); + m_overrideView->recheck(); }); addControlledAction(toolsMenu, overrides, "overrideWindow");