Use godot-ultraleap-binder
This commit is contained in:
parent
b2cb023ddf
commit
5f259c6c34
|
@ -12,4 +12,10 @@ windows.release.x86_64 = "bin/libgdultraleap.windows.template_release.x86_64.dll
|
|||
linux.debug.x86_64 = "bin/libgdultraleap.linux.template_debug.x86_64.so"
|
||||
linux.release.x86_64 = "bin/libgdultraleap.linux.template_release.x86_64.so"
|
||||
android.debug.arm64 = "bin/libgdultraleap.android.template_debug.arm64.so"
|
||||
android.release.arm64 = "bin/libgdultraleap.android.template_release.arm64.so"
|
||||
android.release.arm64 = "bin/libgdultraleap.android.template_release.arm64.so"
|
||||
|
||||
[dependencies]
|
||||
|
||||
android.debug.arm64 = {
|
||||
"bin/libLeapC.so": ""
|
||||
}
|
|
@ -90,7 +90,7 @@ custom_features=""
|
|||
export_filter="all_resources"
|
||||
include_filter=""
|
||||
exclude_filter=""
|
||||
export_path=""
|
||||
export_path="build/UltraleapPluginDemo.Debug.apk"
|
||||
encryption_include_filters=""
|
||||
encryption_exclude_filters=""
|
||||
encrypt_pck=false
|
||||
|
@ -102,8 +102,9 @@ custom_template/debug=""
|
|||
custom_template/release=""
|
||||
gradle_build/use_gradle_build=true
|
||||
gradle_build/export_format=0
|
||||
gradle_build/min_sdk=""
|
||||
gradle_build/min_sdk="29"
|
||||
gradle_build/target_sdk=""
|
||||
plugins/UltraleapBinder=true
|
||||
architectures/armeabi-v7a=false
|
||||
architectures/arm64-v8a=true
|
||||
architectures/x86=false
|
||||
|
@ -140,7 +141,7 @@ permissions/access_coarse_location=false
|
|||
permissions/access_fine_location=false
|
||||
permissions/access_location_extra_commands=false
|
||||
permissions/access_mock_location=false
|
||||
permissions/access_network_state=false
|
||||
permissions/access_network_state=true
|
||||
permissions/access_surface_flinger=false
|
||||
permissions/access_wifi_state=false
|
||||
permissions/account_manager=false
|
||||
|
@ -201,7 +202,7 @@ permissions/install_location_provider=false
|
|||
permissions/install_packages=false
|
||||
permissions/install_shortcut=false
|
||||
permissions/internal_system_window=false
|
||||
permissions/internet=false
|
||||
permissions/internet=true
|
||||
permissions/kill_background_processes=false
|
||||
permissions/location_hardware=false
|
||||
permissions/manage_accounts=false
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
#include "binder.h"
|
||||
|
||||
#ifdef ANDROID_ENABLED
|
||||
#include <jni.h>
|
||||
|
||||
Binder::Binder(JNIEnv *env) {
|
||||
class_binder = env->FindClass("com/ultraleap/tracking/service_binder/ServiceBinder");
|
||||
|
||||
// Really not sure here
|
||||
jmethodID constructor = env->GetMethodID(class_binder, "<init>", "(Landroid/content/Context;Z)V");
|
||||
binder_object = env->NewObject(class_binder, constructor, get_global_context(env), false);
|
||||
bind_method = env->GetMethodID(class_binder, "bind", "()Z");
|
||||
unbind_method = env->GetMethodID(class_binder, "unbind", "()V");
|
||||
is_bound_method = env->GetMethodID(class_binder, "isBound", "()I");
|
||||
}
|
||||
|
||||
jobject Binder::get_global_context(JNIEnv *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 context;
|
||||
}
|
||||
|
||||
void Binder::bind(JNIEnv *env) {
|
||||
jobject status = env->CallObjectMethod(binder_object, bind_method);
|
||||
}
|
||||
|
||||
#endif
|
26
src/binder.h
26
src/binder.h
|
@ -1,26 +0,0 @@
|
|||
#ifndef BINDER_HPP
|
||||
#define BINDER_HPP
|
||||
|
||||
#ifdef ANDROID_ENABLED
|
||||
#include <jni.h>
|
||||
|
||||
class Binder {
|
||||
private:
|
||||
jclass class_binder;
|
||||
jobject binder_object;
|
||||
|
||||
jmethodID bind_method;
|
||||
jmethodID unbind_method;
|
||||
jmethodID is_bound_method;
|
||||
|
||||
static jobject get_global_context(JNIEnv *env);
|
||||
public:
|
||||
Binder(JNIEnv* env);
|
||||
~Binder() {}
|
||||
|
||||
void bind(JNIEnv *env);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -17,8 +17,10 @@
|
|||
#include "allocator.h"
|
||||
|
||||
#ifdef ANDROID_ENABLED
|
||||
#include <jni.h>
|
||||
#include "binder.h"
|
||||
#include <android/log.h>
|
||||
|
||||
#define LOG_TAG "ultraleap.cpp"
|
||||
#define ALOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
using namespace godot;
|
||||
|
@ -225,17 +227,14 @@ void UltraleapHandTracking::start() {
|
|||
UtilityFunctions::print("Starting the tracking");
|
||||
|
||||
#ifdef ANDROID_ENABLED
|
||||
// Acquire a pointer to the current JavaVM
|
||||
jsize jvmBufferLength = 1; // At most vmBufLength number of entries ill be written for the list of returned JavaVMs
|
||||
jsize jvmTotalNumberFound = 0; // The total number of JavaVMs found
|
||||
JavaVM jvmBuffer[jvmBufferLength]; // Array of JavaVMs
|
||||
JavaVM * pjvmBuffer = jvmBuffer; // Pointer to array of JavaVMs
|
||||
jint result = JNI_GetCreatedJavaVMs(&pjvmBuffer, jvmBufferLength, &jvmTotalNumberFound); // Get all created JavaVMs
|
||||
|
||||
JNIEnv *env;
|
||||
pjvmBuffer->AttachCurrentThread(&env, 0);
|
||||
Binder* service_binder = new Binder(env);
|
||||
service_binder->bind(env);
|
||||
if (Engine::get_singleton()->has_singleton("UltraleapBinder")) {
|
||||
ALOGI("We'll try to use the binder");
|
||||
Object* binder = Engine::get_singleton()->get_singleton("UltraleapBinder");
|
||||
binder->call("Bind");
|
||||
while (!binder->call("IsBound")) {
|
||||
ALOGI("Not bound yet");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
LEAP_CONNECTION_CONFIG config;
|
||||
|
|
Loading…
Reference in New Issue