Move three notifications out of Host

This commit is contained in:
Henrik Rydgård 2023-03-21 11:21:19 +01:00
parent 06fcc9ccd7
commit dda8635c89
21 changed files with 51 additions and 95 deletions

View file

@ -308,8 +308,8 @@ void Core_ProcessStepping() {
static int lastSteppingCounter = -1; static int lastSteppingCounter = -1;
if (lastSteppingCounter != steppingCounter) { if (lastSteppingCounter != steppingCounter) {
CBreakPoints::ClearTemporaryBreakPoints(); CBreakPoints::ClearTemporaryBreakPoints();
host->UpdateDisassembly(); System_Notify(SystemNotification::DISASSEMBLY);
host->UpdateMemView(); System_Notify(SystemNotification::MEM_VIEW);
lastSteppingCounter = steppingCounter; lastSteppingCounter = steppingCounter;
} }
@ -320,15 +320,15 @@ void Core_ProcessStepping() {
if (doStep && coreState == CORE_STEPPING) { if (doStep && coreState == CORE_STEPPING) {
Core_SingleStep(); Core_SingleStep();
// Update disasm dialog. // Update disasm dialog.
host->UpdateDisassembly(); System_Notify(SystemNotification::DISASSEMBLY);
host->UpdateMemView(); System_Notify(SystemNotification::MEM_VIEW);
} }
} }
// Many platforms, like Android, do not call this function but handle things on their own. // Many platforms, like Android, do not call this function but handle things on their own.
// Instead they simply call NativeRender and NativeUpdate directly. // Instead they simply call NativeRender and NativeUpdate directly.
bool Core_Run(GraphicsContext *ctx) { bool Core_Run(GraphicsContext *ctx) {
host->UpdateDisassembly(); System_Notify(SystemNotification::DISASSEMBLY);
while (true) { while (true) {
if (GetUIState() != UISTATE_INGAME) { if (GetUIState() != UISTATE_INGAME) {
Core_StateProcessed(); Core_StateProcessed();

View file

@ -19,6 +19,7 @@
#include <atomic> #include <atomic>
#include <mutex> #include <mutex>
#include "Common/System/System.h"
#include "Common/Log.h" #include "Common/Log.h"
#include "Core/Core.h" #include "Core/Core.h"
#include "Core/Debugger/Breakpoints.h" #include "Core/Debugger/Breakpoints.h"
@ -674,7 +675,7 @@ void CBreakPoints::Update(u32 addr) {
} }
// Redraw in order to show the breakpoint. // Redraw in order to show the breakpoint.
host->UpdateDisassembly(); System_Notify(SystemNotification::DISASSEMBLY);
} }
bool CBreakPoints::ValidateLogFormat(DebugInterface *cpu, const std::string &fmt) { bool CBreakPoints::ValidateLogFormat(DebugInterface *cpu, const std::string &fmt) {

View file

@ -55,8 +55,9 @@ void WebSocketGameReset(DebuggerRequest &req) {
ERROR_LOG(BOOT, "Error resetting: %s", resetError.c_str()); ERROR_LOG(BOOT, "Error resetting: %s", resetError.c_str());
return req.Fail("Could not reset"); return req.Fail("Could not reset");
} }
System_Notify(SystemNotification::BOOT_DONE); System_Notify(SystemNotification::BOOT_DONE);
host->UpdateDisassembly(); System_Notify(SystemNotification::DISASSEMBLY);
req.Respond(); req.Respond();
} }

View file

@ -17,6 +17,7 @@
#include <vector> #include <vector>
#include "Common/System/System.h"
#include "Common/Serialize/Serializer.h" #include "Common/Serialize/Serializer.h"
#include "Common/Serialize/SerializeFuncs.h" #include "Common/Serialize/SerializeFuncs.h"
#include "Common/Serialize/SerializeMap.h" #include "Common/Serialize/SerializeMap.h"
@ -104,8 +105,9 @@ void __UmdDoState(PointerWrap &p)
if (s > 1) { if (s > 1) {
Do(p, UMDReplacePermit); Do(p, UMDReplacePermit);
if (UMDReplacePermit) if (UMDReplacePermit) {
host->UpdateUI(); System_Notify(SystemNotification::UI);
}
} }
if (s > 2) { if (s > 2) {
Do(p, umdInsertChangeEvent); Do(p, umdInsertChangeEvent);

View file

@ -27,9 +27,6 @@ class Host {
public: public:
virtual ~Host() {} virtual ~Host() {}
virtual void UpdateUI() {}
virtual void UpdateMemView() {}
virtual void UpdateDisassembly() {}
virtual void NotifySymbolMapUpdated() {} virtual void NotifySymbolMapUpdated() {}
virtual void SetDebugMode(bool mode) { } virtual void SetDebugMode(bool mode) { }
virtual void NotifySwitchUMDUpdated() {} virtual void NotifySwitchUMDUpdated() {}

View file

@ -1080,7 +1080,7 @@ namespace SaveState
return; return;
} }
System_Notify(SystemNotification::BOOT_DONE); System_Notify(SystemNotification::BOOT_DONE);
host->UpdateDisassembly(); System_Notify(SystemNotification::DISASSEMBLY);
needsRestart = false; needsRestart = false;
} }
} }

