2020-07-15 20:59:57 +02:00
|
|
|
/**************************************************************************/
|
2022-07-20 08:28:22 +02:00
|
|
|
/* display_server_ios.h */
|
2020-07-15 20:59:57 +02: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. */
|
|
|
|
/**************************************************************************/
|
|
|
|
|
2022-07-23 23:41:51 +02:00
|
|
|
#ifndef DISPLAY_SERVER_IOS_H
|
|
|
|
#define DISPLAY_SERVER_IOS_H
|
2020-07-15 20:59:57 +02:00
|
|
|
|
|
|
|
#include "core/input/input.h"
|
|
|
|
#include "servers/display_server.h"
|
|
|
|
|
|
|
|
#if defined(VULKAN_ENABLED)
|
2023-06-08 14:51:32 +02:00
|
|
|
#import "vulkan_context_ios.h"
|
|
|
|
|
2020-07-15 20:59:57 +02:00
|
|
|
#include "drivers/vulkan/rendering_device_vulkan.h"
|
2020-12-04 19:26:24 +01:00
|
|
|
#include "servers/rendering/renderer_rd/renderer_compositor_rd.h"
|
2020-07-15 20:59:57 +02:00
|
|
|
|
2021-08-12 13:24:54 +02:00
|
|
|
#ifdef USE_VOLK
|
|
|
|
#include <volk.h>
|
|
|
|
#else
|
|
|
|
#include <vulkan/vulkan.h>
|
|
|
|
#endif
|
2023-06-08 14:51:32 +02:00
|
|
|
#endif // VULKAN_ENABLED
|
2020-07-15 20:59:57 +02:00
|
|
|
|
2023-01-20 23:20:30 +01:00
|
|
|
#if defined(GLES3_ENABLED)
|
|
|
|
#include "drivers/gles3/rasterizer_gles3.h"
|
|
|
|
#endif // GLES3_ENABLED
|
|
|
|
|
2022-10-25 21:20:54 +02:00
|
|
|
#import <Foundation/Foundation.h>
|
|
|
|
#import <QuartzCore/CAMetalLayer.h>
|
|
|
|
|
2022-07-20 08:28:22 +02:00
|
|
|
class DisplayServerIOS : public DisplayServer {
|
2023-05-08 20:32:56 +02:00
|
|
|
// No need to register with GDCLASS, it's platform-specific and nothing is added.
|
2020-07-15 20:59:57 +02:00
|
|
|
|
|
|
|
_THREAD_SAFE_CLASS_
|
|
|
|
|
|
|
|
#if defined(VULKAN_ENABLED)
|
2022-07-20 08:28:22 +02:00
|
|
|
VulkanContextIOS *context_vulkan = nullptr;
|
2021-12-14 02:49:29 +01:00
|
|
|
RenderingDeviceVulkan *rendering_device_vulkan = nullptr;
|
2020-07-15 20:59:57 +02:00
|
|
|
#endif
|
|
|
|
|
2021-11-04 13:33:37 +01:00
|
|
|
id tts = nullptr;
|
|
|
|
|
2020-07-15 20:59:57 +02:00
|
|
|
DisplayServer::ScreenOrientation screen_orientation;
|
|
|
|
|
|
|
|
ObjectID window_attached_instance_id;
|
|
|
|
|
|
|
|
Callable window_event_callback;
|
|
|
|
Callable window_resize_callback;
|
|
|
|
Callable input_event_callback;
|
|
|
|
Callable input_text_callback;
|
|
|
|
|
|
|
|
int virtual_keyboard_height = 0;
|
|
|
|
|
|
|
|
void perform_event(const Ref<InputEvent> &p_event);
|
|
|
|
|
2023-01-04 23:00:02 +01:00
|
|
|
DisplayServerIOS(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, Error &r_error);
|
2022-07-20 08:28:22 +02:00
|
|
|
~DisplayServerIOS();
|
2020-07-15 20:59:57 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
String rendering_driver;
|
|
|
|
|
2022-07-20 08:28:22 +02:00
|
|
|
static DisplayServerIOS *get_singleton();
|
2020-07-15 20:59:57 +02:00
|
|
|
|
2022-07-20 08:28:22 +02:00
|
|
|
static void register_ios_driver();
|
2023-01-04 23:00:02 +01:00
|
|
|
static DisplayServer *create_func(const String &p_rendering_driver, WindowMode p_mode, DisplayServer::VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i *p_position, const Vector2i &p_resolution, int p_screen, Error &r_error);
|
2020-07-15 20:59:57 +02:00
|
|
|
static Vector<String> get_rendering_drivers_func();
|
|
|
|
|
|
|
|
// MARK: - Events
|
|
|
|
|
|
|
|
virtual void process_events() override;
|
|
|
|
|
|
|
|
virtual void window_set_rect_changed_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) override;
|
|
|
|
virtual void window_set_window_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) override;
|
|
|
|
virtual void window_set_input_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) override;
|
|
|
|
virtual void window_set_input_text_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) override;
|
|
|
|
virtual void window_set_drop_files_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) override;
|
|
|
|
|
|
|
|
static void _dispatch_input_events(const Ref<InputEvent> &p_event);
|
|
|
|
void send_input_event(const Ref<InputEvent> &p_event) const;
|
|
|
|
void send_input_text(const String &p_text) const;
|
|
|
|
void send_window_event(DisplayServer::WindowEvent p_event) const;
|
|
|
|
void _window_callback(const Callable &p_callable, const Variant &p_arg) const;
|
|
|
|
|
|
|
|
// MARK: - Input
|
|
|
|
|
2022-12-23 16:37:45 +01:00
|
|
|
// MARK: Touches and Apple Pencil
|
2020-07-15 20:59:57 +02:00
|
|
|
|
2021-04-13 10:25:44 +02:00
|
|
|
void touch_press(int p_idx, int p_x, int p_y, bool p_pressed, bool p_double_click);
|
2022-12-23 16:37:45 +01:00
|
|
|
void touch_drag(int p_idx, int p_prev_x, int p_prev_y, int p_x, int p_y, float p_pressure, Vector2 p_tilt);
|
2023-01-21 12:25:29 +01:00
|
|
|
void touches_canceled(int p_idx);
|
2020-07-15 20:59:57 +02:00
|
|
|
|
|
|
|
// MARK: Keyboard
|
|
|
|
|
2022-12-11 00:21:22 +01:00
|
|
|
void key(Key p_key, char32_t p_char, Key p_unshifted, Key p_physical, NSInteger p_modifier, bool p_pressed);
|
|
|
|
bool is_keyboard_active() const;
|
2020-07-15 20:59:57 +02:00
|
|
|
|
|
|
|
// MARK: Motion
|
|
|
|
|
|
|
|
void update_gravity(float p_x, float p_y, float p_z);
|
|
|
|
void update_accelerometer(float p_x, float p_y, float p_z);
|
|
|
|
void update_magnetometer(float p_x, float p_y, float p_z);
|
|
|
|
void update_gyroscope(float p_x, float p_y, float p_z);
|
|
|
|
|
|
|
|
// MARK: -
|
|
|
|
|
|
|
|
virtual bool has_feature(Feature p_feature) const override;
|
|
|
|
virtual String get_name() const override;
|
|
|
|
|
2021-11-04 13:33:37 +01:00
|
|
|
virtual bool tts_is_speaking() const override;
|
|
|
|
virtual bool tts_is_paused() const override;
|
2022-08-05 03:41:48 +02:00
|
|
|
virtual TypedArray<Dictionary> tts_get_voices() const override;
|
2021-11-04 13:33:37 +01:00
|
|
|
|
|
|
|
virtual void tts_speak(const String &p_text, const String &p_voice, int p_volume = 50, float p_pitch = 1.f, float p_rate = 1.f, int p_utterance_id = 0, bool p_interrupt = false) override;
|
|
|
|
virtual void tts_pause() override;
|
|
|
|
virtual void tts_resume() override;
|
|
|
|
virtual void tts_stop() override;
|
|
|
|
|
2023-09-26 05:00:04 +02:00
|
|
|
virtual bool is_dark_mode_supported() const override;
|
|
|
|
virtual bool is_dark_mode() const override;
|
|
|
|
|
2022-04-26 11:40:57 +02:00
|
|
|
virtual Rect2i get_display_safe_area() const override;
|
|
|
|
|
2020-07-15 20:59:57 +02:00
|
|
|
virtual int get_screen_count() const override;
|
2023-01-04 23:00:02 +01:00
|
|
|
virtual int get_primary_screen() const override;
|
2020-07-15 20:59:57 +02:00
|
|
|
virtual Point2i screen_get_position(int p_screen = SCREEN_OF_MAIN_WINDOW) const override;
|
|
|
|
virtual Size2i screen_get_size(int p_screen = SCREEN_OF_MAIN_WINDOW) const override;
|
|
|
|
virtual Rect2i screen_get_usable_rect(int p_screen = SCREEN_OF_MAIN_WINDOW) const override;
|
|
|
|
virtual int screen_get_dpi(int p_screen = SCREEN_OF_MAIN_WINDOW) const override;
|
|
|
|
virtual float screen_get_scale(int p_screen = SCREEN_OF_MAIN_WINDOW) const override;
|
2022-01-27 20:46:57 +01:00
|
|
|
virtual float screen_get_refresh_rate(int p_screen = SCREEN_OF_MAIN_WINDOW) const override;
|
2020-07-15 20:59:57 +02:00
|
|
|
|
|
|
|
virtual Vector<DisplayServer::WindowID> get_window_list() const override;
|
|
|
|
|
|
|
|
virtual WindowID
|
|
|
|
get_window_at_screen_position(const Point2i &p_position) const override;
|
|
|
|
|
2022-01-14 11:41:04 +01:00
|
|
|
virtual int64_t window_get_native_handle(HandleType p_handle_type, WindowID p_window = MAIN_WINDOW_ID) const override;
|
|
|
|
|
2020-07-15 20:59:57 +02:00
|
|
|
virtual void window_attach_instance_id(ObjectID p_instance, WindowID p_window = MAIN_WINDOW_ID) override;
|
|
|
|
virtual ObjectID window_get_attached_instance_id(WindowID p_window = MAIN_WINDOW_ID) const override;
|
|
|
|
|
|
|
|
virtual void window_set_title(const String &p_title, WindowID p_window = MAIN_WINDOW_ID) override;
|
|
|
|
|
|
|
|
virtual int window_get_current_screen(WindowID p_window = MAIN_WINDOW_ID) const override;
|
|
|
|
virtual void window_set_current_screen(int p_screen, WindowID p_window = MAIN_WINDOW_ID) override;
|
|
|
|
|
|
|
|
virtual Point2i window_get_position(WindowID p_window = MAIN_WINDOW_ID) const override;
|
2022-11-30 09:28:16 +01:00
|
|
|
virtual Point2i window_get_position_with_decorations(WindowID p_window = MAIN_WINDOW_ID) const override;
|
2020-07-15 20:59:57 +02:00
|
|
|
virtual void window_set_position(const Point2i &p_position, WindowID p_window = MAIN_WINDOW_ID) override;
|
|
|
|
|
|
|
|
virtual void window_set_transient(WindowID p_window, WindowID p_parent) override;
|
|
|
|
|
|
|
|
virtual void window_set_max_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID) override;
|
|
|
|
virtual Size2i window_get_max_size(WindowID p_window = MAIN_WINDOW_ID) const override;
|
|
|
|
|
|
|
|
virtual void window_set_min_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID) override;
|
|
|
|
virtual Size2i window_get_min_size(WindowID p_window = MAIN_WINDOW_ID) const override;
|
|
|
|
|
|
|
|
virtual void window_set_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID) override;
|
|
|
|
virtual Size2i window_get_size(WindowID p_window = MAIN_WINDOW_ID) const override;
|
2022-11-30 09:28:16 +01:00
|
|
|
virtual Size2i window_get_size_with_decorations(WindowID p_window = MAIN_WINDOW_ID) const override;
|
2020-07-15 20:59:57 +02:00
|
|
|
|
|
|
|
virtual void window_set_mode(WindowMode p_mode, WindowID p_window = MAIN_WINDOW_ID) override;
|
|
|
|
virtual WindowMode window_get_mode(WindowID p_window = MAIN_WINDOW_ID) const override;
|
|
|
|
|
|
|
|
virtual bool window_is_maximize_allowed(WindowID p_window = MAIN_WINDOW_ID) const override;
|
|
|
|
|
|
|
|
virtual void window_set_flag(WindowFlags p_flag, bool p_enabled, WindowID p_window = MAIN_WINDOW_ID) override;
|
|
|
|
virtual bool window_get_flag(WindowFlags p_flag, WindowID p_window = MAIN_WINDOW_ID) const override;
|
|
|
|
|
|
|
|
virtual void window_request_attention(WindowID p_window = MAIN_WINDOW_ID) override;
|
|
|
|
virtual void window_move_to_foreground(WindowID p_window = MAIN_WINDOW_ID) override;
|
2023-06-15 09:53:31 +02:00
|
|
|
virtual bool window_is_focused(WindowID p_window = MAIN_WINDOW_ID) const override;
|
2020-07-15 20:59:57 +02:00
|
|
|
|
|
|
|
virtual float screen_get_max_scale() const override;
|
|
|
|
|
|
|
|
virtual void screen_set_orientation(DisplayServer::ScreenOrientation p_orientation, int p_screen) override;
|
|
|
|
virtual DisplayServer::ScreenOrientation screen_get_orientation(int p_screen) const override;
|
|
|
|
|
|
|
|
virtual bool window_can_draw(WindowID p_window = MAIN_WINDOW_ID) const override;
|
|
|
|
|
|
|
|
virtual bool can_any_window_draw() const override;
|
|
|
|
|
2021-06-19 17:44:59 +02:00
|
|
|
virtual void window_set_vsync_mode(DisplayServer::VSyncMode p_vsync_mode, WindowID p_window = MAIN_WINDOW_ID) override;
|
|
|
|
virtual DisplayServer::VSyncMode window_get_vsync_mode(WindowID p_vsync_mode) const override;
|
|
|
|
|
2022-10-17 00:59:51 +02:00
|
|
|
virtual bool is_touchscreen_available() const override;
|
2020-07-15 20:59:57 +02:00
|
|
|
|
2022-07-07 20:20:10 +02:00
|
|
|
virtual void 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) override;
|
2020-07-15 20:59:57 +02:00
|
|
|
virtual void virtual_keyboard_hide() override;
|
|
|
|
|
|
|
|
void virtual_keyboard_set_height(int height);
|
|
|
|
virtual int virtual_keyboard_get_height() const override;
|
|
|
|
|
|
|
|
virtual void clipboard_set(const String &p_text) override;
|
|
|
|
virtual String clipboard_get() const override;
|
|
|
|
|
|
|
|
virtual void screen_set_keep_on(bool p_enable) override;
|
|
|
|
virtual bool screen_is_kept_on() const override;
|
|
|
|
|
|
|
|
void resize_window(CGSize size);
|
2023-01-20 23:20:30 +01:00
|
|
|
virtual void swap_buffers() override {}
|
2020-07-15 20:59:57 +02:00
|
|
|
};
|
|
|
|
|
2022-07-23 23:41:51 +02:00
|
|
|
#endif // DISPLAY_SERVER_IOS_H
|