Commit graph

532 commits

Author SHA1 Message Date
Pedro J. Estébanez
abdf931832 Add off-screen GL context 2021-11-09 12:19:12 +01:00
Rémi Verschelde
42d385b312
clang-format: Disable alignment of operands, too unreliable
Sets `AlignOperands` to `DontAlign`.

`clang-format` developers seem to mostly care about space-based indentation and
every other version of clang-format breaks the bad mismatch of tabs and spaces
that it seems to use for operand alignment. So it's better without, so that it
respects our two-tabs `ContinuationIndentWidth`.
2021-10-28 13:23:38 +02:00
Pedro J. Estébanez
beb99fe54b
Expose Input::flush_buffered_events()
(cherry picked from commit 6dc3fae201)
2021-10-23 12:02:48 +02:00
Aaron Franke
5659120af3
[3.x] Add support for the RISC-V architecture
Supports RV64GC (RISC-V 64-bit with general-purpose and compressed-instruction extensions)
2021-10-22 12:51:23 -05:00
bruvzg
b97ca39360 Fix handling multiple "physical key" events in the single input map action. 2021-10-19 22:19:13 +03:00
Дмитрий Сальников
5cf898b897 Exposed setters for sensor values in Input class 2021-10-12 23:09:30 +03:00
Hugo Locurcio
0e943939e2
Add an editor setting to configure number of threads for lightmap baking
This can be used to free some CPU cores when baking lightmaps.
When using fewer CPU cores, lightmap baking is slower but background
tasks aren't slowed down as much.
2021-10-05 17:35:20 +02:00
Lucy
1d3f1c8c0a
Fix Platform Thread Override
(cherry picked from commit 5fe1857496)
2021-10-04 14:37:27 +02:00
Rémi Verschelde
7c9e06f936
Merge pull request #48686 from bruvzg/bundle_icon_3 2021-09-30 14:55:41 +02:00
Rémi Verschelde
b4fc24b73f
Implement OS::get_locale_language() helper method
This method extracts the 2 or 3-letter language code from `OS::get_locale()`,
making it easier for users to identify the "main" language code for users
that might have different OS locales due to different OS or region, but
should be matched to the same translation (e.g. "generic" Spanish).

Fixes #40703.

(cherry picked from commit def99c7baf)
2021-09-21 20:33:12 +02:00
Lucy
83bbb527ad
Allow for platform Thread implementation override
(cherry picked from commit e9723efd34)
2021-09-21 17:15:00 +02:00
Álex Román Núñez
43bc8830f1 Fix InputMap.action_erase_event() failing to erase events correctly.
Fixes #52733

(3.x backport of 7104229a85)
2021-09-17 03:08:21 +02:00
Rémi Verschelde
76c891c257
Merge pull request #51706 from maiself/fix-input-methods-returning-zero-strength
Fix input methods returning zero strength when pressed status not requested
2021-08-16 13:02:36 +02:00
Mai Lavelle
d418443992 Fix input methods returning zero strength when pressed status not requested
Fixes behavior of these methods:

`InputMap::event_get_action_status`
`InputEvent*::action_match`

Previously when `p_pressed` was `nullptr`, `p_strength` would be set to
`0.0f` regardless of event strength. This affected `InputEventAction` events
processed by `Input.parse_input_event` for example.

Regression found in afa89c9eea
2021-08-15 20:00:31 -04:00
ne0fhyk
c88d1608ab Add partial support for Android scoped storage.
This is done by providing API access to app specific directories which don't have any limitations and allows us to bump the target sdk version to 30.
In addition, we're also bumping the min sdk version to 19 as version 18 is no longer supported by Google Play Services and only account of 0.3% of Android devices.
2021-08-13 11:04:17 -07:00
Pedro J. Estébanez
7be9c26e20 Add input buffering framework
Input buffering is implicitly used by event accumulation, but this commit makes it more generic so it can be enabled for other uses.

For desktop OSs it's currently not feasible given main and UI threads are the same).
2021-08-08 12:37:55 +02:00
Pedro J. Estébanez
58a54f534e Improve input event accumulation
- API has been simplified: all events now go through `parse_input_event()`. Whether they are accumulated or not depends on the `use_accumulated_input` flag.
- Event accumulation is now thread-safe (it was not needed so far, but it prepares the ground for the following changes).
- Touch drag events now support accumulation.
2021-08-08 12:37:55 +02:00
Rémi Verschelde
8db0bd4424
OS: Fix used resource debug prints
These methods were broken by 22419082d9
5 years ago and nobody complained, so maybe they're not so useful...
But at least this should restore them to a working state.

(cherry picked from commit 8c3a6b10a9)
2021-08-06 13:24:02 +02:00
Rémi Verschelde
b3c555504f
Improve documentation and simplifies code for File::get_csv_line()
Also forbids using double quotes as a delimiter.

(cherry picked from commit b8c08ba5ad)
2021-08-06 11:13:43 +02:00
EricEzaM
0e5c6e0d55 Allow checking for exact matches with Action events.
Added additional param to action related methods to test for exactness.
If "p_exact_match" is true, then the action will only be "matched" if the provided input event *exactly* matches with the action event.

Before:
* Action Event = KEY_S
* Input Event = KEY_CONTROL + KEY_S
* Is Action Pressed = True

Now:
You can still do the above, however you can optionally check that the input is exactly what the action event is:
* Action Event = KEY_S
* Input Event = KEY_CONTROL + KEY_S
* p_exact_match = True
* Is Action Pressed = False
* If the Input Event was only KEY_S, then the result would be true.

Usage:

```gdscript
Input.is_action_pressed(action_name: String, exact_match: bool)
Input.is_action_pressed("my_action", true)

InputMap.event_is_action(p_event, "my_action", true)

func _input(event: InputEvent):
  event.is_action_pressed("my_action", false, true) # false = "allow_echo", true = "exact_match"
  event.is_action("my_action", true)
```

Co-authored-by: Eric M <itsjusteza@gmail.com>
2021-07-30 15:35:39 +02:00
Raul Santos
daa07219cb Set p_raw_strength in action_match methods 2021-07-28 20:42:21 +02:00
Aaron Franke
69fb14256b
[3.x] Allow getting Input axis/vector values from multiple actions
For get_vector, use raw values and handle deadzones appropriately
2021-07-23 19:17:55 -04:00
Aaron Franke
afa89c9eea
[3.x] Add raw strength value for internal use 2021-07-23 19:09:53 -04:00
lawnjelly
6914d7c6e0 Add frame delta smoothing option
Frame deltas are currently measured by querying the OS timer each frame. This is subject to random error. Frame delta smoothing instead filters the delta read from the OS by replacing it with the refresh rate delta wherever possible.

This PR also contains code to estimate the refresh rate based on the input deltas, without reading the refresh rate from the host OS.
2021-07-14 08:44:31 +01:00
Haoyu Qiu
2b2f3d7f2d
Fix memfree parameter name
(cherry picked from commit 542d7d6460)
2021-07-13 10:20:03 +02:00
Marcel Admiraal
7e03bd1671 Remove duplicate WARN_PRINTS macro 2021-06-18 12:57:59 +01:00
Marcel Admiraal
5a58516231 Remove duplicate ERR_PRINTS macro 2021-06-16 11:56:25 +01:00
Marcel Admiraal
6d63ccba31 Add OS.get_external_data_dir() to get Android external directory 2021-06-10 16:48:37 +01:00
Rémi Verschelde
32047ffd9c
FileAccess: Don't err in store_buffer with buffer of size 0
The error check was added for `FileAccessUnix` but it's not an error when both
`p_src` and `p_length` are zero.

Added correct error checks to all implementations to prevent the actual
erroneous case: `p_src` is nullptr but `p_length > 0` (risk of null pointer
indexing).

Fixes #33564.

