summaryrefslogtreecommitdiffstats
path: root/src/common/android/id_cache.h
diff options
context:
space:
mode:
authorliamwhite <liamwhite@users.noreply.github.com>2024-02-09 17:49:25 +0100
committerGitHub <noreply@github.com>2024-02-09 17:49:25 +0100
commit7ec7ff0f303504950e4270e91076a33efd0ceb17 (patch)
tree1e8346f775550eefd491aa8280412d86000dd637 /src/common/android/id_cache.h
parentMerge pull request #12927 from german77/cheat-pause (diff)
parentandroid: Run OnEmulationStarted frontend callback in another thread (diff)
downloadyuzu-7ec7ff0f303504950e4270e91076a33efd0ceb17.tar
yuzu-7ec7ff0f303504950e4270e91076a33efd0ceb17.tar.gz
yuzu-7ec7ff0f303504950e4270e91076a33efd0ceb17.tar.bz2
yuzu-7ec7ff0f303504950e4270e91076a33efd0ceb17.tar.lz
yuzu-7ec7ff0f303504950e4270e91076a33efd0ceb17.tar.xz
yuzu-7ec7ff0f303504950e4270e91076a33efd0ceb17.tar.zst
yuzu-7ec7ff0f303504950e4270e91076a33efd0ceb17.zip
Diffstat (limited to 'src/common/android/id_cache.h')
-rw-r--r--src/common/android/id_cache.h88
1 files changed, 88 insertions, 0 deletions
diff --git a/src/common/android/id_cache.h b/src/common/android/id_cache.h
new file mode 100644
index 000000000..47802f96c
--- /dev/null
+++ b/src/common/android/id_cache.h
@@ -0,0 +1,88 @@
+// SPDX-FileCopyrightText: 2023 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+#pragma once
+
+#include <future>
+#include <jni.h>
+
+#include "video_core/rasterizer_interface.h"
+
+namespace Common::Android {
+
+JNIEnv* GetEnvForThread();
+
+/**
+ * Starts a new thread to run JNI. Intended to be used when you must run JNI from a fiber.
+ * @tparam T Typename of the return value for the work param
+ * @param work Lambda that runs JNI code. This function will take care of attaching this thread to
+ * the JVM
+ * @return The result from the work lambda param
+ */
+template <typename T = void>
+T RunJNIOnFiber(const std::function<T(JNIEnv*)>& work) {
+ std::future<T> j_result = std::async(std::launch::async, [&] {
+ auto env = GetEnvForThread();
+ return work(env);
+ });
+ return j_result.get();
+}
+
+jclass GetNativeLibraryClass();
+
+jclass GetDiskCacheProgressClass();
+jclass GetDiskCacheLoadCallbackStageClass();
+jclass GetGameDirClass();
+jmethodID GetGameDirConstructor();
+jmethodID GetDiskCacheLoadProgress();
+
+jmethodID GetExitEmulationActivity();
+jmethodID GetOnEmulationStarted();
+jmethodID GetOnEmulationStopped();
+jmethodID GetOnProgramChanged();
+
+jclass GetGameClass();
+jmethodID GetGameConstructor();
+jfieldID GetGameTitleField();
+jfieldID GetGamePathField();
+jfieldID GetGameProgramIdField();
+jfieldID GetGameDeveloperField();
+jfieldID GetGameVersionField();
+jfieldID GetGameIsHomebrewField();
+
+jclass GetStringClass();
+jclass GetPairClass();
+jmethodID GetPairConstructor();
+jfieldID GetPairFirstField();
+jfieldID GetPairSecondField();
+
+jclass GetOverlayControlDataClass();
+jmethodID GetOverlayControlDataConstructor();
+jfieldID GetOverlayControlDataIdField();
+jfieldID GetOverlayControlDataEnabledField();
+jfieldID GetOverlayControlDataLandscapePositionField();
+jfieldID GetOverlayControlDataPortraitPositionField();
+jfieldID GetOverlayControlDataFoldablePositionField();
+
+jclass GetPatchClass();
+jmethodID GetPatchConstructor();
+jfieldID GetPatchEnabledField();
+jfieldID GetPatchNameField();
+jfieldID GetPatchVersionField();
+jfieldID GetPatchTypeField();
+jfieldID GetPatchProgramIdField();
+jfieldID GetPatchTitleIdField();
+
+jclass GetDoubleClass();
+jmethodID GetDoubleConstructor();
+jfieldID GetDoubleValueField();
+
+jclass GetIntegerClass();
+jmethodID GetIntegerConstructor();
+jfieldID GetIntegerValueField();
+
+jclass GetBooleanClass();
+jmethodID GetBooleanConstructor();
+jfieldID GetBooleanValueField();
+
+} // namespace Common::Android