diff options
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 { /** * Begins emulation. */ - external fun run(path: String?, programIndex: Int = 0) + external fun run(path: String?, programIndex: Int, frontendInitiated: Boolean) // Surface Handling 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 { emulationThread.join() emulationThread = Thread({ Log.debug("[EmulationFragment] Starting emulation thread.") - NativeLibrary.run(gamePath, programIndex) + NativeLibrary.run(gamePath, programIndex, false) }, "NativeEmulation") emulationThread.start() } @@ -981,7 +981,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { State.STOPPED -> { emulationThread = Thread({ Log.debug("[EmulationFragment] Starting emulation thread.") - NativeLibrary.run(gamePath, programIndex) + NativeLibrary.run(gamePath, programIndex, true) }, "NativeEmulation") emulationThread.start() } 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 const jstring string = reinterpret_cast<jstring>(env->GetObjectField( object, env->GetFieldID(s_keyboard_data_class, "text", "Ljava/lang/String;"))); return ResultData{GetJString(env, string), - static_cast<Service::AM::Applets::SwkbdResult>(env->GetIntField( + static_cast<Service::AM::Frontend::SwkbdResult>(env->GetIntField( object, env->GetFieldID(s_keyboard_data_class, "result", "I")))}; } @@ -149,7 +149,7 @@ void AndroidKeyboard::ShowNormalKeyboard() const { } void AndroidKeyboard::ShowTextCheckDialog( - Service::AM::Applets::SwkbdTextCheckResult text_check_result, + Service::AM::Frontend::SwkbdTextCheckResult text_check_result, std::u16string text_check_message) const { LOG_WARNING(Frontend, "(STUBBED) called, backend requested to show the text check dialog."); } @@ -204,7 +204,7 @@ void AndroidKeyboard::InlineTextChanged( "\ncursor_position={}", Common::UTF16ToUTF8(text_parameters.input_text), text_parameters.cursor_position); - submit_inline_callback(Service::AM::Applets::SwkbdReplyType::ChangedString, + submit_inline_callback(Service::AM::Frontend::SwkbdReplyType::ChangedString, text_parameters.input_text, text_parameters.cursor_position); } @@ -219,7 +219,7 @@ void AndroidKeyboard::SubmitInlineKeyboardText(std::u16string submitted_text) { m_current_text += submitted_text; - submit_inline_callback(Service::AM::Applets::SwkbdReplyType::ChangedString, m_current_text, + submit_inline_callback(Service::AM::Frontend::SwkbdReplyType::ChangedString, m_current_text, m_current_text.size()); } @@ -236,12 +236,12 @@ void AndroidKeyboard::SubmitInlineKeyboardInput(int key_code) { case KEYCODE_BACK: case KEYCODE_ENTER: m_is_inline_active = false; - submit_inline_callback(Service::AM::Applets::SwkbdReplyType::DecidedEnter, m_current_text, + submit_inline_callback(Service::AM::Frontend::SwkbdReplyType::DecidedEnter, m_current_text, static_cast<s32>(m_current_text.size())); break; case KEYCODE_DEL: m_current_text.pop_back(); - submit_inline_callback(Service::AM::Applets::SwkbdReplyType::ChangedString, m_current_text, + submit_inline_callback(Service::AM::Frontend::SwkbdReplyType::ChangedString, m_current_text, m_current_text.size()); break; } 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: void ShowNormalKeyboard() const override; - void ShowTextCheckDialog(Service::AM::Applets::SwkbdTextCheckResult text_check_result, + void ShowTextCheckDialog(Service::AM::Frontend::SwkbdTextCheckResult text_check_result, std::u16string text_check_message) const override; void ShowInlineKeyboard( @@ -45,7 +45,7 @@ private: static ResultData CreateFromFrontend(jobject object); std::string text; - Service::AM::Applets::SwkbdResult result{}; + Service::AM::Frontend::SwkbdResult result{}; }; 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 @@ #include "core/frontend/applets/cabinet.h" #include "core/frontend/applets/controller.h" #include "core/frontend/applets/error.h" -#include "core/frontend/applets/general_frontend.h" +#include "core/frontend/applets/general.h" #include "core/frontend/applets/mii_edit.h" #include "core/frontend/applets/profile_select.h" #include "core/frontend/applets/software_keyboard.h" #include "core/frontend/applets/web_browser.h" #include "core/hle/service/am/applet_ae.h" +#include "core/hle/service/am/applet_manager.h" #include "core/hle/service/am/applet_oe.h" -#include "core/hle/service/am/applets/applets.h" +#include "core/hle/service/am/frontend/applets.h" #include "core/hle/service/filesystem/filesystem.h" #include "core/loader/loader.h" #include "frontend_common/config.h" @@ -211,8 +212,15 @@ void EmulationSession::InitializeSystem(bool reload) { m_system.GetFileSystemController().CreateFactories(*m_vfs); } +void EmulationSession::SetAppletId(int applet_id) { + m_applet_id = applet_id; + m_system.GetFrontendAppletHolder().SetCurrentAppletId( + static_cast<Service::AM::AppletId>(m_applet_id)); +} + Core::SystemResultStatus EmulationSession::InitializeEmulation(const std::string& filepath, - const std::size_t program_index) { + const std::size_t program_index, + const bool frontend_initiated) { std::scoped_lock lock(m_mutex); // Create the render window. @@ -226,7 +234,7 @@ Core::SystemResultStatus EmulationSession::InitializeEmulation(const std::string m_system.ApplySettings(); Settings::LogSettings(); m_system.HIDCore().ReloadInputDevices(); - m_system.SetAppletFrontendSet({ + m_system.SetFrontendAppletSet({ nullptr, // Amiibo Settings nullptr, // Controller Selector nullptr, // Error Display @@ -242,8 +250,13 @@ Core::SystemResultStatus EmulationSession::InitializeEmulation(const std::string ConfigureFilesystemProvider(filepath); // Load the ROM. - m_load_result = - m_system.Load(EmulationSession::GetInstance().Window(), filepath, 0, program_index); + Service::AM::FrontendAppletParameters params{ + .applet_id = static_cast<Service::AM::AppletId>(m_applet_id), + .launch_type = frontend_initiated ? Service::AM::LaunchType::FrontendInitiated + : Service::AM::LaunchType::ApplicationInitiated, + .program_index = static_cast<s32>(program_index), + }; + m_load_result = m_system.Load(EmulationSession::GetInstance().Window(), filepath, params); if (m_load_result != Core::SystemResultStatus::Success) { return m_load_result; } @@ -339,6 +352,9 @@ void EmulationSession::RunEmulation() { } } } + + // Reset current applet ID. + m_applet_id = static_cast<int>(Service::AM::AppletId::Application); } bool EmulationSession::IsHandheldOnly() { @@ -434,7 +450,8 @@ u64 EmulationSession::GetProgramId(JNIEnv* env, jstring jprogramId) { } static Core::SystemResultStatus RunEmulation(const std::string& filepath, - const size_t program_index = 0) { + const size_t program_index, + const bool frontend_initiated) { MicroProfileOnThreadCreate("EmuThread"); SCOPE_EXIT({ MicroProfileShutdown(); }); @@ -447,7 +464,8 @@ static Core::SystemResultStatus RunEmulation(const std::string& filepath, SCOPE_EXIT({ EmulationSession::GetInstance().ShutdownEmulation(); }); - jconst result = EmulationSession::GetInstance().InitializeEmulation(filepath, program_index); + jconst result = EmulationSession::GetInstance().InitializeEmulation(filepath, program_index, + frontend_initiated); if (result != Core::SystemResultStatus::Success) { return result; } @@ -744,10 +762,12 @@ void Java_org_yuzu_yuzu_1emu_NativeLibrary_logSettings(JNIEnv* env, jobject jobj } void Java_org_yuzu_yuzu_1emu_NativeLibrary_run(JNIEnv* env, jobject jobj, jstring j_path, - jint j_program_index) { + jint j_program_index, + jboolean j_frontend_initiated) { const std::string path = GetJString(env, j_path); - const Core::SystemResultStatus result{RunEmulation(path, j_program_index)}; + const Core::SystemResultStatus result{ + RunEmulation(path, j_program_index, j_frontend_initiated)}; if (result != Core::SystemResultStatus::Success) { env->CallStaticVoidMethod(IDCache::GetNativeLibraryClass(), IDCache::GetExitEmulationActivity(), static_cast<int>(result)); @@ -809,13 +829,12 @@ jstring Java_org_yuzu_yuzu_1emu_NativeLibrary_getAppletLaunchPath(JNIEnv* env, j void Java_org_yuzu_yuzu_1emu_NativeLibrary_setCurrentAppletId(JNIEnv* env, jclass clazz, jint jappletId) { - EmulationSession::GetInstance().System().GetAppletManager().SetCurrentAppletId( - static_cast<Service::AM::Applets::AppletId>(jappletId)); + EmulationSession::GetInstance().SetAppletId(jappletId); } void Java_org_yuzu_yuzu_1emu_NativeLibrary_setCabinetMode(JNIEnv* env, jclass clazz, jint jcabinetMode) { - EmulationSession::GetInstance().System().GetAppletManager().SetCabinetMode( + EmulationSession::GetInstance().System().GetFrontendAppletHolder().SetCabinetMode( static_cast<Service::NFP::CabinetMode>(jcabinetMode)); } 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: const Core::PerfStatsResults& PerfStats(); void ConfigureFilesystemProvider(const std::string& filepath); void InitializeSystem(bool reload); + void SetAppletId(int applet_id); Core::SystemResultStatus InitializeEmulation(const std::string& filepath, - const std::size_t program_index = 0); + const std::size_t program_index, + const bool frontend_initiated); bool IsHandheldOnly(); void SetDeviceType([[maybe_unused]] int index, int type); @@ -79,6 +81,7 @@ private: std::atomic<bool> m_is_paused = false; SoftwareKeyboard::AndroidKeyboard* m_software_keyboard{}; std::unique_ptr<FileSys::ManualContentProvider> m_manual_provider; + int m_applet_id{1}; // GPU driver parameters std::shared_ptr<Common::DynamicLibrary> m_vulkan_library; |