os_iphone.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /*************************************************************************/
  2. /* os_iphone.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
  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. #ifdef IPHONE_ENABLED
  31. #ifndef OS_IPHONE_H
  32. #define OS_IPHONE_H
  33. #include "core/os/input.h"
  34. #include "drivers/coreaudio/audio_driver_coreaudio.h"
  35. #include "drivers/unix/os_unix.h"
  36. #include "joypad_iphone.h"
  37. #include "ios.h"
  38. #include "main/input_default.h"
  39. #include "servers/audio_server.h"
  40. #include "servers/visual/rasterizer.h"
  41. #include "servers/visual_server.h"
  42. class OSIPhone : public OS_Unix {
  43. private:
  44. static HashMap<String, void *> dynamic_symbol_lookup_table;
  45. friend void register_dynamic_symbol(char *name, void *address);
  46. VisualServer *visual_server;
  47. AudioDriverCoreAudio audio_driver;
  48. iOS *ios;
  49. JoypadIPhone *joypad_iphone;
  50. MainLoop *main_loop;
  51. VideoMode video_mode;
  52. virtual int get_video_driver_count() const;
  53. virtual const char *get_video_driver_name(int p_driver) const;
  54. virtual int get_current_video_driver() const;
  55. virtual void initialize_core();
  56. virtual Error initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver);
  57. virtual void set_main_loop(MainLoop *p_main_loop);
  58. virtual MainLoop *get_main_loop() const;
  59. virtual void delete_main_loop();
  60. virtual void finalize();
  61. void perform_event(const Ref<InputEvent> &p_event);
  62. void set_data_dir(String p_dir);
  63. String data_dir;
  64. InputDefault *input;
  65. int virtual_keyboard_height = 0;
  66. int video_driver_index;
  67. bool is_focused = false;
  68. public:
  69. static OSIPhone *get_singleton();
  70. OSIPhone(String p_data_dir);
  71. ~OSIPhone();
  72. bool iterate();
  73. void start();
  74. virtual Error open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path = false);
  75. virtual Error close_dynamic_library(void *p_library_handle);
  76. virtual Error get_dynamic_library_symbol_handle(void *p_library_handle, const String p_name, void *&p_symbol_handle, bool p_optional = false);
  77. virtual void alert(const String &p_alert, const String &p_title = "ALERT!");
  78. virtual String get_name() const;
  79. virtual String get_model_name() const;
  80. virtual void set_clipboard(const String &p_text);
  81. virtual String get_clipboard() const;
  82. Error shell_open(String p_uri);
  83. String get_user_data_dir() const;
  84. String get_locale() const;
  85. String get_unique_id() const;
  86. virtual void vibrate_handheld(int p_duration_ms = 500);
  87. virtual bool _check_internal_feature_support(const String &p_feature);
  88. virtual int get_screen_dpi(int p_screen = -1) const;
  89. void pencil_press(int p_idx, int p_x, int p_y, bool p_pressed, bool p_doubleclick);
  90. void touch_press(int p_idx, int p_x, int p_y, bool p_pressed, bool p_doubleclick);
  91. void pencil_drag(int p_idx, int p_prev_x, int p_prev_y, int p_x, int p_y, float p_force);
  92. void touch_drag(int p_idx, int p_prev_x, int p_prev_y, int p_x, int p_y);
  93. void touches_cancelled(int p_idx);
  94. void pencil_cancelled(int p_idx);
  95. void key(uint32_t p_key, bool p_pressed);
  96. void set_virtual_keyboard_height(int p_height);
  97. int set_base_framebuffer(int p_fb);
  98. void update_gravity(float p_x, float p_y, float p_z);
  99. void update_accelerometer(float p_x, float p_y, float p_z);
  100. void update_magnetometer(float p_x, float p_y, float p_z);
  101. void update_gyroscope(float p_x, float p_y, float p_z);
  102. int get_unused_joy_id();
  103. void joy_connection_changed(int p_idx, bool p_connected, String p_name);
  104. void joy_button(int p_device, int p_button, bool p_pressed);
  105. void joy_axis(int p_device, int p_axis, const InputDefault::JoyAxis &p_value);
  106. virtual void set_mouse_show(bool p_show);
  107. virtual void set_mouse_grab(bool p_grab);
  108. virtual bool is_mouse_grab_enabled() const;
  109. virtual Point2 get_mouse_position() const;
  110. virtual int get_mouse_button_state() const;
  111. virtual void set_window_title(const String &p_title);
  112. virtual void set_video_mode(const VideoMode &p_video_mode, int p_screen = 0);
  113. virtual VideoMode get_video_mode(int p_screen = 0) const;
  114. virtual void get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen = 0) const;
  115. virtual void set_keep_screen_on(bool p_enabled);
  116. virtual bool can_draw() const;
  117. virtual bool has_virtual_keyboard() const;
  118. virtual void show_virtual_keyboard(const String &p_existing_text, const Rect2 &p_screen_rect = Rect2(), bool p_multiline = false, int p_max_input_length = -1, int p_cursor_start = -1, int p_cursor_end = -1);
  119. virtual void hide_virtual_keyboard();
  120. virtual int get_virtual_keyboard_height() const;
  121. virtual Size2 get_window_size() const;
  122. virtual Rect2 get_window_safe_area() const;
  123. virtual bool has_touchscreen_ui_hint() const;
  124. virtual Error native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track);
  125. virtual bool native_video_is_playing() const;
  126. virtual void native_video_pause();
  127. virtual void native_video_unpause();
  128. virtual void native_video_focus_out();
  129. virtual void native_video_stop();
  130. void on_focus_out();
  131. void on_focus_in();
  132. };
  133. #endif // OS_IPHONE_H
  134. #endif