summaryrefslogtreecommitdiff
path: root/src/android
diff options
context:
space:
mode:
authorGravatar Liam2024-01-02 18:26:53 -0500
committerGravatar Liam2024-01-29 20:17:09 -0500
commit3155f4e96d10904f4a207e465f20fb4b25043f5c (patch)
tree849388480f5b7bb17f07a259b3f3661eeca99f61 /src/android
parentam: re-namespace frontend applets to frontend directory (diff)
downloadyuzu-3155f4e96d10904f4a207e465f20fb4b25043f5c.tar.gz
yuzu-3155f4e96d10904f4a207e465f20fb4b25043f5c.tar.xz
yuzu-3155f4e96d10904f4a207e465f20fb4b25043f5c.zip
am: retrieve main applet creation info from frontend
Diffstat (limited to 'src/android')
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt2
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt4
-rw-r--r--src/android/app/src/main/jni/native.cpp37
-rw-r--r--src/android/app/src/main/jni/native.h5
4 files changed, 35 insertions, 13 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/native.cpp b/src/android/app/src/main/jni/native.cpp
index 1da510b7a..654510129 100644
--- a/src/android/app/src/main/jni/native.cpp
+++ b/src/android/app/src/main/jni/native.cpp
@@ -48,6 +48,7 @@
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/frontend/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"
@@ -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
215void 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
214Core::SystemResultStatus EmulationSession::InitializeEmulation(const std::string& filepath, 221Core::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.
@@ -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
344bool EmulationSession::IsHandheldOnly() { 360bool EmulationSession::IsHandheldOnly() {
@@ -434,7 +450,8 @@ u64 EmulationSession::GetProgramId(JNIEnv* env, jstring jprogramId) {
434} 450}
435 451
436static Core::SystemResultStatus RunEmulation(const std::string& filepath, 452static 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
746void Java_org_yuzu_yuzu_1emu_NativeLibrary_run(JNIEnv* env, jobject jobj, jstring j_path, 764void 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,8 +829,7 @@ jstring Java_org_yuzu_yuzu_1emu_NativeLibrary_getAppletLaunchPath(JNIEnv* env, j
809 829
810void Java_org_yuzu_yuzu_1emu_NativeLibrary_setCurrentAppletId(JNIEnv* env, jclass clazz, 830void Java_org_yuzu_yuzu_1emu_NativeLibrary_setCurrentAppletId(JNIEnv* env, jclass clazz,
811 jint jappletId) { 831 jint jappletId) {
812 EmulationSession::GetInstance().System().GetFrontendAppletHolder().SetCurrentAppletId( 832 EmulationSession::GetInstance().SetAppletId(jappletId);
813 static_cast<Service::AM::AppletId>(jappletId));
814} 833}
815 834
816void Java_org_yuzu_yuzu_1emu_NativeLibrary_setCabinetMode(JNIEnv* env, jclass clazz, 835void Java_org_yuzu_yuzu_1emu_NativeLibrary_setCabinetMode(JNIEnv* env, jclass clazz,
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;