mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-06-09 12:31:40 +12:00
Clean up smdh getting
This commit is contained in:
parent
74e8f7d4eb
commit
3aa977c6c5
9 changed files with 45 additions and 52 deletions
|
@ -1,5 +1,3 @@
|
|||
#include "jni_driver.hpp"
|
||||
|
||||
#include <EGL/egl.h>
|
||||
#include <android/log.h>
|
||||
#include <jni.h>
|
||||
|
@ -15,7 +13,6 @@ HIDService* hidService = nullptr;
|
|||
RendererGL* renderer = nullptr;
|
||||
bool romLoaded = false;
|
||||
JavaVM* jvm = nullptr;
|
||||
const char* alberClass = "com/panda3ds/pandroid/AlberDriver";
|
||||
|
||||
#define AlberFunction(type, name) JNIEXPORT type JNICALL Java_com_panda3ds_pandroid_AlberDriver_##name
|
||||
|
||||
|
@ -36,20 +33,6 @@ JNIEnv* jniEnv() {
|
|||
return env;
|
||||
}
|
||||
|
||||
void Pandroid::onSmdhLoaded(const std::vector<u8>& smdh) {
|
||||
JNIEnv* env = jniEnv();
|
||||
int size = smdh.size();
|
||||
|
||||
jbyteArray result = env->NewByteArray(size);
|
||||
env->SetByteArrayRegion(result, 0, size, (jbyte*)smdh.data());
|
||||
|
||||
auto classLoader = env->FindClass(alberClass);
|
||||
auto method = env->GetStaticMethodID(classLoader, "OnSmdhLoaded", "([B)V");
|
||||
|
||||
env->CallStaticVoidMethod(classLoader, method, result);
|
||||
env->DeleteLocalRef(result);
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
||||
AlberFunction(void, Setup)(JNIEnv* env, jobject obj) { env->GetJavaVM(&jvm); }
|
||||
|
@ -104,6 +87,15 @@ AlberFunction(void, SetCirclepadAxis)(JNIEnv* env, jobject obj, jint x, jint y)
|
|||
hidService->setCirclepadX((s16)x);
|
||||
hidService->setCirclepadY((s16)y);
|
||||
}
|
||||
|
||||
AlberFunction(jbyteArray, GetSmdh)(JNIEnv* env, jobject obj) {
|
||||
std::span<u8> smdh = emulator->getSMDH();
|
||||
|
||||
jbyteArray result = env->NewByteArray(smdh.size());
|
||||
env->SetByteArrayRegion(result, 0, smdh.size(), (jbyte*)smdh.data());
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
#undef AlberFunction
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue