godot_js.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. #define WASM_EXPORT __attribute__((visibility("default")))
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36. #include <stddef.h>
  37. #include <stdint.h>
  38. // Config
  39. extern void godot_js_config_locale_get(char *p_ptr, int p_ptr_max);
  40. extern void godot_js_config_canvas_id_get(char *p_ptr, int p_ptr_max);
  41. // OS
  42. extern void godot_js_os_finish_async(void (*p_callback)());
  43. extern void godot_js_os_request_quit_cb(void (*p_callback)());
  44. extern int godot_js_os_fs_is_persistent();
  45. extern void godot_js_os_fs_sync(void (*p_callback)());
  46. extern int godot_js_os_execute(const char *p_json);
  47. extern void godot_js_os_shell_open(const char *p_uri);
  48. extern int godot_js_os_hw_concurrency_get();
  49. extern int godot_js_os_has_feature(const char *p_ftr);
  50. extern int godot_js_pwa_cb(void (*p_callback)());
  51. extern int godot_js_pwa_update();
  52. // Input
  53. 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));
  54. 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));
  55. extern void godot_js_input_mouse_wheel_cb(int (*p_callback)(double p_delta_x, double p_delta_y));
  56. extern void godot_js_input_touch_cb(void (*p_callback)(int p_type, int p_count), uint32_t *r_identifiers, double *r_coords);
  57. 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]);
  58. extern void godot_js_input_vibrate_handheld(int p_duration_ms);
  59. extern void godot_js_set_ime_active(int p_active);
  60. extern void godot_js_set_ime_position(int p_x, int p_y);
  61. 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]);
  62. extern int godot_js_is_ime_focused();
  63. // Input gamepad
  64. 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));
  65. extern int godot_js_input_gamepad_sample();
  66. extern int godot_js_input_gamepad_sample_count();
  67. 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);
  68. extern void godot_js_input_paste_cb(void (*p_callback)(const char *p_text));
  69. extern void godot_js_input_drop_files_cb(void (*p_callback)(const char **p_filev, int p_filec));
  70. // TTS
  71. extern int godot_js_tts_is_speaking();
  72. extern int godot_js_tts_is_paused();
  73. extern int godot_js_tts_get_voices(void (*p_callback)(int p_size, const char **p_voices));
  74. 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));
  75. extern void godot_js_tts_pause();
  76. extern void godot_js_tts_resume();
  77. extern void godot_js_tts_stop();
  78. // Display
  79. extern int godot_js_display_screen_dpi_get();
  80. extern double godot_js_display_pixel_ratio_get();
  81. extern void godot_js_display_alert(const char *p_text);
  82. extern int godot_js_display_touchscreen_is_available();
  83. extern int godot_js_display_is_swap_ok_cancel();
  84. extern void godot_js_display_setup_canvas(int p_width, int p_height, int p_fullscreen, int p_hidpi);
  85. // Display canvas
  86. extern void godot_js_display_canvas_focus();
  87. extern int godot_js_display_canvas_is_focused();
  88. // Display window
  89. extern void godot_js_display_desired_size_set(int p_width, int p_height);
  90. extern int godot_js_display_size_update();
  91. extern void godot_js_display_window_size_get(int32_t *p_x, int32_t *p_y);
  92. extern void godot_js_display_screen_size_get(int32_t *p_x, int32_t *p_y);
  93. extern int godot_js_display_fullscreen_request();
  94. extern int godot_js_display_fullscreen_exit();
  95. extern void godot_js_display_window_title_set(const char *p_text);
  96. extern void godot_js_display_window_icon_set(const uint8_t *p_ptr, int p_len);
  97. extern int godot_js_display_has_webgl(int p_version);
  98. // Display clipboard
  99. extern int godot_js_display_clipboard_set(const char *p_text);
  100. extern int godot_js_display_clipboard_get(void (*p_callback)(const char *p_text));
  101. // Display cursor
  102. extern void godot_js_display_cursor_set_shape(const char *p_cursor);
  103. extern int godot_js_display_cursor_is_hidden();
  104. 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);
  105. extern void godot_js_display_cursor_set_visible(int p_visible);
  106. extern void godot_js_display_cursor_lock_set(int p_lock);
  107. extern int godot_js_display_cursor_is_locked();
  108. // Display listeners
  109. extern void godot_js_display_fullscreen_cb(void (*p_callback)(int p_fullscreen));
  110. extern void godot_js_display_window_blur_cb(void (*p_callback)());
  111. 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);
  112. // Display Virtual Keyboard
  113. extern int godot_js_display_vk_available();
  114. extern int godot_js_display_tts_available();
  115. extern void godot_js_display_vk_cb(void (*p_input)(const char *p_text, int p_cursor));
  116. extern void godot_js_display_vk_show(const char *p_text, int p_type, int p_start, int p_end);
  117. extern void godot_js_display_vk_hide();
  118. #ifdef __cplusplus
  119. }
  120. #endif
  121. #endif // GODOT_JS_H