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.debug.x86_64 = "bin/libgdultraleap.linux.template_debug.x86_64.so"
|
||||||
linux.release.x86_64 = "bin/libgdultraleap.linux.template_release.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.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"
|
export_filter="all_resources"
|
||||||
include_filter=""
|
include_filter=""
|
||||||
exclude_filter=""
|
exclude_filter=""
|
||||||
export_path=""
|
export_path="build/UltraleapPluginDemo.Debug.apk"
|
||||||
encryption_include_filters=""
|
encryption_include_filters=""
|
||||||
encryption_exclude_filters=""
|
encryption_exclude_filters=""
|
||||||
encrypt_pck=false
|
encrypt_pck=false
|
||||||
|
@ -102,8 +102,9 @@ custom_template/debug=""
|
||||||
custom_template/release=""
|
custom_template/release=""
|
||||||
gradle_build/use_gradle_build=true
|
gradle_build/use_gradle_build=true
|
||||||
gradle_build/export_format=0
|
gradle_build/export_format=0
|
||||||
gradle_build/min_sdk=""
|
gradle_build/min_sdk="29"
|
||||||
gradle_build/target_sdk=""
|
gradle_build/target_sdk=""
|
||||||
|
plugins/UltraleapBinder=true
|
||||||
architectures/armeabi-v7a=false
|
architectures/armeabi-v7a=false
|
||||||
architectures/arm64-v8a=true
|
architectures/arm64-v8a=true
|
||||||
architectures/x86=false
|
architectures/x86=false
|
||||||
|
@ -140,7 +141,7 @@ permissions/access_coarse_location=false
|
||||||
permissions/access_fine_location=false
|
permissions/access_fine_location=false
|
||||||
permissions/access_location_extra_commands=false
|
permissions/access_location_extra_commands=false
|
||||||
permissions/access_mock_location=false
|
permissions/access_mock_location=false
|
||||||
permissions/access_network_state=false
|
permissions/access_network_state=true
|
||||||
permissions/access_surface_flinger=false
|
permissions/access_surface_flinger=false
|
||||||
permissions/access_wifi_state=false
|
permissions/access_wifi_state=false
|
||||||
permissions/account_manager=false
|
permissions/account_manager=false
|
||||||
|
@ -201,7 +202,7 @@ permissions/install_location_provider=false
|
||||||
permissions/install_packages=false
|
permissions/install_packages=false
|
||||||
permissions/install_shortcut=false
|
permissions/install_shortcut=false
|
||||||
permissions/internal_system_window=false
|
permissions/internal_system_window=false
|
||||||
permissions/internet=false
|
permissions/internet=true
|
||||||
permissions/kill_background_processes=false
|
permissions/kill_background_processes=false
|
||||||
permissions/location_hardware=false
|
permissions/location_hardware=false
|
||||||
permissions/manage_accounts=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"
|
#include "allocator.h"
|
||||||
|
|
||||||
#ifdef ANDROID_ENABLED
|
#ifdef ANDROID_ENABLED
|
||||||
#include <jni.h>
|
#include <android/log.h>
|
||||||
#include "binder.h"
|
|
||||||
|
#define LOG_TAG "ultraleap.cpp"
|
||||||
|
#define ALOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using namespace godot;
|
using namespace godot;
|
||||||
|
@ -225,17 +227,14 @@ void UltraleapHandTracking::start() {
|
||||||
UtilityFunctions::print("Starting the tracking");
|
UtilityFunctions::print("Starting the tracking");
|
||||||
|
|
||||||
#ifdef ANDROID_ENABLED
|
#ifdef ANDROID_ENABLED
|
||||||
// Acquire a pointer to the current JavaVM
|
if (Engine::get_singleton()->has_singleton("UltraleapBinder")) {
|
||||||
jsize jvmBufferLength = 1; // At most vmBufLength number of entries ill be written for the list of returned JavaVMs
|
ALOGI("We'll try to use the binder");
|
||||||
jsize jvmTotalNumberFound = 0; // The total number of JavaVMs found
|
Object* binder = Engine::get_singleton()->get_singleton("UltraleapBinder");
|
||||||
JavaVM jvmBuffer[jvmBufferLength]; // Array of JavaVMs
|
binder->call("Bind");
|
||||||
JavaVM * pjvmBuffer = jvmBuffer; // Pointer to array of JavaVMs
|
while (!binder->call("IsBound")) {
|
||||||
jint result = JNI_GetCreatedJavaVMs(&pjvmBuffer, jvmBufferLength, &jvmTotalNumberFound); // Get all created JavaVMs
|
ALOGI("Not bound yet");
|
||||||
|
}
|
||||||
JNIEnv *env;
|
}
|
||||||
pjvmBuffer->AttachCurrentThread(&env, 0);
|
|
||||||
Binder* service_binder = new Binder(env);
|
|
||||||
service_binder->bind(env);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
LEAP_CONNECTION_CONFIG config;
|
LEAP_CONNECTION_CONFIG config;
|
||||||
|
|
Loading…
Reference in a new issue