diff --git a/src/common/memory_patcher.cpp b/src/common/memory_patcher.cpp index fb57e2c98..123fcdc9c 100644 --- a/src/common/memory_patcher.cpp +++ b/src/common/memory_patcher.cpp @@ -123,7 +123,6 @@ std::string convertValueToHex(const std::string type, const std::string valueStr void ApplyPendingPatches(); void OnGameLoaded() { - if (!patchFile.empty()) { std::filesystem::path patchDir = Common::FS::GetUserPath(Common::FS::PathType::PatchesDir); @@ -201,16 +200,11 @@ void OnGameLoaded() { } } } - - ApplyPendingPatches(); - return; } else { LOG_ERROR(Loader, "couldnt patch parse xml : {}", result.description()); } - - ApplyPendingPatches(); - return; } + ApplyPendingPatches(); #ifdef ENABLE_QT_GUI // We use the QT headers for the xml and json parsing, this define is only true on QT builds diff --git a/src/core/ipc/ipc.cpp b/src/core/ipc/ipc.cpp index b66c00efc..67df60cf0 100644 --- a/src/core/ipc/ipc.cpp +++ b/src/core/ipc/ipc.cpp @@ -6,9 +6,14 @@ #include #include +#include + #include "common/memory_patcher.h" #include "common/thread.h" #include "common/types.h" +#include "core/debug_state.h" +#include "input/input_handler.h" +#include "sdl_window.h" /** * Protocol summary: @@ -28,7 +33,7 @@ * and ended by * #IPC_END * In between, it will send the current capabilities and commands before the emulator start - * - The IPC client(e.g., launcher) will send RUN then START to conintue the execution + * - The IPC client(e.g., launcher) will send RUN then START to continue the execution **/ /** @@ -43,6 +48,10 @@ * target: str, size: str, isOffset: number, littleEndian: number, * patchMask: number, maskOffset: number * ): add a memory patch, check @ref MemoryPatcher::PatchMemory for details + * - PAUSE: pause the game execution + * - RESUME: resume the game execution + * - STOP: stop and quit the emulator + * - TOGGLE_FULLSCREEN: enable / disable fullscreen * - OUTPUT CMD: * - N/A **/ @@ -61,6 +70,7 @@ void IPC::Init() { std::cerr << ";#IPC_ENABLED\n"; std::cerr << ";ENABLE_MEMORY_PATCH\n"; + std::cerr << ";ENABLE_EMU_CONTROL\n"; std::cerr << ";#IPC_END\n"; std::cerr.flush(); @@ -106,8 +116,22 @@ void IPC::InputLoop() { entry.patchMask = static_cast(next_u64()); entry.maskOffset = static_cast(next_u64()); MemoryPatcher::AddPatchToQueue(entry); + } else if (cmd == "PAUSE") { + DebugState.PauseGuestThreads(); + } else if (cmd == "RESUME") { + DebugState.ResumeGuestThreads(); + } else if (cmd == "STOP") { + SDL_Event event; + SDL_memset(&event, 0, sizeof(event)); + event.type = SDL_EVENT_QUIT; + SDL_PushEvent(&event); + } else if (cmd == "TOGGLE_FULLSCREEN") { + SDL_Event event; + SDL_memset(&event, 0, sizeof(event)); + event.type = SDL_EVENT_TOGGLE_FULLSCREEN; + SDL_PushEvent(&event); } else { - std::cerr << "UNKNOWN CMD: " << cmd << std::endl; + std::cerr << ";UNKNOWN CMD: " << cmd << std::endl; } } } \ No newline at end of file