summaryrefslogtreecommitdiffstats
path: root/src/android
diff options
context:
space:
mode:
authorLiam <byteslice@airmail.cc>2024-01-03 00:26:53 +0100
committerLiam <byteslice@airmail.cc>2024-01-30 02:17:09 +0100
commit3155f4e96d10904f4a207e465f20fb4b25043f5c (patch)
tree849388480f5b7bb17f07a259b3f3661eeca99f61 /src/android
parentam: re-namespace frontend applets to frontend directory (diff)
downloadyuzu-3155f4e96d10904f4a207e465f20fb4b25043f5c.tar
yuzu-3155f4e96d10904f4a207e465f20fb4b25043f5c.tar.gz
yuzu-3155f4e96d10904f4a207e465f20fb4b25043f5c.tar.bz2
yuzu-3155f4e96d10904f4a207e465f20fb4b25043f5c.tar.lz
yuzu-3155f4e96d10904f4a207e465f20fb4b25043f5c.tar.xz
yuzu-3155f4e96d10904f4a207e465f20fb4b25043f5c.tar.zst
yuzu-3155f4e96d10904f4a207e465f20fb4b25043f5c.zip
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 {
/**
* 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/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 @@
#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/frontend/applets.h"
#include "core/hle/service/filesystem/filesystem.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.
@@ -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,8 +829,7 @@ 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().GetFrontendAppletHolder().SetCurrentAppletId(
- static_cast<Service::AM::AppletId>(jappletId));
+ EmulationSession::GetInstance().SetAppletId(jappletId);
}
void 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:
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;