diff options
Diffstat (limited to 'src/common/android/id_cache.h')
| -rw-r--r-- | src/common/android/id_cache.h | 88 |
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 | |||
| 11 | namespace Common::Android { | ||
| 12 | |||
| 13 | JNIEnv* 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 | */ | ||
| 22 | template <typename T = void> | ||
| 23 | T 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 | |||
| 31 | jclass GetNativeLibraryClass(); | ||
| 32 | |||
| 33 | jclass GetDiskCacheProgressClass(); | ||
| 34 | jclass GetDiskCacheLoadCallbackStageClass(); | ||
| 35 | jclass GetGameDirClass(); | ||
| 36 | jmethodID GetGameDirConstructor(); | ||
| 37 | jmethodID GetDiskCacheLoadProgress(); | ||
| 38 | |||
| 39 | jmethodID GetExitEmulationActivity(); | ||
| 40 | jmethodID GetOnEmulationStarted(); | ||
| 41 | jmethodID GetOnEmulationStopped(); | ||
| 42 | jmethodID GetOnProgramChanged(); | ||
| 43 | |||
| 44 | jclass GetGameClass(); | ||
| 45 | jmethodID GetGameConstructor(); | ||
| 46 | jfieldID GetGameTitleField(); | ||
| 47 | jfieldID GetGamePathField(); | ||
| 48 | jfieldID GetGameProgramIdField(); | ||
| 49 | jfieldID GetGameDeveloperField(); | ||
| 50 | jfieldID GetGameVersionField(); | ||
| 51 | jfieldID GetGameIsHomebrewField(); | ||
| 52 | |||
| 53 | jclass GetStringClass(); | ||
| 54 | jclass GetPairClass(); | ||
| 55 | jmethodID GetPairConstructor(); | ||
| 56 | jfieldID GetPairFirstField(); | ||
| 57 | jfieldID GetPairSecondField(); | ||
| 58 | |||
| 59 | jclass GetOverlayControlDataClass(); | ||
| 60 | jmethodID GetOverlayControlDataConstructor(); | ||
| 61 | jfieldID GetOverlayControlDataIdField(); | ||
| 62 | jfieldID GetOverlayControlDataEnabledField(); | ||
| 63 | jfieldID GetOverlayControlDataLandscapePositionField(); | ||
| 64 | jfieldID GetOverlayControlDataPortraitPositionField(); | ||
| 65 | jfieldID GetOverlayControlDataFoldablePositionField(); | ||
| 66 | |||
| 67 | jclass GetPatchClass(); | ||
| 68 | jmethodID GetPatchConstructor(); | ||
| 69 | jfieldID GetPatchEnabledField(); | ||
| 70 | jfieldID GetPatchNameField(); | ||
| 71 | jfieldID GetPatchVersionField(); | ||
| 72 | jfieldID GetPatchTypeField(); | ||
| 73 | jfieldID GetPatchProgramIdField(); | ||
| 74 | jfieldID GetPatchTitleIdField(); | ||
| 75 | |||
| 76 | jclass GetDoubleClass(); | ||
| 77 | jmethodID GetDoubleConstructor(); | ||
| 78 | jfieldID GetDoubleValueField(); | ||
| 79 | |||
| 80 | jclass GetIntegerClass(); | ||
| 81 | jmethodID GetIntegerConstructor(); | ||
| 82 | jfieldID GetIntegerValueField(); | ||
| 83 | |||
| 84 | jclass GetBooleanClass(); | ||
| 85 | jmethodID GetBooleanConstructor(); | ||
| 86 | jfieldID GetBooleanValueField(); | ||
| 87 | |||
| 88 | } // namespace Common::Android | ||