summaryrefslogtreecommitdiff
path: root/platform/javascript
diff options
context:
space:
mode:
Diffstat (limited to 'platform/javascript')
-rw-r--r--platform/javascript/audio_driver_javascript.h2
-rw-r--r--platform/javascript/display_server_javascript.cpp18
-rw-r--r--platform/javascript/display_server_javascript.h2
-rw-r--r--platform/javascript/export/export.cpp1
-rw-r--r--platform/javascript/export/export.h2
-rw-r--r--platform/javascript/export/export_plugin.cpp12
-rw-r--r--platform/javascript/export/export_plugin.h8
-rw-r--r--platform/javascript/export/export_server.h3
-rw-r--r--platform/javascript/godot_audio.h2
-rw-r--r--platform/javascript/godot_js.h5
-rw-r--r--platform/javascript/godot_webgl2.h2
-rw-r--r--platform/javascript/http_client_javascript.h1
-rw-r--r--platform/javascript/javascript_singleton.cpp2
-rw-r--r--platform/javascript/js/engine/config.js1
-rw-r--r--platform/javascript/js/libs/library_godot_display.js47
-rw-r--r--platform/javascript/js/libs/library_godot_input.js9
-rw-r--r--platform/javascript/os_javascript.cpp4
-rw-r--r--platform/javascript/os_javascript.h4
18 files changed, 89 insertions, 36 deletions
diff --git a/platform/javascript/audio_driver_javascript.h b/platform/javascript/audio_driver_javascript.h
index b7b0b3ac96..807e2f936b 100644
--- a/platform/javascript/audio_driver_javascript.h
+++ b/platform/javascript/audio_driver_javascript.h
@@ -158,4 +158,4 @@ public:
};
#endif
-#endif
+#endif // AUDIO_DRIVER_JAVASCRIPT_H
diff --git a/platform/javascript/display_server_javascript.cpp b/platform/javascript/display_server_javascript.cpp
index a96c539a1f..48f637fcfe 100644
--- a/platform/javascript/display_server_javascript.cpp
+++ b/platform/javascript/display_server_javascript.cpp
@@ -83,7 +83,7 @@ void DisplayServerJavaScript::drop_files_js_callback(char **p_filev, int p_filec
Variant *vp = &v;
Variant ret;
Callable::CallError ce;
- ds->drop_files_callback.call((const Variant **)&vp, 1, ret, ce);
+ ds->drop_files_callback.callp((const Variant **)&vp, 1, ret, ce);
}
// JavaScript quit request callback.
@@ -94,7 +94,7 @@ void DisplayServerJavaScript::request_quit_callback() {
Variant *eventp = &event;
Variant ret;
Callable::CallError ce;
- ds->window_event_callback.call((const Variant **)&eventp, 1, ret, ce);
+ ds->window_event_callback.callp((const Variant **)&eventp, 1, ret, ce);
}
}
@@ -236,7 +236,7 @@ void DisplayServerJavaScript::mouse_move_callback(double p_x, double p_y, double
const char *DisplayServerJavaScript::godot2dom_cursor(DisplayServer::CursorShape p_shape) {
switch (p_shape) {
case DisplayServer::CURSOR_ARROW:
- return "auto";
+ return "default";
case DisplayServer::CURSOR_IBEAM:
return "text";
case DisplayServer::CURSOR_POINTING_HAND:
@@ -270,7 +270,7 @@ const char *DisplayServerJavaScript::godot2dom_cursor(DisplayServer::CursorShape
case DisplayServer::CURSOR_HELP:
return "help";
default:
- return "auto";
+ return "default";
}
}
@@ -586,7 +586,7 @@ void DisplayServerJavaScript::vk_input_text_callback(const char *p_text, int p_c
Variant *eventp = &event;
Variant ret;
Callable::CallError ce;
- ds->input_text_callback.call((const Variant **)&eventp, 1, ret, ce);
+ ds->input_text_callback.callp((const Variant **)&eventp, 1, ret, ce);
// Insert key right to reach position.
Input *input = Input::get_singleton();
Ref<InputEventKey> k;
@@ -604,8 +604,8 @@ void DisplayServerJavaScript::vk_input_text_callback(const char *p_text, int p_c
}
}
-void DisplayServerJavaScript::virtual_keyboard_show(const String &p_existing_text, const Rect2 &p_screen_rect, bool p_multiline, int p_max_input_length, int p_cursor_start, int p_cursor_end) {
- godot_js_display_vk_show(p_existing_text.utf8().get_data(), p_multiline, p_cursor_start, p_cursor_end);
+void DisplayServerJavaScript::virtual_keyboard_show(const String &p_existing_text, const Rect2 &p_screen_rect, VirtualKeyboardType p_type, int p_max_input_length, int p_cursor_start, int p_cursor_end) {
+ godot_js_display_vk_show(p_existing_text.utf8().get_data(), p_type, p_cursor_start, p_cursor_end);
}
void DisplayServerJavaScript::virtual_keyboard_hide() {
@@ -691,7 +691,7 @@ void DisplayServerJavaScript::send_window_event_callback(int p_notification) {
Variant *eventp = &event;
Variant ret;
Callable::CallError ce;
- ds->window_event_callback.call((const Variant **)&eventp, 1, ret, ce);
+ ds->window_event_callback.callp((const Variant **)&eventp, 1, ret, ce);
}
}
@@ -734,7 +734,7 @@ void DisplayServerJavaScript::_dispatch_input_event(const Ref<InputEvent> &p_eve
Variant *evp = &ev;
Variant ret;
Callable::CallError ce;
- cb.call((const Variant **)&evp, 1, ret, ce);
+ cb.callp((const Variant **)&evp, 1, ret, ce);
}
}
diff --git a/platform/javascript/display_server_javascript.h b/platform/javascript/display_server_javascript.h
index 79b0fbb652..fb7f5d02a8 100644
--- a/platform/javascript/display_server_javascript.h
+++ b/platform/javascript/display_server_javascript.h
@@ -157,7 +157,7 @@ public:
virtual float screen_get_scale(int p_screen = SCREEN_OF_MAIN_WINDOW) const override;
virtual float screen_get_refresh_rate(int p_screen = SCREEN_OF_MAIN_WINDOW) const override;
- virtual void virtual_keyboard_show(const String &p_existing_text, const Rect2 &p_screen_rect = Rect2(), bool p_multiline = false, int p_max_input_length = -1, int p_cursor_start = -1, int p_cursor_end = -1) override;
+ virtual void virtual_keyboard_show(const String &p_existing_text, const Rect2 &p_screen_rect = Rect2(), VirtualKeyboardType p_type = KEYBOARD_TYPE_DEFAULT, int p_max_input_length = -1, int p_cursor_start = -1, int p_cursor_end = -1) override;
virtual void virtual_keyboard_hide() override;
// windows
diff --git a/platform/javascript/export/export.cpp b/platform/javascript/export/export.cpp
index 825c1b6638..ea236f62f7 100644
--- a/platform/javascript/export/export.cpp
+++ b/platform/javascript/export/export.cpp
@@ -30,6 +30,7 @@
#include "export.h"
+#include "editor/editor_settings.h"
#include "export_plugin.h"
void register_javascript_exporter() {
diff --git a/platform/javascript/export/export.h b/platform/javascript/export/export.h
index 41cc66cfb8..29c335ed0e 100644
--- a/platform/javascript/export/export.h
+++ b/platform/javascript/export/export.h
@@ -33,4 +33,4 @@
void register_javascript_exporter();
-#endif
+#endif // JAVASCRIPT_EXPORT_H
diff --git a/platform/javascript/export/export_plugin.cpp b/platform/javascript/export/export_plugin.cpp
index 901580c140..b99f88d067 100644
--- a/platform/javascript/export/export_plugin.cpp
+++ b/platform/javascript/export/export_plugin.cpp
@@ -31,6 +31,7 @@
#include "export_plugin.h"
#include "core/config/project_settings.h"
+#include "editor/editor_settings.h"
Error EditorExportPlatformJavaScript::_extract_template(const String &p_template, const String &p_dir, const String &p_name, bool pwa) {
Ref<FileAccess> io_fa;
@@ -302,7 +303,7 @@ Error EditorExportPlatformJavaScript::_build_pwa(const Ref<EditorExportPreset> &
return OK;
}
-void EditorExportPlatformJavaScript::get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) {
+void EditorExportPlatformJavaScript::get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) const {
if (p_preset->get("vram_texture_compression/for_desktop")) {
r_features->push_back("s3tc");
}
@@ -661,13 +662,8 @@ EditorExportPlatformJavaScript::EditorExportPlatformJavaScript() {
server.instantiate();
server_thread.start(_server_thread_poll, this);
- Ref<Image> img = memnew(Image(_javascript_logo));
- logo.instantiate();
- logo->create_from_image(img);
-
- img = Ref<Image>(memnew(Image(_javascript_run_icon)));
- run_icon.instantiate();
- run_icon->create_from_image(img);
+ logo = ImageTexture::create_from_image(memnew(Image(_javascript_logo)));
+ run_icon = ImageTexture::create_from_image(memnew(Image(_javascript_run_icon)));
Ref<Theme> theme = EditorNode::get_singleton()->get_editor_theme();
if (theme.is_valid()) {
diff --git a/platform/javascript/export/export_plugin.h b/platform/javascript/export/export_plugin.h
index 1aaec5454d..fbaa3615cb 100644
--- a/platform/javascript/export/export_plugin.h
+++ b/platform/javascript/export/export_plugin.h
@@ -36,8 +36,8 @@
#include "core/io/stream_peer_ssl.h"
#include "core/io/tcp_server.h"
#include "core/io/zip_io.h"
-#include "editor/editor_export.h"
#include "editor/editor_node.h"
+#include "editor/export/editor_export_platform.h"
#include "main/splash.gen.h"
#include "platform/javascript/logo.gen.h"
#include "platform/javascript/run_icon.gen.h"
@@ -110,7 +110,7 @@ class EditorExportPlatformJavaScript : public EditorExportPlatform {
static void _server_thread_poll(void *data);
public:
- virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) override;
+ virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) const override;
virtual void get_export_options(List<ExportOption> *r_options) override;
@@ -130,7 +130,7 @@ public:
virtual Error run(const Ref<EditorExportPreset> &p_preset, int p_option, int p_debug_flags) override;
virtual Ref<Texture2D> get_run_icon() const override;
- virtual void get_platform_features(List<String> *r_features) override {
+ virtual void get_platform_features(List<String> *r_features) const override {
r_features->push_back("web");
r_features->push_back(get_os_name().to_lower());
}
@@ -144,4 +144,4 @@ public:
~EditorExportPlatformJavaScript();
};
-#endif
+#endif // JAVASCRIPT_EXPORT_PLUGIN_H
diff --git a/platform/javascript/export/export_server.h b/platform/javascript/export/export_server.h
index a831b76076..ddbe3cca30 100644
--- a/platform/javascript/export/export_server.h
+++ b/platform/javascript/export/export_server.h
@@ -35,7 +35,6 @@
#include "core/io/stream_peer_ssl.h"
#include "core/io/tcp_server.h"
#include "core/io/zip_io.h"
-#include "editor/editor_export.h"
#include "editor/editor_paths.h"
class EditorHTTPServer : public RefCounted {
@@ -248,4 +247,4 @@ public:
}
};
-#endif
+#endif // JAVASCRIPT_EXPORT_SERVER_H
diff --git a/platform/javascript/godot_audio.h b/platform/javascript/godot_audio.h
index 012f8daeb7..3855b7301e 100644
--- a/platform/javascript/godot_audio.h
+++ b/platform/javascript/godot_audio.h
@@ -63,4 +63,4 @@ extern void godot_audio_script_start(float *p_in_buf, int p_in_size, float *p_ou
}
#endif
-#endif /* GODOT_AUDIO_H */
+#endif // GODOT_AUDIO_H
diff --git a/platform/javascript/godot_js.h b/platform/javascript/godot_js.h
index 1a383c9799..a323f2d157 100644
--- a/platform/javascript/godot_js.h
+++ b/platform/javascript/godot_js.h
@@ -58,6 +58,7 @@ extern void godot_js_input_mouse_move_cb(void (*p_callback)(double p_x, double p
extern void godot_js_input_mouse_wheel_cb(int (*p_callback)(double p_delta_x, double p_delta_y));
extern void godot_js_input_touch_cb(void (*p_callback)(int p_type, int p_count), uint32_t *r_identifiers, double *r_coords);
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]);
+extern void godot_js_input_vibrate_handheld(int p_duration_ms);
// Input gamepad
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));
@@ -120,11 +121,11 @@ extern void godot_js_display_notification_cb(void (*p_callback)(int p_notificati
extern int godot_js_display_vk_available();
extern int godot_js_display_tts_available();
extern void godot_js_display_vk_cb(void (*p_input)(const char *p_text, int p_cursor));
-extern void godot_js_display_vk_show(const char *p_text, int p_multiline, int p_start, int p_end);
+extern void godot_js_display_vk_show(const char *p_text, int p_type, int p_start, int p_end);
extern void godot_js_display_vk_hide();
#ifdef __cplusplus
}
#endif
-#endif /* GODOT_JS_H */
+#endif // GODOT_JS_H
diff --git a/platform/javascript/godot_webgl2.h b/platform/javascript/godot_webgl2.h
index 7c357ff66d..968b70f84b 100644
--- a/platform/javascript/godot_webgl2.h
+++ b/platform/javascript/godot_webgl2.h
@@ -34,4 +34,4 @@
#include "GLES3/gl3.h"
#include "webgl/webgl2.h"
-#endif
+#endif // GODOT_WEBGL2_H
diff --git a/platform/javascript/http_client_javascript.h b/platform/javascript/http_client_javascript.h
index 096aa6a153..fcd225ffc9 100644
--- a/platform/javascript/http_client_javascript.h
+++ b/platform/javascript/http_client_javascript.h
@@ -105,4 +105,5 @@ public:
HTTPClientJavaScript();
~HTTPClientJavaScript();
};
+
#endif // HTTP_CLIENT_JAVASCRIPT_H
diff --git a/platform/javascript/javascript_singleton.cpp b/platform/javascript/javascript_singleton.cpp
index 8dc7aba5f8..204e92b82b 100644
--- a/platform/javascript/javascript_singleton.cpp
+++ b/platform/javascript/javascript_singleton.cpp
@@ -259,7 +259,7 @@ void JavaScriptObjectImpl::_callback(void *p_ref, int p_args_id, int p_argc) {
const Variant *argv[1] = { &arg };
Callable::CallError err;
Variant ret;
- obj->_callable.call(argv, 1, ret, err);
+ obj->_callable.callp(argv, 1, ret, err);
// Set return value
godot_js_wrapper_ex exchange;
diff --git a/platform/javascript/js/engine/config.js b/platform/javascript/js/engine/config.js
index 2e5e1ed0d1..9c4b6c2012 100644
--- a/platform/javascript/js/engine/config.js
+++ b/platform/javascript/js/engine/config.js
@@ -334,6 +334,7 @@ const InternalConfig = function (initConfig) { // eslint-disable-line no-unused-
locale = navigator.languages ? navigator.languages[0] : navigator.language;
locale = locale.split('.')[0];
}
+ locale = locale.replace('-', '_');
const onExit = this.onExit;
// Godot configuration.
diff --git a/platform/javascript/js/libs/library_godot_display.js b/platform/javascript/js/libs/library_godot_display.js
index 5997631bf8..c7729a8c5b 100644
--- a/platform/javascript/js/libs/library_godot_display.js
+++ b/platform/javascript/js/libs/library_godot_display.js
@@ -73,7 +73,7 @@ const GodotDisplayVK = {
GodotDisplayVK.textarea = create('textarea');
GodotDisplayVK.updateSize();
},
- show: function (text, multiline, start, end) {
+ show: function (text, type, start, end) {
if (!GodotDisplayVK.textinput || !GodotDisplayVK.textarea) {
return;
}
@@ -81,7 +81,46 @@ const GodotDisplayVK = {
GodotDisplayVK.hide();
}
GodotDisplayVK.updateSize();
- const elem = multiline ? GodotDisplayVK.textarea : GodotDisplayVK.textinput;
+
+ let elem = GodotDisplayVK.textinput;
+ switch (type) {
+ case 0: // KEYBOARD_TYPE_DEFAULT
+ elem.type = 'text';
+ elem.inputmode = '';
+ break;
+ case 1: // KEYBOARD_TYPE_MULTILINE
+ elem = GodotDisplayVK.textarea;
+ break;
+ case 2: // KEYBOARD_TYPE_NUMBER
+ elem.type = 'text';
+ elem.inputmode = 'numeric';
+ break;
+ case 3: // KEYBOARD_TYPE_NUMBER_DECIMAL
+ elem.type = 'text';
+ elem.inputmode = 'decimal';
+ break;
+ case 4: // KEYBOARD_TYPE_PHONE
+ elem.type = 'tel';
+ elem.inputmode = '';
+ break;
+ case 5: // KEYBOARD_TYPE_EMAIL_ADDRESS
+ elem.type = 'email';
+ elem.inputmode = '';
+ break;
+ case 6: // KEYBOARD_TYPE_PASSWORD
+ elem.type = 'password';
+ elem.inputmode = '';
+ break;
+ case 7: // KEYBOARD_TYPE_URL
+ elem.type = 'url';
+ elem.inputmode = '';
+ break;
+ default:
+ elem.type = 'text';
+ elem.inputmode = '';
+ break;
+ }
+
elem.readonly = false;
elem.disabled = false;
elem.value = text;
@@ -694,11 +733,11 @@ const GodotDisplay = {
* Virtual Keyboard
*/
godot_js_display_vk_show__sig: 'viiii',
- godot_js_display_vk_show: function (p_text, p_multiline, p_start, p_end) {
+ godot_js_display_vk_show: function (p_text, p_type, p_start, p_end) {
const text = GodotRuntime.parseString(p_text);
const start = p_start > 0 ? p_start : 0;
const end = p_end > 0 ? p_end : start;
- GodotDisplayVK.show(text, p_multiline, start, end);
+ GodotDisplayVK.show(text, p_type, start, end);
},
godot_js_display_vk_hide__sig: 'v',
diff --git a/platform/javascript/js/libs/library_godot_input.js b/platform/javascript/js/libs/library_godot_input.js
index 1e64c260f8..51571d64a2 100644
--- a/platform/javascript/js/libs/library_godot_input.js
+++ b/platform/javascript/js/libs/library_godot_input.js
@@ -534,6 +534,15 @@ const GodotInput = {
GodotRuntime.free(ptr);
}, false);
},
+
+ godot_js_input_vibrate_handheld__sig: 'vi',
+ godot_js_input_vibrate_handheld: function (p_duration_ms) {
+ if (typeof navigator.vibrate !== 'function') {
+ GodotRuntime.print('This browser does not support vibration.');
+ } else {
+ navigator.vibrate(p_duration_ms);
+ }
+ },
};
autoAddDeps(GodotInput, '$GodotInput');
diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp
index 1686353229..dc81b8b4b6 100644
--- a/platform/javascript/os_javascript.cpp
+++ b/platform/javascript/os_javascript.cpp
@@ -177,6 +177,10 @@ String OS_JavaScript::get_name() const {
return "HTML5";
}
+void OS_JavaScript::vibrate_handheld(int p_duration_ms) {
+ godot_js_input_vibrate_handheld(p_duration_ms);
+}
+
String OS_JavaScript::get_user_data_dir() const {
return "/userfs";
}
diff --git a/platform/javascript/os_javascript.h b/platform/javascript/os_javascript.h
index 0c672111cc..35e13c94fc 100644
--- a/platform/javascript/os_javascript.h
+++ b/platform/javascript/os_javascript.h
@@ -90,6 +90,8 @@ public:
// Implemented in javascript_main.cpp loop callback instead.
void add_frame_delay(bool p_can_draw) override {}
+ void vibrate_handheld(int p_duration_ms) override;
+
String get_cache_path() const override;
String get_config_path() const override;
String get_data_path() const override;
@@ -107,4 +109,4 @@ public:
OS_JavaScript();
};
-#endif
+#endif // OS_JAVASCRIPT_H