summaryrefslogtreecommitdiff
path: root/src/common/android/id_cache.h
diff options
context:
space:
mode:
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 @@
1// SPDX-FileCopyrightText: 2023 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-3.0-or-later
3
4#pragma once
5
6#include <future>
7#include <jni.h>
8
9#include "video_core/rasterizer_interface.h"
10
11namespace Common::Android {
12
13JNIEnv* GetEnvForThread();
14
15/**
16 * Starts a new thread to run JNI. Intended to be used when you must run JNI from a fiber.
17 * @tparam T Typename of the return value for the work param
18 * @param work Lambda that runs JNI code. This function will take care of attaching this thread to
19 * the JVM
20 * @return The result from the work lambda param
21 */
22template <typename T = void>
23T RunJNIOnFiber(const std::function<T(JNIEnv*)>& work) {
24 std::future<T> j_result = std::async(std::launch::async, [&] {
25 auto env = GetEnvForThread();
26 return work(env);
27 });
28 return j_result.get();
29}
30
31jclass GetNativeLibraryClass();
32
33jclass GetDiskCacheProgressClass();
34jclass GetDiskCacheLoadCallbackStageClass();
35jclass GetGameDirClass();
36jmethodID GetGameDirConstructor();
37jmethodID GetDiskCacheLoadProgress();
38
39jmethodID GetExitEmulationActivity();
40jmethodID GetOnEmulationStarted();
41jmethodID GetOnEmulationStopped();
42jmethodID GetOnProgramChanged();
43
44jclass GetGameClass();
45jmethodID GetGameConstructor();
46jfieldID GetGameTitleField();
47jfieldID GetGamePathField();
48jfieldID GetGameProgramIdField();
49jfieldID GetGameDeveloperField();
50jfieldID GetGameVersionField();
51jfieldID GetGameIsHomebrewField();
52
53jclass GetStringClass();
54jclass GetPairClass();
55jmethodID GetPairConstructor();
56jfieldID GetPairFirstField();
57jfieldID GetPairSecondField();
58
59jclass GetOverlayControlDataClass();
60jmethodID GetOverlayControlDataConstructor();
61jfieldID GetOverlayControlDataIdField();
62jfieldID GetOverlayControlDataEnabledField();
63jfieldID GetOverlayControlDataLandscapePositionField();
64jfieldID GetOverlayControlDataPortraitPositionField();
65jfieldID GetOverlayControlDataFoldablePositionField();
66
67jclass GetPatchClass();
68jmethodID GetPatchConstructor();
69jfieldID GetPatchEnabledField();
70jfieldID GetPatchNameField();
71jfieldID GetPatchVersionField();
72jfieldID GetPatchTypeField();
73jfieldID GetPatchProgramIdField();
74jfieldID GetPatchTitleIdField();
75
76jclass GetDoubleClass();
77jmethodID GetDoubleConstructor();
78jfieldID GetDoubleValueField();
79
80jclass GetIntegerClass();
81jmethodID GetIntegerConstructor();
82jfieldID GetIntegerValueField();
83
84jclass GetBooleanClass();
85jmethodID GetBooleanConstructor();
86jfieldID GetBooleanValueField();
87
88} // namespace Common::Android