Commit Graph

517 Commits

Author SHA1 Message Date
Rémi Verschelde df69945f1f
Merge pull request #52714 from m4gr3d/provide_getter_for_project_data_dir_3x 2021-10-05 21:02:41 +02:00
Fabio Alessandrelli adef4ed958 [HTML5] Remove "maximize" support.
I don't think anyone is actively using it, and it's a lot of convoluted
code.
2021-10-05 15:13:41 +02:00
Fabio Alessandrelli d61fc468a2 [HTML5] Refactor JS library listeners to OS. 2021-10-05 15:13:41 +02:00
Fabio Alessandrelli 5e2e54a4b4 [HTML5] Refactor display/input JS library code. 2021-10-05 15:13:41 +02:00
Fabio Alessandrelli c54f5b90e6 [HTML5] Implement Pointer Lock API in JS library.
Removes more emscripten HTML5 library dependencies.
2021-10-05 15:13:41 +02:00
Fabio Alessandrelli 89c6aaa96d [HTML5] Implement window blur in JS library.
Removes more emscripten HTML5 library dependencies.
2021-10-05 15:13:41 +02:00
Fabio Alessandrelli ac78e7f940 [HTML5] Implement fullscreenchange in JS library.
Removes more emscripten HTML5 library dependencies.
2021-10-05 15:13:41 +02:00
Fabio Alessandrelli b7ac3c1aeb [HTML5] Implement mouse/touch/key events in JS library.
This makes us more independent from emscripten libraries, giving us more
control on the application lifecycle.
2021-10-05 15:13:41 +02:00
Rémi Verschelde e292d79fb3
SCons: Add `DEV_ENABLED` defines for `target=debug` builds
This will allow adding developer checks which will be fully compiled out in
user builds, unlike `DEBUG_ENABLED` which is included in debug tempates and
the editor builds.

This define is not used yet, but we'll soon add code that uses it, and change
some existing `DEBUG_ENABLED` checks to be performed only in dev builds.

Related to https://github.com/godotengine/godot-proposals/issues/3371.
2021-10-04 11:25:02 +02:00
Fabio Alessandrelli acb748e66f
Merge pull request #52973 from selgesel/patch2
[3.x] Release pressed events when the window is blurred on HTML5 platform
2021-09-29 13:11:56 +02:00
Rémi Verschelde bf65c0e479
HTML5: Fix minification error with Emscripten 1.39.9
It used an old vendored version of acorn.js which seems to choke on this
trailing comma. This is not a problem for more recent Emscripten versions.

We disable the `comma-dangle` check in ESLint to prevent this issue.

(cherry picked from commit 23b51a1708)
2021-09-29 10:54:01 +02:00
Selgesel c918b4d246 [3.x] Release pressed events when the window is blurred on HTML5 platform 2021-09-23 16:44:03 +03:00
Hugo Locurcio 8a6bc045ea
Add logo attribution for Android, HTML5 and Linux platform icons
- Tweak the Android platform logo to remove the Android wordmark,
  as it can't be used without explicit permission.

(cherry picked from commit 1513aa9b26)
2021-09-21 17:14:59 +02:00
Rémi Verschelde c906afe045
HTML5: Handle GODOT_VERSION_STATUS env var in @GODOT_VERSION@
Follow-up to #51002.

(cherry picked from commit 16f49d4b29)
2021-09-21 17:14:58 +02:00
Rémi Verschelde 8a48be6980
Merge pull request #52650 from Faless/js/3.x_audioworklet_nothreads_pr
[3.x] [HTML5] Refactor audio drivers. Implement AudioWorklet w/o threads.
2021-09-21 10:44:14 +02:00
Rémi Verschelde b37776fa2f
Merge pull request #52591 from timothyqiu/error-macros
[3.x] Remove do{ } while(0) wrapper around error macros
2021-09-21 10:38:34 +02:00
Fabio Alessandrelli 2024200182 [HTML5] Refactor audio drivers. Implement AudioWorklet w/o threads.
Performances are not great in general, bad on Firefox, on Chrome, well,
it's an improvement compared to the way they broke ScriptProcessorNode.

I'm actually surprised this works, it involves so many allocations, but
there's no way around it when SharedArrayBuffer is not available :(.
2021-09-20 14:53:27 +02:00
Fabio Alessandrelli b7f466012c
[HTML5] Fix bug in AudioWorklet when reading output buffer.
Would attempt an out of bounds read, causing an exception.

