summaryrefslogtreecommitdiffstats
path: root/platform/javascript
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #40755 from Faless/js/fix_and_cancel_swapRémi Verschelde2020-07-273-0/+21
|\ | | | | Cancel/OK swap on HTML5 platform, small fixes.
| * Implement HTML5 cancel/ok button swap on Windows.Fabio Alessandrelli2020-07-272-0/+18
| | | | | | | | Platform is detected on init via the `navigator.platform` string.
| * Correctly include <stdlib.h> in javascript main.Fabio Alessandrelli2020-07-271-0/+1
| | | | | | | | | | 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.
| * Properly set HTML5 DisplayServer init error value.Fabio Alessandrelli2020-07-271-0/+2
| | | | | | | | Checked in main.cpp, would cause the engine to not load.
* | t Add unit testing to Godot using DocTest and added to GitHub Actions CIRevoluPowered2020-07-241-0/+4
|/ | | | | | | | | | 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.
* Add override keywords.Marcel Admiraal2020-07-101-18/+18
|
* Use dummy driver when JS AudioContext is unavailable.Fabio Alessandrelli2020-07-015-15/+40
|
* Limit FPS in JS by skipping iterations.Fabio Alessandrelli2020-07-012-0/+13
|
* [JS] Check canvas size each loop, force redraw.Fabio Alessandrelli2020-07-013-0/+26
| | | | Fix compatibility issues, achieve smoother resizing.
* More static methods in DisplayServerJavaScript.Fabio Alessandrelli2020-07-012-9/+19
| | | | Were static functions in cpp file, polluting global namespace.
* Refactor canvas ID and locale handling.Fabio Alessandrelli2020-07-014-56/+45
|
* Fix FS error on JS startup due to existing folder.Fabio Alessandrelli2020-07-011-2/+5
|
* Immediately run first iteration after JS FS sync.Fabio Alessandrelli2020-06-141-4/+8
| | | | | Which is now run inside an animation frame. This avoid a 1 frame black screen when setting up the canvas.
* Swtich HTML5 key detection from keyCode to code.Fabio Alessandrelli2020-06-042-394/+197
| | | | | | | 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.
* Fix JS audioContext parameters.Fabio Alessandrelli2020-05-251-2/+2
| | | | | Were not passed along correctly. `latencyHint` is supposed to be in seconds, not milliseconds.
* Move mix_rate, ouput_latency to AudioDriverManagerFabio Alessandrelli2020-05-181-2/+2
| | | | | | | 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.
* AudioDriverJavaScript now compute buffer size.Fabio Alessandrelli2020-05-182-15/+35
| | | | Based on mix rate and expected latency.
* Style: Enforce braces around if blocks and loopsRémi Verschelde2020-05-141-8/+14
| | | | | Using clang-tidy's `readability-braces-around-statements`. https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html
* Style: Enforce separation line between function definitionsRémi Verschelde2020-05-141-0/+2
| | | | | | | | | | | | | | | | | | | | | | | 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.
* Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocksRémi Verschelde2020-05-1412-144/+0
| | | | | | | | | | | | | | 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.
* Style: Fix missing/invalid copyright headersRémi Verschelde2020-05-141-0/+30
|
* Port member initialization from constructor to declaration (C++11)Rémi Verschelde2020-05-142-17/+9
| | | | | | | | | | 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.
* Update game controller enums.Marcel Admiraal2020-05-131-8/+1
|
* Add WebSocket debugger, use it for Javascript.Fabio Alessandrelli2020-05-122-4/+23
|
* Add drop files functionFabio Alessandrelli2020-05-104-2/+187
|
* Fix Closure compiler build, python style.Fabio Alessandrelli2020-05-109-44/+73
| | | | Move copyToFS into utils.js library included with '--pre-js'.
* DisplayServerJavaScript implementation.Fabio Alessandrelli2020-05-1010-1208/+1538
|
* [HTML5] Locale, input fix, context, exit.Fabio Alessandrelli2020-05-104-91/+112
| | | | | | | 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)
* Style: clang-format: Disable AllowShortCaseLabelsOnASingleLineRémi Verschelde2020-05-102-72/+149
| | | | Part of #33027.
* Merge pull request #37414 from Schroedi/fix_html_mouse_inputFabio Alessandrelli2020-05-011-1/+1
|\ | | | | Move wheel handlers from window to canvas element in HTML
| * Move mouse wheel handler from window to canvas element in HTMLChristoph Schröder2020-04-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | 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)
* | Rename InputFilter back to InputRémi Verschelde2020-04-281-1/+1
|/ | | | | | | | | | | | | | | | 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.
* Set the `title` tag in the HTML5 export immediatelyHugo Locurcio2020-04-221-0/+1
| | | | | This makes the project title display without having to wait for the project to finish loading.
* Replace NULL with nullptrlupoDharkael2020-04-027-24/+24
|
* SCons: Format buildsystem files with psf/blackRémi Verschelde2020-03-303-123/+122
| | | | | | | | | | | | | | | | | | | | | 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.
* Renaming of servers for coherency.Juan Linietsky2020-03-272-4/+4
| | | | | | | | | | VisualServer -> RenderingServer PhysicsServer -> PhysicsServer3D Physics2DServer -> PhysicsServer2D NavigationServer -> NavigationServer3D Navigation2DServer -> NavigationServer2D Also renamed corresponding files.
* Refactored input, goes all via windows now.Juan Linietsky2020-03-262-7/+7
| | | | Also renamed Input to InputFilter because all it does is filter events.
* Refactored Input, create DisplayServer and DisplayServerX11Juan Linietsky2020-03-261-1/+1
|
* Adding missing include guards to header files identified by LGTM.Rajat Goswami2020-03-231-0/+5
| | | | This addresses the issue godotengine/godot#37143
* Style: Set clang-format Standard to Cpp11Rémi Verschelde2020-03-172-3/+3
| | | | | | | | | | 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`.
* [HTML5] Refactor JS, threads support, closures.Fabio Alessandrelli2020-03-1113-482/+567
| | | | | | | | | | - 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.
* AudioDriverJavascript uses IDHandler.Fabio Alessandrelli2020-03-112-40/+54
| | | | | This makes closure compiler happy, avoiding globals and potentially undefined variables.
* OS_Javascript temporarly uses dummy rasterizer.Fabio Alessandrelli2020-03-081-1/+5
|
* Fix Javascript platform after PoolVector removal.Fabio Alessandrelli2020-03-084-39/+20
| | | | Eval should be rechecked.
* Merge pull request #36557 from Schroedi/fix_html_touchFabio Alessandrelli2020-03-031-4/+4
|\ | | | | Fixes touch events for HTML
| * Fixes touch events for HTMLChristoph Schroeder2020-02-261-4/+4
| | | | | | | | | | | | | | | | | | | | | | 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
* | Merge pull request #18020 from bruvzg/input_fix_non_latin_and_add_hw_scancodesRémi Verschelde2020-03-012-4/+5
|\ \ | | | | | | Fix non-latin layout scancodes on Linux, adds access to physical scancodes.
| * | Rename `scancode` to `keycode`.bruvzg2020-02-252-4/+5
| | | | | | | | | | | | | | | Add `physical_keycode` (keyboard layout independent keycodes) to InputEventKey and InputMap. Fix non-latin keyboard layout keycodes on Linux/X11 (fallback to physical keycodes).
* | | Reimplement Mutex with C++'s <mutex>Pedro J. Estébanez2020-02-261-14/+13
| |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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`.
* | Variant: Added 64-bit packed arrays, renamed Variant::REAL to FLOAT.Juan Linietsky2020-02-251-2/+2
|/ | | | | | | | | | | | | | | | | | | | | - 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.