0.2.0-dev Download ZIP
164 lines ·6.5 KB Raw
| 1 | /**************************************************************************/ |
| 2 | /* os_apple_embedded.h */ |
| 3 | /**************************************************************************/ |
| 4 | /* This file is part of: */ |
| 5 | /* GODOT ENGINE */ |
| 6 | /* https://godotengine.org */ |
| 7 | /**************************************************************************/ |
| 8 | /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ |
| 9 | /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ |
| 10 | /* */ |
| 11 | /* Permission is hereby granted, free of charge, to any person obtaining */ |
| 12 | /* a copy of this software and associated documentation files (the */ |
| 13 | /* "Software"), to deal in the Software without restriction, including */ |
| 14 | /* without limitation the rights to use, copy, modify, merge, publish, */ |
| 15 | /* distribute, sublicense, and/or sell copies of the Software, and to */ |
| 16 | /* permit persons to whom the Software is furnished to do so, subject to */ |
| 17 | /* the following conditions: */ |
| 18 | /* */ |
| 19 | /* The above copyright notice and this permission notice shall be */ |
| 20 | /* included in all copies or substantial portions of the Software. */ |
| 21 | /* */ |
| 22 | /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ |
| 23 | /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ |
| 24 | /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ |
| 25 | /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ |
| 26 | /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ |
| 27 | /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ |
| 28 | /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ |
| 29 | /**************************************************************************/ |
| 30 | |
| 31 | #pragma once |
| 32 | |
| 33 | #ifdef APPLE_EMBEDDED_ENABLED |
| 34 | |
| 35 | #import "drivers/apple_embedded/apple_embedded.h" |
| 36 | #import "drivers/coreaudio/audio_driver_coreaudio.h" |
| 37 | #include "drivers/unix/os_unix.h" |
| 38 | #include "servers/audio/audio_server.h" |
| 39 | #include "servers/rendering/renderer_compositor.h" |
| 40 | |
| 41 | #if defined(RD_ENABLED) |
| 42 | #include "servers/rendering/rendering_device.h" |
| 43 | |
| 44 | #if defined(VULKAN_ENABLED) |
| 45 | #import "drivers/apple_embedded/rendering_context_driver_vulkan_apple_embedded.h" |
| 46 | #endif |
| 47 | #endif |
| 48 | |
| 49 | class JoypadSDL; |
| 50 | |
| 51 | class OS_AppleEmbedded : public OS_Unix { |
| 52 | private: |
| 53 | static HashMap<String, void *> dynamic_symbol_lookup_table; |
| 54 | friend void register_dynamic_symbol(char *name, void *address); |
| 55 | |
| 56 | AudioDriverCoreAudio audio_driver; |
| 57 | |
| 58 | AppleEmbedded *apple_embedded = nullptr; |
| 59 | |
| 60 | #ifdef SDL_ENABLED |
| 61 | JoypadSDL *joypad_sdl = nullptr; |
| 62 | #endif |
| 63 | |
| 64 | MainLoop *main_loop = nullptr; |
| 65 | |
| 66 | virtual void initialize_core() override; |
| 67 | virtual void initialize() override; |
| 68 | |
| 69 | virtual void initialize_joypads() override; |
| 70 | |
| 71 | virtual void set_main_loop(MainLoop *p_main_loop) override; |
| 72 | virtual MainLoop *get_main_loop() const override; |
| 73 | |
| 74 | virtual void delete_main_loop() override; |
| 75 | |
| 76 | virtual void finalize() override; |
| 77 | |
| 78 | bool is_focused = false; |
| 79 | |
| 80 | CGFloat _weight_to_ct(int p_weight) const; |
| 81 | CGFloat _stretch_to_ct(int p_stretch) const; |
| 82 | String _get_default_fontname(const String &p_font_name) const; |
| 83 | |
| 84 | static _FORCE_INLINE_ String get_framework_executable(const String &p_path); |
| 85 | |
| 86 | void deinitialize_modules(); |
| 87 | |
| 88 | mutable String remote_fs_dir; |
| 89 | |
| 90 | public: |
| 91 | static OS_AppleEmbedded *get_singleton(); |
| 92 | |
| 93 | OS_AppleEmbedded(); |
| 94 | ~OS_AppleEmbedded(); |
| 95 | |
| 96 | void initialize_modules(); |
| 97 | |
| 98 | bool iterate(); |
| 99 | |
| 100 | void start(); |
| 101 | |
| 102 | virtual Error get_entropy(uint8_t *r_buffer, int p_bytes) override; |
| 103 | virtual void alert(const String &p_alert, const String &p_title = "ALERT!") override; |
| 104 | |
| 105 | virtual Vector<String> get_system_fonts() const override; |
| 106 | virtual Vector<String> get_system_font_path_for_text(const String &p_font_name, const String &p_text, const String &p_locale = String(), const String &p_script = String(), int p_weight = 400, int p_stretch = 100, bool p_italic = false) const override; |
| 107 | virtual String get_system_font_path(const String &p_font_name, int p_weight = 400, int p_stretch = 100, bool p_italic = false) const override; |
| 108 | |
| 109 | virtual Error open_dynamic_library(const String &p_path, void *&p_library_handle, GDExtensionData *p_data = nullptr) override; |
| 110 | virtual Error close_dynamic_library(void *p_library_handle) override; |
| 111 | virtual Error get_dynamic_library_symbol_handle(void *p_library_handle, const String &p_name, void *&p_symbol_handle, bool p_optional = false) override; |
| 112 | |
| 113 | virtual String get_distribution_name() const override; |
| 114 | virtual String get_version() const override; |
| 115 | virtual String get_model_name() const override; |
| 116 | |
| 117 | virtual Error shell_open(const String &p_uri) override; |
| 118 | |
| 119 | virtual String get_user_data_dir(const String &p_user_dir) const override; |
| 120 | |
| 121 | virtual String get_cache_path() const override; |
| 122 | virtual String get_temp_path() const override; |
| 123 | virtual String get_resource_dir() const override; |
| 124 | virtual String get_bundle_resource_dir() const override; |
| 125 | |
| 126 | virtual String get_locale() const override; |
| 127 | virtual Vector<String> get_preferred_locales() const override; |
| 128 | |
| 129 | virtual String get_unique_id() const override; |
| 130 | virtual String get_processor_name() const override; |
| 131 | |
| 132 | virtual void vibrate_handheld(int p_duration_ms = 500, float p_amplitude = -1.0) override; |
| 133 | |
| 134 | virtual bool _check_internal_feature_support(const String &p_feature) override; |
| 135 | |
| 136 | virtual Error setup_remote_filesystem(const String &p_server_host, int p_port, const String &p_password, String &r_project_path) override; |
| 137 | |
| 138 | void audio_driver_start(); |
| 139 | void audio_driver_stop(); |
| 140 | |
| 141 | void on_focus_out(); |
| 142 | void on_focus_in(); |
| 143 | |
| 144 | void on_enter_background(); |
| 145 | void on_exit_background(); |
| 146 | |
| 147 | virtual Rect2 calculate_boot_screen_rect(const Size2 &p_window_size, const Size2 &p_imgrect_size) const override; |
| 148 | |
| 149 | virtual bool request_permission(const String &p_name) override; |
| 150 | virtual Vector<String> get_granted_permissions() const override; |
| 151 | |
| 152 | virtual String get_platform_string(PlatformString p_platform_string) const override { |
| 153 | switch (p_platform_string) { |
| 154 | case OS::PlatformString::PLATFORM_STRING_FILE_MANAGER_OPEN: |
| 155 | return ETR("Open in Files"); |
| 156 | case OS::PlatformString::PLATFORM_STRING_FILE_MANAGER_SHOW: |
| 157 | return ETR("Show in Files"); |
| 158 | default: |
| 159 | return OS::get_platform_string(p_platform_string); |
| 160 | } |
| 161 | } |
| 162 | }; |
| 163 | |
| 164 | #endif // APPLE_EMBEDDED_ENABLED |