1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-05 12:10:55 +00:00

Add magnetometer sensor support for Android

This commit is contained in:
fluffrabbit
2016-05-27 14:29:37 -03:00
committed by George Marques
parent eb7227a20b
commit 4877b714b3
11 changed files with 76 additions and 6 deletions

View File

@@ -650,6 +650,7 @@ static bool resized_reload=false;
static bool quit_request=false;
static Size2 new_size;
static Vector3 accelerometer;
static Vector3 magnetometer;
static HashMap<String,JNISingleton*> jni_singletons;
static jobject godot_io;
@@ -1088,6 +1089,8 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv * env, jo
os_android->process_accelerometer(accelerometer);
os_android->process_magnetometer(magnetometer);
if (os_android->main_loop_iterate()==true) {
jclass cls = env->FindClass("org/godotengine/godot/Godot");
@@ -1488,6 +1491,14 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_accelerometer(JNIEnv
}
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_magnetometer(JNIEnv * env, jobject obj, jfloat x, jfloat y, jfloat z) {
input_mutex->lock();
magnetometer=Vector3(x,y,z);
input_mutex->unlock();
}
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_focusin(JNIEnv * env, jobject obj){
if (!suspend_mutex)