summaryrefslogtreecommitdiffstats
path: root/platform/web/js/libs/library_godot_os.js
diff options
context:
space:
mode:
authorbruvzg <7645683+bruvzg@users.noreply.github.com>2022-11-14 16:27:26 +0200
committerbruvzg <7645683+bruvzg@users.noreply.github.com>2023-04-11 10:58:54 +0300
commita5009f4d3cc36974a5897c3c819e61c3e0783b0d (patch)
tree3321f8bcc561b450f518e93efd682e4d51b2063c /platform/web/js/libs/library_godot_os.js
parentc3ed7af12347aa04a3d3bb91bc726170e894758e (diff)
downloadredot-engine-a5009f4d3cc36974a5897c3c819e61c3e0783b0d.tar.gz
[Web] Detect host OS and use macOS keys on mac hosts.
Diffstat (limited to 'platform/web/js/libs/library_godot_os.js')
-rw-r--r--platform/web/js/libs/library_godot_os.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/platform/web/js/libs/library_godot_os.js b/platform/web/js/libs/library_godot_os.js
index c4c45a3036..00ae399583 100644
--- a/platform/web/js/libs/library_godot_os.js
+++ b/platform/web/js/libs/library_godot_os.js
@@ -291,6 +291,28 @@ const GodotOS = {
});
},
+ godot_js_os_has_feature__sig: 'ii',
+ godot_js_os_has_feature: function (p_ftr) {
+ const ftr = GodotRuntime.parseString(p_ftr);
+ const ua = navigator.userAgent;
+ if (ftr === 'web_macos') {
+ return (ua.indexOf('Mac') !== -1) ? 1 : 0;
+ }
+ if (ftr === 'web_windows') {
+ return (ua.indexOf('Windows') !== -1) ? 1 : 0;
+ }
+ if (ftr === 'web_android') {
+ return (ua.indexOf('Android') !== -1) ? 1 : 0;
+ }
+ if (ftr === 'web_ios') {
+ return ((ua.indexOf('iPhone') !== -1) || (ua.indexOf('iPad') !== -1) || (ua.indexOf('iPod') !== -1)) ? 1 : 0;
+ }
+ if (ftr === 'web_linuxbsd') {
+ return ((ua.indexOf('CrOS') !== -1) || (ua.indexOf('BSD') !== -1) || (ua.indexOf('Linux') !== -1) || (ua.indexOf('X11') !== -1)) ? 1 : 0;
+ }
+ return 0;
+ },
+
godot_js_os_execute__sig: 'ii',
godot_js_os_execute: function (p_json) {
const json_args = GodotRuntime.parseString(p_json);