diff options
| author | 2024-01-31 10:25:28 -0600 | |
|---|---|---|
| committer | 2024-01-31 10:25:28 -0600 | |
| commit | 7cc7d027f74b5bffc0b3f8f3a6c3110999c7cc4c (patch) | |
| tree | 24b2ed412f2683c8460839778ea7761d052bc38f /src/android/app | |
| parent | Merge pull request #12858 from liamwhite/non-blocking (diff) | |
| parent | am: push storage from error applet with non-zero size (diff) | |
| download | yuzu-7cc7d027f74b5bffc0b3f8f3a6c3110999c7cc4c.tar.gz yuzu-7cc7d027f74b5bffc0b3f8f3a6c3110999c7cc4c.tar.xz yuzu-7cc7d027f74b5bffc0b3f8f3a6c3110999c7cc4c.zip | |
Merge pull request #12760 from liamwhite/mp-am
am: rewrite for multiprocess support
Diffstat (limited to 'src/android/app')
6 files changed, 47 insertions, 25 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt index 53137b2e2..6ebb46af7 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt | |||
| @@ -261,7 +261,7 @@ object NativeLibrary { | |||
| 261 | /** | 261 | /** |
| 262 | * Begins emulation. | 262 | * Begins emulation. |
| 263 | */ | 263 | */ |
| 264 | external fun run(path: String?, programIndex: Int = 0) | 264 | external fun run(path: String?, programIndex: Int, frontendInitiated: Boolean) |
| 265 | 265 | ||
| 266 | // Surface Handling | 266 | // Surface Handling |
| 267 | external fun surfaceChanged(surf: Surface?) | 267 | external fun surfaceChanged(surf: Surface?) |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt index 1f591ced1..937b8faf1 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt | |||
| @@ -927,7 +927,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { | |||
| 927 | emulationThread.join() | 927 | emulationThread.join() |
| 928 | emulationThread = Thread({ | 928 | emulationThread = Thread({ |
| 929 | Log.debug("[EmulationFragment] Starting emulation thread.") | 929 | Log.debug("[EmulationFragment] Starting emulation thread.") |
| 930 | NativeLibrary.run(gamePath, programIndex) | 930 | NativeLibrary.run(gamePath, programIndex, false) |
| 931 | }, "NativeEmulation") | 931 | }, "NativeEmulation") |
| 932 | emulationThread.start() | 932 | emulationThread.start() |
| 933 | } | 933 | } |
| @@ -981,7 +981,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { | |||
| 981 | State.STOPPED -> { | 981 | State.STOPPED -> { |
| 982 | emulationThread = Thread({ | 982 | emulationThread = Thread({ |
| 983 | Log.debug("[EmulationFragment] Starting emulation thread.") | 983 | Log.debug("[EmulationFragment] Starting emulation thread.") |
| 984 | NativeLibrary.run(gamePath, programIndex) | 984 | NativeLibrary.run(gamePath, programIndex, true) |
| 985 | }, "NativeEmulation") | 985 | }, "NativeEmulation") |
| 986 | emulationThread.start() | 986 | emulationThread.start() |
| 987 | } | 987 | } |
diff --git a/src/android/app/src/main/jni/applets/software_keyboard.cpp b/src/android/app/src/main/jni/applets/software_keyboard.cpp index 74e040478..9943483e8 100644 --- a/src/android/app/src/main/jni/applets/software_keyboard.cpp +++ b/src/android/app/src/main/jni/applets/software_keyboard.cpp | |||
| @@ -82,7 +82,7 @@ AndroidKeyboard::ResultData AndroidKeyboard::ResultData::CreateFromFrontend(jobj | |||
| 82 | const jstring string = reinterpret_cast<jstring>(env->GetObjectField( | 82 | const jstring string = reinterpret_cast<jstring>(env->GetObjectField( |
| 83 | object, env->GetFieldID(s_keyboard_data_class, "text", "Ljava/lang/String;"))); | 83 | object, env->GetFieldID(s_keyboard_data_class, "text", "Ljava/lang/String;"))); |
| 84 | return ResultData{GetJString(env, string), | 84 | return ResultData{GetJString(env, string), |
| 85 | static_cast<Service::AM::Applets::SwkbdResult>(env->GetIntField( | 85 | static_cast<Service::AM::Frontend::SwkbdResult>(env->GetIntField( |
| 86 | object, env->GetFieldID(s_keyboard_data_class, "result", "I")))}; | 86 | object, env->GetFieldID(s_keyboard_data_class, "result", "I")))}; |
| 87 | } | 87 | } |
| 88 | 88 | ||
| @@ -149,7 +149,7 @@ void AndroidKeyboard::ShowNormalKeyboard() const { | |||
| 149 | } | 149 | } |
| 150 | 150 | ||
| 151 | void AndroidKeyboard::ShowTextCheckDialog( | 151 | void AndroidKeyboard::ShowTextCheckDialog( |
| 152 | Service::AM::Applets::SwkbdTextCheckResult text_check_result, | 152 | Service::AM::Frontend::SwkbdTextCheckResult text_check_result, |
| 153 | std::u16string text_check_message) const { | 153 | std::u16string text_check_message) const { |
| 154 | LOG_WARNING(Frontend, "(STUBBED) called, backend requested to show the text check dialog."); | 154 | LOG_WARNING(Frontend, "(STUBBED) called, backend requested to show the text check dialog."); |
| 155 | } | 155 | } |
| @@ -204,7 +204,7 @@ void AndroidKeyboard::InlineTextChanged( | |||
| 204 | "\ncursor_position={}", | 204 | "\ncursor_position={}", |
| 205 | Common::UTF16ToUTF8(text_parameters.input_text), text_parameters.cursor_position); | 205 | Common::UTF16ToUTF8(text_parameters.input_text), text_parameters.cursor_position); |
| 206 | 206 | ||
| 207 | submit_inline_callback(Service::AM::Applets::SwkbdReplyType::ChangedString, | 207 | submit_inline_callback(Service::AM::Frontend::SwkbdReplyType::ChangedString, |
| 208 | text_parameters.input_text, text_parameters.cursor_position); | 208 | text_parameters.input_text, text_parameters.cursor_position); |
| 209 | } | 209 | } |
| 210 | 210 | ||
| @@ -219,7 +219,7 @@ void AndroidKeyboard::SubmitInlineKeyboardText(std::u16string submitted_text) { | |||
| 219 | 219 | ||
| 220 | m_current_text += submitted_text; | 220 | m_current_text += submitted_text; |
| 221 | 221 | ||
| 222 | submit_inline_callback(Service::AM::Applets::SwkbdReplyType::ChangedString, m_current_text, | 222 | submit_inline_callback(Service::AM::Frontend::SwkbdReplyType::ChangedString, m_current_text, |
| 223 | m_current_text.size()); | 223 | m_current_text.size()); |
| 224 | } | 224 | } |
| 225 | 225 | ||
| @@ -236,12 +236,12 @@ void AndroidKeyboard::SubmitInlineKeyboardInput(int key_code) { | |||
| 236 | case KEYCODE_BACK: | 236 | case KEYCODE_BACK: |
| 237 | case KEYCODE_ENTER: | 237 | case KEYCODE_ENTER: |
| 238 | m_is_inline_active = false; | 238 | m_is_inline_active = false; |
| 239 | submit_inline_callback(Service::AM::Applets::SwkbdReplyType::DecidedEnter, m_current_text, | 239 | submit_inline_callback(Service::AM::Frontend::SwkbdReplyType::DecidedEnter, m_current_text, |
| 240 | static_cast<s32>(m_current_text.size())); | 240 | static_cast<s32>(m_current_text.size())); |
| 241 | break; | 241 | break; |
| 242 | case KEYCODE_DEL: | 242 | case KEYCODE_DEL: |
| 243 | m_current_text.pop_back(); | 243 | m_current_text.pop_back(); |
| 244 | submit_inline_callback(Service::AM::Applets::SwkbdReplyType::ChangedString, m_current_text, | 244 | submit_inline_callback(Service::AM::Frontend::SwkbdReplyType::ChangedString, m_current_text, |
| 245 | m_current_text.size()); | 245 | m_current_text.size()); |
| 246 | break; | 246 | break; |
| 247 | } | 247 | } |
diff --git a/src/android/app/src/main/jni/applets/software_keyboard.h b/src/android/app/src/main/jni/applets/software_keyboard.h index b2fb59b68..2affc01f6 100644 --- a/src/android/app/src/main/jni/applets/software_keyboard.h +++ b/src/android/app/src/main/jni/applets/software_keyboard.h | |||
| @@ -24,7 +24,7 @@ public: | |||
| 24 | 24 | ||
| 25 | void ShowNormalKeyboard() const override; | 25 | void ShowNormalKeyboard() const override; |
| 26 | 26 | ||
| 27 | void ShowTextCheckDialog(Service::AM::Applets::SwkbdTextCheckResult text_check_result, | 27 | void ShowTextCheckDialog(Service::AM::Frontend::SwkbdTextCheckResult text_check_result, |
| 28 | std::u16string text_check_message) const override; | 28 | std::u16string text_check_message) const override; |
| 29 | 29 | ||
| 30 | void ShowInlineKeyboard( | 30 | void ShowInlineKeyboard( |
| @@ -45,7 +45,7 @@ private: | |||
| 45 | static ResultData CreateFromFrontend(jobject object); | 45 | static ResultData CreateFromFrontend(jobject object); |
| 46 | 46 | ||
| 47 | std::string text; | 47 | std::string text; |
| 48 | Service::AM::Applets::SwkbdResult result{}; | 48 | Service::AM::Frontend::SwkbdResult result{}; |
| 49 | }; | 49 | }; |
| 50 | 50 | ||
| 51 | void SubmitNormalText(const ResultData& result) const; | 51 | void SubmitNormalText(const ResultData& result) const; |
diff --git a/src/android/app/src/main/jni/native.cpp b/src/android/app/src/main/jni/native.cpp index 64627db88..654510129 100644 --- a/src/android/app/src/main/jni/native.cpp +++ b/src/android/app/src/main/jni/native.cpp | |||
| @@ -42,14 +42,15 @@ | |||
| 42 | #include "core/frontend/applets/cabinet.h" | 42 | #include "core/frontend/applets/cabinet.h" |
| 43 | #include "core/frontend/applets/controller.h" | 43 | #include "core/frontend/applets/controller.h" |
| 44 | #include "core/frontend/applets/error.h" | 44 | #include "core/frontend/applets/error.h" |
| 45 | #include "core/frontend/applets/general_frontend.h" | 45 | #include "core/frontend/applets/general.h" |
| 46 | #include "core/frontend/applets/mii_edit.h" | 46 | #include "core/frontend/applets/mii_edit.h" |
| 47 | #include "core/frontend/applets/profile_select.h" | 47 | #include "core/frontend/applets/profile_select.h" |
| 48 | #include "core/frontend/applets/software_keyboard.h" | 48 | #include "core/frontend/applets/software_keyboard.h" |
| 49 | #include "core/frontend/applets/web_browser.h" | 49 | #include "core/frontend/applets/web_browser.h" |
| 50 | #include "core/hle/service/am/applet_ae.h" | 50 | #include "core/hle/service/am/applet_ae.h" |
| 51 | #include "core/hle/service/am/applet_manager.h" | ||
| 51 | #include "core/hle/service/am/applet_oe.h" | 52 | #include "core/hle/service/am/applet_oe.h" |
| 52 | #include "core/hle/service/am/applets/applets.h" | 53 | #include "core/hle/service/am/frontend/applets.h" |
| 53 | #include "core/hle/service/filesystem/filesystem.h" | 54 | #include "core/hle/service/filesystem/filesystem.h" |
| 54 | #include "core/loader/loader.h" | 55 | #include "core/loader/loader.h" |
| 55 | #include "frontend_common/config.h" | 56 | #include "frontend_common/config.h" |
| @@ -211,8 +212,15 @@ void EmulationSession::InitializeSystem(bool reload) { | |||
| 211 | m_system.GetFileSystemController().CreateFactories(*m_vfs); | 212 | m_system.GetFileSystemController().CreateFactories(*m_vfs); |
| 212 | } | 213 | } |
| 213 | 214 | ||
| 215 | void EmulationSession::SetAppletId(int applet_id) { | ||
| 216 | m_applet_id = applet_id; | ||
| 217 | m_system.GetFrontendAppletHolder().SetCurrentAppletId( | ||
| 218 | static_cast<Service::AM::AppletId>(m_applet_id)); | ||
| 219 | } | ||
| 220 | |||
| 214 | Core::SystemResultStatus EmulationSession::InitializeEmulation(const std::string& filepath, | 221 | Core::SystemResultStatus EmulationSession::InitializeEmulation(const std::string& filepath, |
| 215 | const std::size_t program_index) { | 222 | const std::size_t program_index, |
| 223 | const bool frontend_initiated) { | ||
| 216 | std::scoped_lock lock(m_mutex); | 224 | std::scoped_lock lock(m_mutex); |
| 217 | 225 | ||
| 218 | // Create the render window. | 226 | // Create the render window. |
| @@ -226,7 +234,7 @@ Core::SystemResultStatus EmulationSession::InitializeEmulation(const std::string | |||
| 226 | m_system.ApplySettings(); | 234 | m_system.ApplySettings(); |
| 227 | Settings::LogSettings(); | 235 | Settings::LogSettings(); |
| 228 | m_system.HIDCore().ReloadInputDevices(); | 236 | m_system.HIDCore().ReloadInputDevices(); |
| 229 | m_system.SetAppletFrontendSet({ | 237 | m_system.SetFrontendAppletSet({ |
| 230 | nullptr, // Amiibo Settings | 238 | nullptr, // Amiibo Settings |
| 231 | nullptr, // Controller Selector | 239 | nullptr, // Controller Selector |
| 232 | nullptr, // Error Display | 240 | nullptr, // Error Display |
| @@ -242,8 +250,13 @@ Core::SystemResultStatus EmulationSession::InitializeEmulation(const std::string | |||
| 242 | ConfigureFilesystemProvider(filepath); | 250 | ConfigureFilesystemProvider(filepath); |
| 243 | 251 | ||
| 244 | // Load the ROM. | 252 | // Load the ROM. |
| 245 | m_load_result = | 253 | Service::AM::FrontendAppletParameters params{ |
| 246 | m_system.Load(EmulationSession::GetInstance().Window(), filepath, 0, program_index); | 254 | .applet_id = static_cast<Service::AM::AppletId>(m_applet_id), |
| 255 | .launch_type = frontend_initiated ? Service::AM::LaunchType::FrontendInitiated | ||
| 256 | : Service::AM::LaunchType::ApplicationInitiated, | ||
| 257 | .program_index = static_cast<s32>(program_index), | ||
| 258 | }; | ||
| 259 | m_load_result = m_system.Load(EmulationSession::GetInstance().Window(), filepath, params); | ||
| 247 | if (m_load_result != Core::SystemResultStatus::Success) { | 260 | if (m_load_result != Core::SystemResultStatus::Success) { |
| 248 | return m_load_result; | 261 | return m_load_result; |
| 249 | } | 262 | } |
| @@ -339,6 +352,9 @@ void EmulationSession::RunEmulation() { | |||
| 339 | } | 352 | } |
| 340 | } | 353 | } |
| 341 | } | 354 | } |
| 355 | |||
| 356 | // Reset current applet ID. | ||
| 357 | m_applet_id = static_cast<int>(Service::AM::AppletId::Application); | ||
| 342 | } | 358 | } |
| 343 | 359 | ||
| 344 | bool EmulationSession::IsHandheldOnly() { | 360 | bool EmulationSession::IsHandheldOnly() { |
| @@ -434,7 +450,8 @@ u64 EmulationSession::GetProgramId(JNIEnv* env, jstring jprogramId) { | |||
| 434 | } | 450 | } |
| 435 | 451 | ||
| 436 | static Core::SystemResultStatus RunEmulation(const std::string& filepath, | 452 | static Core::SystemResultStatus RunEmulation(const std::string& filepath, |
| 437 | const size_t program_index = 0) { | 453 | const size_t program_index, |
| 454 | const bool frontend_initiated) { | ||
| 438 | MicroProfileOnThreadCreate("EmuThread"); | 455 | MicroProfileOnThreadCreate("EmuThread"); |
| 439 | SCOPE_EXIT({ MicroProfileShutdown(); }); | 456 | SCOPE_EXIT({ MicroProfileShutdown(); }); |
| 440 | 457 | ||
| @@ -447,7 +464,8 @@ static Core::SystemResultStatus RunEmulation(const std::string& filepath, | |||
| 447 | 464 | ||
| 448 | SCOPE_EXIT({ EmulationSession::GetInstance().ShutdownEmulation(); }); | 465 | SCOPE_EXIT({ EmulationSession::GetInstance().ShutdownEmulation(); }); |
| 449 | 466 | ||
| 450 | jconst result = EmulationSession::GetInstance().InitializeEmulation(filepath, program_index); | 467 | jconst result = EmulationSession::GetInstance().InitializeEmulation(filepath, program_index, |
| 468 | frontend_initiated); | ||
| 451 | if (result != Core::SystemResultStatus::Success) { | 469 | if (result != Core::SystemResultStatus::Success) { |
| 452 | return result; | 470 | return result; |
| 453 | } | 471 | } |
| @@ -744,10 +762,12 @@ void Java_org_yuzu_yuzu_1emu_NativeLibrary_logSettings(JNIEnv* env, jobject jobj | |||
| 744 | } | 762 | } |
| 745 | 763 | ||
| 746 | void Java_org_yuzu_yuzu_1emu_NativeLibrary_run(JNIEnv* env, jobject jobj, jstring j_path, | 764 | void Java_org_yuzu_yuzu_1emu_NativeLibrary_run(JNIEnv* env, jobject jobj, jstring j_path, |
| 747 | jint j_program_index) { | 765 | jint j_program_index, |
| 766 | jboolean j_frontend_initiated) { | ||
| 748 | const std::string path = GetJString(env, j_path); | 767 | const std::string path = GetJString(env, j_path); |
| 749 | 768 | ||
| 750 | const Core::SystemResultStatus result{RunEmulation(path, j_program_index)}; | 769 | const Core::SystemResultStatus result{ |
| 770 | RunEmulation(path, j_program_index, j_frontend_initiated)}; | ||
| 751 | if (result != Core::SystemResultStatus::Success) { | 771 | if (result != Core::SystemResultStatus::Success) { |
| 752 | env->CallStaticVoidMethod(IDCache::GetNativeLibraryClass(), | 772 | env->CallStaticVoidMethod(IDCache::GetNativeLibraryClass(), |
| 753 | IDCache::GetExitEmulationActivity(), static_cast<int>(result)); | 773 | IDCache::GetExitEmulationActivity(), static_cast<int>(result)); |
| @@ -809,13 +829,12 @@ jstring Java_org_yuzu_yuzu_1emu_NativeLibrary_getAppletLaunchPath(JNIEnv* env, j | |||
| 809 | 829 | ||
| 810 | void Java_org_yuzu_yuzu_1emu_NativeLibrary_setCurrentAppletId(JNIEnv* env, jclass clazz, | 830 | void Java_org_yuzu_yuzu_1emu_NativeLibrary_setCurrentAppletId(JNIEnv* env, jclass clazz, |
| 811 | jint jappletId) { | 831 | jint jappletId) { |
| 812 | EmulationSession::GetInstance().System().GetAppletManager().SetCurrentAppletId( | 832 | EmulationSession::GetInstance().SetAppletId(jappletId); |
| 813 | static_cast<Service::AM::Applets::AppletId>(jappletId)); | ||
| 814 | } | 833 | } |
| 815 | 834 | ||
| 816 | void Java_org_yuzu_yuzu_1emu_NativeLibrary_setCabinetMode(JNIEnv* env, jclass clazz, | 835 | void Java_org_yuzu_yuzu_1emu_NativeLibrary_setCabinetMode(JNIEnv* env, jclass clazz, |
| 817 | jint jcabinetMode) { | 836 | jint jcabinetMode) { |
| 818 | EmulationSession::GetInstance().System().GetAppletManager().SetCabinetMode( | 837 | EmulationSession::GetInstance().System().GetFrontendAppletHolder().SetCabinetMode( |
| 819 | static_cast<Service::NFP::CabinetMode>(jcabinetMode)); | 838 | static_cast<Service::NFP::CabinetMode>(jcabinetMode)); |
| 820 | } | 839 | } |
| 821 | 840 | ||
diff --git a/src/android/app/src/main/jni/native.h b/src/android/app/src/main/jni/native.h index bfe3fccca..e49d4e015 100644 --- a/src/android/app/src/main/jni/native.h +++ b/src/android/app/src/main/jni/native.h | |||
| @@ -45,8 +45,10 @@ public: | |||
| 45 | const Core::PerfStatsResults& PerfStats(); | 45 | const Core::PerfStatsResults& PerfStats(); |
| 46 | void ConfigureFilesystemProvider(const std::string& filepath); | 46 | void ConfigureFilesystemProvider(const std::string& filepath); |
| 47 | void InitializeSystem(bool reload); | 47 | void InitializeSystem(bool reload); |
| 48 | void SetAppletId(int applet_id); | ||
| 48 | Core::SystemResultStatus InitializeEmulation(const std::string& filepath, | 49 | Core::SystemResultStatus InitializeEmulation(const std::string& filepath, |
| 49 | const std::size_t program_index = 0); | 50 | const std::size_t program_index, |
| 51 | const bool frontend_initiated); | ||
| 50 | 52 | ||
| 51 | bool IsHandheldOnly(); | 53 | bool IsHandheldOnly(); |
| 52 | void SetDeviceType([[maybe_unused]] int index, int type); | 54 | void SetDeviceType([[maybe_unused]] int index, int type); |
| @@ -79,6 +81,7 @@ private: | |||
| 79 | std::atomic<bool> m_is_paused = false; | 81 | std::atomic<bool> m_is_paused = false; |
| 80 | SoftwareKeyboard::AndroidKeyboard* m_software_keyboard{}; | 82 | SoftwareKeyboard::AndroidKeyboard* m_software_keyboard{}; |
| 81 | std::unique_ptr<FileSys::ManualContentProvider> m_manual_provider; | 83 | std::unique_ptr<FileSys::ManualContentProvider> m_manual_provider; |
| 84 | int m_applet_id{1}; | ||
| 82 | 85 | ||
| 83 | // GPU driver parameters | 86 | // GPU driver parameters |
| 84 | std::shared_ptr<Common::DynamicLibrary> m_vulkan_library; | 87 | std::shared_ptr<Common::DynamicLibrary> m_vulkan_library; |