godot_js.h 4.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*************************************************************************/
  2. /* godot_js.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 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. extern int godot_js_config_is_resize_on_start();
  40. // OS
  41. extern void godot_js_os_finish_async(void (*p_callback)());
  42. extern void godot_js_os_request_quit_cb(void (*p_callback)());
  43. extern int godot_js_os_fs_is_persistent();
  44. extern void godot_js_os_fs_sync(void (*p_callback)());
  45. extern int godot_js_os_execute(const char *p_json);
  46. extern void godot_js_os_shell_open(const char *p_uri);
  47. // Display
  48. extern int godot_js_display_screen_dpi_get();
  49. extern double godot_js_display_pixel_ratio_get();
  50. extern void godot_js_display_alert(const char *p_text);
  51. extern int godot_js_display_touchscreen_is_available();
  52. extern int godot_js_display_is_swap_ok_cancel();
  53. // Display canvas
  54. extern void godot_js_display_canvas_focus();
  55. extern int godot_js_display_canvas_is_focused();
  56. extern void godot_js_display_canvas_bounding_rect_position_get(int32_t *p_x, int32_t *p_y);
  57. // Display window
  58. extern void godot_js_display_window_request_fullscreen();
  59. extern void godot_js_display_window_title_set(const char *p_text);
  60. extern void godot_js_display_window_icon_set(const uint8_t *p_ptr, int p_len);
  61. // Display clipboard
  62. extern int godot_js_display_clipboard_set(const char *p_text);
  63. extern int godot_js_display_clipboard_get(void (*p_callback)(const char *p_text));
  64. // Display cursor
  65. extern void godot_js_display_cursor_set_shape(const char *p_cursor);
  66. extern int godot_js_display_cursor_is_hidden();
  67. 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);
  68. extern void godot_js_display_cursor_set_visible(int p_visible);
  69. // Display gamepad
  70. extern char *godot_js_display_gamepad_cb(void (*p_on_change)(int p_index, int p_connected, const char *p_id, const char *p_guid));
  71. extern int godot_js_display_gamepad_sample();
  72. extern int godot_js_display_gamepad_sample_count();
  73. extern int godot_js_display_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);
  74. // Display listeners
  75. 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);
  76. extern void godot_js_display_paste_cb(void (*p_callback)(const char *p_text));
  77. extern void godot_js_display_drop_files_cb(void (*p_callback)(char **p_filev, int p_filec));
  78. extern void godot_js_display_setup_canvas();
  79. #ifdef __cplusplus
  80. }
  81. #endif
  82. #endif /* GODOT_JS_H */