| 
									
										
										
										
											2019-03-13 23:51:55 +11:00
										 |  |  | /**************************************************************************/ | 
					
						
							|  |  |  | /*  java_godot_wrapper.h                                                  */ | 
					
						
							|  |  |  | /**************************************************************************/ | 
					
						
							|  |  |  | /*                         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.                 */ | 
					
						
							|  |  |  | /**************************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-01 03:30:40 +02:00
										 |  |  | #include "java_godot_view_wrapper.h"
 | 
					
						
							| 
									
										
										
										
											2019-03-13 23:51:55 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-01 03:36:26 +05:30
										 |  |  | #include "core/math/color.h"
 | 
					
						
							| 
									
										
										
										
											2023-06-08 14:51:32 +02:00
										 |  |  | #include "core/templates/list.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <android/log.h>
 | 
					
						
							|  |  |  | #include <jni.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-21 15:26:40 +01:00
										 |  |  | // Class that makes functions in java/src/org/godotengine/godot/Godot.kt callable from C++
 | 
					
						
							| 
									
										
										
										
											2019-03-13 23:51:55 +11:00
										 |  |  | class GodotJavaWrapper { | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  | 	jobject godot_instance; | 
					
						
							| 
									
										
										
										
											2020-06-15 00:46:13 -07:00
										 |  |  | 	jclass godot_class; | 
					
						
							| 
									
										
										
										
											2019-03-13 23:51:55 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-05 10:48:08 -07:00
										 |  |  | 	GodotJavaViewWrapper *godot_view = nullptr; | 
					
						
							| 
									
										
										
										
											2020-11-01 03:30:40 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-30 22:13:49 +01:00
										 |  |  | 	jmethodID _restart = nullptr; | 
					
						
							|  |  |  | 	jmethodID _finish = nullptr; | 
					
						
							|  |  |  | 	jmethodID _set_keep_screen_on = nullptr; | 
					
						
							|  |  |  | 	jmethodID _alert = nullptr; | 
					
						
							| 
									
										
										
										
											2023-09-26 11:00:04 +08:00
										 |  |  | 	jmethodID _is_dark_mode_supported = nullptr; | 
					
						
							|  |  |  | 	jmethodID _is_dark_mode = nullptr; | 
					
						
							| 
									
										
										
										
											2024-11-01 03:36:26 +05:30
										 |  |  | 	jmethodID _get_accent_color = nullptr; | 
					
						
							| 
									
										
										
										
											2024-12-09 17:55:42 +05:30
										 |  |  | 	jmethodID _get_base_color = nullptr; | 
					
						
							| 
									
										
										
										
											2022-05-30 22:13:49 +01:00
										 |  |  | 	jmethodID _get_clipboard = nullptr; | 
					
						
							|  |  |  | 	jmethodID _set_clipboard = nullptr; | 
					
						
							|  |  |  | 	jmethodID _has_clipboard = nullptr; | 
					
						
							| 
									
										
										
										
											2025-01-03 09:24:38 +05:30
										 |  |  | 	jmethodID _show_dialog = nullptr; | 
					
						
							| 
									
										
										
										
											2024-10-27 16:29:55 +05:30
										 |  |  | 	jmethodID _show_input_dialog = nullptr; | 
					
						
							| 
									
										
										
										
											2024-10-21 14:47:32 +05:30
										 |  |  | 	jmethodID _show_file_picker = nullptr; | 
					
						
							| 
									
										
										
										
											2022-05-30 22:13:49 +01:00
										 |  |  | 	jmethodID _request_permission = nullptr; | 
					
						
							|  |  |  | 	jmethodID _request_permissions = nullptr; | 
					
						
							|  |  |  | 	jmethodID _get_granted_permissions = nullptr; | 
					
						
							| 
									
										
										
										
											2023-07-17 12:11:37 -07:00
										 |  |  | 	jmethodID _get_gdextension_list_config_file = nullptr; | 
					
						
							| 
									
										
										
										
											2023-04-13 21:17:55 +02:00
										 |  |  | 	jmethodID _get_ca_certificates = nullptr; | 
					
						
							| 
									
										
										
										
											2022-05-30 22:13:49 +01:00
										 |  |  | 	jmethodID _init_input_devices = nullptr; | 
					
						
							|  |  |  | 	jmethodID _vibrate = nullptr; | 
					
						
							|  |  |  | 	jmethodID _get_input_fallback_mapping = nullptr; | 
					
						
							|  |  |  | 	jmethodID _on_godot_setup_completed = nullptr; | 
					
						
							|  |  |  | 	jmethodID _on_godot_main_loop_started = nullptr; | 
					
						
							| 
									
										
										
										
											2024-07-22 17:51:45 -07:00
										 |  |  | 	jmethodID _on_godot_terminating = nullptr; | 
					
						
							| 
									
										
										
										
											2022-05-30 22:13:49 +01:00
										 |  |  | 	jmethodID _create_new_godot_instance = nullptr; | 
					
						
							| 
									
										
										
										
											2022-10-05 10:48:08 -07:00
										 |  |  | 	jmethodID _get_render_view = nullptr; | 
					
						
							| 
									
										
										
										
											2023-01-13 11:24:12 -08:00
										 |  |  | 	jmethodID _begin_benchmark_measure = nullptr; | 
					
						
							|  |  |  | 	jmethodID _end_benchmark_measure = nullptr; | 
					
						
							|  |  |  | 	jmethodID _dump_benchmark = nullptr; | 
					
						
							| 
									
										
										
										
											2023-06-08 12:05:20 +10:00
										 |  |  | 	jmethodID _has_feature = nullptr; | 
					
						
							| 
									
										
										
										
											2024-06-16 12:14:34 -07:00
										 |  |  | 	jmethodID _sign_apk = nullptr; | 
					
						
							|  |  |  | 	jmethodID _verify_apk = nullptr; | 
					
						
							| 
									
										
										
										
											2024-08-27 13:54:17 -07:00
										 |  |  | 	jmethodID _enable_immersive_mode = nullptr; | 
					
						
							|  |  |  | 	jmethodID _is_in_immersive_mode = nullptr; | 
					
						
							| 
									
										
										
										
											2025-08-10 19:57:02 +05:30
										 |  |  | 	jmethodID _set_window_color = nullptr; | 
					
						
							| 
									
										
										
										
											2025-01-07 21:31:53 -08:00
										 |  |  | 	jmethodID _on_editor_workspace_selected = nullptr; | 
					
						
							| 
									
										
										
										
											2025-02-03 04:34:29 -08:00
										 |  |  | 	jmethodID _get_activity = nullptr; | 
					
						
							| 
									
										
										
										
											2019-03-13 23:51:55 +11:00
										 |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2025-02-03 04:34:29 -08:00
										 |  |  | 	GodotJavaWrapper(JNIEnv *p_env, jobject p_godot_instance); | 
					
						
							| 
									
										
										
										
											2019-03-13 23:51:55 +11:00
										 |  |  | 	~GodotJavaWrapper(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	jobject get_activity(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-01 03:30:40 +02:00
										 |  |  | 	GodotJavaViewWrapper *get_godot_view(); | 
					
						
							| 
									
										
										
										
											2019-03-13 23:51:55 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-16 00:36:31 -07:00
										 |  |  | 	void on_godot_setup_completed(JNIEnv *p_env = nullptr); | 
					
						
							| 
									
										
										
										
											2020-04-02 01:20:12 +02:00
										 |  |  | 	void on_godot_main_loop_started(JNIEnv *p_env = nullptr); | 
					
						
							| 
									
										
										
										
											2024-07-22 17:51:45 -07:00
										 |  |  | 	void on_godot_terminating(JNIEnv *p_env = nullptr); | 
					
						
							| 
									
										
										
										
											2020-04-02 01:20:12 +02:00
										 |  |  | 	void restart(JNIEnv *p_env = nullptr); | 
					
						
							| 
									
										
										
										
											2023-01-26 02:55:47 -08:00
										 |  |  | 	bool force_quit(JNIEnv *p_env = nullptr, int p_instance_id = 0); | 
					
						
							| 
									
										
										
										
											2019-03-13 23:51:55 +11:00
										 |  |  | 	void set_keep_screen_on(bool p_enabled); | 
					
						
							|  |  |  | 	void alert(const String &p_message, const String &p_title); | 
					
						
							| 
									
										
										
										
											2023-09-26 11:00:04 +08:00
										 |  |  | 	bool is_dark_mode_supported(); | 
					
						
							|  |  |  | 	bool is_dark_mode(); | 
					
						
							| 
									
										
										
										
											2024-11-01 03:36:26 +05:30
										 |  |  | 	Color get_accent_color(); | 
					
						
							| 
									
										
										
										
											2024-12-09 17:55:42 +05:30
										 |  |  | 	Color get_base_color(); | 
					
						
							| 
									
										
										
										
											2019-03-13 23:51:55 +11:00
										 |  |  | 	bool has_get_clipboard(); | 
					
						
							|  |  |  | 	String get_clipboard(); | 
					
						
							|  |  |  | 	bool has_set_clipboard(); | 
					
						
							|  |  |  | 	void set_clipboard(const String &p_text); | 
					
						
							| 
									
										
										
										
											2022-01-19 21:04:52 +08:00
										 |  |  | 	bool has_has_clipboard(); | 
					
						
							|  |  |  | 	bool has_clipboard(); | 
					
						
							| 
									
										
										
										
											2025-01-03 09:24:38 +05:30
										 |  |  | 	Error show_dialog(const String &p_title, const String &p_description, const Vector<String> &p_buttons); | 
					
						
							| 
									
										
										
										
											2024-10-27 16:29:55 +05:30
										 |  |  | 	Error show_input_dialog(const String &p_title, const String &p_message, const String &p_existing_text); | 
					
						
							| 
									
										
										
										
											2024-10-21 14:47:32 +05:30
										 |  |  | 	Error show_file_picker(const String &p_current_directory, const String &p_filename, int p_mode, const Vector<String> &p_filters); | 
					
						
							| 
									
										
										
										
											2019-03-13 23:51:55 +11:00
										 |  |  | 	bool request_permission(const String &p_name); | 
					
						
							| 
									
										
										
										
											2019-10-06 21:17:44 +03:00
										 |  |  | 	bool request_permissions(); | 
					
						
							|  |  |  | 	Vector<String> get_granted_permissions() const; | 
					
						
							| 
									
										
										
										
											2023-04-13 21:17:55 +02:00
										 |  |  | 	String get_ca_certificates() const; | 
					
						
							| 
									
										
										
										
											2019-05-03 15:56:44 +02:00
										 |  |  | 	void init_input_devices(); | 
					
						
							| 
									
										
										
										
											2024-05-02 16:15:42 +03:00
										 |  |  | 	void vibrate(int p_duration_ms, float p_amplitude = -1.0); | 
					
						
							| 
									
										
										
										
											2019-08-26 17:47:13 -07:00
										 |  |  | 	String get_input_fallback_mapping(); | 
					
						
							| 
									
										
										
										
											2021-08-01 16:47:20 -03:00
										 |  |  | 	int create_new_godot_instance(const List<String> &args); | 
					
						
							| 
									
										
										
										
											2023-12-08 12:52:49 +01:00
										 |  |  | 	void begin_benchmark_measure(const String &p_context, const String &p_label); | 
					
						
							|  |  |  | 	void end_benchmark_measure(const String &p_context, const String &p_label); | 
					
						
							| 
									
										
										
										
											2023-01-13 11:24:12 -08:00
										 |  |  | 	void dump_benchmark(const String &benchmark_file); | 
					
						
							| 
									
										
										
										
											2023-07-17 12:11:37 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// Return the list of gdextensions config file.
 | 
					
						
							|  |  |  | 	Vector<String> get_gdextension_list_config_file() const; | 
					
						
							| 
									
										
										
										
											2023-06-08 12:05:20 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// Return true if the given feature is supported.
 | 
					
						
							|  |  |  | 	bool has_feature(const String &p_feature) const; | 
					
						
							| 
									
										
										
										
											2024-06-16 12:14:34 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// Sign and verify apks
 | 
					
						
							|  |  |  | 	Error sign_apk(const String &p_input_path, const String &p_output_path, const String &p_keystore_path, const String &p_keystore_user, const String &p_keystore_password); | 
					
						
							|  |  |  | 	Error verify_apk(const String &p_apk_path); | 
					
						
							| 
									
										
										
										
											2024-08-27 13:54:17 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	void enable_immersive_mode(bool p_enabled); | 
					
						
							|  |  |  | 	bool is_in_immersive_mode(); | 
					
						
							| 
									
										
										
										
											2025-01-07 21:31:53 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-10 19:57:02 +05:30
										 |  |  | 	void set_window_color(const Color &p_color); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-07 21:31:53 -08:00
										 |  |  | 	void on_editor_workspace_selected(const String &p_workspace); | 
					
						
							| 
									
										
										
										
											2019-03-13 23:51:55 +11:00
										 |  |  | }; |