mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-06-09 12:31:40 +12:00
Game metadata extractor and some fixes
- App not closing on back pressed (AlberInputListener.java) - Extract SMDH from rom. - Extract metadata from SMDH
This commit is contained in:
parent
9ca7e88b6c
commit
c0960dcccd
13 changed files with 370 additions and 16 deletions
|
@ -8,10 +8,14 @@
|
|||
#include "renderer_gl/renderer_gl.hpp"
|
||||
#include "services/hid.hpp"
|
||||
|
||||
#include "jni_driver.hpp"
|
||||
|
||||
std::unique_ptr<Emulator> emulator = nullptr;
|
||||
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
|
||||
|
||||
|
@ -20,7 +24,47 @@ void throwException(JNIEnv* env, const char* message) {
|
|||
env->ThrowNew(exceptionClass, message);
|
||||
}
|
||||
|
||||
JNIEnv* jniEnv(){
|
||||
JNIEnv* env;
|
||||
auto status = jvm->GetEnv((void **)&env, JNI_VERSION_1_6);
|
||||
if(status == JNI_EDETACHED){
|
||||
jvm->AttachCurrentThread(&env, nullptr);
|
||||
} else if(status != JNI_OK){
|
||||
throw std::runtime_error("Failed to obtain JNIEnv from JVM!!");
|
||||
}
|
||||
return env;
|
||||
}
|
||||
|
||||
|
||||
void Pandroid::onSmdhLoaded(const std::vector<u8> &smdh){
|
||||
JNIEnv* env = jniEnv();
|
||||
int size = smdh.size();
|
||||
|
||||
jbyteArray result = env->NewByteArray(size);
|
||||
|
||||
jbyte buffer[size];
|
||||
|
||||
for(int i = 0; i < size; i++){
|
||||
buffer[i] = (jbyte) smdh[i];
|
||||
}
|
||||
env->SetByteArrayRegion(result, 0, size, buffer);
|
||||
|
||||
|
||||
auto clazz = env->FindClass(alberClass);
|
||||
auto method = env->GetStaticMethodID(clazz, "OnSmdhLoaded", "([B)V");
|
||||
|
||||
env->CallStaticVoidMethod(clazz, method, result);
|
||||
|
||||
env->DeleteLocalRef(result);
|
||||
}
|
||||
|
||||
|
||||
extern "C" {
|
||||
|
||||
AlberFunction(void, Setup)(JNIEnv* env, jobject obj) {
|
||||
env->GetJavaVM(&jvm);
|
||||
}
|
||||
|
||||
AlberFunction(void, Initialize)(JNIEnv* env, jobject obj) {
|
||||
emulator = std::make_unique<Emulator>();
|
||||
|
||||
|
@ -73,4 +117,4 @@ AlberFunction(void, SetCirclepadAxis)(JNIEnv* env, jobject obj, jint x, jint y)
|
|||
}
|
||||
}
|
||||
|
||||
#undef AlberFunction
|
||||
#undef AlberFunction
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue