mirror of
https://github.com/godotengine/godot.git
synced 2025-11-01 06:01:14 +00:00
[HTML5] Port JavaScript inline code to libraries.
The API is implemented in javascript, and generates C functions that can be called from godot. This allows much cleaner code replacing all `EM_ASM` calls in our C++ code with plain C function calls. This also gets rid of few hacks and comes with few optimizations (e.g. custom cursor shapes should be much faster now).
This commit is contained in:
parent
a7ecb3c048
commit
e52ed6d89e
31 changed files with 2016 additions and 1502 deletions
|
|
@ -40,7 +40,7 @@
|
|||
#include <emscripten/html5.h>
|
||||
|
||||
class OS_JavaScript : public OS_Unix {
|
||||
|
||||
private:
|
||||
VideoMode video_mode;
|
||||
Vector2 windowed_size;
|
||||
bool window_maximized;
|
||||
|
|
@ -53,10 +53,10 @@ class OS_JavaScript : public OS_Unix {
|
|||
InputDefault *input;
|
||||
Ref<InputEventKey> deferred_key_event;
|
||||
CursorShape cursor_shape;
|
||||
String cursors[CURSOR_MAX];
|
||||
Map<CursorShape, Vector<Variant> > cursors_cache;
|
||||
Point2 touches[32];
|
||||
|
||||
char canvas_id[256];
|
||||
bool cursor_inside_canvas;
|
||||
Point2i last_click_pos;
|
||||
double last_click_ms;
|
||||
int last_click_button_index;
|
||||
|
|
@ -72,7 +72,9 @@ class OS_JavaScript : public OS_Unix {
|
|||
bool swap_ok_cancel;
|
||||
bool idb_available;
|
||||
bool idb_needs_sync;
|
||||
bool idb_is_syncing;
|
||||
|
||||
static Point2 compute_position_in_canvas(int x, int y);
|
||||
static EM_BOOL fullscreen_change_callback(int p_event_type, const EmscriptenFullscreenChangeEvent *p_event, void *p_user_data);
|
||||
|
||||
static EM_BOOL keydown_callback(int p_event_type, const EmscriptenKeyboardEvent *p_event, void *p_user_data);
|
||||
|
|
@ -92,6 +94,12 @@ class OS_JavaScript : public OS_Unix {
|
|||
|
||||
static void file_access_close_callback(const String &p_file, int p_flags);
|
||||
|
||||
static void request_quit_callback();
|
||||
static void drop_files_callback(char **p_filev, int p_filec);
|
||||
static void send_notification_callback(int p_notification);
|
||||
static void fs_sync_callback();
|
||||
static void update_clipboard_callback(const char *p_text);
|
||||
|
||||
protected:
|
||||
void resume_audio();
|
||||
|
||||
|
|
@ -108,9 +116,6 @@ protected:
|
|||
virtual bool _check_internal_feature_support(const String &p_feature);
|
||||
|
||||
public:
|
||||
String canvas_id;
|
||||
bool idb_is_syncing;
|
||||
void finalize_async();
|
||||
bool check_size_force_redraw();
|
||||
|
||||
// Override return type to make writing static callbacks less tedious.
|
||||
|
|
@ -179,10 +184,9 @@ public:
|
|||
virtual int get_power_seconds_left();
|
||||
virtual int get_power_percent_left();
|
||||
|
||||
void set_idb_available(bool p_idb_available);
|
||||
virtual bool is_userfs_persistent() const;
|
||||
|
||||
OS_JavaScript(int p_argc, char *p_argv[]);
|
||||
OS_JavaScript();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue