2014-12-04 07:56:54 +00:00
|
|
|
#include <jni.h>
|
2014-12-07 03:05:14 +00:00
|
|
|
#include <cassert>
|
|
|
|
#include <android/log.h>
|
2015-03-11 01:03:38 -04:00
|
|
|
#include <android/native_window.h>
|
|
|
|
#include <android/native_window_jni.h>
|
2014-12-07 03:05:14 +00:00
|
|
|
#include "PathUtils.h"
|
2014-12-04 07:56:54 +00:00
|
|
|
#include "../PS2VM.h"
|
2015-03-11 01:03:38 -04:00
|
|
|
#include "../GSH_Null.h"
|
|
|
|
#include "GSH_OpenGLAndroid.h"
|
2014-12-04 07:56:54 +00:00
|
|
|
|
2014-12-07 03:05:14 +00:00
|
|
|
#define LOG_NAME "Play!"
|
|
|
|
|
|
|
|
static CPS2VM* g_virtualMachine = nullptr;
|
|
|
|
|
|
|
|
void Log_Print(const char* fmt, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
va_start(ap, fmt);
|
|
|
|
__android_log_vprint(ANDROID_LOG_INFO, LOG_NAME, fmt, ap);
|
|
|
|
va_end(ap);
|
|
|
|
}
|
|
|
|
|
2015-03-19 23:54:47 -04:00
|
|
|
std::string GetStringFromJstring(JNIEnv* env, jstring javaString)
|
|
|
|
{
|
|
|
|
auto nativeString = env->GetStringUTFChars(javaString, JNI_FALSE);
|
|
|
|
std::string result(nativeString);
|
|
|
|
env->ReleaseStringUTFChars(javaString, nativeString);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2014-12-07 03:05:14 +00:00
|
|
|
extern "C" JNIEXPORT void JNICALL Java_com_virtualapplications_play_NativeInterop_setFilesDirPath(JNIEnv* env, jobject obj, jstring dirPathString)
|
|
|
|
{
|
|
|
|
auto dirPath = env->GetStringUTFChars(dirPathString, 0);
|
|
|
|
Framework::PathUtils::SetFilesDirPath(dirPath);
|
|
|
|
env->ReleaseStringUTFChars(dirPathString, dirPath);
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" JNIEXPORT void JNICALL Java_com_virtualapplications_play_NativeInterop_createVirtualMachine(JNIEnv* env, jobject obj)
|
|
|
|
{
|
|
|
|
g_virtualMachine = new CPS2VM();
|
|
|
|
g_virtualMachine->Initialize();
|
|
|
|
}
|
|
|
|
|
2015-03-19 23:54:47 -04:00
|
|
|
extern "C" JNIEXPORT void JNICALL Java_com_virtualapplications_play_NativeInterop_start(JNIEnv* env, jobject obj,
|
|
|
|
jobject surface, jstring selectedFilePath)
|
2014-12-04 07:56:54 +00:00
|
|
|
{
|
2015-03-11 01:03:38 -04:00
|
|
|
auto nativeWindow = ANativeWindow_fromSurface(env, surface);
|
|
|
|
g_virtualMachine->CreateGSHandler(CGSH_OpenGLAndroid::GetFactoryFunction(nativeWindow));
|
2014-12-07 03:05:14 +00:00
|
|
|
g_virtualMachine->Reset();
|
2015-03-19 23:54:47 -04:00
|
|
|
g_virtualMachine->m_ee->m_os->BootFromFile(GetStringFromJstring(env, selectedFilePath).c_str());
|
2014-12-07 03:05:14 +00:00
|
|
|
Log_Print("Before step.");
|
|
|
|
g_virtualMachine->StepEe();
|
|
|
|
Log_Print("Stepping.");
|
2014-12-04 07:56:54 +00:00
|
|
|
}
|