godot_js.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /**************************************************************************/
  2. /* godot_js.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 GODOT_JS_H
  31. #define GODOT_JS_H
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35. #include "stddef.h"
  36. // Config
  37. extern void godot_js_config_locale_get(char *p_ptr, int p_ptr_max);
  38. extern void godot_js_config_canvas_id_get(char *p_ptr, int p_ptr_max);
  39. // OS
  40. extern void godot_js_os_finish_async(void (*p_callback)());
  41. extern void godot_js_os_request_quit_cb(void (*p_callback)());
  42. extern int godot_js_os_fs_is_persistent();
  43. extern void godot_js_os_fs_sync(void (*p_callback)());
  44. extern int godot_js_os_execute(const char *p_json);
  45. extern void godot_js_os_shell_open(const char *p_uri);
  46. extern int godot_js_os_hw_concurrency_get();
  47. extern int godot_js_pwa_cb(void (*p_callback)());
  48. extern int godot_js_pwa_update();
  49. // Input
  50. extern void godot_js_input_mouse_button_cb(int (*p_callback)(int p_pressed, int p_button, double p_x, double p_y, int p_modifiers));
  51. extern void godot_js_input_mouse_move_cb(void (*p_callback)(double p_x, double p_y, double p_rel_x, double p_rel_y, int p_modifiers));
  52. extern void godot_js_input_mouse_wheel_cb(int (*p_callback)(double p_delta_x, double p_delta_y));
  53. extern void godot_js_input_touch_cb(void (*p_callback)(int p_type, int p_count), uint32_t *r_identifiers, double *r_coords);
  54. extern void godot_js_input_key_cb(void (*p_callback)(int p_type, int p_repeat, int p_modifiers), char r_code[32], char r_key[32]);
  55. extern void godot_js_input_vibrate_handheld(int p_duration_ms);
  56. // IME
  57. extern void godot_js_set_ime_active(int p_active);
  58. extern void godot_js_set_ime_position(int p_x, int p_y);
  59. extern void godot_js_set_ime_cb(void (*p_input)(int p_type, const char *p_text), void (*p_callback)(int p_type, int p_repeat, int p_modifiers), char r_code[32], char r_key[32]);
  60. extern int godot_js_is_ime_focused();
  61. // Input gamepad
  62. extern void godot_js_input_gamepad_cb(void (*p_on_change)(int p_index, int p_connected, const char *p_id, const char *p_guid));
  63. extern int godot_js_input_gamepad_sample();
  64. extern int godot_js_input_gamepad_sample_count();
  65. extern int godot_js_input_gamepad_sample_get(int p_idx, float r_btns[16], int32_t *r_btns_num, float r_axes[10], int32_t *r_axes_num, int32_t *r_standard);
  66. extern void godot_js_input_paste_cb(void (*p_callback)(const char *p_text));
  67. extern void godot_js_input_drop_files_cb(void (*p_callback)(char **p_filev, int p_filec));
  68. // TTS
  69. extern int godot_js_tts_is_speaking();
  70. extern int godot_js_tts_is_paused();
  71. extern int godot_js_tts_get_voices(void (*p_callback)(int p_size, const char **p_voices));
  72. extern void godot_js_tts_speak(const char *p_text, const char *p_voice, int p_volume, float p_pitch, float p_rate, int p_utterance_id, void (*p_callback)(int p_event, int p_id, int p_pos));
  73. extern void godot_js_tts_pause();
  74. extern void godot_js_tts_resume();
  75. extern void godot_js_tts_stop();
  76. // Display
  77. extern int godot_js_display_screen_dpi_get();
  78. extern double godot_js_display_pixel_ratio_get();
  79. extern void godot_js_display_alert(const char *p_text);
  80. extern int godot_js_display_touchscreen_is_available();
  81. extern int godot_js_display_is_swap_ok_cancel();
  82. extern void godot_js_display_setup_canvas(int p_width, int p_height, int p_fullscreen, int p_hidpi);
  83. // Display canvas
  84. extern void godot_js_display_canvas_focus();
  85. extern int godot_js_display_canvas_is_focused();
  86. // Display window
  87. extern void godot_js_display_desired_size_set(int p_width, int p_height);
  88. extern int godot_js_display_size_update();
  89. extern void godot_js_display_window_size_get(int32_t *p_x, int32_t *p_y);
  90. extern void godot_js_display_screen_size_get(int32_t *p_x, int32_t *p_y);
  91. extern int godot_js_display_fullscreen_request();
  92. extern int godot_js_display_fullscreen_exit();
  93. extern void godot_js_display_window_title_set(const char *p_text);
  94. extern void godot_js_display_window_icon_set(const uint8_t *p_ptr, int p_len);
  95. extern int godot_js_display_has_webgl(int p_version);
  96. // Display clipboard
  97. extern int godot_js_display_clipboard_set(const char *p_text);
  98. extern int godot_js_display_clipboard_get(void (*p_callback)(const char *p_text));
  99. // Display cursor
  100. extern void godot_js_display_cursor_set_shape(const char *p_cursor);
  101. extern int godot_js_display_cursor_is_hidden();
  102. extern void godot_js_display_cursor_set_custom_shape(const char *p_shape, const uint8_t *p_ptr, int p_len, int p_hotspot_x, int p_hotspot_y);
  103. extern void godot_js_display_cursor_set_visible(int p_visible);
  104. extern void godot_js_display_cursor_lock_set(int p_lock);
  105. extern int godot_js_display_cursor_is_locked();
  106. // Display listeners
  107. extern void godot_js_display_fullscreen_cb(void (*p_callback)(int p_fullscreen));
  108. extern void godot_js_display_window_blur_cb(void (*p_callback)());
  109. extern void godot_js_display_notification_cb(void (*p_callback)(int p_notification), int p_enter, int p_exit, int p_in, int p_out);
  110. // Display Virtual Keyboard
  111. extern int godot_js_display_vk_available();
  112. extern int godot_js_display_tts_available();
  113. extern void godot_js_display_vk_cb(void (*p_input)(const char *p_text, int p_cursor));
  114. extern void godot_js_display_vk_show(const char *p_text, int p_type, int p_start, int p_end);
  115. extern void godot_js_display_vk_hide();
  116. #ifdef __cplusplus
  117. }
  118. #endif
  119. #endif // GODOT_JS_H