From b440e28e3803a4b55044c759671f8683cfd0cee9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 22 Mar 2023 23:25:00 +0100 Subject: [PATCH] Remove System_SendMessage! iOS, Qt buildfixes --- Common/System/Request.h | 4 ++++ Common/System/System.h | 5 ++--- Core/System.cpp | 3 ++- Qt/QtMain.cpp | 9 ++++----- SDL/SDLMain.cpp | 2 -- UI/EmuScreen.cpp | 7 ------- UI/GameSettingsScreen.cpp | 2 +- UI/MainScreen.cpp | 1 - UWP/PPSSPP_UWPMain.cpp | 2 -- Windows/main.cpp | 2 -- android/jni/app-android.cpp | 11 ++++++----- headless/Headless.cpp | 1 - ios/ViewController.mm | 5 +++++ ios/main.mm | 12 +++++------- libretro/libretro.cpp | 1 - unittest/JitHarness.cpp | 1 - 16 files changed, 29 insertions(+), 39 deletions(-) diff --git a/Common/System/Request.h b/Common/System/Request.h index b42c96fc9e..9972ee4205 100644 --- a/Common/System/Request.h +++ b/Common/System/Request.h @@ -116,3 +116,7 @@ inline void System_MicrophoneCommand(const std::string &command) { inline void System_ShareText(const std::string &text) { g_requestManager.MakeSystemRequest(SystemRequestType::SHARE_TEXT, nullptr, text, "", 0); } + +inline void System_NotifyUIState(const std::string &state) { + g_requestManager.MakeSystemRequest(SystemRequestType::NOTIFY_UI_STATE, nullptr, state, "", 0); +} diff --git a/Common/System/System.h b/Common/System/System.h index 4187358187..795493ae44 100644 --- a/Common/System/System.h +++ b/Common/System/System.h @@ -73,6 +73,7 @@ enum class SystemRequestType { MICROPHONE_COMMAND, SHARE_TEXT, + NOTIFY_UI_STATE, // Used on Android only. Not a SystemNotification since it takes a parameter. }; // Implementations are supposed to process the request, and post the response to the g_RequestManager (see Message.h). @@ -82,9 +83,6 @@ enum class SystemRequestType { // Some requests don't use responses. bool System_MakeRequest(SystemRequestType type, int requestId, const std::string ¶m1, const std::string ¶m2, int param3); -// TODO: To be separated into requests, see Request.h, and a way to post "UI messages". -void System_SendMessage(const char *command, const char *parameter); - PermissionStatus System_GetPermissionStatus(SystemPermission permission); void System_AskForPermission(SystemPermission permission); @@ -181,6 +179,7 @@ enum class SystemNotification { FORCE_RECREATE_ACTIVITY, IMMERSIVE_MODE_CHANGE, AUDIO_RESET_DEVICE, + SUSTAINED_PERF_CHANGE, }; std::string System_GetProperty(SystemProperty prop); diff --git a/Core/System.cpp b/Core/System.cpp index 71aacc931e..5a1c26b338 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -33,6 +33,7 @@ #include #include "Common/System/System.h" +#include "Common/System/Request.h" #include "Common/File/Path.h" #include "Common/Math/math_util.h" #include "Common/Thread/ThreadUtil.h" @@ -134,7 +135,7 @@ void UpdateUIState(GlobalUIState newState) { case UISTATE_EXCEPTION: state = "exception"; break; } if (state) { - System_SendMessage("uistate", state); + System_NotifyUIState(state); } } } diff --git a/Qt/QtMain.cpp b/Qt/QtMain.cpp index 0b256e3f19..c165914bba 100644 --- a/Qt/QtMain.cpp +++ b/Qt/QtMain.cpp @@ -343,7 +343,7 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string qApp->exit(0); return true; case SystemRequestType::COPY_TO_CLIPBOARD: - QApplication::clipboard()->setText(parameter); + QApplication::clipboard()->setText(param1.c_str()); return true; case SystemRequestType::INPUT_TEXT_MODAL: { @@ -371,11 +371,11 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string QCoreApplication::postEvent(emugl, new QEvent((QEvent::Type)browseFolderEvent)); return true; case SystemRequestType::CAMERA_COMMAND: - if (!strncmp(parameter, "startVideo", 10)) { + if (!strncmp(param1.c_str(), "startVideo", 10)) { int width = 0, height = 0; - sscanf(parameter, "startVideo_%dx%d", &width, &height); + sscanf(param1.c_str(), "startVideo_%dx%d", &width, &height); emit(qtcamera->onStartCamera(width, height)); - } else if (!strcmp(parameter, "stopVideo")) { + } else if (param1 == "stopVideo") { emit(qtcamera->onStopCamera()); } return true; @@ -384,7 +384,6 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string } } -void System_SendMessage(const char *command, const char *parameter) {} void System_Toast(const char *text) {} void System_AskForPermission(SystemPermission permission) {} diff --git a/SDL/SDLMain.cpp b/SDL/SDLMain.cpp index 4042e77232..8aadab0be5 100644 --- a/SDL/SDLMain.cpp +++ b/SDL/SDLMain.cpp @@ -222,8 +222,6 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string } } -void System_SendMessage(const char *command, const char *parameter) {} - void System_AskForPermission(SystemPermission permission) {} PermissionStatus System_GetPermissionStatus(SystemPermission permission) { return PERMISSION_STATUS_GRANTED; } diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index b367e3b067..19b17a7a46 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -211,7 +211,6 @@ bool EmuScreen::bootAllowStorage(const Path &filename) { case PERMISSION_STATUS_DENIED: stopRender_ = true; screenManager()->switchScreen(new MainScreen()); - System_SendMessage("event", "failstartgame"); return false; case PERMISSION_STATUS_PENDING: @@ -244,7 +243,6 @@ void EmuScreen::bootGame(const Path &filename) { if (invalid_) { errorMessage_ = error_string; ERROR_LOG(BOOT, "%s", errorMessage_.c_str()); - System_SendMessage("event", "failstartgame"); return; } bootComplete(); @@ -329,7 +327,6 @@ void EmuScreen::bootGame(const Path &filename) { invalid_ = true; errorMessage_ = error_string; ERROR_LOG(BOOT, "%s", errorMessage_.c_str()); - System_SendMessage("event", "failstartgame"); } if (PSP_CoreParameter().compat.flags().RequireBufferedRendering && g_Config.bSkipBufferEffects) { @@ -393,8 +390,6 @@ void EmuScreen::bootComplete() { #endif } - System_SendMessage("event", "startgame"); - saveStateSlot_ = SaveState::GetCurrentSlot(); loadingViewColor_->Divert(0x00FFFFFF, 0.2f); @@ -430,7 +425,6 @@ void EmuScreen::dialogFinished(const Screen *dialog, DialogResult result) { // DR_YES means a message sent to PauseMenu by NativeMessageReceived. if (result == DR_OK || quit_) { screenManager()->switchScreen(new MainScreen()); - System_SendMessage("event", "exitgame"); quit_ = false; } // Returning to the PauseScreen, unless we're stepping, means we should go back to controls. @@ -473,7 +467,6 @@ void EmuScreen::sendMessage(const char *message, const char *value) { ERROR_LOG(LOADER, "Error resetting: %s", resetError.c_str()); stopRender_ = true; screenManager()->switchScreen(new MainScreen()); - System_SendMessage("event", "failstartgame"); return; } } else if (!strcmp(message, "boot")) { diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 58eb2c68bd..eba83997d1 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1210,7 +1210,7 @@ UI::EventReturn GameSettingsScreen::OnImmersiveModeChange(UI::EventParams &e) { } UI::EventReturn GameSettingsScreen::OnSustainedPerformanceModeChange(UI::EventParams &e) { - System_SendMessage("sustainedPerfMode", ""); + System_Notify(SystemNotification::SUSTAINED_PERF_CHANGE); return UI::EVENT_DONE; } diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index 2fa799e9b7..d5baa80ef1 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -980,7 +980,6 @@ UI::EventReturn GameBrowser::OnHomebrewStore(UI::EventParams &e) { } MainScreen::MainScreen() { - System_SendMessage("event", "mainscreen"); g_BackgroundAudio.SetGame(Path()); } diff --git a/UWP/PPSSPP_UWPMain.cpp b/UWP/PPSSPP_UWPMain.cpp index 0af1409d3d..f78a8e0787 100644 --- a/UWP/PPSSPP_UWPMain.cpp +++ b/UWP/PPSSPP_UWPMain.cpp @@ -507,8 +507,6 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string } } -void System_SendMessage(const char *command, const char *parameter) {} - void System_ShowFileInFolder(const char *path) { // Unsupported } diff --git a/Windows/main.cpp b/Windows/main.cpp index 057522fc68..9b6f19df4f 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -565,8 +565,6 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string } } -void System_SendMessage(const char *command, const char *parameter) {} - void System_AskForPermission(SystemPermission permission) {} PermissionStatus System_GetPermissionStatus(SystemPermission permission) { return PERMISSION_STATUS_GRANTED; } diff --git a/android/jni/app-android.cpp b/android/jni/app-android.cpp index b4f5892b03..dc114d850c 100644 --- a/android/jni/app-android.cpp +++ b/android/jni/app-android.cpp @@ -401,11 +401,6 @@ void System_LaunchUrl(LaunchUrlType urlType, const char *url) { } } -void System_SendMessage(const char *command, const char *parameter) { - // TODO: Using sendmessage this way is deprecated. - PushCommand(command, parameter); -} - std::string System_GetProperty(SystemProperty prop) { switch (prop) { case SYSPROP_NAME: @@ -1036,6 +1031,9 @@ void System_Notify(SystemNotification notification) { case SystemNotification::IMMERSIVE_MODE_CHANGE: PushCommand("immersive", ""); break; + case SystemNotification::SUSTAINED_PERF_CHANGE: + PushCommand("sustainedPerfMode", ""); + break; } } @@ -1075,6 +1073,9 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string case SystemRequestType::SHARE_TEXT: PushCommand("share_text", param1); return true; + case SystemRequestType::NOTIFY_UI_STATE: + PushCommand("uistate", param1); + return true; default: return false; } diff --git a/headless/Headless.cpp b/headless/Headless.cpp index 137b3ae1f3..c085bab344 100644 --- a/headless/Headless.cpp +++ b/headless/Headless.cpp @@ -115,7 +115,6 @@ bool System_GetPropertyBool(SystemProperty prop) { } } void System_Notify(SystemNotification notification) {} -void System_SendMessage(const char *command, const char *parameter) {} bool System_MakeRequest(SystemRequestType type, int requestId, const std::string ¶m1, const std::string ¶m2, int param3) { return false; } void System_InputBoxGetString(const std::string &title, const std::string &defaultValue, std::function cb) { cb(false, ""); } void System_AskForPermission(SystemPermission permission) {} diff --git a/ios/ViewController.mm b/ios/ViewController.mm index a693dd771c..49f8a011dd 100644 --- a/ios/ViewController.mm +++ b/ios/ViewController.mm @@ -160,6 +160,11 @@ static LocationHelper *locationHelper; }); } +extern float g_safeInsetLeft; +extern float g_safeInsetRight; +extern float g_safeInsetTop; +extern float g_safeInsetBottom; + - (void)viewSafeAreaInsetsDidChange { if (@available(iOS 11.0, *)) { [super viewSafeAreaInsetsDidChange]; diff --git a/ios/main.mm b/ios/main.mm index a6a5ec4bf3..e90b60e8a1 100644 --- a/ios/main.mm +++ b/ios/main.mm @@ -89,10 +89,10 @@ void *exception_handler(void *argument) { return NULL; } -static float g_safeInsetLeft = 0.0; -static float g_safeInsetRight = 0.0; -static float g_safeInsetTop = 0.0; -static float g_safeInsetBottom = 0.0; +float g_safeInsetLeft = 0.0; +float g_safeInsetRight = 0.0; +float g_safeInsetTop = 0.0; +float g_safeInsetBottom = 0.0; // We no longer need to judge if jit is usable or not by according to the ios version. /* @@ -176,8 +176,6 @@ void System_Notify(SystemNotification notification) { } } -void System_SendMessage(const char *command, const char *parameter) {} - bool System_MakeRequest(SystemRequestType type, int requestId, const std::string ¶m1, const std::string ¶m2, int param3) { switch (type) { case SystemRequestType::EXIT_APP: @@ -227,7 +225,7 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string case SystemRequestType::GPS_COMMAND: if (param1 == "open") { startLocation(); - } else if (param1 == "close")) { + } else if (param1 == "close") { stopLocation(); } return true; diff --git a/libretro/libretro.cpp b/libretro/libretro.cpp index 2289b1fb97..dea29a92a9 100644 --- a/libretro/libretro.cpp +++ b/libretro/libretro.cpp @@ -1875,7 +1875,6 @@ void System_Notify(SystemNotification notification) { } } bool System_MakeRequest(SystemRequestType type, int requestId, const std::string ¶m1, const std::string ¶m2, int param3) { return false; } -void System_SendMessage(const char *command, const char *parameter) {} void NativeUpdate() {} void NativeRender(GraphicsContext *graphicsContext) {} void NativeResized() {} diff --git a/unittest/JitHarness.cpp b/unittest/JitHarness.cpp index d578c0af13..18518360f6 100644 --- a/unittest/JitHarness.cpp +++ b/unittest/JitHarness.cpp @@ -41,7 +41,6 @@ void NativeUpdate() { } void NativeRender(GraphicsContext *graphicsContext) { } void NativeResized() { } -void System_SendMessage(const char *command, const char *parameter) {} bool System_MakeRequest(SystemRequestType type, int requestId, const std::string ¶m1, const std::string ¶m2, int param3) { return false; } void System_InputBoxGetString(const std::string &title, const std::string &defaultValue, std::function cb) { cb(false, ""); } void System_AskForPermission(SystemPermission permission) {}