Android: Implement basic read-only cheats list

This commit is contained in:
JosJuice
2021-07-17 19:47:11 +02:00
parent ee3a5a4a81
commit 4d609c769f
19 changed files with 636 additions and 0 deletions

View File

@ -58,6 +58,18 @@ static jmethodID s_network_helper_get_network_gateway;
static jclass s_boolean_supplier_class;
static jmethodID s_boolean_supplier_get;
static jclass s_ar_cheat_class;
static jfieldID s_ar_cheat_pointer;
static jmethodID s_ar_cheat_constructor;
static jclass s_gecko_cheat_class;
static jfieldID s_gecko_cheat_pointer;
static jmethodID s_gecko_cheat_constructor;
static jclass s_patch_cheat_class;
static jfieldID s_patch_cheat_pointer;
static jmethodID s_patch_cheat_constructor;
namespace IDCache
{
JNIEnv* GetEnvForThread()
@ -268,6 +280,51 @@ jmethodID GetBooleanSupplierGet()
return s_boolean_supplier_get;
}
jclass GetARCheatClass()
{
return s_ar_cheat_class;
}
jfieldID GetARCheatPointer()
{
return s_ar_cheat_pointer;
}
jmethodID GetARCheatConstructor()
{
return s_ar_cheat_constructor;
}
jclass GetGeckoCheatClass()
{
return s_gecko_cheat_class;
}
jfieldID GetGeckoCheatPointer()
{
return s_gecko_cheat_pointer;
}
jmethodID GetGeckoCheatConstructor()
{
return s_gecko_cheat_constructor;
}
jclass GetPatchCheatClass()
{
return s_patch_cheat_class;
}
jfieldID GetPatchCheatPointer()
{
return s_patch_cheat_pointer;
}
jmethodID GetPatchCheatConstructor()
{
return s_patch_cheat_constructor;
}
} // namespace IDCache
extern "C" {
@ -376,6 +433,27 @@ JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved)
s_boolean_supplier_get = env->GetMethodID(s_boolean_supplier_class, "get", "()Z");
env->DeleteLocalRef(boolean_supplier_class);
const jclass ar_cheat_class =
env->FindClass("org/dolphinemu/dolphinemu/features/cheats/model/ARCheat");
s_ar_cheat_class = reinterpret_cast<jclass>(env->NewGlobalRef(ar_cheat_class));
s_ar_cheat_pointer = env->GetFieldID(ar_cheat_class, "mPointer", "J");
s_ar_cheat_constructor = env->GetMethodID(ar_cheat_class, "<init>", "(J)V");
env->DeleteLocalRef(ar_cheat_class);
const jclass gecko_cheat_class =
env->FindClass("org/dolphinemu/dolphinemu/features/cheats/model/GeckoCheat");
s_gecko_cheat_class = reinterpret_cast<jclass>(env->NewGlobalRef(gecko_cheat_class));
s_gecko_cheat_pointer = env->GetFieldID(gecko_cheat_class, "mPointer", "J");
s_gecko_cheat_constructor = env->GetMethodID(gecko_cheat_class, "<init>", "(J)V");
env->DeleteLocalRef(gecko_cheat_class);
const jclass patch_cheat_class =
env->FindClass("org/dolphinemu/dolphinemu/features/cheats/model/PatchCheat");
s_patch_cheat_class = reinterpret_cast<jclass>(env->NewGlobalRef(patch_cheat_class));
s_patch_cheat_pointer = env->GetFieldID(patch_cheat_class, "mPointer", "J");
s_patch_cheat_constructor = env->GetMethodID(patch_cheat_class, "<init>", "(J)V");
env->DeleteLocalRef(patch_cheat_class);
return JNI_VERSION;
}
@ -396,5 +474,8 @@ JNIEXPORT void JNI_OnUnload(JavaVM* vm, void* reserved)
env->DeleteGlobalRef(s_content_handler_class);
env->DeleteGlobalRef(s_network_helper_class);
env->DeleteGlobalRef(s_boolean_supplier_class);
env->DeleteGlobalRef(s_ar_cheat_class);
env->DeleteGlobalRef(s_gecko_cheat_class);
env->DeleteGlobalRef(s_patch_cheat_class);
}
}