Compare commits

...

5 Commits

14 changed files with 312 additions and 18 deletions

2
.gitignore vendored
View File

@ -2,3 +2,5 @@
*.dblite
*.os
demo/build/
demo/android/build/
demo/android/.build_version

View File

@ -52,8 +52,13 @@ elif env["platform"] == "windows":
env.Append(LIBPATH = ['C:/Program Files/Ultraleap/LeapSDK/lib/x64'])
env.Append(CPPPATH = ["C:/Program Files/Ultraleap/LeapSDK/include"])
elif env["platform"] == "android":
print("Android is not supported yet")
exit(1)
library = env.SharedLibrary(
"demo/addons/godot_ultraleap_plugin/bin/libgdultraleap{}{}".format(env["suffix"], env["SHLIBSUFFIX"]),
source=sources,
)
env.Append(LIBS=['LeapC'])
env.Append(LIBPATH = ['./android'])
env.Append(CPPPATH = ["./android"])
else:
library = env.SharedLibrary(
"demo/addons/godot_ultraleap_plugin/bin/libgdultraleap{}{}".format(env["suffix"], env["SHLIBSUFFIX"]),

View File

@ -10,4 +10,6 @@ macos.release = "bin/libgdultraleap.macos.template_release.framework"
windows.debug.x86_64 = "bin/libgdultraleap.windows.template_debug.x86_64.dll"
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"
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"

View File

@ -13,13 +13,12 @@ encryption_include_filters=""
encryption_exclude_filters=""
encrypt_pck=false
encrypt_directory=false
script_encryption_key=""
[preset.0.options]
custom_template/debug=""
custom_template/release=""
debug/export_console_script=0
debug/export_console_wrapper=1
binary_format/embed_pck=false
texture_format/bptc=false
texture_format/s3tc=true
@ -38,6 +37,7 @@ unzip -o -q \"{temp_dir}/{archive_name}\" -d \"{temp_dir}\"
ssh_remote_deploy/cleanup_script="#!/usr/bin/env bash
kill $(pgrep -x -f \"{temp_dir}/{exe_name} {cmd_args}\")
rm -rf \"{temp_dir}\""
debug/export_console_script=0
[preset.1]
@ -54,13 +54,12 @@ encryption_include_filters=""
encryption_exclude_filters=""
encrypt_pck=false
encrypt_directory=false
script_encryption_key=""
[preset.1.options]
custom_template/debug=""
custom_template/release=""
debug/export_console_script=0
debug/export_console_wrapper=1
binary_format/embed_pck=false
texture_format/bptc=true
texture_format/s3tc=true
@ -79,3 +78,206 @@ unzip -o -q \"{temp_dir}/{archive_name}\" -d \"{temp_dir}\"
ssh_remote_deploy/cleanup_script="#!/usr/bin/env bash
kill $(pgrep -x -f \"{temp_dir}/{exe_name} {cmd_args}\")
rm -rf \"{temp_dir}\""
debug/export_console_script=0
[preset.2]
name="Android"
platform="Android"
runnable=true
dedicated_server=false
custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path=""
encryption_include_filters=""
encryption_exclude_filters=""
encrypt_pck=false
encrypt_directory=false
[preset.2.options]
custom_template/debug=""
custom_template/release=""
gradle_build/use_gradle_build=true
gradle_build/export_format=0
gradle_build/min_sdk=""
gradle_build/target_sdk=""
architectures/armeabi-v7a=false
architectures/arm64-v8a=true
architectures/x86=false
architectures/x86_64=false
version/code=1
version/name="1.0"
package/unique_name="org.godotengine.$genname"
package/name=""
package/signed=true
package/app_category=2
package/retain_data_on_uninstall=false
package/exclude_from_recents=false
launcher_icons/main_192x192=""
launcher_icons/adaptive_foreground_432x432=""
launcher_icons/adaptive_background_432x432=""
graphics/opengl_debug=false
xr_features/xr_mode=0
xr_features/hand_tracking=0
xr_features/hand_tracking_frequency=0
xr_features/passthrough=0
screen/immersive_mode=true
screen/support_small=true
screen/support_normal=true
screen/support_large=true
screen/support_xlarge=true
user_data_backup/allow=false
command_line/extra_args=""
apk_expansion/enable=false
apk_expansion/SALT=""
apk_expansion/public_key=""
permissions/custom_permissions=PackedStringArray()
permissions/access_checkin_properties=false
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_surface_flinger=false
permissions/access_wifi_state=false
permissions/account_manager=false
permissions/add_voicemail=false
permissions/authenticate_accounts=false
permissions/battery_stats=false
permissions/bind_accessibility_service=false
permissions/bind_appwidget=false
permissions/bind_device_admin=false
permissions/bind_input_method=false
permissions/bind_nfc_service=false
permissions/bind_notification_listener_service=false
permissions/bind_print_service=false
permissions/bind_remoteviews=false
permissions/bind_text_service=false
permissions/bind_vpn_service=false
permissions/bind_wallpaper=false
permissions/bluetooth=false
permissions/bluetooth_admin=false
permissions/bluetooth_privileged=false
permissions/brick=false
permissions/broadcast_package_removed=false
permissions/broadcast_sms=false
permissions/broadcast_sticky=false
permissions/broadcast_wap_push=false
permissions/call_phone=false
permissions/call_privileged=false
permissions/camera=false
permissions/capture_audio_output=false
permissions/capture_secure_video_output=false
permissions/capture_video_output=false
permissions/change_component_enabled_state=false
permissions/change_configuration=false
permissions/change_network_state=false
permissions/change_wifi_multicast_state=false
permissions/change_wifi_state=false
permissions/clear_app_cache=false
permissions/clear_app_user_data=false
permissions/control_location_updates=false
permissions/delete_cache_files=false
permissions/delete_packages=false
permissions/device_power=false
permissions/diagnostic=false
permissions/disable_keyguard=false
permissions/dump=false
permissions/expand_status_bar=false
permissions/factory_test=false
permissions/flashlight=false
permissions/force_back=false
permissions/get_accounts=false
permissions/get_package_size=false
permissions/get_tasks=false
permissions/get_top_activity_info=false
permissions/global_search=false
permissions/hardware_test=false
permissions/inject_events=false
permissions/install_location_provider=false
permissions/install_packages=false
permissions/install_shortcut=false
permissions/internal_system_window=false
permissions/internet=false
permissions/kill_background_processes=false
permissions/location_hardware=false
permissions/manage_accounts=false
permissions/manage_app_tokens=false
permissions/manage_documents=false
permissions/manage_external_storage=false
permissions/master_clear=false
permissions/media_content_control=false
permissions/modify_audio_settings=false
permissions/modify_phone_state=false
permissions/mount_format_filesystems=false
permissions/mount_unmount_filesystems=false
permissions/nfc=false
permissions/persistent_activity=false
permissions/process_outgoing_calls=false
permissions/read_calendar=false
permissions/read_call_log=false
permissions/read_contacts=false
permissions/read_external_storage=false
permissions/read_frame_buffer=false
permissions/read_history_bookmarks=false
permissions/read_input_state=false
permissions/read_logs=false
permissions/read_phone_state=false
permissions/read_profile=false
permissions/read_sms=false
permissions/read_social_stream=false
permissions/read_sync_settings=false
permissions/read_sync_stats=false
permissions/read_user_dictionary=false
permissions/reboot=false
permissions/receive_boot_completed=false
permissions/receive_mms=false
permissions/receive_sms=false
permissions/receive_wap_push=false
permissions/record_audio=false
permissions/reorder_tasks=false
permissions/restart_packages=false
permissions/send_respond_via_message=false
permissions/send_sms=false
permissions/set_activity_watcher=false
permissions/set_alarm=false
permissions/set_always_finish=false
permissions/set_animation_scale=false
permissions/set_debug_app=false
permissions/set_orientation=false
permissions/set_pointer_speed=false
permissions/set_preferred_applications=false
permissions/set_process_limit=false
permissions/set_time=false
permissions/set_time_zone=false
permissions/set_wallpaper=false
permissions/set_wallpaper_hints=false
permissions/signal_persistent_processes=false
permissions/status_bar=false
permissions/subscribed_feeds_read=false
permissions/subscribed_feeds_write=false
permissions/system_alert_window=false
permissions/transmit_ir=false
permissions/uninstall_shortcut=false
permissions/update_device_stats=false
permissions/use_credentials=false
permissions/use_sip=false
permissions/vibrate=false
permissions/wake_lock=false
permissions/write_apn_settings=false
permissions/write_calendar=false
permissions/write_call_log=false
permissions/write_contacts=false
permissions/write_external_storage=false
permissions/write_gservices=false
permissions/write_history_bookmarks=false
permissions/write_profile=false
permissions/write_secure_settings=false
permissions/write_settings=false
permissions/write_sms=false
permissions/write_social_stream=false
permissions/write_sync_settings=false
permissions/write_user_dictionary=false

View File

@ -4,15 +4,16 @@ importer="texture"
type="CompressedTexture2D"
uid="uid://d3767foinml1c"
path.s3tc="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.s3tc.ctex"
path.etc2="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.etc2.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"imported_formats": ["s3tc_bptc", "etc2_astc"],
"vram_texture": true
}
[deps]
source_file="res://icon.svg"
dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.s3tc.ctex"]
dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.s3tc.ctex", "res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.etc2.ctex"]
[params]

View File

@ -87,5 +87,6 @@ common/physics_ticks_per_second=120
[rendering]
textures/vram_compression/import_etc2_astc=true
lights_and_shadows/directional_shadow/soft_shadow_filter_quality=5
anti_aliasing/quality/msaa_3d=3

View File

@ -4,15 +4,16 @@ importer="texture"
type="CompressedTexture2D"
uid="uid://d4d5e7880umaa"
path.s3tc="res://.godot/imported/circles.png-11b9b0a9acc9dba4a834e2474dc0c446.s3tc.ctex"
path.etc2="res://.godot/imported/circles.png-11b9b0a9acc9dba4a834e2474dc0c446.etc2.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"imported_formats": ["s3tc_bptc", "etc2_astc"],
"vram_texture": true
}
[deps]
source_file="res://textures/circles.png"
dest_files=["res://.godot/imported/circles.png-11b9b0a9acc9dba4a834e2474dc0c446.s3tc.ctex"]
dest_files=["res://.godot/imported/circles.png-11b9b0a9acc9dba4a834e2474dc0c446.s3tc.ctex", "res://.godot/imported/circles.png-11b9b0a9acc9dba4a834e2474dc0c446.etc2.ctex"]
[params]

View File

@ -4,15 +4,16 @@ importer="texture"
type="CompressedTexture2D"
uid="uid://db4h7k72xse3v"
path.s3tc="res://.godot/imported/cube_border.png-d995297aef82249c95cc50dc7569bcb9.s3tc.ctex"
path.etc2="res://.godot/imported/cube_border.png-d995297aef82249c95cc50dc7569bcb9.etc2.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"imported_formats": ["s3tc_bptc", "etc2_astc"],
"vram_texture": true
}
[deps]
source_file="res://textures/cube_border.png"
dest_files=["res://.godot/imported/cube_border.png-d995297aef82249c95cc50dc7569bcb9.s3tc.ctex"]
dest_files=["res://.godot/imported/cube_border.png-d995297aef82249c95cc50dc7569bcb9.s3tc.ctex", "res://.godot/imported/cube_border.png-d995297aef82249c95cc50dc7569bcb9.etc2.ctex"]
[params]