(cherry picked from commit 01d5c463be)
2021-06-07 22:36:07 +02:00
Marcel Admiraal
18825ad4ff Fix game controllers ignoring the last listed button 2021-06-03 15:45:05 +01:00
Hugo Locurcio
914b5dc525
Remove duplicate orientation settings in the iOS export preset
The screen orientation is now sourced from the Project Settings
like it is done for Android already.
2021-05-25 23:55:37 +02:00
Rémi Verschelde
b94b09cd19
Merge pull request #46860 from bruvzg/symlinks_and_macos_gdn_framework_export 2021-05-24 15:15:10 +02:00
bruvzg
6aa8f7d85b
Add symlink API to the DirAccess (on macOS and Linux). 2021-05-22 17:36:16 +03:00
Morris Tabor
ba396caefc Replace QuickHull with Bullet's convex hull computer.
The code is based on the current version of thirdparty/vhacd and modified to use Godot's types and code style.

Additional changes:
- backported and extended PagedAllocator to allow leaked objects
- applied patch from https://github.com/bulletphysics/bullet3/pull/3037
2021-05-22 08:16:43 +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
bruvzg
3b0c071ce2
[macOS] Prefer .app bundle icon over the default one. 2021-05-13 09:30:56 +03:00
Rémi Verschelde
e96f0ea1d7
Android: Remove non-functional native video OS methods
Those methods are only properly implemented for iOS.

Supersedes #43811.
2021-05-07 16:42:17 +02: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
140350d767
Style: Enforce braces around if blocks and loops
Using clang-tidy's `readability-braces-around-statements`.
https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html
2021-05-05 15:02:01 +02:00
Rémi Verschelde
b4af1eba0a
Style: Enforce use of bool literals instead of integers
Using clang-tidy's `modernize-use-bool-literals`.
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-bool-literals.html
2021-05-04 16:39:13 +02: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
Rémi Verschelde
3d15f04668
Style: clang-format: Disable AllowShortIfStatementsOnASingleLine 2021-05-04 14:45:15 +02:00
Rémi Verschelde
6e600cb3f0
Style: Set clang-format Standard to c++14 2021-05-04 14:45:15 +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
Hein-Pieter van Braam-Stewart
ff3099abcf Fix thread_local, tls, ASLR, and DEP with MingW
This commit changes the way Thread::caller_id works. By moving caller_id
to the .cpp file we make sure that the TLS variable doesn't get
relocated twice causing a crash. Since we build with LTO for release
builds (and everyone should be doing that anyway) there is no extra
overhead from the non-static method. We do do an extra bool check now
there but I don't think this will add much in the way of overhead.

This check cannot be avoided if we still want to be able to cache the
thread ID hash, as we had to move the setter because of limitations of
the WinRT platform. The original workaround for this was in #46813 but
this has some unintended consequences. Specifically; threads that never
create a Thread object will always return 0 in Thread::get_caller_id()
which caused a regression. For instance the editor now freezes when
importing large textures. This PR also addresses that.

Additionally we now enable ASLR support when building with MingW, this
includes a workaround for MingW. MingW refuses to create an appropriate
relocation table if no symbols are exported. So we just export the
various main() functions in godot_windows.cpp.

While ASLR support isn't criticial for Godot, previous versions of Godot
just happened to work with a dynamic base 'by accident' and some users
run Godot this way. After the thread change the .tls section now needs
relocations to make this work. By enabling ASLR at build-time we create
these relocations and people who forced ALSR on previously will now get
a working Godot again.

This fixes #47256 and fixes #47219

This is the 3.x version of this PR. For master a different approach is
possible which I will make in the coming days.
2021-03-25 23:20:12 +01:00
Alex Hirsch
0b541af8a1
Allow nullptr with zero length in FileAccess get_buffer
fix #47071

(cherry picked from commit c28428fe4d)
2021-03-17 15:17:02 +01:00
Alex Hirsch
5a882a659a
Add parameter checkes to FileAccess get_buffer functions
fix #46540

(cherry picked from commit cdf3099c68)
2021-03-14 12:03:22 +01:00
bruvzg
8feb53e509 Move caller_id init to Thread constructor to fix UWP build.
(cherry picked from commit 741e1cf672)
2021-03-12 10:12:52 +01:00