2020-03-27 16:30:18 +00:00
|
|
|
/**************************************************************************/
|
|
|
|
/* display_server_android.cpp */
|
|
|
|
/**************************************************************************/
|
|
|
|
/* 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. */
|
|
|
|
/**************************************************************************/
|
|
|
|
|
|
|
|
#include "display_server_android.h"
|
|
|
|
|
|
|
|
#include "java_godot_io_wrapper.h"
|
|
|
|
#include "java_godot_wrapper.h"
|
|
|
|
#include "os_android.h"
|
2021-11-04 12:33:37 +00:00
|
|
|
#include "tts_android.h"
|
2020-03-27 16:30:18 +00:00
|
|
|
|
2023-06-08 12:51:32 +00:00
|
|
|
#include "core/config/project_settings.h"
|
|
|
|
|
2023-12-19 11:48:02 +00:00
|
|
|
#if defined(RD_ENABLED)
|
|
|
|
#include "servers/rendering/renderer_rd/renderer_compositor_rd.h"
|
|
|
|
#include "servers/rendering/rendering_device.h"
|
|
|
|
|
2020-03-27 16:30:18 +00:00
|
|
|
#if defined(VULKAN_ENABLED)
|
2023-12-19 17:57:56 +00:00
|
|
|
#include "rendering_context_driver_vulkan_android.h"
|
2023-12-19 11:48:02 +00:00
|
|
|
#endif
|
2020-03-27 16:30:18 +00:00
|
|
|
#endif
|
2023-06-08 12:51:32 +00:00
|
|
|
|
2022-11-11 23:30:06 +00:00
|
|
|
#ifdef GLES3_ENABLED
|
|
|
|
#include "drivers/gles3/rasterizer_gles3.h"
|
2023-06-08 12:51:32 +00:00
|
|
|
|
2022-11-11 23:30:06 +00:00
|
|
|
#include <EGL/egl.h>
|
|
|
|
#endif
|
2020-03-27 16:30:18 +00:00
|
|
|
|
|
|
|
DisplayServerAndroid *DisplayServerAndroid::get_singleton() {
|
2022-04-05 10:40:26 +00:00
|
|
|
return static_cast<DisplayServerAndroid *>(DisplayServer::get_singleton());
|
2020-03-27 16:30:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool DisplayServerAndroid::has_feature(Feature p_feature) const {
|
|
|
|
switch (p_feature) {
|
2024-01-19 17:41:01 +00:00
|
|
|
#ifndef DISABLE_DEPRECATED
|
|
|
|
case FEATURE_GLOBAL_MENU: {
|
|
|
|
return (native_menu && native_menu->has_feature(NativeMenu::FEATURE_GLOBAL_MENU));
|
|
|
|
} break;
|
|
|
|
#endif
|
2020-11-04 21:55:28 +00:00
|
|
|
case FEATURE_CURSOR_SHAPE:
|
2020-03-27 16:30:18 +00:00
|
|
|
//case FEATURE_CUSTOM_CURSOR_SHAPE:
|
|
|
|
//case FEATURE_HIDPI:
|
|
|
|
//case FEATURE_ICON:
|
|
|
|
//case FEATURE_IME:
|
2020-10-07 23:37:58 +00:00
|
|
|
case FEATURE_MOUSE:
|
2020-03-27 16:30:18 +00:00
|
|
|
//case FEATURE_MOUSE_WARP:
|
|
|
|
//case FEATURE_NATIVE_DIALOG:
|
2024-03-26 13:18:06 +00:00
|
|
|
//case FEATURE_NATIVE_DIALOG_INPUT:
|
|
|
|
//case FEATURE_NATIVE_DIALOG_FILE:
|
2020-03-27 16:30:18 +00:00
|
|
|
//case FEATURE_NATIVE_ICON:
|
|
|
|
//case FEATURE_WINDOW_TRANSPARENCY:
|
|
|
|
case FEATURE_CLIPBOARD:
|
|
|
|
case FEATURE_KEEP_SCREEN_ON:
|
|
|
|
case FEATURE_ORIENTATION:
|
|
|
|
case FEATURE_TOUCHSCREEN:
|
|
|
|
case FEATURE_VIRTUAL_KEYBOARD:
|
2021-11-04 12:33:37 +00:00
|
|
|
case FEATURE_TEXT_TO_SPEECH:
|
2020-03-27 16:30:18 +00:00
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
String DisplayServerAndroid::get_name() const {
|
|
|
|
return "Android";
|
|
|
|
}
|
|
|
|
|
2021-11-04 12:33:37 +00:00
|
|
|
bool DisplayServerAndroid::tts_is_speaking() const {
|
|
|
|
return TTS_Android::is_speaking();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DisplayServerAndroid::tts_is_paused() const {
|
|
|
|
return TTS_Android::is_paused();
|
|
|
|
}
|
|
|
|
|
2022-08-05 01:41:48 +00:00
|
|
|
TypedArray<Dictionary> DisplayServerAndroid::tts_get_voices() const {
|
2021-11-04 12:33:37 +00:00
|
|
|
return TTS_Android::get_voices();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayServerAndroid::tts_speak(const String &p_text, const String &p_voice, int p_volume, float p_pitch, float p_rate, int p_utterance_id, bool p_interrupt) {
|
|
|
|
TTS_Android::speak(p_text, p_voice, p_volume, p_pitch, p_rate, p_utterance_id, p_interrupt);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayServerAndroid::tts_pause() {
|
|
|
|
TTS_Android::pause();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayServerAndroid::tts_resume() {
|
|
|
|
TTS_Android::resume();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayServerAndroid::tts_stop() {
|
|
|
|
TTS_Android::stop();
|
|
|
|
}
|
|
|
|
|
2023-09-26 03:00:04 +00:00
|
|
|
bool DisplayServerAndroid::is_dark_mode_supported() const {
|
|
|
|
GodotJavaWrapper *godot_java = OS_Android::get_singleton()->get_godot_java();
|
|
|
|
ERR_FAIL_NULL_V(godot_java, false);
|
|
|
|
|
|
|
|
return godot_java->is_dark_mode_supported();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DisplayServerAndroid::is_dark_mode() const {
|
|
|
|
GodotJavaWrapper *godot_java = OS_Android::get_singleton()->get_godot_java();
|
|
|
|
ERR_FAIL_NULL_V(godot_java, false);
|
|
|
|
|
|
|
|
return godot_java->is_dark_mode();
|
|
|
|
}
|
|
|
|
|
2024-01-19 18:46:26 +00:00
|
|
|
void DisplayServerAndroid::set_system_theme_change_callback(const Callable &p_callable) {
|
|
|
|
system_theme_changed = p_callable;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayServerAndroid::emit_system_theme_changed() {
|
|
|
|
if (system_theme_changed.is_valid()) {
|
|
|
|
system_theme_changed.call_deferred();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-27 16:30:18 +00:00
|
|
|
void DisplayServerAndroid::clipboard_set(const String &p_text) {
|
|
|
|
GodotJavaWrapper *godot_java = OS_Android::get_singleton()->get_godot_java();
|
2022-05-30 21:13:49 +00:00
|
|
|
ERR_FAIL_NULL(godot_java);
|
2020-03-27 16:30:18 +00:00
|
|
|
|
|
|
|
if (godot_java->has_set_clipboard()) {
|
|
|
|
godot_java->set_clipboard(p_text);
|
|
|
|
} else {
|
|
|
|
DisplayServer::clipboard_set(p_text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
String DisplayServerAndroid::clipboard_get() const {
|
|
|
|
GodotJavaWrapper *godot_java = OS_Android::get_singleton()->get_godot_java();
|
2022-05-30 21:13:49 +00:00
|
|
|
ERR_FAIL_NULL_V(godot_java, String());
|
2020-03-27 16:30:18 +00:00
|
|
|
|
|
|
|
if (godot_java->has_get_clipboard()) {
|
|
|
|
return godot_java->get_clipboard();
|
|
|
|
} else {
|
|
|
|
return DisplayServer::clipboard_get();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-19 13:04:52 +00:00
|
|
|
bool DisplayServerAndroid::clipboard_has() const {
|
|
|
|
GodotJavaWrapper *godot_java = OS_Android::get_singleton()->get_godot_java();
|
2022-05-30 21:13:49 +00:00
|
|
|
ERR_FAIL_NULL_V(godot_java, false);
|
2022-01-19 13:04:52 +00:00
|
|
|
|
|
|
|
if (godot_java->has_has_clipboard()) {
|
|
|
|
return godot_java->has_clipboard();
|
|
|
|
} else {
|
|
|
|
return DisplayServer::clipboard_has();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-05 01:41:48 +00:00
|
|
|
TypedArray<Rect2> DisplayServerAndroid::get_display_cutouts() const {
|
2022-04-24 19:12:22 +00:00
|
|
|
GodotIOJavaWrapper *godot_io_java = OS_Android::get_singleton()->get_godot_io_java();
|
|
|
|
ERR_FAIL_NULL_V(godot_io_java, Array());
|
|
|
|
return godot_io_java->get_display_cutouts();
|
|
|
|
}
|
|
|
|
|
2022-04-26 09:40:57 +00:00
|
|
|
Rect2i DisplayServerAndroid::get_display_safe_area() const {
|
|
|
|
GodotIOJavaWrapper *godot_io_java = OS_Android::get_singleton()->get_godot_io_java();
|
|
|
|
ERR_FAIL_NULL_V(godot_io_java, Rect2i());
|
|
|
|
return godot_io_java->get_display_safe_area();
|
|
|
|
}
|
|
|
|
|
2020-03-27 16:30:18 +00:00
|
|
|
void DisplayServerAndroid::screen_set_keep_on(bool p_enable) {
|
|
|
|
GodotJavaWrapper *godot_java = OS_Android::get_singleton()->get_godot_java();
|
2022-05-30 21:13:49 +00:00
|
|
|
ERR_FAIL_NULL(godot_java);
|
2020-03-27 16:30:18 +00:00
|
|
|
|
|
|
|
godot_java->set_keep_screen_on(p_enable);
|
|
|
|
keep_screen_on = p_enable;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DisplayServerAndroid::screen_is_kept_on() const {
|
|
|
|
return keep_screen_on;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayServerAndroid::screen_set_orientation(DisplayServer::ScreenOrientation p_orientation, int p_screen) {
|
|
|
|
GodotIOJavaWrapper *godot_io_java = OS_Android::get_singleton()->get_godot_io_java();
|
2022-05-30 21:13:49 +00:00
|
|
|
ERR_FAIL_NULL(godot_io_java);
|
2020-03-27 16:30:18 +00:00
|
|
|
|
|
|
|
godot_io_java->set_screen_orientation(p_orientation);
|
|
|
|
}
|
|
|
|
|
|
|
|
DisplayServer::ScreenOrientation DisplayServerAndroid::screen_get_orientation(int p_screen) const {
|
|
|
|
GodotIOJavaWrapper *godot_io_java = OS_Android::get_singleton()->get_godot_io_java();
|
2022-05-30 21:13:49 +00:00
|
|
|
ERR_FAIL_NULL_V(godot_io_java, SCREEN_LANDSCAPE);
|
2020-03-27 16:30:18 +00:00
|
|
|
|
2021-11-21 11:37:09 +00:00
|
|
|
const int orientation = godot_io_java->get_screen_orientation();
|
|
|
|
ERR_FAIL_INDEX_V_MSG(orientation, 7, SCREEN_LANDSCAPE, "Unrecognized screen orientation");
|
|
|
|
return (ScreenOrientation)orientation;
|
2020-03-27 16:30:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int DisplayServerAndroid::get_screen_count() const {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2023-01-04 22:00:02 +00:00
|
|
|
int DisplayServerAndroid::get_primary_screen() const {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-03-27 16:30:18 +00:00
|
|
|
Point2i DisplayServerAndroid::screen_get_position(int p_screen) const {
|
|
|
|
return Point2i(0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
Size2i DisplayServerAndroid::screen_get_size(int p_screen) const {
|
|
|
|
return OS_Android::get_singleton()->get_display_size();
|
|
|
|
}
|
|
|
|
|
|
|
|
Rect2i DisplayServerAndroid::screen_get_usable_rect(int p_screen) const {
|
2022-04-26 09:40:57 +00:00
|
|
|
Size2i display_size = OS_Android::get_singleton()->get_display_size();
|
|
|
|
return Rect2i(0, 0, display_size.width, display_size.height);
|
2020-03-27 16:30:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int DisplayServerAndroid::screen_get_dpi(int p_screen) const {
|
|
|
|
GodotIOJavaWrapper *godot_io_java = OS_Android::get_singleton()->get_godot_io_java();
|
2022-05-30 21:13:49 +00:00
|
|
|
ERR_FAIL_NULL_V(godot_io_java, 0);
|
2020-03-27 16:30:18 +00:00
|
|
|
|
|
|
|
return godot_io_java->get_screen_dpi();
|
|
|
|
}
|
|
|
|
|
2022-04-04 09:22:51 +00:00
|
|
|
float DisplayServerAndroid::screen_get_scale(int p_screen) const {
|
|
|
|
GodotIOJavaWrapper *godot_io_java = OS_Android::get_singleton()->get_godot_io_java();
|
2022-05-30 21:13:49 +00:00
|
|
|
ERR_FAIL_NULL_V(godot_io_java, 1.0f);
|
2022-04-04 09:22:51 +00:00
|
|
|
|
2023-01-22 06:04:44 +00:00
|
|
|
float screen_scale = godot_io_java->get_scaled_density();
|
|
|
|
|
|
|
|
// Update the scale to avoid cropping.
|
|
|
|
Size2i screen_size = screen_get_size(p_screen);
|
|
|
|
if (screen_size != Size2i()) {
|
|
|
|
float width_scale = screen_size.width / (float)OS_Android::DEFAULT_WINDOW_WIDTH;
|
|
|
|
float height_scale = screen_size.height / (float)OS_Android::DEFAULT_WINDOW_HEIGHT;
|
|
|
|
screen_scale = MIN(screen_scale, MIN(width_scale, height_scale));
|
|
|
|
}
|
|
|
|
|
|
|
|
print_line("Selected screen scale: ", screen_scale);
|
|
|
|
return screen_scale;
|
2022-04-04 09:22:51 +00:00
|
|
|
}
|
|
|
|
|
2022-01-27 19:46:57 +00:00
|
|
|
float DisplayServerAndroid::screen_get_refresh_rate(int p_screen) const {
|
|
|
|
GodotIOJavaWrapper *godot_io_java = OS_Android::get_singleton()->get_godot_io_java();
|
|
|
|
if (!godot_io_java) {
|
2022-02-10 11:00:11 +00:00
|
|
|
ERR_PRINT("An error occurred while trying to get the screen refresh rate.");
|
2022-01-27 19:46:57 +00:00
|
|
|
return SCREEN_REFRESH_RATE_FALLBACK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return godot_io_java->get_screen_refresh_rate(SCREEN_REFRESH_RATE_FALLBACK);
|
|
|
|
}
|
|
|
|
|
2022-10-16 22:59:51 +00:00
|
|
|
bool DisplayServerAndroid::is_touchscreen_available() const {
|
2020-03-27 16:30:18 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-07-07 18:20:10 +00:00
|
|
|
void DisplayServerAndroid::virtual_keyboard_show(const String &p_existing_text, const Rect2 &p_screen_rect, VirtualKeyboardType p_type, int p_max_length, int p_cursor_start, int p_cursor_end) {
|
2020-03-27 16:30:18 +00:00
|
|
|
GodotIOJavaWrapper *godot_io_java = OS_Android::get_singleton()->get_godot_io_java();
|
2022-05-30 21:13:49 +00:00
|
|
|
ERR_FAIL_NULL(godot_io_java);
|
2020-03-27 16:30:18 +00:00
|
|
|
|
|
|
|
if (godot_io_java->has_vk()) {
|
2022-07-07 18:20:10 +00:00
|
|
|
godot_io_java->show_vk(p_existing_text, (int)p_type, p_max_length, p_cursor_start, p_cursor_end);
|
2020-03-27 16:30:18 +00:00
|
|
|
} else {
|
|
|
|
ERR_PRINT("Virtual keyboard not available");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayServerAndroid::virtual_keyboard_hide() {
|
|
|
|
GodotIOJavaWrapper *godot_io_java = OS_Android::get_singleton()->get_godot_io_java();
|
2022-05-30 21:13:49 +00:00
|
|
|
ERR_FAIL_NULL(godot_io_java);
|
2020-03-27 16:30:18 +00:00
|
|
|
|
|
|
|
if (godot_io_java->has_vk()) {
|
|
|
|
godot_io_java->hide_vk();
|
|
|
|
} else {
|
|
|
|
ERR_PRINT("Virtual keyboard not available");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int DisplayServerAndroid::virtual_keyboard_get_height() const {
|
|
|
|
GodotIOJavaWrapper *godot_io_java = OS_Android::get_singleton()->get_godot_io_java();
|
2022-05-30 21:13:49 +00:00
|
|
|
ERR_FAIL_NULL_V(godot_io_java, 0);
|
2020-03-27 16:30:18 +00:00
|
|
|
|
|
|
|
return godot_io_java->get_vk_height();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayServerAndroid::window_set_window_event_callback(const Callable &p_callable, DisplayServer::WindowID p_window) {
|
|
|
|
window_event_callback = p_callable;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayServerAndroid::window_set_input_event_callback(const Callable &p_callable, DisplayServer::WindowID p_window) {
|
|
|
|
input_event_callback = p_callable;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayServerAndroid::window_set_input_text_callback(const Callable &p_callable, DisplayServer::WindowID p_window) {
|
|
|
|
input_text_callback = p_callable;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayServerAndroid::window_set_rect_changed_callback(const Callable &p_callable, DisplayServer::WindowID p_window) {
|
2021-05-03 16:23:05 +00:00
|
|
|
rect_changed_callback = p_callable;
|
2020-03-27 16:30:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayServerAndroid::window_set_drop_files_callback(const Callable &p_callable, DisplayServer::WindowID p_window) {
|
|
|
|
// Not supported on Android.
|
|
|
|
}
|
|
|
|
|
2021-08-04 19:22:11 +00:00
|
|
|
void DisplayServerAndroid::_window_callback(const Callable &p_callable, const Variant &p_arg, bool p_deferred) const {
|
2024-04-27 09:56:39 +00:00
|
|
|
if (p_callable.is_valid()) {
|
2021-08-04 19:22:11 +00:00
|
|
|
if (p_deferred) {
|
2023-07-11 14:18:10 +00:00
|
|
|
p_callable.call_deferred(p_arg);
|
2023-10-14 00:17:28 +00:00
|
|
|
} else {
|
|
|
|
p_callable.call(p_arg);
|
2021-08-04 19:22:11 +00:00
|
|
|
}
|
2020-03-27 16:30:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-04 19:22:11 +00:00
|
|
|
void DisplayServerAndroid::send_window_event(DisplayServer::WindowEvent p_event, bool p_deferred) const {
|
|
|
|
_window_callback(window_event_callback, int(p_event), p_deferred);
|
2020-03-27 16:30:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayServerAndroid::send_input_event(const Ref<InputEvent> &p_event) const {
|
|
|
|
_window_callback(input_event_callback, p_event);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayServerAndroid::send_input_text(const String &p_text) const {
|
|
|
|
_window_callback(input_text_callback, p_text);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayServerAndroid::_dispatch_input_events(const Ref<InputEvent> &p_event) {
|
|
|
|
DisplayServerAndroid::get_singleton()->send_input_event(p_event);
|
|
|
|
}
|
|
|
|
|
|
|
|
Vector<DisplayServer::WindowID> DisplayServerAndroid::get_window_list() const {
|
|
|
|
Vector<WindowID> ret;
|
|
|
|
ret.push_back(MAIN_WINDOW_ID);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
DisplayServer::WindowID DisplayServerAndroid::get_window_at_screen_position(const Point2i &p_position) const {
|
|
|
|
return MAIN_WINDOW_ID;
|
|
|
|
}
|
|
|
|
|
2022-01-14 10:41:04 +00:00
|
|
|
int64_t DisplayServerAndroid::window_get_native_handle(HandleType p_handle_type, WindowID p_window) const {
|
|
|
|
ERR_FAIL_COND_V(p_window != MAIN_WINDOW_ID, 0);
|
|
|
|
switch (p_handle_type) {
|
|
|
|
case WINDOW_HANDLE: {
|
2022-04-05 10:40:26 +00:00
|
|
|
return reinterpret_cast<int64_t>(static_cast<OS_Android *>(OS::get_singleton())->get_godot_java()->get_activity());
|
2022-01-14 10:41:04 +00:00
|
|
|
}
|
|
|
|
case WINDOW_VIEW: {
|
|
|
|
return 0; // Not supported.
|
|
|
|
}
|
2022-10-23 01:29:15 +00:00
|
|
|
#ifdef GLES3_ENABLED
|
2022-12-04 19:07:51 +00:00
|
|
|
case DISPLAY_HANDLE: {
|
|
|
|
if (rendering_driver == "opengl3") {
|
|
|
|
return reinterpret_cast<int64_t>(eglGetCurrentDisplay());
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2022-10-23 01:29:15 +00:00
|
|
|
case OPENGL_CONTEXT: {
|
2022-12-04 19:07:51 +00:00
|
|
|
if (rendering_driver == "opengl3") {
|
|
|
|
return reinterpret_cast<int64_t>(eglGetCurrentContext());
|
|
|
|
}
|
|
|
|
return 0;
|
2022-10-23 01:29:15 +00:00
|
|
|
}
|
|
|
|
#endif
|
2022-01-14 10:41:04 +00:00
|
|
|
default: {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-27 16:30:18 +00:00
|
|
|
void DisplayServerAndroid::window_attach_instance_id(ObjectID p_instance, DisplayServer::WindowID p_window) {
|
|
|
|
window_attached_instance_id = p_instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
ObjectID DisplayServerAndroid::window_get_attached_instance_id(DisplayServer::WindowID p_window) const {
|
|
|
|
return window_attached_instance_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayServerAndroid::window_set_title(const String &p_title, DisplayServer::WindowID p_window) {
|
|
|
|
// Not supported on Android.
|
|
|
|
}
|
|
|
|
|
|
|
|
int DisplayServerAndroid::window_get_current_screen(DisplayServer::WindowID p_window) const {
|
|
|
|
return SCREEN_OF_MAIN_WINDOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayServerAndroid::window_set_current_screen(int p_screen, DisplayServer::WindowID p_window) {
|
|
|
|
// Not supported on Android.
|
|
|
|
}
|
|
|
|
|
|
|
|
Point2i DisplayServerAndroid::window_get_position(DisplayServer::WindowID p_window) const {
|
|
|
|
return Point2i();
|
|
|
|
}
|
|
|
|
|
2022-11-30 08:28:16 +00:00
|
|
|
Point2i DisplayServerAndroid::window_get_position_with_decorations(DisplayServer::WindowID p_window) const {
|
|
|
|
return Point2i();
|
|
|
|
}
|
|
|
|
|
2020-03-27 16:30:18 +00:00
|
|
|
void DisplayServerAndroid::window_set_position(const Point2i &p_position, DisplayServer::WindowID p_window) {
|
|
|
|
// Not supported on Android.
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayServerAndroid::window_set_transient(DisplayServer::WindowID p_window, DisplayServer::WindowID p_parent) {
|
|
|
|
// Not supported on Android.
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayServerAndroid::window_set_max_size(const Size2i p_size, DisplayServer::WindowID p_window) {
|
|
|
|
// Not supported on Android.
|
|
|
|
}
|
|
|
|
|
|
|
|
Size2i DisplayServerAndroid::window_get_max_size(DisplayServer::WindowID p_window) const {
|
|
|
|
return Size2i();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayServerAndroid::window_set_min_size(const Size2i p_size, DisplayServer::WindowID p_window) {
|
|
|
|
// Not supported on Android.
|
|
|
|
}
|
|
|
|
|
|
|
|
Size2i DisplayServerAndroid::window_get_min_size(DisplayServer::WindowID p_window) const {
|
|
|
|
return Size2i();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayServerAndroid::window_set_size(const Size2i p_size, DisplayServer::WindowID p_window) {
|
|
|
|
// Not supported on Android.
|
|
|
|
}
|
|
|
|
|
|
|
|
Size2i DisplayServerAndroid::window_get_size(DisplayServer::WindowID p_window) const {
|
|
|
|
return OS_Android::get_singleton()->get_display_size();
|
|
|
|
}
|
|
|
|
|
2022-11-30 08:28:16 +00:00
|
|
|
Size2i DisplayServerAndroid::window_get_size_with_decorations(DisplayServer::WindowID p_window) const {
|
2020-03-27 16:30:18 +00:00
|
|
|
return OS_Android::get_singleton()->get_display_size();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayServerAndroid::window_set_mode(DisplayServer::WindowMode p_mode, DisplayServer::WindowID p_window) {
|
|
|
|
// Not supported on Android.
|
|
|
|
}
|
|
|
|
|
|
|
|
DisplayServer::WindowMode DisplayServerAndroid::window_get_mode(DisplayServer::WindowID p_window) const {
|
|
|
|
return WINDOW_MODE_FULLSCREEN;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DisplayServerAndroid::window_is_maximize_allowed(DisplayServer::WindowID p_window) const {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayServerAndroid::window_set_flag(DisplayServer::WindowFlags p_flag, bool p_enabled, DisplayServer::WindowID p_window) {
|
|
|
|
// Not supported on Android.
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DisplayServerAndroid::window_get_flag(DisplayServer::WindowFlags p_flag, DisplayServer::WindowID p_window) const {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayServerAndroid::window_request_attention(DisplayServer::WindowID p_window) {
|
|
|
|
// Not supported on Android.
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayServerAndroid::window_move_to_foreground(DisplayServer::WindowID p_window) {
|
|
|
|
// Not supported on Android.
|
|
|
|
}
|
|
|
|
|
2023-06-15 07:53:31 +00:00
|
|
|
bool DisplayServerAndroid::window_is_focused(WindowID p_window) const {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-03-27 16:30:18 +00:00
|
|
|
bool DisplayServerAndroid::window_can_draw(DisplayServer::WindowID p_window) const {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DisplayServerAndroid::can_any_window_draw() const {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayServerAndroid::process_events() {
|
2021-08-12 22:38:41 +00:00
|
|
|
Input::get_singleton()->flush_buffered_events();
|
2020-03-27 16:30:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Vector<String> DisplayServerAndroid::get_rendering_drivers_func() {
|
|
|
|
Vector<String> drivers;
|
|
|
|
|
2021-10-26 15:18:39 +00:00
|
|
|
#ifdef GLES3_ENABLED
|
|
|
|
drivers.push_back("opengl3");
|
2020-03-27 16:30:18 +00:00
|
|
|
#endif
|
|
|
|
#ifdef VULKAN_ENABLED
|
|
|
|
drivers.push_back("vulkan");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return drivers;
|
|
|
|
}
|
|
|
|
|
2024-05-22 12:06:04 +00:00
|
|
|
DisplayServer *DisplayServerAndroid::create_func(const String &p_rendering_driver, DisplayServer::WindowMode p_mode, DisplayServer::VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i *p_position, const Vector2i &p_resolution, int p_screen, Context p_context, Error &r_error) {
|
|
|
|
DisplayServer *ds = memnew(DisplayServerAndroid(p_rendering_driver, p_mode, p_vsync_mode, p_flags, p_position, p_resolution, p_screen, p_context, r_error));
|
2020-07-13 16:24:04 +00:00
|
|
|
if (r_error != OK) {
|
2022-11-11 23:30:06 +00:00
|
|
|
if (p_rendering_driver == "vulkan") {
|
2023-01-17 14:26:10 +00:00
|
|
|
OS::get_singleton()->alert(
|
|
|
|
"Your device seems not to support the required Vulkan version.\n\n"
|
|
|
|
"Please try exporting your game using the 'gl_compatibility' renderer.",
|
|
|
|
"Unable to initialize Vulkan video driver");
|
2022-11-11 23:30:06 +00:00
|
|
|
} else {
|
2023-01-17 14:26:10 +00:00
|
|
|
OS::get_singleton()->alert(
|
|
|
|
"Your device seems not to support the required OpenGL ES 3.0 version.",
|
|
|
|
"Unable to initialize OpenGL video driver");
|
2022-11-11 23:30:06 +00:00
|
|
|
}
|
2020-07-13 16:24:04 +00:00
|
|
|
}
|
|
|
|
return ds;
|
2020-03-27 16:30:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayServerAndroid::register_android_driver() {
|
|
|
|
register_create_function("android", create_func, get_rendering_drivers_func);
|
|
|
|
}
|
|
|
|
|
2020-05-24 08:04:59 +00:00
|
|
|
void DisplayServerAndroid::reset_window() {
|
2023-12-19 11:48:02 +00:00
|
|
|
#if defined(RD_ENABLED)
|
2023-12-19 17:57:56 +00:00
|
|
|
if (rendering_context) {
|
|
|
|
if (rendering_device) {
|
|
|
|
rendering_device->screen_free(MAIN_WINDOW_ID);
|
|
|
|
}
|
2020-05-24 08:04:59 +00:00
|
|
|
|
2023-12-19 17:57:56 +00:00
|
|
|
VSyncMode last_vsync_mode = rendering_context->window_get_vsync_mode(MAIN_WINDOW_ID);
|
|
|
|
rendering_context->window_destroy(MAIN_WINDOW_ID);
|
2023-12-19 11:48:02 +00:00
|
|
|
|
|
|
|
union {
|
|
|
|
#ifdef VULKAN_ENABLED
|
2023-12-19 17:57:56 +00:00
|
|
|
RenderingContextDriverVulkanAndroid::WindowPlatformData vulkan;
|
2023-12-19 11:48:02 +00:00
|
|
|
#endif
|
|
|
|
} wpd;
|
|
|
|
#ifdef VULKAN_ENABLED
|
|
|
|
if (rendering_driver == "vulkan") {
|
|
|
|
ANativeWindow *native_window = OS_Android::get_singleton()->get_native_window();
|
|
|
|
ERR_FAIL_NULL(native_window);
|
|
|
|
wpd.vulkan.window = native_window;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2023-12-19 17:57:56 +00:00
|
|
|
if (rendering_context->window_create(MAIN_WINDOW_ID, &wpd) != OK) {
|
|
|
|
ERR_PRINT(vformat("Failed to reset %s window.", rendering_driver));
|
|
|
|
memdelete(rendering_context);
|
|
|
|
rendering_context = nullptr;
|
2024-01-05 17:27:10 +00:00
|
|
|
return;
|
2020-05-24 08:04:59 +00:00
|
|
|
}
|
2023-12-19 17:57:56 +00:00
|
|
|
|
|
|
|
Size2i display_size = OS_Android::get_singleton()->get_display_size();
|
|
|
|
rendering_context->window_set_size(MAIN_WINDOW_ID, display_size.width, display_size.height);
|
|
|
|
rendering_context->window_set_vsync_mode(MAIN_WINDOW_ID, last_vsync_mode);
|
|
|
|
|
|
|
|
if (rendering_device) {
|
|
|
|
rendering_device->screen_create(MAIN_WINDOW_ID);
|
|
|
|
}
|
2020-05-24 08:04:59 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2021-05-03 16:23:05 +00:00
|
|
|
void DisplayServerAndroid::notify_surface_changed(int p_width, int p_height) {
|
2023-07-11 14:18:10 +00:00
|
|
|
if (rect_changed_callback.is_valid()) {
|
|
|
|
rect_changed_callback.call(Rect2i(0, 0, p_width, p_height));
|
2021-05-03 16:23:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-22 12:06:04 +00:00
|
|
|
DisplayServerAndroid::DisplayServerAndroid(const String &p_rendering_driver, DisplayServer::WindowMode p_mode, DisplayServer::VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i *p_position, const Vector2i &p_resolution, int p_screen, Context p_context, Error &r_error) {
|
2020-03-27 16:30:18 +00:00
|
|
|
rendering_driver = p_rendering_driver;
|
|
|
|
|
|
|
|
keep_screen_on = GLOBAL_GET("display/window/energy_saving/keep_screen_on");
|
|
|
|
|
2024-01-19 17:41:01 +00:00
|
|
|
native_menu = memnew(NativeMenu);
|
|
|
|
|
2021-10-26 15:18:39 +00:00
|
|
|
#if defined(GLES3_ENABLED)
|
|
|
|
if (rendering_driver == "opengl3") {
|
2021-11-12 12:49:49 +00:00
|
|
|
RasterizerGLES3::make_current(false);
|
2020-03-27 16:30:18 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2023-12-19 11:48:02 +00:00
|
|
|
#if defined(RD_ENABLED)
|
2023-12-19 17:57:56 +00:00
|
|
|
rendering_context = nullptr;
|
2023-12-19 11:48:02 +00:00
|
|
|
rendering_device = nullptr;
|
2020-03-27 16:30:18 +00:00
|
|
|
|
2023-12-19 11:48:02 +00:00
|
|
|
#if defined(VULKAN_ENABLED)
|
2020-03-27 16:30:18 +00:00
|
|
|
if (rendering_driver == "vulkan") {
|
2023-12-19 17:57:56 +00:00
|
|
|
rendering_context = memnew(RenderingContextDriverVulkanAndroid);
|
2023-12-19 11:48:02 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2023-12-19 17:57:56 +00:00
|
|
|
if (rendering_context) {
|
|
|
|
if (rendering_context->initialize() != OK) {
|
|
|
|
ERR_PRINT(vformat("Failed to initialize %s context", rendering_driver));
|
|
|
|
memdelete(rendering_context);
|
|
|
|
rendering_context = nullptr;
|
2024-01-05 17:27:10 +00:00
|
|
|
return;
|
2020-03-27 16:30:18 +00:00
|
|
|
}
|
|
|
|
|
2023-12-19 11:48:02 +00:00
|
|
|
union {
|
|
|
|
#ifdef VULKAN_ENABLED
|
2023-12-19 17:57:56 +00:00
|
|
|
RenderingContextDriverVulkanAndroid::WindowPlatformData vulkan;
|
2023-12-19 11:48:02 +00:00
|
|
|
#endif
|
|
|
|
} wpd;
|
|
|
|
#ifdef VULKAN_ENABLED
|
|
|
|
if (rendering_driver == "vulkan") {
|
|
|
|
ANativeWindow *native_window = OS_Android::get_singleton()->get_native_window();
|
|
|
|
ERR_FAIL_NULL(native_window);
|
|
|
|
wpd.vulkan.window = native_window;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2023-12-19 17:57:56 +00:00
|
|
|
if (rendering_context->window_create(MAIN_WINDOW_ID, &wpd) != OK) {
|
|
|
|
ERR_PRINT(vformat("Failed to create %s window.", rendering_driver));
|
|
|
|
memdelete(rendering_context);
|
|
|
|
rendering_context = nullptr;
|
2024-01-05 17:27:10 +00:00
|
|
|
return;
|
2020-03-27 16:30:18 +00:00
|
|
|
}
|
|
|
|
|
2023-12-19 17:57:56 +00:00
|
|
|
Size2i display_size = OS_Android::get_singleton()->get_display_size();
|
|
|
|
rendering_context->window_set_size(MAIN_WINDOW_ID, display_size.width, display_size.height);
|
|
|
|
rendering_context->window_set_vsync_mode(MAIN_WINDOW_ID, p_vsync_mode);
|
|
|
|
|
2023-12-19 11:48:02 +00:00
|
|
|
rendering_device = memnew(RenderingDevice);
|
2023-12-19 17:57:56 +00:00
|
|
|
rendering_device->initialize(rendering_context, MAIN_WINDOW_ID);
|
|
|
|
rendering_device->screen_create(MAIN_WINDOW_ID);
|
2020-03-27 16:30:18 +00:00
|
|
|
|
2020-12-04 18:26:24 +00:00
|
|
|
RendererCompositorRD::make_current();
|
2020-03-27 16:30:18 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2020-04-28 13:19:37 +00:00
|
|
|
Input::get_singleton()->set_event_dispatch_function(_dispatch_input_events);
|
2021-08-04 19:22:11 +00:00
|
|
|
Input::get_singleton()->set_use_input_buffering(true); // Needed because events will come directly from the UI thread
|
2020-07-14 16:37:36 +00:00
|
|
|
|
|
|
|
r_error = OK;
|
2020-03-27 16:30:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DisplayServerAndroid::~DisplayServerAndroid() {
|
2024-01-19 17:41:01 +00:00
|
|
|
if (native_menu) {
|
|
|
|
memdelete(native_menu);
|
|
|
|
native_menu = nullptr;
|
|
|
|
}
|
|
|
|
|
2023-12-19 11:48:02 +00:00
|
|
|
#if defined(RD_ENABLED)
|
|
|
|
if (rendering_device) {
|
|
|
|
memdelete(rendering_device);
|
|
|
|
}
|
2023-12-19 17:57:56 +00:00
|
|
|
if (rendering_context) {
|
|
|
|
memdelete(rendering_context);
|
2020-03-27 16:30:18 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayServerAndroid::process_accelerometer(const Vector3 &p_accelerometer) {
|
2020-04-28 13:19:37 +00:00
|
|
|
Input::get_singleton()->set_accelerometer(p_accelerometer);
|
2020-03-27 16:30:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayServerAndroid::process_gravity(const Vector3 &p_gravity) {
|
2020-04-28 13:19:37 +00:00
|
|
|
Input::get_singleton()->set_gravity(p_gravity);
|
2020-03-27 16:30:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayServerAndroid::process_magnetometer(const Vector3 &p_magnetometer) {
|
2020-04-28 13:19:37 +00:00
|
|
|
Input::get_singleton()->set_magnetometer(p_magnetometer);
|
2020-03-27 16:30:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayServerAndroid::process_gyroscope(const Vector3 &p_gyroscope) {
|
2020-04-28 13:19:37 +00:00
|
|
|
Input::get_singleton()->set_gyroscope(p_gyroscope);
|
2020-03-27 16:30:18 +00:00
|
|
|
}
|
2020-10-07 23:37:58 +00:00
|
|
|
|
2020-11-01 01:30:40 +00:00
|
|
|
void DisplayServerAndroid::mouse_set_mode(MouseMode p_mode) {
|
2022-10-05 17:48:08 +00:00
|
|
|
if (!OS_Android::get_singleton()->get_godot_java()->get_godot_view()->can_update_pointer_icon() || !OS_Android::get_singleton()->get_godot_java()->get_godot_view()->can_capture_pointer()) {
|
|
|
|
return;
|
|
|
|
}
|
2020-11-01 01:30:40 +00:00
|
|
|
if (mouse_mode == p_mode) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-11-04 21:55:28 +00:00
|
|
|
if (p_mode == MouseMode::MOUSE_MODE_HIDDEN) {
|
|
|
|
OS_Android::get_singleton()->get_godot_java()->get_godot_view()->set_pointer_icon(CURSOR_TYPE_NULL);
|
|
|
|
} else {
|
|
|
|
cursor_set_shape(cursor_shape);
|
|
|
|
}
|
|
|
|
|
2020-11-01 01:30:40 +00:00
|
|
|
if (p_mode == MouseMode::MOUSE_MODE_CAPTURED) {
|
|
|
|
OS_Android::get_singleton()->get_godot_java()->get_godot_view()->request_pointer_capture();
|
|
|
|
} else {
|
|
|
|
OS_Android::get_singleton()->get_godot_java()->get_godot_view()->release_pointer_capture();
|
|
|
|
}
|
|
|
|
|
|
|
|
mouse_mode = p_mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
DisplayServer::MouseMode DisplayServerAndroid::mouse_get_mode() const {
|
|
|
|
return mouse_mode;
|
|
|
|
}
|
|
|
|
|
2020-10-07 23:37:58 +00:00
|
|
|
Point2i DisplayServerAndroid::mouse_get_position() const {
|
2021-08-04 19:22:11 +00:00
|
|
|
return Input::get_singleton()->get_mouse_position();
|
2020-10-07 23:37:58 +00:00
|
|
|
}
|
|
|
|
|
2023-01-07 23:55:54 +00:00
|
|
|
BitField<MouseButtonMask> DisplayServerAndroid::mouse_get_button_state() const {
|
|
|
|
return Input::get_singleton()->get_mouse_button_mask();
|
2020-10-07 23:37:58 +00:00
|
|
|
}
|
2020-11-04 21:55:28 +00:00
|
|
|
|
2022-11-28 06:03:28 +00:00
|
|
|
void DisplayServerAndroid::_cursor_set_shape_helper(CursorShape p_shape, bool force) {
|
2022-10-05 17:48:08 +00:00
|
|
|
if (!OS_Android::get_singleton()->get_godot_java()->get_godot_view()->can_update_pointer_icon()) {
|
|
|
|
return;
|
|
|
|
}
|
2022-11-28 06:03:28 +00:00
|
|
|
if (cursor_shape == p_shape && !force) {
|
2020-11-04 21:55:28 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
cursor_shape = p_shape;
|
|
|
|
|
|
|
|
if (mouse_mode == MouseMode::MOUSE_MODE_VISIBLE || mouse_mode == MouseMode::MOUSE_MODE_CONFINED) {
|
|
|
|
OS_Android::get_singleton()->get_godot_java()->get_godot_view()->set_pointer_icon(android_cursors[cursor_shape]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-28 06:03:28 +00:00
|
|
|
void DisplayServerAndroid::cursor_set_shape(DisplayServer::CursorShape p_shape) {
|
2023-02-17 13:17:37 +00:00
|
|
|
ERR_FAIL_INDEX(p_shape, CURSOR_MAX);
|
2022-11-28 06:03:28 +00:00
|
|
|
_cursor_set_shape_helper(p_shape);
|
|
|
|
}
|
|
|
|
|
2020-11-04 21:55:28 +00:00
|
|
|
DisplayServer::CursorShape DisplayServerAndroid::cursor_get_shape() const {
|
|
|
|
return cursor_shape;
|
|
|
|
}
|
2021-06-19 15:44:59 +00:00
|
|
|
|
2022-11-28 06:03:28 +00:00
|
|
|
void DisplayServerAndroid::cursor_set_custom_image(const Ref<Resource> &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) {
|
2023-02-17 13:17:37 +00:00
|
|
|
ERR_FAIL_INDEX(p_shape, CURSOR_MAX);
|
2022-11-28 06:03:28 +00:00
|
|
|
String cursor_path = p_cursor.is_valid() ? p_cursor->get_path() : "";
|
|
|
|
if (!cursor_path.is_empty()) {
|
|
|
|
cursor_path = ProjectSettings::get_singleton()->globalize_path(cursor_path);
|
|
|
|
}
|
|
|
|
OS_Android::get_singleton()->get_godot_java()->get_godot_view()->configure_pointer_icon(android_cursors[cursor_shape], cursor_path, p_hotspot);
|
|
|
|
_cursor_set_shape_helper(p_shape, true);
|
|
|
|
}
|
|
|
|
|
2021-06-19 15:44:59 +00:00
|
|
|
void DisplayServerAndroid::window_set_vsync_mode(DisplayServer::VSyncMode p_vsync_mode, WindowID p_window) {
|
2023-12-19 11:48:02 +00:00
|
|
|
#if defined(RD_ENABLED)
|
2023-12-19 17:57:56 +00:00
|
|
|
if (rendering_context) {
|
|
|
|
rendering_context->window_set_vsync_mode(p_window, p_vsync_mode);
|
2023-03-11 17:03:55 +00:00
|
|
|
}
|
2021-06-19 15:44:59 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
DisplayServer::VSyncMode DisplayServerAndroid::window_get_vsync_mode(WindowID p_window) const {
|
2023-12-19 11:48:02 +00:00
|
|
|
#if defined(RD_ENABLED)
|
2023-12-19 17:57:56 +00:00
|
|
|
if (rendering_context) {
|
|
|
|
return rendering_context->window_get_vsync_mode(p_window);
|
2023-03-11 17:03:55 +00:00
|
|
|
}
|
2021-06-19 15:44:59 +00:00
|
|
|
#endif
|
2023-03-11 17:03:55 +00:00
|
|
|
return DisplayServer::VSYNC_ENABLED;
|
2021-06-19 15:44:59 +00:00
|
|
|
}
|
2022-11-28 06:03:28 +00:00
|
|
|
|
|
|
|
void DisplayServerAndroid::reset_swap_buffers_flag() {
|
|
|
|
swap_buffers_flag = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DisplayServerAndroid::should_swap_buffers() const {
|
|
|
|
return swap_buffers_flag;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayServerAndroid::swap_buffers() {
|
|
|
|
swap_buffers_flag = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayServerAndroid::set_native_icon(const String &p_filename) {
|
|
|
|
// NOT SUPPORTED
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayServerAndroid::set_icon(const Ref<Image> &p_icon) {
|
|
|
|
// NOT SUPPORTED
|
|
|
|
}
|