View File

@ -4,15 +4,16 @@ importer="texture"
type="CompressedTexture2D"
uid="uid://3w6gtvgxxvs0"
path.s3tc="res://.godot/imported/cube_emission.png-cb902755aeed5a689ebab4d26b30f6dc.s3tc.ctex"
path.etc2="res://.godot/imported/cube_emission.png-cb902755aeed5a689ebab4d26b30f6dc.etc2.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"imported_formats": ["s3tc_bptc", "etc2_astc"],
"vram_texture": true
}
[deps]
source_file="res://textures/cube_emission.png"
dest_files=["res://.godot/imported/cube_emission.png-cb902755aeed5a689ebab4d26b30f6dc.s3tc.ctex"]
dest_files=["res://.godot/imported/cube_emission.png-cb902755aeed5a689ebab4d26b30f6dc.s3tc.ctex", "res://.godot/imported/cube_emission.png-cb902755aeed5a689ebab4d26b30f6dc.etc2.ctex"]
[params]

View File

@ -4,15 +4,16 @@ importer="texture"
type="CompressedTexture2D"
uid="uid://cegr0wkrccadm"
path.s3tc="res://.godot/imported/grid_square.png-2c3884cc6134a99150267407ac4a5374.s3tc.ctex"
path.etc2="res://.godot/imported/grid_square.png-2c3884cc6134a99150267407ac4a5374.etc2.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"imported_formats": ["s3tc_bptc", "etc2_astc"],
"vram_texture": true
}
[deps]
source_file="res://textures/grid_square.png"
dest_files=["res://.godot/imported/grid_square.png-2c3884cc6134a99150267407ac4a5374.s3tc.ctex"]
dest_files=["res://.godot/imported/grid_square.png-2c3884cc6134a99150267407ac4a5374.s3tc.ctex", "res://.godot/imported/grid_square.png-2c3884cc6134a99150267407ac4a5374.etc2.ctex"]
[params]

@ -1 +1 @@
Subproject commit 1009da4d7e395abadfdb454cff6623e9456181c4
Subproject commit 48b92acf8c1de8ab39aab0d5f0f83b7fe4895ee9

31
src/binder.cpp Normal file
View File

@ -0,0 +1,31 @@
#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 Normal file
View File

@ -0,0 +1,26 @@
#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

View File

@ -16,6 +16,11 @@
#include "frame.h"
#include "allocator.h"
#ifdef ANDROID_ENABLED
#include <jni.h>
#include "binder.h"
#endif
using namespace godot;
UltraleapHandTracking::~UltraleapHandTracking() {
@ -218,6 +223,21 @@ void UltraleapHandTracking::_bind_methods() {
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);
#endif
LEAP_CONNECTION_CONFIG config;
// Set connection to multi-device aware