1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-18 14:21:41 +00:00

Setup Godot to support the Oculus Mobile SDK.

This commit is contained in:
fhuya
2019-05-30 12:50:36 -07:00
parent a2cf1c3d04
commit 2c3536810a
18 changed files with 1336 additions and 667 deletions

View File

@@ -34,6 +34,8 @@
// These entry points are only for the android platform and are simple stubs in all others.
#ifdef __ANDROID__
#include "platform/android/java_godot_wrapper.h"
#include "platform/android/os_android.h"
#include "platform/android/thread_jandroid.h"
#else
#define JNIEnv void
@@ -54,20 +56,31 @@ JNIEnv *GDAPI godot_android_get_env() {
jobject GDAPI godot_android_get_activity() {
#ifdef __ANDROID__
JNIEnv *env = ThreadAndroid::get_env();
jclass activityThread = env->FindClass("android/app/ActivityThread");
jmethodID currentActivityThread = env->GetStaticMethodID(activityThread, "currentActivityThread", "()Landroid/app/ActivityThread;");
jobject at = env->CallStaticObjectMethod(activityThread, currentActivityThread);
jmethodID getApplication = env->GetMethodID(activityThread, "getApplication", "()Landroid/app/Application;");
jobject context = env->CallObjectMethod(at, getApplication);
return env->NewGlobalRef(context);
OS_Android *os_android = (OS_Android *)OS::get_singleton();
return os_android->get_godot_java()->get_activity();
#else
return NULL;
#endif
}
jobject GDAPI godot_android_get_surface() {
#ifdef __ANDROID__
OS_Android *os_android = (OS_Android *)OS::get_singleton();
return os_android->get_godot_java()->get_surface();
#else
return NULL;
#endif
}
bool GDAPI godot_android_is_activity_resumed() {
#ifdef __ANDROID__
OS_Android *os_android = (OS_Android *)OS::get_singleton();
return os_android->get_godot_java()->is_activity_resumed();
#else
return false;
#endif
}
#ifdef __cplusplus
}
#endif