Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/drivers/apple_embedded/os_apple_embedded.h
9898 views
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 "apple_embedded.h"
36
37
#import "drivers/apple/joypad_apple.h"
38
#import "drivers/coreaudio/audio_driver_coreaudio.h"
39
#include "drivers/unix/os_unix.h"
40
#include "servers/audio_server.h"
41
#include "servers/rendering/renderer_compositor.h"
42
43
#if defined(RD_ENABLED)
44
#include "servers/rendering/rendering_device.h"
45
46
#if defined(VULKAN_ENABLED)
47
#import "rendering_context_driver_vulkan_apple_embedded.h"
48
#endif
49
#endif
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
JoypadApple *joypad_apple = nullptr;
61
62
MainLoop *main_loop = nullptr;
63
64
virtual void initialize_core() override;
65
virtual void initialize() override;
66
67
virtual void initialize_joypads() override;
68
69
virtual void set_main_loop(MainLoop *p_main_loop) override;
70
virtual MainLoop *get_main_loop() const override;
71
72
virtual void delete_main_loop() override;
73
74
virtual void finalize() override;
75
76
bool is_focused = false;
77
78
CGFloat _weight_to_ct(int p_weight) const;
79
CGFloat _stretch_to_ct(int p_stretch) const;
80
String _get_default_fontname(const String &p_font_name) const;
81
82
static _FORCE_INLINE_ String get_framework_executable(const String &p_path);
83
84
void deinitialize_modules();
85
86
mutable String remote_fs_dir;
87
88
public:
89
static OS_AppleEmbedded *get_singleton();
90
91
OS_AppleEmbedded();
92
~OS_AppleEmbedded();
93
94
void initialize_modules();
95
96
bool iterate();
97
98
void start();
99
100
virtual void alert(const String &p_alert, const String &p_title = "ALERT!") override;
101
102
virtual Vector<String> get_system_fonts() const override;
103
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;
104
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;
105
106
virtual Error open_dynamic_library(const String &p_path, void *&p_library_handle, GDExtensionData *p_data = nullptr) override;
107
virtual Error close_dynamic_library(void *p_library_handle) override;
108
virtual Error get_dynamic_library_symbol_handle(void *p_library_handle, const String &p_name, void *&p_symbol_handle, bool p_optional = false) override;
109
110
virtual String get_distribution_name() const override;
111
virtual String get_version() const override;
112
virtual String get_model_name() const override;
113
114
virtual Error shell_open(const String &p_uri) override;
115
116
virtual String get_user_data_dir(const String &p_user_dir) const override;
117
118
virtual String get_cache_path() const override;
119
virtual String get_temp_path() const override;
120
virtual String get_resource_dir() const override;
121
122
virtual String get_locale() const override;
123
124
virtual String get_unique_id() const override;
125
virtual String get_processor_name() const override;
126
127
virtual void vibrate_handheld(int p_duration_ms = 500, float p_amplitude = -1.0) override;
128
129
virtual bool _check_internal_feature_support(const String &p_feature) override;
130
131
virtual Error setup_remote_filesystem(const String &p_server_host, int p_port, const String &p_password, String &r_project_path) override;
132
133
void on_focus_out();
134
void on_focus_in();
135
136
void on_enter_background();
137
void on_exit_background();
138
139
virtual Rect2 calculate_boot_screen_rect(const Size2 &p_window_size, const Size2 &p_imgrect_size) const override;
140
141
virtual bool request_permission(const String &p_name) override;
142
virtual Vector<String> get_granted_permissions() const override;
143
};
144
145
#endif // APPLE_EMBEDDED_ENABLED
146
147