Path: blob/master/platform/android/java_godot_wrapper.h
10277 views
/**************************************************************************/1/* java_godot_wrapper.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#include "java_godot_view_wrapper.h"3334#include "core/math/color.h"35#include "core/templates/list.h"3637#include <android/log.h>38#include <jni.h>3940// Class that makes functions in java/src/org/godotengine/godot/Godot.kt callable from C++41class GodotJavaWrapper {42private:43jobject godot_instance;44jclass godot_class;4546GodotJavaViewWrapper *godot_view = nullptr;4748jmethodID _restart = nullptr;49jmethodID _finish = nullptr;50jmethodID _set_keep_screen_on = nullptr;51jmethodID _alert = nullptr;52jmethodID _is_dark_mode_supported = nullptr;53jmethodID _is_dark_mode = nullptr;54jmethodID _get_accent_color = nullptr;55jmethodID _get_base_color = nullptr;56jmethodID _get_clipboard = nullptr;57jmethodID _set_clipboard = nullptr;58jmethodID _has_clipboard = nullptr;59jmethodID _show_dialog = nullptr;60jmethodID _show_input_dialog = nullptr;61jmethodID _show_file_picker = nullptr;62jmethodID _request_permission = nullptr;63jmethodID _request_permissions = nullptr;64jmethodID _get_granted_permissions = nullptr;65jmethodID _get_gdextension_list_config_file = nullptr;66jmethodID _get_ca_certificates = nullptr;67jmethodID _init_input_devices = nullptr;68jmethodID _vibrate = nullptr;69jmethodID _get_input_fallback_mapping = nullptr;70jmethodID _on_godot_setup_completed = nullptr;71jmethodID _on_godot_main_loop_started = nullptr;72jmethodID _on_godot_terminating = nullptr;73jmethodID _create_new_godot_instance = nullptr;74jmethodID _get_render_view = nullptr;75jmethodID _begin_benchmark_measure = nullptr;76jmethodID _end_benchmark_measure = nullptr;77jmethodID _dump_benchmark = nullptr;78jmethodID _has_feature = nullptr;79jmethodID _sign_apk = nullptr;80jmethodID _verify_apk = nullptr;81jmethodID _enable_immersive_mode = nullptr;82jmethodID _is_in_immersive_mode = nullptr;83jmethodID _on_editor_workspace_selected = nullptr;84jmethodID _get_activity = nullptr;8586public:87GodotJavaWrapper(JNIEnv *p_env, jobject p_godot_instance);88~GodotJavaWrapper();8990jobject get_activity();9192GodotJavaViewWrapper *get_godot_view();9394void on_godot_setup_completed(JNIEnv *p_env = nullptr);95void on_godot_main_loop_started(JNIEnv *p_env = nullptr);96void on_godot_terminating(JNIEnv *p_env = nullptr);97void restart(JNIEnv *p_env = nullptr);98bool force_quit(JNIEnv *p_env = nullptr, int p_instance_id = 0);99void set_keep_screen_on(bool p_enabled);100void alert(const String &p_message, const String &p_title);101bool is_dark_mode_supported();102bool is_dark_mode();103Color get_accent_color();104Color get_base_color();105bool has_get_clipboard();106String get_clipboard();107bool has_set_clipboard();108void set_clipboard(const String &p_text);109bool has_has_clipboard();110bool has_clipboard();111Error show_dialog(const String &p_title, const String &p_description, const Vector<String> &p_buttons);112Error show_input_dialog(const String &p_title, const String &p_message, const String &p_existing_text);113Error show_file_picker(const String &p_current_directory, const String &p_filename, int p_mode, const Vector<String> &p_filters);114bool request_permission(const String &p_name);115bool request_permissions();116Vector<String> get_granted_permissions() const;117String get_ca_certificates() const;118void init_input_devices();119void vibrate(int p_duration_ms, float p_amplitude = -1.0);120String get_input_fallback_mapping();121int create_new_godot_instance(const List<String> &args);122void begin_benchmark_measure(const String &p_context, const String &p_label);123void end_benchmark_measure(const String &p_context, const String &p_label);124void dump_benchmark(const String &benchmark_file);125126// Return the list of gdextensions config file.127Vector<String> get_gdextension_list_config_file() const;128129// Return true if the given feature is supported.130bool has_feature(const String &p_feature) const;131132// Sign and verify apks133Error 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);134Error verify_apk(const String &p_apk_path);135136void enable_immersive_mode(bool p_enabled);137bool is_in_immersive_mode();138139void on_editor_workspace_selected(const String &p_workspace);140};141142143