(cherry picked from commit ba08f39e47)
2021-09-19 11:30:21 +02:00
Rémi Verschelde e4c4e7c2e0
Merge pull request #52721 from Faless/js/3.x_fix_wheel
[3.x] [HTML5] Fix wheel/touch callback modifying event after parse.
2021-09-16 09:41:53 +02:00
Fredia Huya-Kouadio c8b022c165 Provide a getter for the project data directory. 2021-09-15 13:00:25 -07:00
Fabio Alessandrelli b800438efb [HTML5] Use browser mix rate by default on the Web.
Browsers doesn't really like forcing the mix rate, e.g. Firefox does not
allow input (microphone) if the mix rate is not the default one, Chrom*
will exhibit worse performances, etc.
2021-09-15 20:36:19 +02:00
Fabio Alessandrelli 7dfbc4e57c [HTML5] Fix wheel/touch callback modifying event after parse.
The events should be duplicated or reinstantiated without
assuming that parse_input will consume them immediately.
2021-09-15 17:28:44 +02:00
Fabio Alessandrelli 98b42ca958 [HTML5] Fix input not working when buffered.
After input buffering was reworked, input accumulation is now handled
outside of OS, and the JavaScript plaform never implemented that.
Additionally, the JavaScript platform is quite obnoxious about calling
specific APIs outside specific user triggered events.

This commit adds event flushing during the main iteration, and forces it
during keydown/keyup/mousedown/mouseup/touchstart/touchend/touchcanel
events (effectively only accumulating only "move" events).
2021-09-12 18:42:43 +02:00
Haoyu Qiu 70853fd669 Remove do{ } while(0) wrapper around error macros 2021-09-12 15:04:53 +08:00
Fabio Alessandrelli b7b9b902e5
Update Godot Javascript FS library to manually depend on ERRNO_CODES.
Fixes compatibility with Emscripten 2.0.26+.

(cherry picked from commit 71fb2429a0)
2021-08-18 23:20:34 +02:00
Fabio Alessandrelli 207fb165bf
[HTML5] Raise default initial memory to 32 MiB.
The memory was resized in any case during start.

Mitigate Chromium issue:
https://bugs.chromium.org/p/v8/issues/detail?id=11863

Also fix a warning about SAFE_HEAP being a linker only flag.

(cherry picked from commit 897c906ebf)
2021-07-13 17:03:44 +02:00
Fabio Alessandrelli b8f1f13b85
[HTML5] Fix JavaScript string parsing with new interface.
Strings are UTF-8 encoded and should be parsed as such, while it was
being parsed as a C string before.

(cherry picked from commit d4e302a3a4)
2021-07-13 10:20:02 +02:00
Fabio Alessandrelli 69645b0e44
[HTML5] Add option to focus canvas on start.
Enabled by default.

(cherry picked from commit c12fca57f4)
2021-06-29 14:02:23 +02:00
Haoyu Qiu 38e0ca9b47
Strip query string when parsing HTTP request line for path
(cherry picked from commit 91477cd4a9)
2021-06-29 14:02:23 +02:00
Fabio Alessandrelli 2c64218415
[HTML5] Update eslint and jsdoc dependencies.
(cherry picked from commit a1cbb6daa6)
2021-06-17 12:47:55 +02:00
Fabio Alessandrelli cfedd60e6b
[HTML5] Fix JS build without eval.
Also fix download_buffer return type.

(cherry picked from commit 049b5159f1)
2021-06-17 12:47:55 +02:00
Fabio Alessandrelli 0f5fbf5fbf
[HTML5] Fix some JS library signature.
(cherry picked from commit 9b7b0a28b9)
2021-06-17 12:47:54 +02:00
Marcel Admiraal 5a58516231 Remove duplicate ERR_PRINTS macro 2021-06-16 11:56:25 +01:00
Arthur Bikmullin f3d931410b
Fixed missed IDHandler dependency in GodotFetch
(cherry picked from commit ee2bea7a86)
2021-06-08 10:20:35 +02:00
Fabio Alessandrelli bf078814cc [HTML5] Add easy to use download API.
New `JavaScript.download_buffer` method to create a prompt that let the
user download a file.
2021-05-21 16:03:38 +02:00
Rémi Verschelde f0fa8a103b
Merge pull request #48691 from Faless/js/3.x_interfaces
[HTML5] [3.x] Implement Godot <-> JavaScript interface.
2021-05-20 17:13:12 +02:00
Fabio Alessandrelli 730a894bcf [HTML5] Implement Godot <-> JavaScript interface. 2021-05-20 14:33:00 +02:00
Rémi Verschelde eb78f80f03
Fix typos with codespell
Using codespell 2.0.0.

