Commit graph

45 commits

Author SHA1 Message Date
Aaron Franke fa3a32a2d6
Use Key enum instead of plain integers 2021-08-10 16:26:55 -05:00
bruvzg 618eb27e8b Move alert function from DisplayServer to OS. 2021-07-22 21:50:35 +03:00
Fabio Alessandrelli 3d8acc7a54 [HTML5] Fix build (with module_webxr_enabled=no).
The XR API changed a bit, and it's not just a rename, though probably an
easy update for someone who is qualified :).
2021-07-15 14:37:21 +02:00
Aaron Franke 0ce49800ac
Use mouse and joypad enums instead of plain integers
Also MIDIMessage
2021-06-20 11:54:24 -04:00
Lightning_A e28fd07b2b Rename instance()->instantiate() when it's a verb 2021-06-19 20:49:18 -06:00
Aaron Franke 98aa3b669e
Add MOUSE_MODE_CONFINED_HIDDEN
Co-authored-by: Hugo Locurcio <hugo.locurcio@hugo.pro>
2021-06-03 11:44:28 -04:00
Fabio Alessandrelli 8cdef21d6c Move remaining dummy drivers to servers. 2021-06-01 16:50:32 +02:00
Rémi Verschelde 4219a4cb6f
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:38:56 +02:00
Rémi Verschelde 6c367f8e0d
Merge pull request #48168 from LightningAA/control-to-ctrl-4.0 2021-05-17 17:38:02 +02:00
Lightning_A 97fecd1b69 Rename "Control" key to "Ctrl" and add "_pressed" suffix to all InputEventWithModifiers properties/methods 2021-05-07 14:00:50 -06:00
Rémi Verschelde 35ec0e9be7
OS: Remove native video API only implemented on iOS
See discussion in #43811, it was only implemented on iOS and even that
implementation was fairly limited. This would best be provided as plugins
for Android and iOS without cluttering the shared OS API.
2021-05-07 20:40:24 +02:00
Aaron Franke 0de9a7d803
Rename doubleclick to double_click 2021-05-04 04:38:08 -04:00
Rémi Verschelde 5b16020846
Replace remaining uses of NULL with nullptr
Follow-up to #38736 (these uses were likely added after this PR was merged).
2021-04-29 11:53:27 +02:00
Marcel Admiraal fd30c36985 Rename Texture.get_data() to get_image() 2021-03-28 13:00:46 +01:00
Aaron Franke a5324787c8
Rename some more global enums (Key, Joy, MIDI) 2021-03-23 07:13:23 -04:00
Aaron Franke 10d7fccb54
Rename ButtonList enum and members to MouseButton 2021-03-23 07:13:23 -04:00
Fabio Alessandrelli 3416f7b521 [HTML5] Opt-in virtual keyboard support.
Added as an export option "Experimental Virtual Keyboard".
There is no zoom, so text/line edit must be in the top part of the
screen, or it will get hidden by the virtual keyboard.
UTF8/Latin-1 only (I think regular UTF-8 should work out of the box in
4.0 but I can't test it).
It uses an hidden textarea or input, based on the multiline variable,
and only gets activated if the device has a touchscreen.
This could cause problems on devices with both touchscreen and a real
keyboard (although input should still work in general with some minor
focus issues). I'm thinking of a system to detect the first physical
keystroke and disable it in case, but it might do more harm then good,
so it must be well thought.
2021-03-11 23:08:08 +01:00
Fabio Alessandrelli f34c7982c5 [HTML5] Respect allow_hidpi option during setup
The option was forced to `true` before, unlike on other platforms.
2021-03-08 23:37:53 +01:00
Fabio Alessandrelli 65abf94675 [HTML5] Better fullscreen, canvas resizing.
Three canvas resize policies:
- `None`: Godot window settings are ignored.
- `Project`: Godot handles the canvas like a native app (resizing it
  when setting the window size).
- `Adaptive`: Canvas size will always adapt to browser window size.

Use `None` if you want to control the canvas size with custom JavaScript
code.
2021-02-19 05:12:32 +01:00
Fabio Alessandrelli 2972ea3229 [HTML5] Easier HTML templates, better deinit/cleanup. 2021-02-19 05:12:32 +01:00
Fabio Alessandrelli 6cff589b5b [HTML5] Detect screen scale and DPI.
`OS.get_screen_scale` will now return the `window.devicePixelRatio`
value, `OS.get_screen_dpi` uses CSS media queries to find approximate
DPI value for the current display.
`OS.get_screen_size` also return the actual screen size (not the CSS
pixel size).
2021-02-12 12:01:44 +01:00
Fabio Alessandrelli 3366122e1a [HTML5] Handle contextmenu, webglcontextlost internally.
This way they are automatically cleaned up when the engine exits,
landing a hand to browsers garbage collectors.
2021-02-11 07:56:10 +01:00
Fabio Alessandrelli 97288f25f4 [HTML5] Fix mouse_mode and fullscreen detection.
The canvas_id is `#`-prefixed to work with emscripten as a CSS selector.
When comparing to an event target ID (e.g. when checking if the canvas
is fullscreen, or is locking the mouse) we need to skip the first char
(the hash).
2021-02-02 20:08:51 +01:00
Fabio Alessandrelli bab20c6e09 [HTML5] Custom Gamepad library to allow remapping.
No longer use emscripten functions for gamepads, implement them as
library functions in library_godot_display.js instead.
This allows us to do a better job at "guessing" vendorId, productId, OS,
etc. thus allowing us to better find the remapping for the controller.
2021-01-18 12:30:38 +01:00
Rémi Verschelde b5334d14f7
Update copyright statements to 2021
Happy new year to the wonderful Godot community!

2020 has been a tough year for most of us personally, but a good year for
Godot development nonetheless with a huge amount of work done towards Godot
4.0 and great improvements backported to the long-lived 3.2 branch.

We've had close to 400 contributors to engine code this year, authoring near
7,000 commit! (And that's only for the `master` branch and for the engine code,
there's a lot more when counting docs, demos and other first-party repos.)

Here's to a great year 2021 for all Godot users 🎆
2021-01-01 20:19:21 +01:00
Rémi Verschelde 09212fba1e
Fix missed renamings from empty() to is_empty()
Those were missed in #44401 or added by later PRs.
2020-12-29 09:55:07 +01:00
Fabio Alessandrelli 178546ac3e [HTML5] Fix broken layout on load in HiDPI screens
This was caused by the devicePixelRatio being applied twice, once by the
HTML code, once by the OS code.
More specifically, OS.get_window_size() would return the canvas element
size, while OS.set_window_size() would set the element size to the
specified value times the devicePixelRatio.
Calling OS.set_window_size(OS.get_window_size()) would reapply the
devicePixelRatio every time.
This commit changes the behaviour so that OS.set_window_size() do not
apply the devicePixelRatio to the canvas element size, by it divides the
CSS size instead.
2020-11-30 12:07:20 +01:00
Aaron Franke 02161aad5a
Remove empty lines around braces with the formatting script 2020-11-16 23:38:11 -05:00
Fabio Alessandrelli e2083871eb [HTML5] Port JavaScript inline code to libraries.
The API is implemented in javascript, and generates C functions that can
be called from godot.
This allows much cleaner code replacing all `EM_ASM` calls in our C++
code with plain C function calls.
This also gets rid of few hacks and comes with few optimizations (e.g.
custom cursor shapes should be much faster now).
2020-11-10 11:42:51 +01:00
Fabio Alessandrelli 806edcae5b Better HiDPI support in HTML5. 2020-09-23 09:51:06 +02:00
Fabio Alessandrelli 7d0896e763 Window event listener do not use capture. 2020-09-23 09:51:06 +02:00
Fabio Alessandrelli 48aa0b5b03 Small refactor to JavaScript handlers.
Crated helper class in native/utils.js.
Simplify code in OS/DisplayServer.
2020-09-23 09:51:06 +02:00
Fabio Alessandrelli 0b286a287c Implement HTML5 cancel/ok button swap on Windows.
Platform is detected on init via the `navigator.platform` string.
2020-07-27 14:17:10 +02:00
Fabio Alessandrelli 757af6a69f Properly set HTML5 DisplayServer init error value.
Checked in main.cpp, would cause the engine to not load.
2020-07-27 14:17:10 +02:00
Fabio Alessandrelli 07d4513886 [JS] Check canvas size each loop, force redraw.
Fix compatibility issues, achieve smoother resizing.
2020-07-01 17:16:13 +02:00
Fabio Alessandrelli a1c4c1d318 More static methods in DisplayServerJavaScript.
Were static functions in cpp file, polluting global namespace.
2020-07-01 17:16:03 +02:00
Fabio Alessandrelli fd92270b0a Refactor canvas ID and locale handling. 2020-07-01 13:10:05 +02:00
Fabio Alessandrelli 0a35b97b62 Swtich HTML5 key detection from keyCode to code.
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-06-04 21:15:05 +02:00
Rémi Verschelde 07bc4e2f96 Style: Enforce separation line between function definitions
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-14 16:54:55 +02:00
Rémi Verschelde 0be6d925dc Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks
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-14 16:54:55 +02:00
Rémi Verschelde 710b34b702 Style: Fix missing/invalid copyright headers 2020-05-14 16:54:54 +02:00
Marcel Admiraal e7fee711b3 Update game controller enums. 2020-05-13 10:33:32 +01:00
Fabio Alessandrelli 6a49b83e39 Add drop files function 2020-05-10 18:22:48 +02:00
Fabio Alessandrelli d2eef39731 Fix Closure compiler build, python style.
Move copyToFS into utils.js library included with '--pre-js'.
2020-05-10 18:22:48 +02:00
Fabio Alessandrelli 7411e7fd37 DisplayServerJavaScript implementation. 2020-05-10 18:22:48 +02:00