From 4c99712b6011f64689e803ffb5e550a29c9b2bc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 22 Mar 2023 23:15:08 +0100 Subject: [PATCH] And "immersive", "audio_resetDevice" --- Common/System/System.h | 2 ++ Qt/QtMain.cpp | 13 +++++-------- SDL/SDLMain.cpp | 12 ++++++------ UI/ControlMappingScreen.cpp | 2 +- UI/GameSettingsScreen.cpp | 4 ++-- android/jni/AndroidVulkanContext.cpp | 2 +- android/jni/app-android.cpp | 11 +++++++---- 7 files changed, 24 insertions(+), 22 deletions(-) diff --git a/Common/System/System.h b/Common/System/System.h index 8c3774c342..4187358187 100644 --- a/Common/System/System.h +++ b/Common/System/System.h @@ -179,6 +179,8 @@ enum class SystemNotification { SWITCH_UMD_UPDATED, ROTATE_UPDATED, FORCE_RECREATE_ACTIVITY, + IMMERSIVE_MODE_CHANGE, + AUDIO_RESET_DEVICE, }; std::string System_GetProperty(SystemProperty prop); diff --git a/Qt/QtMain.cpp b/Qt/QtMain.cpp index b01acce6ba..0b256e3f19 100644 --- a/Qt/QtMain.cpp +++ b/Qt/QtMain.cpp @@ -271,6 +271,10 @@ void System_Notify(SystemNotification notification) { if (g_symbolMap) g_symbolMap->SortSymbols(); break; + case SystemNotification::AUDIO_RESET_DEVICE: + StopSDLAudioDevice(); + InitSDLAudioDevice(); + break; default: break; } @@ -380,14 +384,7 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string } } -void System_SendMessage(const char *command, const char *parameter) { -#if defined(SDL) - if (!strcmp(command, "audio_resetDevice")) { - StopSDLAudioDevice(); - InitSDLAudioDevice(); - } -#endif -} +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 f6defed98f..4042e77232 100644 --- a/SDL/SDLMain.cpp +++ b/SDL/SDLMain.cpp @@ -222,12 +222,7 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string } } -void System_SendMessage(const char *command, const char *parameter) { - if (!strcmp(command, "audio_resetDevice")) { - StopSDLAudioDevice(); - InitSDLAudioDevice(); - } -} +void System_SendMessage(const char *command, const char *parameter) {} void System_AskForPermission(SystemPermission permission) {} PermissionStatus System_GetPermissionStatus(SystemPermission permission) { return PERMISSION_STATUS_GRANTED; } @@ -469,6 +464,11 @@ bool System_GetPropertyBool(SystemProperty prop) { void System_Notify(SystemNotification notification) { switch (notification) { + case SystemNotification::AUDIO_RESET_DEVICE: + StopSDLAudioDevice(); + InitSDLAudioDevice(); + break; + default: break; } diff --git a/UI/ControlMappingScreen.cpp b/UI/ControlMappingScreen.cpp index 5dbe5c4db6..eba85e37bf 100644 --- a/UI/ControlMappingScreen.cpp +++ b/UI/ControlMappingScreen.cpp @@ -731,7 +731,7 @@ void RecreateActivity() { } UI::EventReturn TouchTestScreen::OnImmersiveModeChange(UI::EventParams &e) { - System_SendMessage("immersive", ""); + System_Notify(SystemNotification::IMMERSIVE_MODE_CHANGE); return UI::EVENT_DONE; } diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 6d3004fe3a..58eb2c68bd 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1205,7 +1205,7 @@ UI::EventReturn GameSettingsScreen::OnAdhocGuides(UI::EventParams &e) { } UI::EventReturn GameSettingsScreen::OnImmersiveModeChange(UI::EventParams &e) { - System_SendMessage("immersive", ""); + System_Notify(SystemNotification::IMMERSIVE_MODE_CHANGE); return UI::EVENT_DONE; } @@ -1547,7 +1547,7 @@ UI::EventReturn GameSettingsScreen::OnAudioDevice(UI::EventParams &e) { if (g_Config.sAudioDevice == a->T("Auto")) { g_Config.sAudioDevice.clear(); } - System_SendMessage("audio_resetDevice", ""); + System_Notify(SystemNotification::AUDIO_RESET_DEVICE); return UI::EVENT_DONE; } diff --git a/android/jni/AndroidVulkanContext.cpp b/android/jni/AndroidVulkanContext.cpp index 6d5693273e..d12832a7fe 100644 --- a/android/jni/AndroidVulkanContext.cpp +++ b/android/jni/AndroidVulkanContext.cpp @@ -85,7 +85,7 @@ bool AndroidVulkanContext::InitAPI() { INFO_LOG(G3D, "Creating Vulkan device"); if (g_Vulkan->CreateDevice() != VK_SUCCESS) { INFO_LOG(G3D, "Failed to create vulkan device: %s", g_Vulkan->InitError().c_str()); - System_SendMessage("toast", "No Vulkan driver found. Using OpenGL instead."); + System_Toast("No Vulkan driver found. Using OpenGL instead."); g_Vulkan->DestroyInstance(); delete g_Vulkan; g_Vulkan = nullptr; diff --git a/android/jni/app-android.cpp b/android/jni/app-android.cpp index a7e3747553..b4f5892b03 100644 --- a/android/jni/app-android.cpp +++ b/android/jni/app-android.cpp @@ -1033,6 +1033,9 @@ void System_Notify(SystemNotification notification) { case SystemNotification::FORCE_RECREATE_ACTIVITY: PushCommand("recreate", ""); break; + case SystemNotification::IMMERSIVE_MODE_CHANGE: + PushCommand("immersive", ""); + break; } } @@ -1062,16 +1065,16 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string case SystemRequestType::CAMERA_COMMAND: PushCommand("camera_command", param1); - break; + return true; case SystemRequestType::GPS_COMMAND: PushCommand("gps_command", param1); - break; + return true; case SystemRequestType::MICROPHONE_COMMAND: PushCommand("microphone_command", param1); - break; + return true; case SystemRequestType::SHARE_TEXT: PushCommand("share_text", param1); - break; + return true; default: return false; }