os_macos.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /**************************************************************************/
  2. /* os_macos.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. #ifndef OS_MACOS_H
  31. #define OS_MACOS_H
  32. #include "crash_handler_macos.h"
  33. #include "joypad_macos.h"
  34. #include "core/input/input.h"
  35. #import "drivers/coreaudio/audio_driver_coreaudio.h"
  36. #import "drivers/coremidi/midi_driver_coremidi.h"
  37. #include "drivers/unix/os_unix.h"
  38. #include "servers/audio_server.h"
  39. class OS_MacOS : public OS_Unix {
  40. JoypadMacOS *joypad_macos = nullptr;
  41. #ifdef COREAUDIO_ENABLED
  42. AudioDriverCoreAudio audio_driver;
  43. #endif
  44. #ifdef COREMIDI_ENABLED
  45. MIDIDriverCoreMidi midi_driver;
  46. #endif
  47. CrashHandler crash_handler;
  48. CFRunLoopObserverRef pre_wait_observer;
  49. MainLoop *main_loop = nullptr;
  50. List<String> launch_service_args;
  51. CGFloat _weight_to_ct(int p_weight) const;
  52. CGFloat _stretch_to_ct(int p_stretch) const;
  53. String _get_default_fontname(const String &p_font_name) const;
  54. static _FORCE_INLINE_ String get_framework_executable(const String &p_path);
  55. static void pre_wait_observer_cb(CFRunLoopObserverRef p_observer, CFRunLoopActivity p_activiy, void *p_context);
  56. protected:
  57. virtual void initialize_core() override;
  58. virtual void initialize() override;
  59. virtual void finalize() override;
  60. virtual void initialize_joypads() override;
  61. virtual void set_main_loop(MainLoop *p_main_loop) override;
  62. virtual void delete_main_loop() override;
  63. public:
  64. virtual void set_cmdline_platform_args(const List<String> &p_args);
  65. virtual List<String> get_cmdline_platform_args() const override;
  66. virtual String get_name() const override;
  67. virtual String get_distribution_name() const override;
  68. virtual String get_version() const override;
  69. virtual void alert(const String &p_alert, const String &p_title = "ALERT!") override;
  70. virtual Error open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path = false, String *r_resolved_path = nullptr) override;
  71. virtual MainLoop *get_main_loop() const override;
  72. virtual String get_config_path() const override;
  73. virtual String get_data_path() const override;
  74. virtual String get_cache_path() const override;
  75. virtual String get_bundle_resource_dir() const override;
  76. virtual String get_bundle_icon_path() const override;
  77. virtual String get_godot_dir_name() const override;
  78. virtual String get_system_dir(SystemDir p_dir, bool p_shared_storage = true) const override;
  79. virtual Error shell_open(String p_uri) override;
  80. virtual Error shell_show_in_file_manager(String p_path, bool p_open_folder) override;
  81. virtual String get_locale() const override;
  82. virtual Vector<String> get_system_fonts() const override;
  83. 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;
  84. 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;
  85. virtual String get_executable_path() const override;
  86. virtual Error create_process(const String &p_path, const List<String> &p_arguments, ProcessID *r_child_id = nullptr, bool p_open_console = false) override;
  87. virtual Error create_instance(const List<String> &p_arguments, ProcessID *r_child_id = nullptr) override;
  88. virtual String get_unique_id() const override;
  89. virtual String get_processor_name() const override;
  90. virtual bool is_sandboxed() const override;
  91. virtual Vector<String> get_granted_permissions() const override;
  92. virtual void revoke_granted_permissions() override;
  93. virtual bool _check_internal_feature_support(const String &p_feature) override;
  94. virtual void disable_crash_handler() override;
  95. virtual bool is_disable_crash_handler() const override;
  96. virtual Error move_to_trash(const String &p_path) override;
  97. virtual String get_system_ca_certificates() override;
  98. virtual OS::PreferredTextureFormat get_preferred_texture_format() const override;
  99. void run();
  100. OS_MacOS();
  101. ~OS_MacOS();
  102. };
  103. #endif // OS_MACOS_H