Method:
```
$ cat > ../godot-word-whitelist.txt << EOF
ang
curvelinear
dof
doubleclick
fave
findn
GIRD
leapyear
lod
merchantibility
nd
numer
ois
ony
que
seeked
synching
te
uint
unselect
webp
EOF

$ codespell -w -q 3 -I ../godot-word-whitelist.txt --skip="./thirdparty,*.po"
$ git diff // undo unwanted changes
```
2021-05-20 12:56:56 +02:00
Fabio Alessandrelli 7d9d795af8
[HTML5] Fix GDNative compilation with emcc 2.0.19+
Add `WARN_ON_UNDEFINED_SYMBOLS=0` for the main module (which defines
`godot_js_main` as extern coming from the "side" module, i.e. the main
Godot binary).

(cherry picked from commit 14c057eab6)
2021-05-19 15:21:41 +02:00
Pedro J. Estébanez 817ffc01e1
Make all file access 64-bit (`uint64_t`)
This changes the types of a big number of variables.

General rules:
- Using `uint64_t` in general. We also considered `int64_t` but eventually
  settled on keeping it unsigned, which is also closer to what one would expect
  with `size_t`/`off_t`.
- We only keep `int64_t` for `seek_end` (takes a negative offset from the end)
  and for the `Variant` bindings, since `Variant::INT` is `int64_t`. This means
  we only need to guard against passing negative values in `core_bind.cpp`.
- Using `uint32_t` integers for concepts not needing such a huge range, like
  pages, blocks, etc.

In addition:
- Improve usage of integer types in some related places; namely, `DirAccess`,
  core binds.

Note:
- On Windows, `_ftelli64` reports invalid values when using 32-bit MinGW with
  version < 8.0. This was an upstream bug fixed in 8.0. It breaks support for
  big files on 32-bit Windows builds made with that toolchain. We might add a
  workaround.

Fixes #44363.
Fixes godotengine/godot-proposals#400.

Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
2021-05-16 17:52:31 +02:00
Rémi Verschelde cb438028ee
CI: Update JavaScript linter deps with known security vulnerabilities
jsdoc has no new release so I'm tracking this PR:
https://github.com/jsdoc/jsdoc/pull/1906

(cherry picked from commit e743b6b24c)
2021-05-13 23:21:37 +02:00
Fabio Alessandrelli 6c1c2ed414
[HTML5] Fix target_fps when window loses focus.
We don't get updates when the window is unfocused/minimized, so we must
detect the situation where the counted ticks start drifting away
resulting in more frames drawn than needed.
This commit adds a check to ensure that the target ticks do not drift
away more than one second.

(cherry picked from commit a1fe6d6899)
2021-05-09 17:14:36 +02:00
Fabio Alessandrelli 23ef985bb8
[HTML5] Use 64KiB chunk size in JS HTTPClient.
For consistency with the native one, and the documentation.

(cherry picked from commit 6243835619)
2021-05-09 17:14:35 +02:00
Fabio Alessandrelli 8740e95f15
[HTML5] Add support for `physical_keycode`.
This uses the `event.code` value to retrieve the physical code, while
still using the extra logic to map the unicode value to our keylist,
when computing the `scancode` (supporting ASCII and Latin-1).
2021-05-06 23:19:46 +03:00
bruvzg dab4cf3ed6
Add `physical_scancode` (keyboard layout independent keycodes) to InputEventKey and InputMap.
Fix non-latin keyboard layout keycodes on Linux/X11 (fallback to physical keycodes).
2021-05-06 23:19:45 +03:00
Rémi Verschelde a828398655
Style: Replaces uses of 0/NULL by nullptr (C++11)
Using clang-tidy's `modernize-use-nullptr`.
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
2021-05-04 16:30:23 +02:00
Rémi Verschelde b5e1e05ef2
Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks 2021-05-04 14:45:16 +02:00
Rémi Verschelde 64a63e0861
Style: clang-format: Disable AllowShortCaseLabelsOnASingleLine 2021-05-04 14:45:15 +02:00
Fabio Alessandrelli b0f6dec02e [HTML5] Fix build for recent emscripten versions.
Library suffix should be `.a`, the `EXTRA_` in
`EXTRA_EXPORTED_RUNTIME_METHODS` is deprecated.
2021-04-30 08:02:21 +02:00
Rémi Verschelde 70ae90e0e8
Core: Drop custom `copymem`/`zeromem` defines
We've been using standard C library functions `memcpy`/`memset` for these since
2016 with 67f65f6639.

There was still the possibility for third-party platform ports to override the
definitions with a custom header, but this doesn't seem useful anymore.

Backport of #48239.
2021-04-29 12:34:11 +02:00