2014-02-10 01:10:30 +00:00
|
|
|
/**************************************************************************/
|
2019-03-13 12:51:55 +00:00
|
|
|
/* java_godot_lib_jni.cpp */
|
2014-02-10 01:10:30 +00:00
|
|
|
/**************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* https://godotengine.org */
|
|
|
|
/**************************************************************************/
|
|
|
|
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
|
|
|
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/**************************************************************************/
|
2018-01-04 23:50:27 +00:00
|
|
|
|
2019-03-13 12:51:55 +00:00
|
|
|
#include "java_godot_lib_jni.h"
|
2020-03-04 16:36:09 +00:00
|
|
|
|
2021-08-04 19:22:11 +00:00
|
|
|
#include "android_input_handler.h"
|
2020-01-19 19:02:40 +00:00
|
|
|
#include "api/java_class_wrapper.h"
|
2020-03-25 21:01:12 +00:00
|
|
|
#include "api/jni_singleton.h"
|
2014-02-10 01:10:30 +00:00
|
|
|
#include "dir_access_jandroid.h"
|
2020-03-27 16:30:18 +00:00
|
|
|
#include "display_server_android.h"
|
2015-09-04 02:24:55 +00:00
|
|
|
#include "file_access_android.h"
|
2021-07-11 01:39:31 +00:00
|
|
|
#include "file_access_filesystem_jandroid.h"
|
2023-06-08 12:51:32 +00:00
|
|
|
#include "java_godot_io_wrapper.h"
|
|
|
|
#include "java_godot_wrapper.h"
|
2020-03-04 17:21:59 +00:00
|
|
|
#include "jni_utils.h"
|
2019-11-25 14:01:44 +00:00
|
|
|
#include "net_socket_android.h"
|
2014-02-10 01:10:30 +00:00
|
|
|
#include "os_android.h"
|
2024-05-19 22:48:30 +00:00
|
|
|
#include "plugin/godot_plugin_jni.h"
|
2019-02-26 20:54:45 +00:00
|
|
|
#include "string_android.h"
|
2014-02-10 01:10:30 +00:00
|
|
|
#include "thread_jandroid.h"
|
2021-11-04 12:33:37 +00:00
|
|
|
#include "tts_android.h"
|
2020-03-04 16:36:09 +00:00
|
|
|
|
2023-06-08 12:51:32 +00:00
|
|
|
#include "core/config/engine.h"
|
|
|
|
#include "core/config/project_settings.h"
|
|
|
|
#include "core/input/input.h"
|
|
|
|
#include "main/main.h"
|
2024-08-31 06:11:50 +00:00
|
|
|
|
|
|
|
#ifndef _3D_DISABLED
|
2024-07-10 17:52:42 +00:00
|
|
|
#include "servers/xr_server.h"
|
2024-08-31 06:11:50 +00:00
|
|
|
#endif // _3D_DISABLED
|
2020-03-05 18:00:28 +00:00
|
|
|
|
2023-02-21 17:18:08 +00:00
|
|
|
#ifdef TOOLS_ENABLED
|
|
|
|
#include "editor/editor_settings.h"
|
|
|
|
#endif
|
|
|
|
|
2023-06-08 12:51:32 +00:00
|
|
|
#include <android/asset_manager_jni.h>
|
|
|
|
#include <android/input.h>
|
|
|
|
#include <android/native_window_jni.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
2020-04-01 23:20:12 +00:00
|
|
|
static JavaClassWrapper *java_class_wrapper = nullptr;
|
|
|
|
static OS_Android *os_android = nullptr;
|
2021-08-04 19:22:11 +00:00
|
|
|
static AndroidInputHandler *input_handler = nullptr;
|
2020-04-01 23:20:12 +00:00
|
|
|
static GodotJavaWrapper *godot_java = nullptr;
|
|
|
|
static GodotIOJavaWrapper *godot_io_java = nullptr;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2024-07-03 09:37:14 +00:00
|
|
|
enum StartupStep {
|
|
|
|
STEP_TERMINATED = -1,
|
|
|
|
STEP_SETUP,
|
|
|
|
STEP_SHOW_LOGO,
|
|
|
|
STEP_STARTED
|
|
|
|
};
|
|
|
|
|
2021-08-04 19:22:11 +00:00
|
|
|
static SafeNumeric<int> step; // Shared between UI and render threads
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-03-04 17:21:59 +00:00
|
|
|
static Size2 new_size;
|
|
|
|
static Vector3 accelerometer;
|
|
|
|
static Vector3 gravity;
|
|
|
|
static Vector3 magnetometer;
|
|
|
|
static Vector3 gyroscope;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2022-11-15 16:46:45 +00:00
|
|
|
static void _terminate(JNIEnv *env, bool p_restart = false) {
|
2024-07-29 16:20:50 +00:00
|
|
|
if (step.get() == STEP_TERMINATED) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-07-03 09:37:14 +00:00
|
|
|
step.set(STEP_TERMINATED); // Ensure no further steps are attempted and no further events are sent
|
2022-11-15 16:46:45 +00:00
|
|
|
|
|
|
|
// lets cleanup
|
2024-05-19 22:48:30 +00:00
|
|
|
// Unregister android plugins
|
|
|
|
unregister_plugins_singletons();
|
|
|
|
|
2022-11-15 16:46:45 +00:00
|
|
|
if (java_class_wrapper) {
|
|
|
|
memdelete(java_class_wrapper);
|
|
|
|
}
|
|
|
|
if (input_handler) {
|
|
|
|
delete input_handler;
|
|
|
|
}
|
|
|
|
// Whether restarting is handled by 'Main::cleanup()'
|
|
|
|
bool restart_on_cleanup = false;
|
|
|
|
if (os_android) {
|
|
|
|
restart_on_cleanup = os_android->is_restart_on_exit_set();
|
|
|
|
os_android->main_loop_end();
|
|
|
|
Main::cleanup();
|
|
|
|
delete os_android;
|
|
|
|
}
|
|
|
|
if (godot_io_java) {
|
|
|
|
delete godot_io_java;
|
|
|
|
}
|
2024-04-15 17:30:18 +00:00
|
|
|
|
|
|
|
TTS_Android::terminate();
|
|
|
|
FileAccessAndroid::terminate();
|
|
|
|
DirAccessJAndroid::terminate();
|
|
|
|
FileAccessFilesystemJAndroid::terminate();
|
|
|
|
NetSocketAndroid::terminate();
|
|
|
|
|
2022-11-15 16:46:45 +00:00
|
|
|
if (godot_java) {
|
2024-07-23 00:51:45 +00:00
|
|
|
godot_java->on_godot_terminating(env);
|
2022-11-15 16:46:45 +00:00
|
|
|
if (!restart_on_cleanup) {
|
|
|
|
if (p_restart) {
|
|
|
|
godot_java->restart(env);
|
|
|
|
} else {
|
|
|
|
godot_java->force_quit(env);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
delete godot_java;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-04 17:21:59 +00:00
|
|
|
extern "C" {
|
2014-03-14 01:57:24 +00:00
|
|
|
|
2020-03-04 17:21:59 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_setVirtualKeyboardHeight(JNIEnv *env, jclass clazz, jint p_height) {
|
2019-03-13 12:51:55 +00:00
|
|
|
if (godot_io_java) {
|
|
|
|
godot_io_java->set_vk_height(p_height);
|
|
|
|
}
|
2017-10-04 08:39:31 +00:00
|
|
|
}
|
|
|
|
|
2023-05-16 11:18:12 +00:00
|
|
|
JNIEXPORT jboolean JNICALL Java_org_godotengine_godot_GodotLib_initialize(JNIEnv *env, jclass clazz, jobject p_activity, jobject p_godot_instance, jobject p_asset_manager, jobject p_godot_io, jobject p_net_utils, jobject p_directory_access_handler, jobject p_file_access_handler, jboolean p_use_apk_expansion) {
|
2014-02-10 01:10:30 +00:00
|
|
|
JavaVM *jvm;
|
|
|
|
env->GetJavaVM(&jvm);
|
|
|
|
|
2019-03-13 12:51:55 +00:00
|
|
|
// create our wrapper classes
|
2021-07-11 01:39:31 +00:00
|
|
|
godot_java = new GodotJavaWrapper(env, p_activity, p_godot_instance);
|
|
|
|
godot_io_java = new GodotIOJavaWrapper(env, p_godot_io);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2021-01-19 12:29:41 +00:00
|
|
|
init_thread_jandroid(jvm, env);
|
2015-09-04 02:24:55 +00:00
|
|
|
|
2024-04-15 17:30:18 +00:00
|
|
|
FileAccessAndroid::setup(p_asset_manager);
|
2021-07-11 01:39:31 +00:00
|
|
|
DirAccessJAndroid::setup(p_directory_access_handler);
|
|
|
|
FileAccessFilesystemJAndroid::setup(p_file_access_handler);
|
|
|
|
NetSocketAndroid::setup(p_net_utils);
|
2019-03-13 12:51:55 +00:00
|
|
|
|
|
|
|
os_android = new OS_Android(godot_java, godot_io_java, p_use_apk_expansion);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2023-05-22 22:40:38 +00:00
|
|
|
return true;
|
2019-03-13 12:51:55 +00:00
|
|
|
}
|
|
|
|
|
2020-06-15 07:46:13 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_ondestroy(JNIEnv *env, jclass clazz) {
|
2022-11-15 16:46:45 +00:00
|
|
|
_terminate(env, false);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2023-05-16 11:18:12 +00:00
|
|
|
JNIEXPORT jboolean JNICALL Java_org_godotengine_godot_GodotLib_setup(JNIEnv *env, jclass clazz, jobjectArray p_cmdline, jobject p_godot_tts) {
|
2021-01-19 12:29:41 +00:00
|
|
|
setup_android_thread();
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-04-01 23:20:12 +00:00
|
|
|
const char **cmdline = nullptr;
|
|
|
|
jstring *j_cmdline = nullptr;
|
2017-08-18 14:17:35 +00:00
|
|
|
int cmdlen = 0;
|
|
|
|
if (p_cmdline) {
|
|
|
|
cmdlen = env->GetArrayLength(p_cmdline);
|
|
|
|
if (cmdlen) {
|
2021-03-10 18:31:44 +00:00
|
|
|
cmdline = (const char **)memalloc((cmdlen + 1) * sizeof(const char *));
|
2022-09-07 21:21:34 +00:00
|
|
|
ERR_FAIL_NULL_V_MSG(cmdline, false, "Out of memory.");
|
2020-04-01 23:20:12 +00:00
|
|
|
cmdline[cmdlen] = nullptr;
|
2021-03-10 18:31:44 +00:00
|
|
|
j_cmdline = (jstring *)memalloc(cmdlen * sizeof(jstring));
|
2022-09-07 21:21:34 +00:00
|
|
|
ERR_FAIL_NULL_V_MSG(j_cmdline, false, "Out of memory.");
|
2017-08-18 14:17:35 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < cmdlen; i++) {
|
|
|
|
jstring string = (jstring)env->GetObjectArrayElement(p_cmdline, i);
|
2022-05-30 21:13:49 +00:00
|
|
|
const char *rawString = env->GetStringUTFChars(string, nullptr);
|
2017-08-18 14:17:35 +00:00
|
|
|
|
|
|
|
cmdline[i] = rawString;
|
2019-02-26 20:54:45 +00:00
|
|
|
j_cmdline[i] = string;
|
2017-08-18 14:17:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-25 13:45:16 +00:00
|
|
|
Error err = Main::setup(OS_Android::ANDROID_EXEC_PATH, cmdlen, (char **)cmdline, false);
|
2017-08-18 14:17:35 +00:00
|
|
|
if (cmdline) {
|
2019-02-26 20:54:45 +00:00
|
|
|
if (j_cmdline) {
|
|
|
|
for (int i = 0; i < cmdlen; ++i) {
|
|
|
|
env->ReleaseStringUTFChars(j_cmdline[i], cmdline[i]);
|
|
|
|
}
|
2021-03-10 18:31:44 +00:00
|
|
|
memfree(j_cmdline);
|
2019-02-26 20:54:45 +00:00
|
|
|
}
|
2021-03-10 18:31:44 +00:00
|
|
|
memfree(cmdline);
|
2017-08-18 14:17:35 +00:00
|
|
|
}
|
|
|
|
|
2022-07-01 23:05:20 +00:00
|
|
|
// Note: --help and --version return ERR_HELP, but this should be translated to 0 if exit codes are propagated.
|
2017-08-18 14:17:35 +00:00
|
|
|
if (err != OK) {
|
2022-09-07 21:21:34 +00:00
|
|
|
return false;
|
2017-08-18 14:17:35 +00:00
|
|
|
}
|
|
|
|
|
2023-05-16 11:18:12 +00:00
|
|
|
TTS_Android::setup(p_godot_tts);
|
|
|
|
|
2019-03-13 12:51:55 +00:00
|
|
|
java_class_wrapper = memnew(JavaClassWrapper(godot_java->get_activity()));
|
2021-07-11 22:30:33 +00:00
|
|
|
GDREGISTER_CLASS(JNISingleton);
|
2022-09-07 21:21:34 +00:00
|
|
|
return true;
|
2017-08-18 14:17:35 +00:00
|
|
|
}
|
|
|
|
|
2020-05-24 08:04:59 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_resize(JNIEnv *env, jclass clazz, jobject p_surface, jint p_width, jint p_height) {
|
|
|
|
if (os_android) {
|
|
|
|
os_android->set_display_size(Size2i(p_width, p_height));
|
|
|
|
|
|
|
|
// No need to reset the surface during startup
|
2024-07-03 09:37:14 +00:00
|
|
|
if (step.get() > STEP_SETUP) {
|
2020-05-24 08:04:59 +00:00
|
|
|
if (p_surface) {
|
|
|
|
ANativeWindow *native_window = ANativeWindow_fromSurface(env, p_surface);
|
|
|
|
os_android->set_native_window(native_window);
|
|
|
|
}
|
2023-04-26 07:43:13 +00:00
|
|
|
DisplayServerAndroid::get_singleton()->reset_window();
|
|
|
|
DisplayServerAndroid::get_singleton()->notify_surface_changed(p_width, p_height);
|
2020-05-24 08:04:59 +00:00
|
|
|
}
|
|
|
|
}
|
2017-08-18 14:17:35 +00:00
|
|
|
}
|
|
|
|
|
2021-10-31 19:22:48 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_newcontext(JNIEnv *env, jclass clazz, jobject p_surface) {
|
2017-08-18 14:17:35 +00:00
|
|
|
if (os_android) {
|
2024-07-03 09:37:14 +00:00
|
|
|
if (step.get() == STEP_SETUP) {
|
2019-03-05 22:29:44 +00:00
|
|
|
// During startup
|
2020-03-05 18:00:28 +00:00
|
|
|
if (p_surface) {
|
|
|
|
ANativeWindow *native_window = ANativeWindow_fromSurface(env, p_surface);
|
|
|
|
os_android->set_native_window(native_window);
|
|
|
|
}
|
2019-03-05 22:29:44 +00:00
|
|
|
} else {
|
2020-03-05 18:00:28 +00:00
|
|
|
// Rendering context recreated because it was lost; restart app to let it reload everything
|
2022-11-15 16:46:45 +00:00
|
|
|
_terminate(env, true);
|
2019-03-05 22:29:44 +00:00
|
|
|
}
|
2017-08-18 14:17:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-04 17:21:59 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_back(JNIEnv *env, jclass clazz) {
|
2024-07-03 09:37:14 +00:00
|
|
|
if (step.get() <= STEP_SETUP) {
|
2018-03-27 15:03:44 +00:00
|
|
|
return;
|
2022-02-16 12:56:32 +00:00
|
|
|
}
|
2018-03-27 15:03:44 +00:00
|
|
|
|
2021-08-04 19:22:11 +00:00
|
|
|
if (DisplayServerAndroid *dsa = Object::cast_to<DisplayServerAndroid>(DisplayServer::get_singleton())) {
|
|
|
|
dsa->send_window_event(DisplayServer::WINDOW_EVENT_GO_BACK_REQUEST);
|
|
|
|
}
|
2017-08-18 14:17:35 +00:00
|
|
|
}
|
|
|
|
|
2021-11-04 12:33:37 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_ttsCallback(JNIEnv *env, jclass clazz, jint event, jint id, jint pos) {
|
|
|
|
TTS_Android::_java_utterance_callback(event, id, pos);
|
|
|
|
}
|
|
|
|
|
2022-03-28 01:09:48 +00:00
|
|
|
JNIEXPORT jboolean JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env, jclass clazz) {
|
2024-07-03 09:37:14 +00:00
|
|
|
if (step.get() == STEP_TERMINATED) {
|
2022-03-28 01:09:48 +00:00
|
|
|
return true;
|
2022-02-16 12:56:32 +00:00
|
|
|
}
|
2019-03-05 22:29:44 +00:00
|
|
|
|
2024-07-03 09:37:14 +00:00
|
|
|
if (step.get() == STEP_SETUP) {
|
2021-01-19 12:29:41 +00:00
|
|
|
// Since Godot is initialized on the UI thread, main_thread_id was set to that thread's id,
|
2017-08-22 15:21:41 +00:00
|
|
|
// but for Godot purposes, the main thread is the one running the game loop
|
2024-07-03 09:37:14 +00:00
|
|
|
Main::setup2(false); // The logo is shown in the next frame otherwise we run into rendering issues
|
2021-08-04 19:22:11 +00:00
|
|
|
input_handler = new AndroidInputHandler();
|
|
|
|
step.increment();
|
2022-03-28 01:09:48 +00:00
|
|
|
return true;
|
2017-08-18 14:17:35 +00:00
|
|
|
}
|
|
|
|
|
2024-07-03 09:37:14 +00:00
|
|
|
if (step.get() == STEP_SHOW_LOGO) {
|
2024-08-31 06:11:50 +00:00
|
|
|
bool xr_enabled = false;
|
|
|
|
#ifndef _3D_DISABLED
|
|
|
|
// Unlike PCVR, there's no additional 2D screen onto which to render the boot logo,
|
|
|
|
// so we skip this step if xr is enabled.
|
2024-07-10 17:52:42 +00:00
|
|
|
if (XRServer::get_xr_mode() == XRServer::XRMODE_DEFAULT) {
|
|
|
|
xr_enabled = GLOBAL_GET("xr/shaders/enabled");
|
|
|
|
} else {
|
|
|
|
xr_enabled = XRServer::get_xr_mode() == XRServer::XRMODE_ON;
|
|
|
|
}
|
2024-08-31 06:11:50 +00:00
|
|
|
#endif // _3D_DISABLED
|
2024-07-10 17:52:42 +00:00
|
|
|
if (!xr_enabled) {
|
|
|
|
Main::setup_boot_logo();
|
|
|
|
}
|
|
|
|
|
2024-07-03 09:37:14 +00:00
|
|
|
step.increment();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (step.get() == STEP_STARTED) {
|
2024-03-25 16:50:02 +00:00
|
|
|
if (Main::start() != EXIT_SUCCESS) {
|
2022-03-28 01:09:48 +00:00
|
|
|
return true; // should exit instead and print the error
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2021-03-16 07:36:31 +00:00
|
|
|
godot_java->on_godot_setup_completed(env);
|
2014-02-10 01:10:30 +00:00
|
|
|
os_android->main_loop_begin();
|
2020-03-19 22:28:33 +00:00
|
|
|
godot_java->on_godot_main_loop_started(env);
|
2021-08-04 19:22:11 +00:00
|
|
|
step.increment();
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2020-03-27 16:30:18 +00:00
|
|
|
DisplayServerAndroid::get_singleton()->process_accelerometer(accelerometer);
|
|
|
|
DisplayServerAndroid::get_singleton()->process_gravity(gravity);
|
|
|
|
DisplayServerAndroid::get_singleton()->process_magnetometer(magnetometer);
|
|
|
|
DisplayServerAndroid::get_singleton()->process_gyroscope(gyroscope);
|
2016-07-15 07:31:34 +00:00
|
|
|
|
2022-03-28 01:09:48 +00:00
|
|
|
bool should_swap_buffers = false;
|
|
|
|
if (os_android->main_loop_iterate(&should_swap_buffers)) {
|
2022-11-15 16:46:45 +00:00
|
|
|
_terminate(env, false);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
2022-03-28 01:09:48 +00:00
|
|
|
|
|
|
|
return should_swap_buffers;
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2022-08-15 06:07:43 +00:00
|
|
|
// Called on the UI thread
|
2023-08-14 23:45:29 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_dispatchMouseEvent(JNIEnv *env, jclass clazz, jint p_event_type, jint p_button_mask, jfloat p_x, jfloat p_y, jfloat p_delta_x, jfloat p_delta_y, jboolean p_double_click, jboolean p_source_mouse_relative, jfloat p_pressure, jfloat p_tilt_x, jfloat p_tilt_y) {
|
2024-07-03 09:37:14 +00:00
|
|
|
if (step.get() <= STEP_SETUP) {
|
2022-08-15 06:07:43 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-08-14 23:45:29 +00:00
|
|
|
input_handler->process_mouse_event(p_event_type, p_button_mask, Point2(p_x, p_y), Vector2(p_delta_x, p_delta_y), p_double_click, p_source_mouse_relative, p_pressure, Vector2(p_tilt_x, p_tilt_y));
|
2022-08-15 06:07:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Called on the UI thread
|
2022-10-22 14:30:46 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_dispatchTouchEvent(JNIEnv *env, jclass clazz, jint ev, jint pointer, jint pointer_count, jfloatArray position, jboolean p_double_tap) {
|
2024-07-03 09:37:14 +00:00
|
|
|
if (step.get() <= STEP_SETUP) {
|
2018-03-27 15:03:44 +00:00
|
|
|
return;
|
2022-02-16 12:56:32 +00:00
|
|
|
}
|
2018-03-27 15:03:44 +00:00
|
|
|
|
2021-08-04 19:22:11 +00:00
|
|
|
Vector<AndroidInputHandler::TouchPos> points;
|
2020-10-07 23:37:58 +00:00
|
|
|
for (int i = 0; i < pointer_count; i++) {
|
2024-05-19 17:06:35 +00:00
|
|
|
jfloat p[6];
|
|
|
|
env->GetFloatArrayRegion(position, i * 6, 6, p);
|
2021-08-04 19:22:11 +00:00
|
|
|
AndroidInputHandler::TouchPos tp;
|
2020-10-07 23:37:58 +00:00
|
|
|
tp.id = (int)p[0];
|
2024-05-19 17:06:35 +00:00
|
|
|
tp.pos = Point2(p[1], p[2]);
|
|
|
|
tp.pressure = p[3];
|
|
|
|
tp.tilt = Vector2(p[4], p[5]);
|
2014-02-10 01:10:30 +00:00
|
|
|
points.push_back(tp);
|
|
|
|
}
|
2020-10-07 23:37:58 +00:00
|
|
|
|
2022-10-22 14:30:46 +00:00
|
|
|
input_handler->process_touch_event(ev, pointer, points, p_double_tap);
|
2020-10-07 23:37:58 +00:00
|
|
|
}
|
|
|
|
|
2021-08-04 19:22:11 +00:00
|
|
|
// Called on the UI thread
|
2022-08-15 06:07:43 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_magnify(JNIEnv *env, jclass clazz, jfloat p_x, jfloat p_y, jfloat p_factor) {
|
2024-07-03 09:37:14 +00:00
|
|
|
if (step.get() <= STEP_SETUP) {
|
2018-08-29 15:06:48 +00:00
|
|
|
return;
|
2022-02-16 12:56:32 +00:00
|
|
|
}
|
2022-08-15 06:07:43 +00:00
|
|
|
input_handler->process_magnify(Point2(p_x, p_y), p_factor);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2021-08-04 19:22:11 +00:00
|
|
|
// Called on the UI thread
|
2022-08-15 06:07:43 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_pan(JNIEnv *env, jclass clazz, jfloat p_x, jfloat p_y, jfloat p_delta_x, jfloat p_delta_y) {
|
2024-07-03 09:37:14 +00:00
|
|
|
if (step.get() <= STEP_SETUP) {
|
2019-11-14 23:34:50 +00:00
|
|
|
return;
|
2022-02-16 12:56:32 +00:00
|
|
|
}
|
2022-08-15 06:07:43 +00:00
|
|
|
input_handler->process_pan(Point2(p_x, p_y), Vector2(p_delta_x, p_delta_y));
|
2019-11-14 23:34:50 +00:00
|
|
|
}
|
|
|
|
|
2021-08-04 19:22:11 +00:00
|
|
|
// Called on the UI thread
|
2020-03-04 17:21:59 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joybutton(JNIEnv *env, jclass clazz, jint p_device, jint p_button, jboolean p_pressed) {
|
2024-07-03 09:37:14 +00:00
|
|
|
if (step.get() <= STEP_SETUP) {
|
2018-03-27 15:03:44 +00:00
|
|
|
return;
|
2022-02-16 12:56:32 +00:00
|
|
|
}
|
2014-07-02 03:09:36 +00:00
|
|
|
|
2021-08-04 19:22:11 +00:00
|
|
|
AndroidInputHandler::JoypadEvent jevent;
|
2016-01-24 04:11:59 +00:00
|
|
|
jevent.device = p_device;
|
2021-08-04 19:22:11 +00:00
|
|
|
jevent.type = AndroidInputHandler::JOY_EVENT_BUTTON;
|
2016-01-24 04:11:59 +00:00
|
|
|
jevent.index = p_button;
|
2017-06-07 03:29:19 +00:00
|
|
|
jevent.pressed = p_pressed;
|
2014-07-02 03:09:36 +00:00
|
|
|
|
2021-08-04 19:22:11 +00:00
|
|
|
input_handler->process_joy_event(jevent);
|
2016-07-21 10:07:01 +00:00
|
|
|
}
|
2014-07-02 03:09:36 +00:00
|
|
|
|
2021-08-04 19:22:11 +00:00
|
|
|
// Called on the UI thread
|
2020-03-04 17:21:59 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyaxis(JNIEnv *env, jclass clazz, jint p_device, jint p_axis, jfloat p_value) {
|
2024-07-03 09:37:14 +00:00
|
|
|
if (step.get() <= STEP_SETUP) {
|
2018-03-27 15:03:44 +00:00
|
|
|
return;
|
2021-08-13 21:31:57 +00:00
|
|
|
}
|
2014-07-02 03:09:36 +00:00
|
|
|
|
2021-08-04 19:22:11 +00:00
|
|
|
AndroidInputHandler::JoypadEvent jevent;
|
2016-01-24 04:11:59 +00:00
|
|
|
jevent.device = p_device;
|
2021-08-04 19:22:11 +00:00
|
|
|
jevent.type = AndroidInputHandler::JOY_EVENT_AXIS;
|
2016-01-24 04:11:59 +00:00
|
|
|
jevent.index = p_axis;
|
|
|
|
jevent.value = p_value;
|
2014-07-02 03:09:36 +00:00
|
|
|
|
2021-08-04 19:22:11 +00:00
|
|
|
input_handler->process_joy_event(jevent);
|
2016-07-21 10:07:01 +00:00
|
|
|
}
|
2014-07-02 03:09:36 +00:00
|
|
|
|
2021-08-04 19:22:11 +00:00
|
|
|
// Called on the UI thread
|
2020-03-04 17:21:59 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyhat(JNIEnv *env, jclass clazz, jint p_device, jint p_hat_x, jint p_hat_y) {
|
2024-07-03 09:37:14 +00:00
|
|
|
if (step.get() <= STEP_SETUP) {
|
2018-03-27 15:03:44 +00:00
|
|
|
return;
|
2021-08-13 21:31:57 +00:00
|
|
|
}
|
2018-03-27 15:03:44 +00:00
|
|
|
|
2021-08-04 19:22:11 +00:00
|
|
|
AndroidInputHandler::JoypadEvent jevent;
|
2016-01-24 04:11:59 +00:00
|
|
|
jevent.device = p_device;
|
2021-08-04 19:22:11 +00:00
|
|
|
jevent.type = AndroidInputHandler::JOY_EVENT_HAT;
|
2023-01-07 23:55:54 +00:00
|
|
|
BitField<HatMask> hat;
|
2016-01-24 04:11:59 +00:00
|
|
|
if (p_hat_x != 0) {
|
2021-08-13 21:31:57 +00:00
|
|
|
if (p_hat_x < 0) {
|
2023-01-07 23:55:54 +00:00
|
|
|
hat.set_flag(HatMask::LEFT);
|
2021-08-13 21:31:57 +00:00
|
|
|
} else {
|
2023-01-07 23:55:54 +00:00
|
|
|
hat.set_flag(HatMask::RIGHT);
|
2021-08-13 21:31:57 +00:00
|
|
|
}
|
2016-01-24 04:11:59 +00:00
|
|
|
}
|
|
|
|
if (p_hat_y != 0) {
|
2021-08-13 21:31:57 +00:00
|
|
|
if (p_hat_y < 0) {
|
2023-01-07 23:55:54 +00:00
|
|
|
hat.set_flag(HatMask::UP);
|
2021-08-13 21:31:57 +00:00
|
|
|
} else {
|
2023-01-07 23:55:54 +00:00
|
|
|
hat.set_flag(HatMask::DOWN);
|
2021-08-13 21:31:57 +00:00
|
|
|
}
|
2016-01-24 04:11:59 +00:00
|
|
|
}
|
|
|
|
jevent.hat = hat;
|
2017-10-02 09:40:16 +00:00
|
|
|
|
2021-08-04 19:22:11 +00:00
|
|
|
input_handler->process_joy_event(jevent);
|
2016-01-24 04:11:59 +00:00
|
|
|
}
|
|
|
|
|
2021-08-04 19:22:11 +00:00
|
|
|
// Called on the UI thread
|
2020-03-04 17:21:59 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyconnectionchanged(JNIEnv *env, jclass clazz, jint p_device, jboolean p_connected, jstring p_name) {
|
2016-01-24 04:11:59 +00:00
|
|
|
if (os_android) {
|
2019-02-26 20:54:45 +00:00
|
|
|
String name = jstring_to_string(p_name, env);
|
2020-04-28 13:19:37 +00:00
|
|
|
Input::get_singleton()->joy_connection_changed(p_device, p_connected, name);
|
2016-01-24 04:11:59 +00:00
|
|
|
}
|
|
|
|
}
|
2014-07-02 03:09:36 +00:00
|
|
|
|
2021-08-04 19:22:11 +00:00
|
|
|
// Called on the UI thread
|
2023-07-05 12:34:18 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_key(JNIEnv *env, jclass clazz, jint p_physical_keycode, jint p_unicode, jint p_key_label, jboolean p_pressed, jboolean p_echo) {
|
2024-07-03 09:37:14 +00:00
|
|
|
if (step.get() <= STEP_SETUP) {
|
2018-03-27 15:03:44 +00:00
|
|
|
return;
|
2022-02-16 12:56:32 +00:00
|
|
|
}
|
2023-07-05 12:34:18 +00:00
|
|
|
input_handler->process_key_event(p_physical_keycode, p_unicode, p_key_label, p_pressed, p_echo);
|
2016-07-21 10:07:01 +00:00
|
|
|
}
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-03-04 17:21:59 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_accelerometer(JNIEnv *env, jclass clazz, jfloat x, jfloat y, jfloat z) {
|
2014-02-10 01:10:30 +00:00
|
|
|
accelerometer = Vector3(x, y, z);
|
|
|
|
}
|
|
|
|
|
2020-03-04 17:21:59 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_gravity(JNIEnv *env, jclass clazz, jfloat x, jfloat y, jfloat z) {
|
2017-11-10 22:42:23 +00:00
|
|
|
gravity = Vector3(x, y, z);
|
|
|
|
}
|
|
|
|
|
2020-03-04 17:21:59 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_magnetometer(JNIEnv *env, jclass clazz, jfloat x, jfloat y, jfloat z) {
|
2016-05-27 17:29:37 +00:00
|
|
|
magnetometer = Vector3(x, y, z);
|
|
|
|
}
|
|
|
|
|
2020-03-04 17:21:59 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_gyroscope(JNIEnv *env, jclass clazz, jfloat x, jfloat y, jfloat z) {
|
2016-07-15 07:31:34 +00:00
|
|
|
gyroscope = Vector3(x, y, z);
|
|
|
|
}
|
|
|
|
|
2020-03-04 17:21:59 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_focusin(JNIEnv *env, jclass clazz) {
|
2024-07-03 09:37:14 +00:00
|
|
|
if (step.get() <= STEP_SETUP) {
|
2018-03-27 15:03:44 +00:00
|
|
|
return;
|
2022-02-16 12:56:32 +00:00
|
|
|
}
|
2018-03-27 15:03:44 +00:00
|
|
|
|
|
|
|
os_android->main_loop_focusin();
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2020-03-04 17:21:59 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_focusout(JNIEnv *env, jclass clazz) {
|
2024-07-03 09:37:14 +00:00
|
|
|
if (step.get() <= STEP_SETUP) {
|
2018-03-27 15:03:44 +00:00
|
|
|
return;
|
2022-02-16 12:56:32 +00:00
|
|
|
}
|
2018-03-27 15:03:44 +00:00
|
|
|
|
|
|
|
os_android->main_loop_focusout();
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2020-03-04 17:21:59 +00:00
|
|
|
JNIEXPORT jstring JNICALL Java_org_godotengine_godot_GodotLib_getGlobal(JNIEnv *env, jclass clazz, jstring path) {
|
2019-02-26 20:54:45 +00:00
|
|
|
String js = jstring_to_string(path, env);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2024-09-08 20:34:23 +00:00
|
|
|
Variant setting_with_override = GLOBAL_GET(js);
|
|
|
|
String setting_value = (setting_with_override.get_type() == Variant::NIL) ? "" : setting_with_override;
|
|
|
|
return env->NewStringUTF(setting_value.utf8().get_data());
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2023-02-21 17:18:08 +00:00
|
|
|
JNIEXPORT jstring JNICALL Java_org_godotengine_godot_GodotLib_getEditorSetting(JNIEnv *env, jclass clazz, jstring p_setting_key) {
|
2024-09-08 20:34:23 +00:00
|
|
|
String editor_setting_value = "";
|
2023-02-21 17:18:08 +00:00
|
|
|
#ifdef TOOLS_ENABLED
|
|
|
|
String godot_setting_key = jstring_to_string(p_setting_key, env);
|
2024-09-08 20:34:23 +00:00
|
|
|
Variant editor_setting = EDITOR_GET(godot_setting_key);
|
|
|
|
editor_setting_value = (editor_setting.get_type() == Variant::NIL) ? "" : editor_setting;
|
2023-02-21 17:18:08 +00:00
|
|
|
#else
|
|
|
|
WARN_PRINT("Access to the Editor Settings in only available on Editor builds");
|
|
|
|
#endif
|
|
|
|
|
2024-09-08 20:34:23 +00:00
|
|
|
return env->NewStringUTF(editor_setting_value.utf8().get_data());
|
2023-02-21 17:18:08 +00:00
|
|
|
}
|
|
|
|
|
2020-05-24 11:26:18 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_callobject(JNIEnv *env, jclass clazz, jlong ID, jstring method, jobjectArray params) {
|
|
|
|
Object *obj = ObjectDB::get_instance(ObjectID(ID));
|
2022-05-30 21:13:49 +00:00
|
|
|
ERR_FAIL_NULL(obj);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2019-02-26 20:54:45 +00:00
|
|
|
String str_method = jstring_to_string(method, env);
|
2015-05-18 15:45:53 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
int count = env->GetArrayLength(params);
|
2023-04-28 09:31:22 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
Variant *vlist = (Variant *)alloca(sizeof(Variant) * count);
|
2023-04-28 09:31:22 +00:00
|
|
|
const Variant **vptr = (const Variant **)alloca(sizeof(Variant *) * count);
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
for (int i = 0; i < count; i++) {
|
2022-05-30 21:13:49 +00:00
|
|
|
jobject jobj = env->GetObjectArrayElement(params, i);
|
2023-04-28 09:31:22 +00:00
|
|
|
ERR_FAIL_NULL(jobj);
|
|
|
|
memnew_placement(&vlist[i], Variant(_jobject_to_variant(env, jobj)));
|
2014-02-10 01:10:30 +00:00
|
|
|
vptr[i] = &vlist[i];
|
2022-05-30 21:13:49 +00:00
|
|
|
env->DeleteLocalRef(jobj);
|
2022-02-16 12:56:32 +00:00
|
|
|
}
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-02-19 19:27:19 +00:00
|
|
|
Callable::CallError err;
|
2023-04-28 09:31:22 +00:00
|
|
|
obj->callp(str_method, vptr, count, err);
|
2016-07-21 10:07:01 +00:00
|
|
|
}
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-05-24 11:26:18 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_calldeferred(JNIEnv *env, jclass clazz, jlong ID, jstring method, jobjectArray params) {
|
|
|
|
Object *obj = ObjectDB::get_instance(ObjectID(ID));
|
2022-05-30 21:13:49 +00:00
|
|
|
ERR_FAIL_NULL(obj);
|
2014-02-13 21:03:28 +00:00
|
|
|
|
2019-02-26 20:54:45 +00:00
|
|
|
String str_method = jstring_to_string(method, env);
|
2015-05-18 15:45:53 +00:00
|
|
|
|
2014-02-13 21:03:28 +00:00
|
|
|
int count = env->GetArrayLength(params);
|
|
|
|
|
2022-03-09 13:58:40 +00:00
|
|
|
Variant *args = (Variant *)alloca(sizeof(Variant) * count);
|
|
|
|
const Variant **argptrs = (const Variant **)alloca(sizeof(Variant *) * count);
|
|
|
|
|
|
|
|
for (int i = 0; i < count; i++) {
|
2022-05-30 21:13:49 +00:00
|
|
|
jobject jobj = env->GetObjectArrayElement(params, i);
|
2023-04-28 09:31:22 +00:00
|
|
|
ERR_FAIL_NULL(jobj);
|
|
|
|
memnew_placement(&args[i], Variant(_jobject_to_variant(env, jobj)));
|
2022-03-09 13:58:40 +00:00
|
|
|
argptrs[i] = &args[i];
|
2023-04-28 09:31:22 +00:00
|
|
|
env->DeleteLocalRef(jobj);
|
2022-02-16 12:56:32 +00:00
|
|
|
}
|
2014-02-13 21:03:28 +00:00
|
|
|
|
2023-12-18 14:46:56 +00:00
|
|
|
Callable(obj, str_method).call_deferredp(argptrs, count);
|
2016-07-21 10:07:01 +00:00
|
|
|
}
|
2019-03-05 02:06:37 +00:00
|
|
|
|
2024-01-19 18:46:26 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_onNightModeChanged(JNIEnv *env, jclass clazz) {
|
|
|
|
DisplayServerAndroid *ds = (DisplayServerAndroid *)DisplayServer::get_singleton();
|
|
|
|
if (ds) {
|
|
|
|
ds->emit_system_theme_changed();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-04 17:21:59 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_requestPermissionResult(JNIEnv *env, jclass clazz, jstring p_permission, jboolean p_result) {
|
2019-03-05 02:06:37 +00:00
|
|
|
String permission = jstring_to_string(p_permission, env);
|
|
|
|
if (permission == "android.permission.RECORD_AUDIO" && p_result) {
|
2023-02-08 15:40:15 +00:00
|
|
|
AudioDriver::get_singleton()->input_start();
|
2019-03-05 02:06:37 +00:00
|
|
|
}
|
2019-10-06 18:17:44 +00:00
|
|
|
|
|
|
|
if (os_android->get_main_loop()) {
|
2021-07-17 21:22:52 +00:00
|
|
|
os_android->get_main_loop()->emit_signal(SNAME("on_request_permissions_result"), permission, p_result == JNI_TRUE);
|
2019-10-06 18:17:44 +00:00
|
|
|
}
|
2019-03-05 02:06:37 +00:00
|
|
|
}
|
2019-09-09 21:42:17 +00:00
|
|
|
|
|
|
|
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_onRendererResumed(JNIEnv *env, jclass clazz) {
|
2024-07-03 09:37:14 +00:00
|
|
|
if (step.get() <= STEP_SETUP) {
|
2019-09-09 21:42:17 +00:00
|
|
|
return;
|
2022-02-16 12:56:32 +00:00
|
|
|
}
|
2019-09-09 21:42:17 +00:00
|
|
|
|
2022-04-25 07:03:00 +00:00
|
|
|
// We force redraw to ensure we render at least once when resuming the app.
|
|
|
|
Main::force_redraw();
|
2019-09-09 21:42:17 +00:00
|
|
|
if (os_android->get_main_loop()) {
|
2020-06-29 23:47:18 +00:00
|
|
|
os_android->get_main_loop()->notification(MainLoop::NOTIFICATION_APPLICATION_RESUMED);
|
2019-09-09 21:42:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_onRendererPaused(JNIEnv *env, jclass clazz) {
|
2024-07-03 09:37:14 +00:00
|
|
|
if (step.get() <= STEP_SETUP) {
|
2019-09-09 21:42:17 +00:00
|
|
|
return;
|
2022-02-16 12:56:32 +00:00
|
|
|
}
|
2019-09-09 21:42:17 +00:00
|
|
|
|
|
|
|
if (os_android->get_main_loop()) {
|
2020-06-29 23:47:18 +00:00
|
|
|
os_android->get_main_loop()->notification(MainLoop::NOTIFICATION_APPLICATION_PAUSED);
|
2019-09-09 21:42:17 +00:00
|
|
|
}
|
|
|
|
}
|
2024-05-09 17:22:26 +00:00
|
|
|
|
2024-07-07 21:16:29 +00:00
|
|
|
JNIEXPORT jboolean JNICALL Java_org_godotengine_godot_GodotLib_shouldDispatchInputToRenderThread(JNIEnv *env, jclass clazz) {
|
|
|
|
Input *input = Input::get_singleton();
|
|
|
|
if (input) {
|
|
|
|
return !input->is_agile_input_event_flushing();
|
2024-05-09 17:22:26 +00:00
|
|
|
}
|
2024-07-07 21:16:29 +00:00
|
|
|
return false;
|
2024-05-09 17:22:26 +00:00
|
|
|
}
|
2024-03-08 03:16:25 +00:00
|
|
|
|
|
|
|
JNIEXPORT jstring JNICALL Java_org_godotengine_godot_GodotLib_getProjectResourceDir(JNIEnv *env, jclass clazz) {
|
|
|
|
const String resource_dir = OS::get_singleton()->get_resource_dir();
|
|
|
|
return env->NewStringUTF(resource_dir.utf8().get_data());
|
|
|
|
}
|
2020-03-04 17:21:59 +00:00
|
|
|
}
|