View file

@ -124,8 +124,7 @@ void UpdateUIState(GlobalUIState newState) {
// Never leave the EXIT state. // Never leave the EXIT state.
if (globalUIState != newState && globalUIState != UISTATE_EXIT) { if (globalUIState != newState && globalUIState != UISTATE_EXIT) {
globalUIState = newState; globalUIState = newState;
if (host) System_Notify(SystemNotification::DISASSEMBLY);
host->UpdateDisassembly();
const char *state = nullptr; const char *state = nullptr;
switch (globalUIState) { switch (globalUIState) {
case UISTATE_EXIT: state = "exit"; break; case UISTATE_EXIT: state = "exit"; break;

View file

@ -30,16 +30,6 @@ public:
mainWindow = mainWindow_; mainWindow = mainWindow_;
} }
void UpdateUI() override {
mainWindow->updateMenus();
}
void UpdateMemView() override {
}
void UpdateDisassembly() override {
mainWindow->updateMenus();
}
void SetDebugMode(bool mode) override {} void SetDebugMode(bool mode) override {}
bool InitGraphics(std::string *error_message, GraphicsContext **ctx) override { return true; } bool InitGraphics(std::string *error_message, GraphicsContext **ctx) override { return true; }

View file

@ -355,8 +355,7 @@ void EmuScreen::bootGame(const Path &filename) {
void EmuScreen::bootComplete() { void EmuScreen::bootComplete() {
UpdateUIState(UISTATE_INGAME); UpdateUIState(UISTATE_INGAME);
System_Notify(SystemNotification::BOOT_DONE); System_Notify(SystemNotification::BOOT_DONE);
System_Notify(SystemNotification::DISASSEMBLY);
host->UpdateDisassembly();
NOTICE_LOG(BOOT, "Loading %s...", PSP_CoreParameter().fileToStart.c_str()); NOTICE_LOG(BOOT, "Loading %s...", PSP_CoreParameter().fileToStart.c_str());
autoLoad(); autoLoad();
@ -448,7 +447,7 @@ static void AfterSaveStateAction(SaveState::Status status, const std::string &me
static void AfterStateBoot(SaveState::Status status, const std::string &message, void *ignored) { static void AfterStateBoot(SaveState::Status status, const std::string &message, void *ignored) {
AfterSaveStateAction(status, message, ignored); AfterSaveStateAction(status, message, ignored);
Core_EnableStepping(false); Core_EnableStepping(false);
host->UpdateDisassembly(); System_Notify(SystemNotification::DISASSEMBLY);
} }
void EmuScreen::sendMessage(const char *message, const char *value) { void EmuScreen::sendMessage(const char *message, const char *value) {
@ -461,12 +460,12 @@ void EmuScreen::sendMessage(const char *message, const char *value) {
bootPending_ = false; bootPending_ = false;
stopRender_ = true; stopRender_ = true;
invalid_ = true; invalid_ = true;
host->UpdateDisassembly(); System_Notify(SystemNotification::DISASSEMBLY);
} else if (!strcmp(message, "reset")) { } else if (!strcmp(message, "reset")) {
PSP_Shutdown(); PSP_Shutdown();
bootPending_ = true; bootPending_ = true;
invalid_ = true; invalid_ = true;
host->UpdateDisassembly(); System_Notify(SystemNotification::DISASSEMBLY);
std::string resetError; std::string resetError;
if (!PSP_InitStart(PSP_CoreParameter(), &resetError)) { if (!PSP_InitStart(PSP_CoreParameter(), &resetError)) {

View file

@ -913,8 +913,7 @@ void GameSettingsScreen::CreateSystemSettings(UI::ViewGroup *systemSettings) {
auto langScreen = new NewLanguageScreen(sy->T("Language")); auto langScreen = new NewLanguageScreen(sy->T("Language"));
langScreen->OnChoice.Add([&](UI::EventParams &e) { langScreen->OnChoice.Add([&](UI::EventParams &e) {
screenManager()->RecreateAllViews(); screenManager()->RecreateAllViews();
if (host) System_Notify(SystemNotification::UI);
host->UpdateUI();
return UI::EVENT_DONE; return UI::EVENT_DONE;
}); });
if (e.v) if (e.v)
@ -1362,7 +1361,7 @@ void GameSettingsScreen::onFinish(DialogResult result) {
g_Config.unloadGameConfig(); g_Config.unloadGameConfig();
} }
host->UpdateUI(); System_Notify(SystemNotification::UI);
KeyMap::UpdateNativeMenuKeys(); KeyMap::UpdateNativeMenuKeys();
@ -1895,7 +1894,7 @@ void GameSettingsScreen::CallbackRestoreDefaults(bool yes) {
if (yes) { if (yes) {
g_Config.RestoreDefaults(RestoreSettingsBits::SETTINGS); g_Config.RestoreDefaults(RestoreSettingsBits::SETTINGS);
} }
host->UpdateUI(); System_Notify(SystemNotification::UI);
} }
UI::EventReturn GameSettingsScreen::OnRestoreDefaultSettings(UI::EventParams &e) { UI::EventReturn GameSettingsScreen::OnRestoreDefaultSettings(UI::EventParams &e) {

View file

@ -24,11 +24,6 @@ class NativeHost : public Host {
public: public:
NativeHost() {} NativeHost() {}
void UpdateUI() override {}
void UpdateMemView() override {}
void UpdateDisassembly() override {}
void SetDebugMode(bool mode) override { } void SetDebugMode(bool mode) override { }
bool InitGraphics(std::string *error_message, GraphicsContext **ctx) override { return true; } bool InitGraphics(std::string *error_message, GraphicsContext **ctx) override { return true; }

View file

@ -964,9 +964,7 @@ UI::EventReturn GameBrowser::GridSettingsClick(UI::EventParams &e) {
UI::EventReturn GameBrowser::OnRecentClear(UI::EventParams &e) { UI::EventReturn GameBrowser::OnRecentClear(UI::EventParams &e) {
screenManager_->RecreateAllViews(); screenManager_->RecreateAllViews();
if (host) { System_Notify(SystemNotification::UI);
host->UpdateUI();
}
return UI::EVENT_DONE; return UI::EVENT_DONE;
} }

View file

@ -431,9 +431,7 @@ void HandleCommonMessages(const char *message, const char *value, ScreenManager
auto langScreen = new NewLanguageScreen(sy->T("Language")); auto langScreen = new NewLanguageScreen(sy->T("Language"));
langScreen->OnChoice.Add([](UI::EventParams &) { langScreen->OnChoice.Add([](UI::EventParams &) {
NativeMessageReceived("recreateviews", ""); NativeMessageReceived("recreateviews", "");
if (host) { System_Notify(SystemNotification::UI);
host->UpdateUI();
}
return UI::EVENT_DONE; return UI::EVENT_DONE;
}); });
manager->push(langScreen); manager->push(langScreen);

View file

@ -438,13 +438,6 @@ bool System_GetPropertyBool(SystemProperty prop) {
void System_Notify(SystemNotification notification) { void System_Notify(SystemNotification notification) {
switch (notification) { switch (notification) {
case SystemNotification::BOOT_DONE:
g_symbolMap->SortSymbols();
SetDebugMode(false);
Core_EnableStepping(false);
break;
default: default:
break; break;
} }

View file

@ -64,7 +64,6 @@ void UWPHost::ShutdownGraphics() {
} }
void UWPHost::SetWindowTitle(const char *message) { void UWPHost::SetWindowTitle(const char *message) {
// Should really be done differently
} }
void UWPHost::InitSound() { void UWPHost::InitSound() {
@ -76,15 +75,6 @@ void UWPHost::UpdateSound() {
void UWPHost::ShutdownSound() { void UWPHost::ShutdownSound() {
} }
void UWPHost::UpdateUI() {
}
void UWPHost::UpdateMemView() {
}
void UWPHost::UpdateDisassembly() {
}
void UWPHost::SetDebugMode(bool mode) {} void UWPHost::SetDebugMode(bool mode) {}
void UWPHost::PollControllers() { void UWPHost::PollControllers() {

View file

@ -12,9 +12,6 @@ public:
UWPHost(); UWPHost();
~UWPHost(); ~UWPHost();
void UpdateMemView() override;
void UpdateDisassembly() override;
void UpdateUI() override;
void SetDebugMode(bool mode) override; void SetDebugMode(bool mode) override;
// If returns false, will return a null context // If returns false, will return a null context

View file

@ -161,7 +161,7 @@ void MainThreadFunc() {
// Let's continue (and probably crash) just so they have a way to keep trying. // Let's continue (and probably crash) just so they have a way to keep trying.
} }
host->UpdateUI(); System_Notify(SystemNotification::UI);
std::string error_string; std::string error_string;
bool success = host->InitGraphics(&error_string, &g_graphicsContext); bool success = host->InitGraphics(&error_string, &g_graphicsContext);

View file

@ -189,26 +189,6 @@ void WindowsHost::UpdateSound() {
void WindowsHost::ShutdownSound() { void WindowsHost::ShutdownSound() {
} }
void WindowsHost::UpdateUI() {
PostMessage(mainWindow_, MainWindow::WM_USER_UPDATE_UI, 0, 0);
int peers = GetInstancePeerCount();
if (PPSSPP_ID >= 1 && peers != lastNumInstances_) {
lastNumInstances_ = peers;
PostMessage(mainWindow_, MainWindow::WM_USER_WINDOW_TITLE_CHANGED, 0, 0);
}
}
void WindowsHost::UpdateMemView() {
if (memoryWindow)
PostDialogMessage(memoryWindow, WM_DEB_UPDATE);
}
void WindowsHost::UpdateDisassembly() {
if (disasmWindow)
PostDialogMessage(disasmWindow, WM_DEB_UPDATE);
}
void WindowsHost::SetDebugMode(bool mode) { void WindowsHost::SetDebugMode(bool mode) {
if (disasmWindow) if (disasmWindow)
PostDialogMessage(disasmWindow, WM_DEB_SETDEBUGLPARAM, 0, (LPARAM)mode); PostDialogMessage(disasmWindow, WM_DEB_SETDEBUGLPARAM, 0, (LPARAM)mode);

View file

@ -34,9 +34,6 @@ public:
UpdateConsolePosition(); UpdateConsolePosition();
} }
void UpdateMemView() override;
void UpdateDisassembly() override;
void UpdateUI() override;
void SetDebugMode(bool mode) override; void SetDebugMode(bool mode) override;
// If returns false, will return a null context // If returns false, will return a null context
@ -74,7 +71,6 @@ private:
GraphicsContext *gfx_ = nullptr; GraphicsContext *gfx_ = nullptr;
size_t numDinputDevices_ = 0; size_t numDinputDevices_ = 0;
std::wstring lastTitle_; std::wstring lastTitle_;
int lastNumInstances_ = 0;
std::list<std::unique_ptr<InputDevice>> input; std::list<std::unique_ptr<InputDevice>> input;
}; };

View file

@ -47,6 +47,7 @@
#include "Core/Config.h" #include "Core/Config.h"
#include "Core/ConfigValues.h" #include "Core/ConfigValues.h"
#include "Core/SaveState.h" #include "Core/SaveState.h"
#include "Core/Instance.h"
#include "Windows/EmuThread.h" #include "Windows/EmuThread.h"
#include "Windows/WindowsAudio.h" #include "Windows/WindowsAudio.h"
#include "ext/disarm.h" #include "ext/disarm.h"
@ -110,6 +111,7 @@ int g_activeWindow = 0;
static std::thread inputBoxThread; static std::thread inputBoxThread;
static bool inputBoxRunning = false; static bool inputBoxRunning = false;
int g_lastNumInstances = 0;
void System_ShowFileInFolder(const char *path) { void System_ShowFileInFolder(const char *path) {
// SHParseDisplayName can't handle relative paths, so normalize first. // SHParseDisplayName can't handle relative paths, so normalize first.
@ -377,6 +379,7 @@ static BOOL PostDialogMessage(Dialog *dialog, UINT message, WPARAM wParam = 0, L
void System_Notify(SystemNotification notification) { void System_Notify(SystemNotification notification) {
switch (notification) { switch (notification) {
case SystemNotification::BOOT_DONE: case SystemNotification::BOOT_DONE:
{
if (g_symbolMap) if (g_symbolMap)
g_symbolMap->SortSymbols(); g_symbolMap->SortSymbols();
PostMessage(MainWindow::GetHWND(), WM_USER + 1, 0, 0); PostMessage(MainWindow::GetHWND(), WM_USER + 1, 0, 0);
@ -386,6 +389,29 @@ void System_Notify(SystemNotification notification) {
PostDialogMessage(disasmWindow, WM_DEB_SETDEBUGLPARAM, 0, (LPARAM)mode); PostDialogMessage(disasmWindow, WM_DEB_SETDEBUGLPARAM, 0, (LPARAM)mode);
break; break;
} }
case SystemNotification::UI:
{
PostMessage(MainWindow::GetHWND(), MainWindow::WM_USER_UPDATE_UI, 0, 0);
int peers = GetInstancePeerCount();
if (PPSSPP_ID >= 1 && peers != g_lastNumInstances) {
g_lastNumInstances = peers;
PostMessage(MainWindow::GetHWND(), MainWindow::WM_USER_WINDOW_TITLE_CHANGED, 0, 0);
}
break;
}
case SystemNotification::MEM_VIEW:
if (memoryWindow)
PostDialogMessage(memoryWindow, WM_DEB_UPDATE);
break;
case SystemNotification::DISASSEMBLY:
if (disasmWindow)
PostDialogMessage(disasmWindow, WM_DEB_UPDATE);
break;
}
} }
void System_SendMessage(const char *command, const char *parameter) { void System_SendMessage(const char *command, const char *parameter) {

View file

@ -26,11 +26,6 @@
// TODO: Get rid of this junk // TODO: Get rid of this junk
class HeadlessHost : public Host { class HeadlessHost : public Host {
public: public:
void UpdateUI() override {}
void UpdateMemView() override {}
void UpdateDisassembly() override {}
void SetDebugMode(bool mode) override { } void SetDebugMode(bool mode) override { }
void SetGraphicsCore(GPUCore core) { gpuCore_ = core; } void SetGraphicsCore(GPUCore core) { gpuCore_ = core; }