os_android.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*************************************************************************/
  2. /* os_android.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2021 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. #ifndef OS_ANDROID_H
  31. #define OS_ANDROID_H
  32. #include "audio_driver_jandroid.h"
  33. #include "audio_driver_opensl.h"
  34. #include "core/os/main_loop.h"
  35. #include "drivers/unix/os_unix.h"
  36. #include "servers/audio_server.h"
  37. class GodotJavaWrapper;
  38. class GodotIOJavaWrapper;
  39. struct ANativeWindow;
  40. class OS_Android : public OS_Unix {
  41. private:
  42. Size2i display_size;
  43. bool use_apk_expansion;
  44. #if defined(OPENGL_ENABLED)
  45. bool use_16bits_fbo;
  46. const char *gl_extensions;
  47. #endif
  48. #if defined(VULKAN_ENABLED)
  49. ANativeWindow *native_window;
  50. #endif
  51. mutable String data_dir_cache;
  52. //AudioDriverAndroid audio_driver_android;
  53. AudioDriverOpenSL audio_driver_android;
  54. MainLoop *main_loop;
  55. GodotJavaWrapper *godot_java;
  56. GodotIOJavaWrapper *godot_io_java;
  57. public:
  58. virtual void initialize_core() override;
  59. virtual void initialize() 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. virtual void finalize() override;
  64. typedef int64_t ProcessID;
  65. static OS_Android *get_singleton();
  66. GodotJavaWrapper *get_godot_java();
  67. GodotIOJavaWrapper *get_godot_io_java();
  68. virtual bool request_permission(const String &p_name) override;
  69. virtual bool request_permissions() override;
  70. virtual Vector<String> get_granted_permissions() const override;
  71. virtual Error open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path = false) override;
  72. virtual String get_name() const override;
  73. virtual MainLoop *get_main_loop() const override;
  74. void main_loop_begin();
  75. bool main_loop_iterate();
  76. void main_loop_request_go_back();
  77. void main_loop_end();
  78. void main_loop_focusout();
  79. void main_loop_focusin();
  80. void set_display_size(const Size2i &p_size);
  81. Size2i get_display_size() const;
  82. void set_context_is_16_bits(bool p_is_16);
  83. void set_opengl_extensions(const char *p_gl_extensions);
  84. void set_native_window(ANativeWindow *p_native_window);
  85. ANativeWindow *get_native_window() const;
  86. virtual Error shell_open(String p_uri) override;
  87. virtual String get_user_data_dir() const override;
  88. virtual String get_resource_dir() const override;
  89. virtual String get_locale() const override;
  90. virtual String get_model_name() const override;
  91. virtual String get_unique_id() const override;
  92. virtual String get_system_dir(SystemDir p_dir) const override;
  93. void vibrate_handheld(int p_duration_ms) override;
  94. virtual bool _check_internal_feature_support(const String &p_feature) override;
  95. OS_Android(GodotJavaWrapper *p_godot_java, GodotIOJavaWrapper *p_godot_io_java, bool p_use_apk_expansion);
  96. ~OS_Android();
  97. };
  98. #endif