Commit Graph

537 Commits

Author SHA1 Message Date
keptsecret b95221fb0a fix unable to change directory in user access mode
(cherry picked from commit c69689ab5a)
2022-04-13 12:18:45 +02:00
Bartłomiej T. Listwon 9029e5d66f Include platform_config.h in thread.cpp and thread.h
(cherry picked from commit 6c6291b84f)
2022-03-17 13:05:47 +01:00
Rémi Verschelde 71066cd63b
Update copyright statements to 2022
Happy new year to the wonderful Godot community!

(cherry picked from commit a627cdafc5)
2022-01-13 16:00:37 +01:00
bruvzg b7fbfc2776
Add joystick button index boundary check. Increase max. button number to 128 (max. buttons supported by DirectInput).
(cherry picked from commit 61ea8f8337)
2022-01-12 16:29:19 +01:00
bruvzg cb6d82a111
Fix multiple missing UTF-8 decoding.
(cherry picked from commit c69e0d16bc)
2022-01-06 21:30:41 +01:00
bruvzg b8f888a43b
Add Input.is_physical_key_pressed method.
(cherry picked from commit 9877d91c4a)
2021-11-25 23:13:15 +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