From 7c86baee50371da1b9aef84dbfb33ae5b097b311 Mon Sep 17 00:00:00 2001 From: OatmealDome Date: Sun, 9 Jan 2022 15:42:26 -0500 Subject: [PATCH] WiiUpdateCallback: Add interface for update callback --- .../dolphinemu/utils/WiiUpdateCallback.java | 11 ++++++++++ Source/Android/jni/AndroidCommon/IDCache.cpp | 20 +++++++++++++++++++ Source/Android/jni/AndroidCommon/IDCache.h | 3 +++ 3 files changed, 34 insertions(+) create mode 100644 Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/WiiUpdateCallback.java diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/WiiUpdateCallback.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/WiiUpdateCallback.java new file mode 100644 index 0000000000..cd7096974e --- /dev/null +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/WiiUpdateCallback.java @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +package org.dolphinemu.dolphinemu.utils; + +import androidx.annotation.Keep; + +public interface WiiUpdateCallback +{ + @Keep + boolean run(int processed, int total, long titleId); +} diff --git a/Source/Android/jni/AndroidCommon/IDCache.cpp b/Source/Android/jni/AndroidCommon/IDCache.cpp index a5a52a4f36..b125babb81 100644 --- a/Source/Android/jni/AndroidCommon/IDCache.cpp +++ b/Source/Android/jni/AndroidCommon/IDCache.cpp @@ -73,6 +73,9 @@ static jmethodID s_patch_cheat_constructor; static jclass s_riivolution_patches_class; static jfieldID s_riivolution_patches_pointer; +static jclass s_wii_update_cb_class; +static jmethodID s_wii_update_cb_run; + namespace IDCache { JNIEnv* GetEnvForThread() @@ -338,6 +341,16 @@ jfieldID GetRiivolutionPatchesPointer() return s_riivolution_patches_pointer; } +jclass GetWiiUpdateCallbackClass() +{ + return s_wii_update_cb_class; +} + +jmethodID GetWiiUpdateCallbackFunction() +{ + return s_wii_update_cb_run; +} + } // namespace IDCache extern "C" { @@ -474,6 +487,12 @@ JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) s_riivolution_patches_pointer = env->GetFieldID(riivolution_patches_class, "mPointer", "J"); env->DeleteLocalRef(riivolution_patches_class); + const jclass wii_update_cb_class = + env->FindClass("org/dolphinemu/dolphinemu/utils/WiiUpdateCallback"); + s_wii_update_cb_class = reinterpret_cast(env->NewGlobalRef(wii_update_cb_class)); + s_wii_update_cb_run = env->GetMethodID(s_wii_update_cb_class, "run", "(IIJ)Z"); + env->DeleteLocalRef(wii_update_cb_class); + return JNI_VERSION; } @@ -498,5 +517,6 @@ JNIEXPORT void JNI_OnUnload(JavaVM* vm, void* reserved) env->DeleteGlobalRef(s_gecko_cheat_class); env->DeleteGlobalRef(s_patch_cheat_class); env->DeleteGlobalRef(s_riivolution_patches_class); + env->DeleteGlobalRef(s_wii_update_cb_class); } } diff --git a/Source/Android/jni/AndroidCommon/IDCache.h b/Source/Android/jni/AndroidCommon/IDCache.h index 8dc93d60ba..83eaa85894 100644 --- a/Source/Android/jni/AndroidCommon/IDCache.h +++ b/Source/Android/jni/AndroidCommon/IDCache.h @@ -72,4 +72,7 @@ jmethodID GetPatchCheatConstructor(); jclass GetRiivolutionPatchesClass(); jfieldID GetRiivolutionPatchesPointer(); +jclass GetWiiUpdateCallbackClass(); +jmethodID GetWiiUpdateCallbackFunction(); + } // namespace IDCache