java_godot_io_wrapper.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /**************************************************************************/
  2. /* java_godot_io_wrapper.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. // note, swapped java and godot around in the file name so all the java
  31. // wrappers are together
  32. #ifndef JAVA_GODOT_IO_WRAPPER_H
  33. #define JAVA_GODOT_IO_WRAPPER_H
  34. #include <android/log.h>
  35. #include <jni.h>
  36. #include "string_android.h"
  37. // Class that makes functions in java/src/org/godotengine/godot/GodotIO.java callable from C++
  38. class GodotIOJavaWrapper {
  39. private:
  40. jobject godot_io_instance;
  41. jclass cls;
  42. jmethodID _open_URI = 0;
  43. jmethodID _get_cache_dir = 0;
  44. jmethodID _get_data_dir = 0;
  45. jmethodID _get_display_cutouts = 0;
  46. jmethodID _get_locale = 0;
  47. jmethodID _get_model = 0;
  48. jmethodID _get_screen_DPI = 0;
  49. jmethodID _get_scaled_density = 0;
  50. jmethodID _get_screen_refresh_rate = 0;
  51. jmethodID _get_window_safe_area = 0;
  52. jmethodID _get_unique_id = 0;
  53. jmethodID _show_keyboard = 0;
  54. jmethodID _hide_keyboard = 0;
  55. jmethodID _set_screen_orientation = 0;
  56. jmethodID _get_screen_orientation = 0;
  57. jmethodID _get_system_dir = 0;
  58. public:
  59. GodotIOJavaWrapper(JNIEnv *p_env, jobject p_godot_io_instance);
  60. ~GodotIOJavaWrapper();
  61. jobject get_instance();
  62. Error open_uri(const String &p_uri);
  63. String get_cache_dir();
  64. String get_user_data_dir();
  65. String get_locale();
  66. String get_model();
  67. int get_screen_dpi();
  68. float get_scaled_density();
  69. void get_window_safe_area(int (&p_rect_xywh)[4]);
  70. Array get_display_cutouts();
  71. float get_screen_refresh_rate(float p_fallback);
  72. String get_unique_id();
  73. bool has_vk();
  74. void show_vk(const String &p_existing, int p_type, int p_max_input_length, int p_cursor_start, int p_cursor_end);
  75. void hide_vk();
  76. int get_vk_height();
  77. void set_vk_height(int p_height);
  78. void set_screen_orientation(int p_orient);
  79. int get_screen_orientation() const;
  80. String get_system_dir(int p_dir, bool p_shared_storage);
  81. };
  82. #endif // JAVA_GODOT_IO_WRAPPER_H