diff --git a/CMakeLists.txt b/CMakeLists.txt index 283405ff91..ff2c70af5c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2030,8 +2030,6 @@ add_library(${CoreLibName} ${CoreLinkType} Core/HW/SasReverb.h Core/HW/StereoResampler.cpp Core/HW/StereoResampler.h - Core/Host.cpp - Core/Host.h Core/Loaders.cpp Core/Loaders.h Core/FileLoaders/CachingFileLoader.cpp @@ -2413,8 +2411,8 @@ set(NativeAssets if(HEADLESS) set(HeadlessSource headless/Headless.cpp - headless/StubHost.cpp - headless/StubHost.h + headless/HeadlessHost.cpp + headless/HeadlessHost.h headless/Compare.cpp headless/Compare.h headless/SDLHeadlessHost.cpp diff --git a/Common/System/Request.cpp b/Common/System/Request.cpp index 48cf9f2e91..2173eecd59 100644 --- a/Common/System/Request.cpp +++ b/Common/System/Request.cpp @@ -19,14 +19,14 @@ bool RequestManager::MakeSystemRequest(SystemRequestType type, RequestCallback c int requestId = idCounter_++; // NOTE: We need to register immediately, in order to support synchronous implementations. - { + if (callback || failedCallback) { std::lock_guard guard(callbackMutex_); callbackMap_[requestId] = { callback, failedCallback }; } - INFO_LOG(SYSTEM, "Making system request %s: id %d", RequestTypeAsString(type), requestId); + DEBUG_LOG(SYSTEM, "Making system request %s: id %d", RequestTypeAsString(type), requestId); if (!System_MakeRequest(type, requestId, param1, param2, param3)) { - { + if (callback || failedCallback) { std::lock_guard guard(callbackMutex_); callbackMap_.erase(requestId); } @@ -50,7 +50,7 @@ void RequestManager::PostSystemSuccess(int requestId, const char *responseString response.responseString = responseString; response.responseValue = responseValue; pendingSuccesses_.push_back(response); - INFO_LOG(SYSTEM, "PostSystemSuccess: Request %d (%s, %d)", requestId, responseString, responseValue); + DEBUG_LOG(SYSTEM, "PostSystemSuccess: Request %d (%s, %d)", requestId, responseString, responseValue); callbackMap_.erase(iter); } @@ -62,7 +62,7 @@ void RequestManager::PostSystemFailure(int requestId) { return; } - INFO_LOG(SYSTEM, "PostSystemFailure: Request %d failed", requestId); + WARN_LOG(SYSTEM, "PostSystemFailure: Request %d failed", requestId); std::lock_guard responseGuard(responseMutex_); PendingFailure response; diff --git a/Common/System/Request.h b/Common/System/Request.h index 173da797fb..3f7d1c0bc1 100644 --- a/Common/System/Request.h +++ b/Common/System/Request.h @@ -142,6 +142,14 @@ inline void System_SetWindowTitle(const std::string ¶m) { g_requestManager.MakeSystemRequest(SystemRequestType::SET_WINDOW_TITLE, nullptr, nullptr, param, "", 0); } +inline void System_SendDebugOutput(const std::string &string) { + g_requestManager.MakeSystemRequest(SystemRequestType::SEND_DEBUG_OUTPUT, nullptr, nullptr, string, "", 0); +} + +inline void System_SendDebugScreenshot(const std::string &data, int height) { + g_requestManager.MakeSystemRequest(SystemRequestType::SEND_DEBUG_SCREENSHOT, nullptr, nullptr, data, "", height); +} + // Non-inline to avoid including Path.h void System_CreateGameShortcut(const Path &path, const std::string &title); diff --git a/Common/System/System.h b/Common/System/System.h index 8148d099e7..420fb54e3a 100644 --- a/Common/System/System.h +++ b/Common/System/System.h @@ -6,8 +6,7 @@ // Platform integration -// To run the PPSSPP core, a platform needs to implement all the System_ functions in this file, -// plus derive an object from Host (see Host.h). The latter will be phased out. +// To run the PPSSPP core, a platform needs to implement all the System_ functions in this file. // Failure to implement all of these will simply cause linker failures. There are a few that are // only implemented on specific platforms, but they're also only called on those platforms. @@ -70,6 +69,11 @@ enum class SystemRequestType { GRAPHICS_BACKEND_FAILED_ALERT, CREATE_GAME_SHORTCUT, + // Commonly ignored, used when automated tests generate output. + SEND_DEBUG_OUTPUT, + // Note: height specified as param3, width based on param1.size() / param3. + SEND_DEBUG_SCREENSHOT, + NOTIFY_UI_STATE, // Used on Android only. Not a SystemNotification since it takes a parameter. // High-level hardware control diff --git a/Core/Core.vcxproj b/Core/Core.vcxproj index 0fad6b30a7..8600cb3ef7 100644 --- a/Core/Core.vcxproj +++ b/Core/Core.vcxproj @@ -711,7 +711,6 @@ - @@ -1265,7 +1264,6 @@ - diff --git a/Core/Core.vcxproj.filters b/Core/Core.vcxproj.filters index 4b2b04de05..f1488fd3ed 100644 --- a/Core/Core.vcxproj.filters +++ b/Core/Core.vcxproj.filters @@ -300,9 +300,6 @@ Core - - Core - Core @@ -1401,9 +1398,6 @@ Core - - Core - Core diff --git a/Core/HLE/sceIo.cpp b/Core/HLE/sceIo.cpp index e02f9e1620..55766694f0 100644 --- a/Core/HLE/sceIo.cpp +++ b/Core/HLE/sceIo.cpp @@ -29,6 +29,7 @@ #include "Common/Serialize/SerializeMap.h" #include "Common/Serialize/SerializeSet.h" #include "Common/StringUtils.h" +#include "Common/System/Request.h" #include "Core/Core.h" #include "Core/Config.h" #include "Core/ConfigValues.h" @@ -37,7 +38,6 @@ #include "Core/MemMapHelpers.h" #include "Core/System.h" #include "Core/HDRemaster.h" -#include "Core/Host.h" #include "Core/SaveState.h" #include "Core/HLE/HLE.h" #include "Core/HLE/HLEHelperThread.h" @@ -2012,8 +2012,8 @@ static u32 sceIoDevctl(const char *name, int cmd, u32 argAddr, int argLen, u32 o case EMULATOR_DEVCTL__SEND_OUTPUT: { std::string data(Memory::GetCharPointer(argAddr), argLen); - if (PSP_CoreParameter().printfEmuLog && host) { - host->SendDebugOutput(data); + if (PSP_CoreParameter().printfEmuLog) { + System_SendDebugOutput(data); } else { if (PSP_CoreParameter().collectEmuLog) { *PSP_CoreParameter().collectEmuLog += data; @@ -2040,9 +2040,7 @@ static u32 sceIoDevctl(const char *name, int cmd, u32 argAddr, int argLen, u32 o __DisplayGetFramebuf(&topaddr, &linesize, nullptr, 0); // TODO: Convert based on pixel format / mode / something? - if (host) { - host->SendDebugScreenshot(topaddr, linesize, 272); - } + System_SendDebugScreenshot(std::string((const char *)&topaddr[0], linesize * 272), 272); return 0; } case EMULATOR_DEVCTL__TOGGLE_FASTFORWARD: diff --git a/Core/HLE/sceKernelModule.cpp b/Core/HLE/sceKernelModule.cpp index 1801967426..3133e65b09 100644 --- a/Core/HLE/sceKernelModule.cpp +++ b/Core/HLE/sceKernelModule.cpp @@ -26,6 +26,7 @@ #include "Common/Serialize/SerializeSet.h" #include "Common/File/FileUtil.h" #include "Common/StringUtils.h" +#include "Common/System/Request.h" #include "Common/System/System.h" #include "Core/Config.h" @@ -37,7 +38,6 @@ #include "Core/HLE/ReplaceTables.h" #include "Core/HLE/sceDisplay.h" #include "Core/Reporting.h" -#include "Core/Host.h" #include "Core/Loaders.h" #include "Core/MIPS/MIPS.h" #include "Core/MIPS/MIPSAnalyst.h" @@ -1934,9 +1934,7 @@ void __KernelGPUReplay() { PSPPointer topaddr; u32 linesize = 512; __DisplayGetFramebuf(&topaddr, &linesize, nullptr, 0); - if (host) { - host->SendDebugScreenshot(topaddr, linesize, 272); - } + System_SendDebugScreenshot(std::string((const char *)&topaddr[0], linesize * 272), 272); Core_Stop(); } } diff --git a/Core/Host.cpp b/Core/Host.cpp deleted file mode 100644 index 81fb73f9bf..0000000000 --- a/Core/Host.cpp +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) 2012- PPSSPP Project. - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, version 2.0 or later versions. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License 2.0 for more details. - -// A copy of the GPL 2.0 should have been included with the program. -// If not, see http://www.gnu.org/licenses/ - -// Official git repository and contact information can be found at -// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. - -#include "Core/Host.h" - -Host *host = nullptr; diff --git a/Core/Host.h b/Core/Host.h deleted file mode 100644 index 7384341479..0000000000 --- a/Core/Host.h +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) 2012- PPSSPP Project. - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, version 2.0 or later versions. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License 2.0 for more details. - -// A copy of the GPL 2.0 should have been included with the program. -// If not, see http://www.gnu.org/licenses/ - -// Official git repository and contact information can be found at -// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. - -#pragma once - -#include - -#include "Common/CommonTypes.h" - -class GraphicsContext; - -class Host { -public: - virtual ~Host() {} - - virtual void SendDebugOutput(const std::string &output) {} - virtual void SendDebugScreenshot(const u8 *pixbuf, u32 w, u32 h) {} -}; - -extern Host *host; diff --git a/Core/PSPLoaders.cpp b/Core/PSPLoaders.cpp index c0556f47de..c23c29ed43 100644 --- a/Core/PSPLoaders.cpp +++ b/Core/PSPLoaders.cpp @@ -45,8 +45,6 @@ #include "Core/MIPS/MIPSAnalyst.h" #include "Core/MIPS/MIPSCodeUtils.h" -#include "Host.h" - #include "Core/Config.h" #include "Core/ConfigValues.h" #include "Core/System.h" diff --git a/GPU/Common/ReplacedTexture.cpp b/GPU/Common/ReplacedTexture.cpp index ea63e529f8..87b8c30fe6 100644 --- a/GPU/Common/ReplacedTexture.cpp +++ b/GPU/Common/ReplacedTexture.cpp @@ -720,8 +720,10 @@ bool ReplacedTexture::CopyLevelTo(int level, uint8_t *out, size_t outDataSize, i } }, 0, info.h, MIN_LINES_PER_THREAD); #else + int extraPixels = outW - info.w; for (int y = 0; y < info.h; ++y) { memcpy((uint8_t *)out + rowPitch * y, data.data() + info.w * 4 * y, info.w * 4); + memset((uint8_t *)out + rowPitch * y + info.w * 4, 0, extraPixels * 4); } #endif // Memset the rest of the padding to avoid leaky edge pixels. Guess we could parallelize this too, but meh. diff --git a/Qt/QtMain.cpp b/Qt/QtMain.cpp index 2a572703dc..411f26e1fd 100644 --- a/Qt/QtMain.cpp +++ b/Qt/QtMain.cpp @@ -47,7 +47,6 @@ #include "Common/StringUtils.h" #include "Core/Config.h" #include "Core/ConfigValues.h" -#include "Core/Host.h" #include "Core/HW/Camera.h" #include "Core/Debugger/SymbolMap.h" diff --git a/UI/ControlMappingScreen.cpp b/UI/ControlMappingScreen.cpp index eba85e37bf..b729fac4e9 100644 --- a/UI/ControlMappingScreen.cpp +++ b/UI/ControlMappingScreen.cpp @@ -40,7 +40,6 @@ #include "Common/System/Request.h" #include "Common/TimeUtil.h" #include "Core/KeyMap.h" -#include "Core/Host.h" #include "Core/HLE/sceCtrl.h" #include "Core/System.h" #include "Core/Config.h" diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 2c955b4acd..9ffa65d8a6 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -55,7 +55,6 @@ using namespace std::placeholders; #include "Core/CoreParameter.h" #include "Core/Core.h" #include "Core/CwCheat.h" -#include "Core/Host.h" #include "Core/KeyMap.h" #include "Core/MemFault.h" #include "Core/Reporting.h" diff --git a/UI/GameScreen.cpp b/UI/GameScreen.cpp index 7b7a0b8561..11b6035045 100644 --- a/UI/GameScreen.cpp +++ b/UI/GameScreen.cpp @@ -31,7 +31,6 @@ #include "Common/System/System.h" #include "Common/System/Request.h" #include "Common/System/NativeApp.h" -#include "Core/Host.h" #include "Core/Config.h" #include "Core/Reporting.h" #include "Core/System.h" diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 533673eb3b..6c40d6afbe 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -60,7 +60,6 @@ #include "Common/StringUtils.h" #include "Core/Config.h" #include "Core/ConfigValues.h" -#include "Core/Host.h" #include "Core/KeyMap.h" #include "Core/TiltEventProcessor.h" #include "Core/Instance.h" diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index d5baa80ef1..68641be108 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -41,7 +41,6 @@ #include "Common/TimeUtil.h" #include "Common/StringUtils.h" #include "Core/System.h" -#include "Core/Host.h" #include "Core/Reporting.h" #include "Core/ELF/PBPReader.h" #include "Core/ELF/ParamSFO.h" @@ -541,8 +540,7 @@ UI::EventReturn GameBrowser::LastClick(UI::EventParams &e) { UI::EventReturn GameBrowser::BrowseClick(UI::EventParams &e) { auto mm = GetI18NCategory("MainMenu"); - System_BrowseForFolder(mm->T("Choose folder"), [this](const std::string &value, int) { - std::string filename = value; + System_BrowseForFolder(mm->T("Choose folder"), [this](const std::string &filename, int) { this->SetPath(Path(filename)); }); return UI::EVENT_DONE; diff --git a/UI/MiscScreens.cpp b/UI/MiscScreens.cpp index 84dbbbe80f..63f09cc7d5 100644 --- a/UI/MiscScreens.cpp +++ b/UI/MiscScreens.cpp @@ -39,7 +39,6 @@ #include "Common/TimeUtil.h" #include "Common/File/FileUtil.h" #include "Core/Config.h" -#include "Core/Host.h" #include "Core/System.h" #include "Core/MIPS/JitCommon/JitCommon.h" #include "Core/HLE/sceUtility.h" diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 743cad6718..8545491682 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -87,7 +87,6 @@ #include "Core/ConfigValues.h" #include "Core/Core.h" #include "Core/FileLoaders/DiskCachingFileLoader.h" -#include "Core/Host.h" #include "Core/KeyMap.h" #include "Core/Reporting.h" #include "Core/SaveState.h" diff --git a/UI/SavedataScreen.cpp b/UI/SavedataScreen.cpp index c7ab4b7136..3bb168eb26 100644 --- a/UI/SavedataScreen.cpp +++ b/UI/SavedataScreen.cpp @@ -38,7 +38,6 @@ #include "Common/File/FileUtil.h" #include "Common/TimeUtil.h" #include "Common/StringUtils.h" -#include "Core/Host.h" #include "Core/Config.h" #include "Core/Loaders.h" #include "Core/SaveState.h" diff --git a/UWP/CoreUWP/CoreUWP.vcxproj b/UWP/CoreUWP/CoreUWP.vcxproj index 6fe4ea1320..3e6d8d018c 100644 --- a/UWP/CoreUWP/CoreUWP.vcxproj +++ b/UWP/CoreUWP/CoreUWP.vcxproj @@ -417,7 +417,6 @@ - @@ -652,7 +651,6 @@ - diff --git a/UWP/CoreUWP/CoreUWP.vcxproj.filters b/UWP/CoreUWP/CoreUWP.vcxproj.filters index 7fead01f06..75814511c3 100644 --- a/UWP/CoreUWP/CoreUWP.vcxproj.filters +++ b/UWP/CoreUWP/CoreUWP.vcxproj.filters @@ -96,7 +96,6 @@ - @@ -1136,7 +1135,6 @@ - diff --git a/Windows/EmuThread.cpp b/Windows/EmuThread.cpp index 70f20acb14..031500da70 100644 --- a/Windows/EmuThread.cpp +++ b/Windows/EmuThread.cpp @@ -22,7 +22,6 @@ #include "Core/Reporting.h" #include "Core/MemMap.h" #include "Core/Core.h" -#include "Core/Host.h" #include "Core/System.h" #include "Core/Config.h" #include "Core/ConfigValues.h" @@ -336,6 +335,7 @@ shutdown: g_graphicsContext->Shutdown(); + UpdateConsolePosition(); NativeShutdown(); PostMessage(MainWindow::GetHWND(), MainWindow::WM_USER_UPDATE_UI, 0, 0); diff --git a/Windows/GEDebugger/TabDisplayLists.cpp b/Windows/GEDebugger/TabDisplayLists.cpp index cb14c14eb1..2b29a91d36 100644 --- a/Windows/GEDebugger/TabDisplayLists.cpp +++ b/Windows/GEDebugger/TabDisplayLists.cpp @@ -1,7 +1,6 @@ #include "Windows/GEDebugger/TabDisplayLists.h" #include "Windows/GEDebugger/GEDebugger.h" #include "Windows/GEDebugger/CtrlDisplayListView.h" -#include "Windows/WindowsHost.h" #include "Windows/MainWindow.h" #include "Windows/main.h" #include "GPU/GPUInterface.h" diff --git a/Windows/main.cpp b/Windows/main.cpp index ea0298ad27..dd1cb8f966 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -111,9 +111,6 @@ static std::string restartArgs; int g_activeWindow = 0; -// Used for all the system dialogs. -static std::thread g_dialogThread; - WindowsInputManager g_inputManager; int g_lastNumInstances = 0; @@ -496,24 +493,17 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string return true; } case SystemRequestType::INPUT_TEXT_MODAL: - if (g_dialogThread.joinable()) - g_dialogThread.join(); - - g_dialogThread = std::thread([=] { + std::thread([=] { std::string out; if (InputBox_GetString(MainWindow::GetHInstance(), MainWindow::GetHWND(), ConvertUTF8ToWString(param1).c_str(), param2, out)) { g_requestManager.PostSystemSuccess(requestId, out.c_str()); } else { g_requestManager.PostSystemFailure(requestId); } - }); - g_dialogThread.detach(); + }).detach(); return true; case SystemRequestType::BROWSE_FOR_IMAGE: - if (g_dialogThread.joinable()) - g_dialogThread.join(); - - g_dialogThread = std::thread([=] { + std::thread([=] { std::string out; if (W32Util::BrowseForFileName(true, MainWindow::GetHWND(), ConvertUTF8ToWString(param1).c_str(), nullptr, MakeFilter(L"All supported images (*.jpg *.jpeg *.png)|*.jpg;*.jpeg;*.png|All files (*.*)|*.*||").c_str(), L"jpg", out)) { @@ -521,8 +511,7 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string } else { g_requestManager.PostSystemFailure(requestId); } - }); - g_dialogThread.detach(); + }).detach(); return true; case SystemRequestType::BROWSE_FOR_FILE: { @@ -545,28 +534,26 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string return false; } - g_dialogThread = std::thread([=] { + std::thread([=] { std::string out; if (W32Util::BrowseForFileName(true, MainWindow::GetHWND(), ConvertUTF8ToWString(param1).c_str(), nullptr, filter.c_str(), L"", out)) { g_requestManager.PostSystemSuccess(requestId, out.c_str()); } else { g_requestManager.PostSystemFailure(requestId); } - }); - g_dialogThread.detach(); + }).detach(); return true; } case SystemRequestType::BROWSE_FOR_FOLDER: { - g_dialogThread = std::thread([=] { + std::thread([=] { std::string folder = W32Util::BrowseForFolder(MainWindow::GetHWND(), param1.c_str()); if (folder.size()) { g_requestManager.PostSystemSuccess(requestId, folder.c_str()); } else { g_requestManager.PostSystemFailure(requestId); } - }); - g_dialogThread.detach(); + }).detach(); return true; } case SystemRequestType::TOGGLE_FULLSCREEN_STATE: @@ -728,9 +715,8 @@ static void WinMainInit() { } static void WinMainCleanup() { - if (g_dialogThread.joinable()) { - g_dialogThread.join(); - } + // This will ensure no further callbacks are called, which may prevent crashing. + g_requestManager.Clear(); net::Shutdown(); CoUninitialize(); diff --git a/android/jni/Android.mk b/android/jni/Android.mk index 3aef9bcf5a..23f1f5220b 100644 --- a/android/jni/Android.mk +++ b/android/jni/Android.mk @@ -445,7 +445,6 @@ EXEC_AND_LIB_FILES := \ $(SRC)/Core/Instance.cpp \ $(SRC)/Core/KeyMap.cpp \ $(SRC)/Core/KeyMapDefaults.cpp \ - $(SRC)/Core/Host.cpp \ $(SRC)/Core/Loaders.cpp \ $(SRC)/Core/PSPLoaders.cpp \ $(SRC)/Core/FileLoaders/CachingFileLoader.cpp \ @@ -764,7 +763,7 @@ ifeq ($(HEADLESS),1) LOCAL_MODULE := ppsspp_headless LOCAL_SRC_FILES := \ $(SRC)/headless/Headless.cpp \ - $(SRC)/headless/StubHost.cpp \ + $(SRC)/headless/HeadlessHost.cpp \ $(SRC)/headless/Compare.cpp include $(BUILD_EXECUTABLE) diff --git a/headless/Compare.cpp b/headless/Compare.cpp index e99b496b30..4fd7ce8cdf 100644 --- a/headless/Compare.cpp +++ b/headless/Compare.cpp @@ -27,7 +27,6 @@ #include "Common/Data/Format/PNGLoad.h" #include "Common/File/FileUtil.h" #include "Common/StringUtils.h" -#include "Core/Host.h" #include "Core/Loaders.h" #include "GPU/GPUState.h" diff --git a/headless/Headless.cpp b/headless/Headless.cpp index 12dbb9c456..2650272f9b 100644 --- a/headless/Headless.cpp +++ b/headless/Headless.cpp @@ -14,6 +14,7 @@ #include "Common/Profiler/Profiler.h" #include "Common/System/NativeApp.h" +#include "Common/System/Request.h" #include "Common/System/System.h" #include "Common/CommonWindows.h" @@ -37,20 +38,21 @@ #include "Core/System.h" #include "Core/WebServer.h" #include "Core/HLE/sceUtility.h" -#include "Core/Host.h" #include "Core/SaveState.h" #include "GPU/Common/FramebufferManagerCommon.h" #include "Log.h" #include "LogManager.h" #include "Compare.h" -#include "StubHost.h" +#include "HeadlessHost.h" #if defined(_WIN32) #include "WindowsHeadlessHost.h" #elif defined(SDL) #include "SDLHeadlessHost.h" #endif +static HeadlessHost *g_headlessHost; + #if PPSSPP_PLATFORM(ANDROID) JNIEnv *getEnv() { return nullptr; @@ -117,7 +119,23 @@ bool System_GetPropertyBool(SystemProperty prop) { void System_Notify(SystemNotification notification) {} void System_PostUIMessage(const std::string &message, const std::string ¶m) {} void System_NotifyUserMessage(const std::string &message, float duration, u32 color, const char *id) {} -bool System_MakeRequest(SystemRequestType type, int requestId, const std::string ¶m1, const std::string ¶m2, int param3) { return false; } +bool System_MakeRequest(SystemRequestType type, int requestId, const std::string ¶m1, const std::string ¶m2, int param3) { + switch (type) { + case SystemRequestType::SEND_DEBUG_OUTPUT: + if (g_headlessHost) { + g_headlessHost->SendDebugOutput(param1); + return true; + } + return false; + case SystemRequestType::SEND_DEBUG_SCREENSHOT: + if (g_headlessHost) { + g_headlessHost->SendDebugScreenshot((const u8 *)param1.data(), (uint32_t)(param1.size() / param3), param3); + return true; + } + return false; + } + return false; +} void System_InputBoxGetString(const std::string &title, const std::string &defaultValue, std::function cb) { cb(false, ""); } void System_AskForPermission(SystemPermission permission) {} PermissionStatus System_GetPermissionStatus(SystemPermission permission) { return PERMISSION_STATUS_GRANTED; } @@ -238,7 +256,7 @@ bool RunAutoTest(HeadlessHost *headlessHost, CoreParameter &coreParameter, const if (!opt.bench) { printf("%s", output.c_str()); - host->SendDebugOutput("TIMEOUT\n"); + System_SendDebugOutput("TIMEOUT\n"); TeamCityPrint("testFailed name='%s' message='Test timeout'", currentTestName.c_str()); GitHubActionsPrint("error", "Test timeout for %s", currentTestName.c_str()); } @@ -414,7 +432,7 @@ int main(int argc, const char* argv[]) g_threadManager.Init(cpu_info.num_cores, cpu_info.logical_cpu_count); HeadlessHost *headlessHost = getHost(gpuCore); - host = headlessHost; + g_headlessHost = headlessHost; std::string error_string; GraphicsContext *graphicsContext = nullptr; @@ -583,9 +601,9 @@ int main(int argc, const char* argv[]) } headlessHost->ShutdownGraphics(); - delete host; - host = nullptr; + delete headlessHost; headlessHost = nullptr; + g_headlessHost = nullptr; g_VFS.Clear(); LogManager::Shutdown(); diff --git a/headless/Headless.vcxproj b/headless/Headless.vcxproj index 6ef86ce3ee..ed551d84f2 100644 --- a/headless/Headless.vcxproj +++ b/headless/Headless.vcxproj @@ -477,7 +477,7 @@ true true - + @@ -510,7 +510,7 @@ - + diff --git a/headless/Headless.vcxproj.filters b/headless/Headless.vcxproj.filters index f084554e71..0cc2cc7b61 100644 --- a/headless/Headless.vcxproj.filters +++ b/headless/Headless.vcxproj.filters @@ -22,20 +22,19 @@ Windows - Other Platforms Windows + - Windows @@ -43,6 +42,7 @@ Other Platforms + diff --git a/headless/StubHost.cpp b/headless/HeadlessHost.cpp similarity index 98% rename from headless/StubHost.cpp rename to headless/HeadlessHost.cpp index 03a27ab1bf..a18fd63abf 100644 --- a/headless/StubHost.cpp +++ b/headless/HeadlessHost.cpp @@ -22,7 +22,7 @@ #include "Core/System.h" #include "GPU/Common/GPUDebugInterface.h" #include "headless/Compare.h" -#include "headless/StubHost.h" +#include "headless/HeadlessHost.h" void HeadlessHost::SendOrCollectDebugOutput(const std::string &data) { diff --git a/headless/StubHost.h b/headless/HeadlessHost.h similarity index 90% rename from headless/StubHost.h rename to headless/HeadlessHost.h index 7c75b09c66..3be7bc38c5 100644 --- a/headless/StubHost.h +++ b/headless/HeadlessHost.h @@ -17,17 +17,18 @@ #pragma once +#include "Common/CommonTypes.h" #include "Common/File/Path.h" #include "Core/CoreParameter.h" -#include "Core/Host.h" -class HeadlessHost : public Host { +class HeadlessHost { public: + virtual ~HeadlessHost() {} virtual bool InitGraphics(std::string *error_message, GraphicsContext **ctx, GPUCore core) {return false;} virtual void ShutdownGraphics() {} - void SendDebugOutput(const std::string &output) override { + virtual void SendDebugOutput(const std::string &output) { if (output.find('\n') != output.npos) { DoFlushDebugOutput(); fwrite(output.data(), sizeof(char), output.length(), stdout); @@ -53,7 +54,7 @@ public: writeFailureScreenshot_ = flag; } - void SendDebugScreenshot(const u8 *pixbuf, u32 w, u32 h) override; + virtual void SendDebugScreenshot(const u8 *pixbuf, u32 w, u32 h); // Unique for HeadlessHost virtual void SwapBuffers() {} diff --git a/headless/SDLHeadlessHost.h b/headless/SDLHeadlessHost.h index afcac2e2ac..413223e2c4 100644 --- a/headless/SDLHeadlessHost.h +++ b/headless/SDLHeadlessHost.h @@ -19,7 +19,7 @@ #ifdef SDL -#include "headless/StubHost.h" +#include "headless/HeadlessHost.h" #undef HEADLESSHOST_CLASS #define HEADLESSHOST_CLASS SDLHeadlessHost diff --git a/headless/WindowsHeadlessHost.h b/headless/WindowsHeadlessHost.h index 3b67fee26a..daa380b74d 100644 --- a/headless/WindowsHeadlessHost.h +++ b/headless/WindowsHeadlessHost.h @@ -17,7 +17,7 @@ #pragma once -#include "headless/StubHost.h" +#include "headless/HeadlessHost.h" #include #undef HEADLESSHOST_CLASS diff --git a/ios/ViewController.mm b/ios/ViewController.mm index 5d9735d8bb..4535b39a80 100644 --- a/ios/ViewController.mm +++ b/ios/ViewController.mm @@ -36,7 +36,6 @@ #include "Core/System.h" #include "Core/HLE/sceUsbCam.h" #include "Core/HLE/sceUsbGps.h" -#include "Core/Host.h" #include #include diff --git a/libretro/Makefile.common b/libretro/Makefile.common index 83e477f941..39e68cc1d2 100644 --- a/libretro/Makefile.common +++ b/libretro/Makefile.common @@ -523,7 +523,7 @@ SOURCES_CXX += \ $(COREDIR)/Dialog/PSPGamedataInstallDialog.cpp \ $(COREDIR)/Dialog/PSPMsgDialog.cpp \ $(COREDIR)/Dialog/PSPNetconfDialog.cpp \ - $(COREDIR)/Dialog/PSPNpSigninDialog.cpp \ + $(COREDIR)/Dialog/PSPNpSigninDialog.cpp \ $(COREDIR)/Dialog/PSPOskDialog.cpp \ $(COREDIR)/Dialog/PSPSaveDialog.cpp \ $(COREDIR)/Dialog/PSPScreenshotDialog.cpp \ @@ -611,7 +611,7 @@ SOURCES_CXX += \ $(COREDIR)/HLE/sceVaudio.cpp \ $(COREDIR)/HLE/scePspNpDrm_user.cpp \ $(COREDIR)/HLE/sceNp.cpp \ - $(COREDIR)/HLE/sceNp2.cpp \ + $(COREDIR)/HLE/sceNp2.cpp \ $(COREDIR)/HLE/scePauth.cpp \ $(COREDIR)/HLE/sceUsbGps.cpp \ $(COREDIR)/HW/BufferQueue.cpp \ @@ -626,7 +626,6 @@ SOURCES_CXX += \ $(COREDIR)/HW/SasReverb.cpp \ $(COREDIR)/HW/StereoResampler.cpp \ $(COREDIR)/Compatibility.cpp \ - $(COREDIR)/Host.cpp \ $(COREDIR)/Loaders.cpp \ $(COREDIR)/MIPS/JitCommon/JitCommon.cpp \ $(COREDIR)/MIPS/JitCommon/JitState.cpp \ @@ -666,7 +665,7 @@ SOURCES_CXX += \ $(COREDIR)/Util/PPGeDraw.cpp \ $(COREDIR)/Util/AudioFormat.cpp \ $(COREDIR)/Util/PortManager.cpp \ - $(CORE_DIR)/UI/GameInfoCache.cpp + $(CORE_DIR)/UI/GameInfoCache.cpp SOURCES_CXX += $(COREDIR)/HLE/__sceAudio.cpp diff --git a/libretro/libretro.cpp b/libretro/libretro.cpp index 7f43e46ad0..476d66ccc4 100644 --- a/libretro/libretro.cpp +++ b/libretro/libretro.cpp @@ -33,7 +33,6 @@ #include "Core/HLE/__sceAudio.h" #include "Core/HW/MemoryStick.h" #include "Core/HW/StereoResampler.h" -#include "Core/Host.h" #include "Core/MemMap.h" #include "Core/System.h" #include "Core/CoreTiming.h" @@ -385,8 +384,6 @@ namespace Libretro using namespace Libretro; -class LibretroHost : public Host {}; - class PrintfLogger : public LogListener { public: @@ -1268,8 +1265,6 @@ void retro_init(void) g_Config.bDiscordPresence = false; g_VFS.Register("", new DirectoryReader(retro_base_dir)); - - host = new LibretroHost(); } void retro_deinit(void) @@ -1280,9 +1275,6 @@ void retro_deinit(void) delete printfLogger; printfLogger = nullptr; - delete host; - host = nullptr; - libretro_supports_bitmasks = false; libretro_supports_option_categories = false;