java_godot_wrapper.h 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*************************************************************************/
  2. /* java_godot_wrapper.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2020 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. // note, swapped java and godot around in the file name so all the java
  31. // wrappers are together
  32. #ifndef JAVA_GODOT_WRAPPER_H
  33. #define JAVA_GODOT_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/Godot.java callable from C++
  38. class GodotJavaWrapper {
  39. private:
  40. jobject godot_instance;
  41. jclass cls;
  42. jmethodID _on_video_init = 0;
  43. jmethodID _restart = 0;
  44. jmethodID _finish = 0;
  45. jmethodID _set_keep_screen_on = 0;
  46. jmethodID _alert = 0;
  47. jmethodID _get_GLES_version_code = 0;
  48. jmethodID _get_clipboard = 0;
  49. jmethodID _set_clipboard = 0;
  50. jmethodID _request_permission = 0;
  51. jmethodID _request_permissions = 0;
  52. jmethodID _get_granted_permissions = 0;
  53. jmethodID _init_input_devices = 0;
  54. jmethodID _get_surface = 0;
  55. jmethodID _is_activity_resumed = 0;
  56. jmethodID _vibrate = 0;
  57. jmethodID _get_input_fallback_mapping = 0;
  58. jmethodID _on_godot_main_loop_started = 0;
  59. public:
  60. GodotJavaWrapper(JNIEnv *p_env, jobject p_godot_instance);
  61. ~GodotJavaWrapper();
  62. jobject get_activity();
  63. jobject get_member_object(const char *p_name, const char *p_class, JNIEnv *p_env = NULL);
  64. jobject get_class_loader();
  65. void gfx_init(bool gl2);
  66. void on_video_init(JNIEnv *p_env = NULL);
  67. void on_godot_main_loop_started(JNIEnv *p_env = NULL);
  68. void restart(JNIEnv *p_env = NULL);
  69. void force_quit(JNIEnv *p_env = NULL);
  70. void set_keep_screen_on(bool p_enabled);
  71. void alert(const String &p_message, const String &p_title);
  72. int get_gles_version_code();
  73. bool has_get_clipboard();
  74. String get_clipboard();
  75. bool has_set_clipboard();
  76. void set_clipboard(const String &p_text);
  77. bool request_permission(const String &p_name);
  78. bool request_permissions();
  79. Vector<String> get_granted_permissions() const;
  80. void init_input_devices();
  81. jobject get_surface();
  82. bool is_activity_resumed();
  83. void vibrate(int p_duration_ms);
  84. String get_input_fallback_mapping();
  85. };
  86. #endif /* !JAVA_GODOT_WRAPPER_H */