| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
#include "audio_driver_web.h" |
| 34 |
#include "webmidi_driver.h" |
| 35 |
|
| 36 |
#include "godot_js.h" |
| 37 |
|
| 38 |
#include "core/input/input.h" |
| 39 |
#include "drivers/unix/os_unix.h" |
| 40 |
#include "servers/audio/audio_server.h" |
| 41 |
|
| 42 |
#include <emscripten/html5.h> |
| 43 |
|
| 44 |
class OS_Web : public OS_Unix { |
| 45 |
MainLoop *main_loop = nullptr; |
| 46 |
List<AudioDriverWeb *> audio_drivers; |
| 47 |
|
| 48 |
MIDIDriverWebMidi midi_driver; |
| 49 |
|
| 50 |
bool idb_is_syncing = false; |
| 51 |
bool idb_available = false; |
| 52 |
bool idb_needs_sync = false; |
| 53 |
bool pwa_is_waiting = false; |
| 54 |
|
| 55 |
WASM_EXPORT static void main_loop_callback(); |
| 56 |
|
| 57 |
WASM_EXPORT static void file_access_close_callback(const String &p_file, int p_flags); |
| 58 |
WASM_EXPORT static void dir_access_remove_callback(const String &p_file); |
| 59 |
WASM_EXPORT static void fs_sync_callback(); |
| 60 |
WASM_EXPORT static void update_pwa_state_callback(); |
| 61 |
|
| 62 |
protected: |
| 63 |
void initialize() override; |
| 64 |
|
| 65 |
void set_main_loop(MainLoop *p_main_loop) override; |
| 66 |
void delete_main_loop() override; |
| 67 |
|
| 68 |
void finalize() override; |
| 69 |
|
| 70 |
bool _check_internal_feature_support(const String &p_feature) override; |
| 71 |
|
| 72 |
public: |
| 73 |
|
| 74 |
static OS_Web *get_singleton(); |
| 75 |
|
| 76 |
bool pwa_needs_update() const { return pwa_is_waiting; } |
| 77 |
Error pwa_update(); |
| 78 |
void force_fs_sync(); |
| 79 |
|
| 80 |
void initialize_joypads() override; |
| 81 |
|
| 82 |
MainLoop *get_main_loop() const override; |
| 83 |
bool main_loop_iterate(); |
| 84 |
|
| 85 |
Error execute(const String &p_path, const List<String> &p_arguments, String *r_pipe = nullptr, int *r_exitcode = nullptr, bool read_stderr = false, Mutex *p_pipe_mutex = nullptr, bool p_open_console = false) override; |
| 86 |
Dictionary execute_with_pipe(const String &p_path, const List<String> &p_arguments, bool p_blocking = true) override; |
| 87 |
Error create_process(const String &p_path, const List<String> &p_arguments, ProcessID *r_child_id = nullptr, bool p_open_console = false) override; |
| 88 |
Error kill(const ProcessID &p_pid) override; |
| 89 |
int get_process_id() const override; |
| 90 |
bool is_process_running(const ProcessID &p_pid) const override; |
| 91 |
int get_process_exit_code(const ProcessID &p_pid) const override; |
| 92 |
int get_processor_count() const override; |
| 93 |
String get_unique_id() const override; |
| 94 |
int get_default_thread_pool_size() const override; |
| 95 |
|
| 96 |
String get_executable_path() const override; |
| 97 |
Error shell_open(const String &p_uri) override; |
| 98 |
String get_name() const override; |
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
void add_frame_delay(bool p_can_draw, bool p_wake_for_events) override; |
| 103 |
|
| 104 |
void vibrate_handheld(int p_duration_ms, float p_amplitude) override; |
| 105 |
|
| 106 |
String get_cache_path() const override; |
| 107 |
String get_config_path() const override; |
| 108 |
String get_data_path() const override; |
| 109 |
String get_user_data_dir(const String &p_user_dir) const override; |
| 110 |
|
| 111 |
bool is_userfs_persistent() const override; |
| 112 |
|
| 113 |
void alert(const String &p_alert, const String &p_title = "ALERT!") override; |
| 114 |
|
| 115 |
Error open_dynamic_library(const String &p_path, void *&p_library_handle, GDExtensionData *p_data = nullptr) override; |
| 116 |
|
| 117 |
void resume_audio(); |
| 118 |
|
| 119 |
OS_Web(); |
| 120 |
}; |