summaryrefslogtreecommitdiff
path: root/platform/javascript
AgeCommit message (Collapse)Author
2020-07-27Merge pull request #40755 from Faless/js/fix_and_cancel_swapRémi Verschelde
Cancel/OK swap on HTML5 platform, small fixes.
2020-07-27Implement HTML5 cancel/ok button swap on Windows.Fabio Alessandrelli
Platform is detected on init via the `navigator.platform` string.
2020-07-27Correctly include <stdlib.h> in javascript main.Fabio Alessandrelli
Already fixed in 3.2, this header is needed since it's where setenv is declared and we should not assume it to be already included.
2020-07-27Properly set HTML5 DisplayServer init error value.Fabio Alessandrelli
Checked in main.cpp, would cause the engine to not load.
2020-07-24t Add unit testing to Godot using DocTest and added to GitHub Actions CIRevoluPowered
Implements exit codes into the engine so tests can return their statuses. Ideally we don't do this, and we use FIXUP logic to 'begin' and 'end' the engine execution for tests specifically. Since realistically we're initialising the engine here we don't want to do that, since String should not require an engine startup to test a single header. This lowers the complexity of running the unit tests and even for physics should be possible to implement such a fix.
2020-07-10Add override keywords.Marcel Admiraal
2020-07-01Use dummy driver when JS AudioContext is unavailable.Fabio Alessandrelli
2020-07-01Limit FPS in JS by skipping iterations.Fabio Alessandrelli
2020-07-01[JS] Check canvas size each loop, force redraw.Fabio Alessandrelli
Fix compatibility issues, achieve smoother resizing.
2020-07-01More static methods in DisplayServerJavaScript.Fabio Alessandrelli
Were static functions in cpp file, polluting global namespace.
2020-07-01Refactor canvas ID and locale handling.Fabio Alessandrelli
2020-07-01Fix FS error on JS startup due to existing folder.Fabio Alessandrelli
2020-06-14Immediately run first iteration after JS FS sync.Fabio Alessandrelli
Which is now run inside an animation frame. This avoid a 1 frame black screen when setting up the canvas.
2020-06-04Swtich HTML5 key detection from keyCode to code.Fabio Alessandrelli
The value of this, does not include the layout. The code has extra logic to map the unicode value to our keylist, supporting ASCII and Latin-1. Also add support for `physical_keycode` in HTML5 platform.
2020-05-25Fix JS audioContext parameters.Fabio Alessandrelli
Were not passed along correctly. `latencyHint` is supposed to be in seconds, not milliseconds.
2020-05-18Move mix_rate, ouput_latency to AudioDriverManagerFabio Alessandrelli
Each driver used to define the (same) project settings values `audio/mix_rate` and `audio/output_latency`, but the setting names are not driver specific. Overriding is still possible via platform tags.
2020-05-18AudioDriverJavaScript now compute buffer size.Fabio Alessandrelli
Based on mix rate and expected latency.
2020-05-14Style: Enforce braces around if blocks and loopsRémi Verschelde
Using clang-tidy's `readability-braces-around-statements`. https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html
2020-05-14Style: Enforce separation line between function definitionsRémi Verschelde
I couldn't find a tool that enforces it, so I went the manual route: ``` find -name "thirdparty" -prune \ -o -name "*.cpp" -o -name "*.h" -o -name "*.m" -o -name "*.mm" \ -o -name "*.glsl" > files perl -0777 -pi -e 's/\n}\n([^#])/\n}\n\n\1/g' $(cat files) misc/scripts/fix_style.sh -c ``` This adds a newline after all `}` on the first column, unless they are followed by `#` (typically `#endif`). This leads to having lots of places with two lines between function/class definitions, but clang-format then fixes it as we enforce max one line of separation. This doesn't fix potential occurrences of function definitions which are indented (e.g. for a helper class defined in a .cpp), but it's better than nothing. Also can't be made to run easily on CI/hooks so we'll have to be careful with new code. Part of #33027.
2020-05-14Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocksRémi Verschelde
Which means that reduz' beloved style which we all became used to will now be changed automatically to remove the first empty line. This makes us lean closer to 1TBS (the one true brace style) instead of hybridating it with some Allman-inspired spacing. There's still the case of braces around single-statement blocks that needs to be addressed (but clang-format can't help with that, but clang-tidy may if we agree about it). Part of #33027.
2020-05-14Style: Fix missing/invalid copyright headersRémi Verschelde
2020-05-14Port member initialization from constructor to declaration (C++11)Rémi Verschelde
Using `clang-tidy`'s `modernize-use-default-member-init` check and manual review of the changes, and some extra manual changes that `clang-tidy` failed to do. Also went manually through all of `core` to find occurrences that `clang-tidy` couldn't handle, especially all initializations done in a constructor without using initializer lists.
2020-05-13Update game controller enums.Marcel Admiraal
2020-05-12Add WebSocket debugger, use it for Javascript.Fabio Alessandrelli
2020-05-10Add drop files functionFabio Alessandrelli
2020-05-10Fix Closure compiler build, python style.Fabio Alessandrelli
Move copyToFS into utils.js library included with '--pre-js'.
2020-05-10DisplayServerJavaScript implementation.Fabio Alessandrelli
2020-05-10[HTML5] Locale, input fix, context, exit.Fabio Alessandrelli
Add missing semicolumns in engine.js Add optional extra args to JS Engine.startGame Remove loader.js, explicit noExitRuntime. Also add onExit callback (undocumented in emscripten)
2020-05-10Style: clang-format: Disable AllowShortCaseLabelsOnASingleLineRémi Verschelde
Part of #33027.
2020-05-01Merge pull request #37414 from Schroedi/fix_html_mouse_inputFabio Alessandrelli
Move wheel handlers from window to canvas element in HTML
2020-04-28Rename InputFilter back to InputRémi Verschelde
It changed name as part of the DisplayServer and input refactoring in #37317, with the rationale that input no longer goes through the main loop, so the previous Input singleton now only does filtering. But the gains in consistency are quite limited in the renaming, and it breaks compatibility for all scripts and tutorials that access the Input singleton via the scripting language. A temporary option was suggested to keep the scripting singleton named `Input` even if its type is `InputFilter`, but that adds inconsistency and breaks C#. Fixes godotengine/godot-proposals#639. Fixes #37319. Fixes #37690.
2020-04-28Move mouse wheel handler from window to canvas element in HTMLChristoph Schröder
Similar to https://github.com/godotengine/godot/pull/36557 At least in chrome, the following error is printed for each mouse wheel rotation: [Intervention] Unable to preventDefault inside passive event listener due to target being treated as passive. See https://www.chromestatus.com/features/6662647093133312 This PR moves the handler to the canvas and thereby fixes the error. Tested on: Chrome and Firefox (MacOS), Firefox, Chrome(Android), Safari (IPad + MacOS)
2020-04-22Set the `title` tag in the HTML5 export immediatelyHugo Locurcio
This makes the project title display without having to wait for the project to finish loading.
2020-04-02Replace NULL with nullptrlupoDharkael
2020-03-30SCons: Format buildsystem files with psf/blackRémi Verschelde
Configured for a max line length of 120 characters. psf/black is very opinionated and purposely doesn't leave much room for configuration. The output is mostly OK so that should be fine for us, but some things worth noting: - Manually wrapped strings will be reflowed, so by using a line length of 120 for the sake of preserving readability for our long command calls, it also means that some manually wrapped strings are back on the same line and should be manually merged again. - Code generators using string concatenation extensively look awful, since black puts each operand on a single line. We need to refactor these generators to use more pythonic string formatting, for which many options are available (`%`, `format` or f-strings). - CI checks and a pre-commit hook will be added to ensure that future buildsystem changes are well-formatted.
2020-03-27Renaming of servers for coherency.Juan Linietsky
VisualServer -> RenderingServer PhysicsServer -> PhysicsServer3D Physics2DServer -> PhysicsServer2D NavigationServer -> NavigationServer3D Navigation2DServer -> NavigationServer2D Also renamed corresponding files.
2020-03-26Refactored input, goes all via windows now.Juan Linietsky
Also renamed Input to InputFilter because all it does is filter events.
2020-03-26Refactored Input, create DisplayServer and DisplayServerX11Juan Linietsky
2020-03-23Adding missing include guards to header files identified by LGTM.Rajat Goswami
This addresses the issue godotengine/godot#37143
2020-03-17Style: Set clang-format Standard to Cpp11Rémi Verschelde
For us, it practically only changes the fact that `A<A<int>>` is now used instead of the C++03 compatible `A<A<int> >`. Note: clang-format 10+ changed the `Standard` arguments to fully specified `c++11`, `c++14`, etc. versions, but we can't use `c++17` now if we want to preserve compatibility with clang-format 8 and 9. `Cpp11` is still supported as deprecated alias for `Latest`.
2020-03-11[HTML5] Refactor JS, threads support, closures.Fabio Alessandrelli
- Refactored the Engine code, splitted across files. - Use MODULARIZE option to build emscripten code into it's own closure. - Enable lto support (saves ~2MiB in release). - Enable optional closure compiler pass for JS and generated code. - Enable optional pthreads support. - Can now build with tools=yes (not much to see yet). - Dropped some deprecated code for older toolchains.
2020-03-11AudioDriverJavascript uses IDHandler.Fabio Alessandrelli
This makes closure compiler happy, avoiding globals and potentially undefined variables.
2020-03-08OS_Javascript temporarly uses dummy rasterizer.Fabio Alessandrelli
2020-03-08Fix Javascript platform after PoolVector removal.Fabio Alessandrelli
Eval should be rechecked.
2020-03-03Merge pull request #36557 from Schroedi/fix_html_touchFabio Alessandrelli
Fixes touch events for HTML
2020-03-01Merge pull request #18020 from bruvzg/input_fix_non_latin_and_add_hw_scancodesRémi Verschelde
Fix non-latin layout scancodes on Linux, adds access to physical scancodes.
2020-02-26Reimplement Mutex with C++'s <mutex>Pedro J. Estébanez
Main: - It's now implemented thanks to `<mutex>`. No more platform-specific implementations. - `BinaryMutex` (non-recursive) is added, as an alternative for special cases. - Doesn't need allocation/deallocation anymore. It can live in the stack and be part of other classes. - Because of that, it's methods are now `const` and the inner mutex is `mutable` so it can be easily used in `const` contexts. - A no-op implementation is provided if `NO_THREADS` is defined. No more need to add `#ifdef NO_THREADS` just for this. - `MutexLock` now takes a reference. At this point the cases of null `Mutex`es are rare. If you ever need that, just don't use `MutexLock`. - Thread-safe utilities are therefore simpler now. Misc.: - `ScopedMutexLock` is dropped and replaced by `MutexLock`, because they were pretty much the same. - Every case of lock, do-something, unlock is replaced by `MutexLock` (complex cases where it's not straightfoward are kept as as explicit lock and unlock). - `ShaderRD` contained an `std::mutex`, which has been replaced by `Mutex`.
2020-02-26Fixes touch events for HTMLChristoph Schroeder
Without this patch, the following exception is thrown when the touch screen is used: TypeError: e.getBoundingClientRect is not a function. No touch events arrive in the engine. From my testing, this PR fixes the issue and behaves as expected. Tested with godot-demo-projects/misc/multitouch_view/, emscripten 1.39.8 and Firefox mobile emulator as well as FF on Android
2020-02-25Variant: Added 64-bit packed arrays, renamed Variant::REAL to FLOAT.Juan Linietsky
- Renames PackedIntArray to PackedInt32Array. - Renames PackedFloatArray to PackedFloat32Array. - Adds PackedInt64Array and PackedFloat64Array. - Renames Variant::REAL to Variant::FLOAT for consistency. Packed arrays are for storing large amount of data and creating stuff like meshes, buffers. textures, etc. Forcing them to be 64 is a huge waste of memory. That said, many users requested the ability to have 64 bits packed arrays for their games, so this is just an optional added type. For Variant, the float datatype is always 64 bits, and exposed as `float`. We still have `real_t` which is the datatype that can change from 32 to 64 bits depending on a compile flag (not entirely working right now, but that's the idea). It affects math related datatypes and code only. Neither Variant nor PackedArray make use of real_t, which is only intended for math precision, so the term is removed from there to keep only float.
2020-02-25Rename `scancode` to `keycode`.bruvzg
Add `physical_keycode` (keyboard layout independent keycodes) to InputEventKey and InputMap. Fix non-latin keyboard layout keycodes on Linux/X11 (fallback to physical keycodes).