Commit Graph

337 Commits

Author SHA1 Message Date
Lisandro Lorea 9dd372f316 Fix gamepad triggers not working on web exports
Fixes #81758

DisplayServerWeb::process_joypads handles buttons 6 and 7 of the
HTML5 Standard Gamepad as a special case by doing:
`input->joy_axis(idx, (JoyAxis)b, s_btns[b]);`

This doesn't work because there is no JoyAxis 6 or 7 in the enum

To fix this we use JoyAxis::TRIGGER_LEFT and TRIGGER_RIGHT for button 6
and 7

However since we are now lying to input->joy_axis we also need to lie in
the mappings for the standard gamepad in godotcontrollersdb.txt,
otherwise input->joy_axis will try to find a mapping to axis 4(LT) and
axis 5(RT) that's not defined.

Therefore we set lefttrigger to +a4 and righttrigger to +a5 in the
mapping, to match what we are actually sending.

A cleaner, and more involved fix to this would be modifying
input->joy_button so that it can handle analog buttons and map them to
axes preserving their value instead of converting to boolean
2024-08-14 16:13:16 -03:00
Rémi Verschelde 59737bf3f0
Merge pull request #94413 from rburing/fix_action_press_tick
Fix physics tick count in `Input.action_press` and `Input.action_release`
2024-07-17 11:44:31 +02:00
Rémi Verschelde 496fd12b17
Merge pull request #94052 from m4gr3d/clean_input_dispatch_settings
Cleanup Android input on render thread settings
2024-07-17 11:42:52 +02:00
Ricardo Buring b41ec93d63 Fix physics tick count in Input.action_press and Input.action_release
The physics tick count was not yet updated there.
2024-07-16 00:31:44 +02:00
Fredia Huya-Kouadio 5e59819727 Cleanup Android input on render thread settings
Follow up to https://github.com/godotengine/godot/pull/93933
Clean up the set of settings use to control whether Android input should be dispatched on the render thread.

Addresses comments in https://github.com/godotengine/godot/pull/93933#issuecomment-2210437977
2024-07-09 09:15:18 -07:00
Mikael Hermansson 085f0cc50a Add Home/End to text caret movements on macOS 2024-07-08 16:08:27 +02:00
Ricardo Buring 23521635d2 Fix physics tick counter
The counter is now incremented at the start of a physics tick rather than at the end.

Co-authored-by: lawnjelly <lawnjelly@gmail.com>
2024-07-07 19:04:05 +02:00
Rémi Verschelde 62120c7841
Fix Steam input "crc" errors, and some other Coverity reports of uninitialized scalar variable
- Fixes #88630.
- Fixes #92578.
2024-05-31 09:55:02 +02:00
Rémi Verschelde be2c5e66f4
Merge pull request #92201 from bruvzg/input_flush
Clean `Input::frame_parsed_events` before de-initialising scripting languages to ensure no script created events exist at the exit.
2024-05-30 15:41:56 +02:00
kobewi 17d3f26e5d Add event_index to InputEventAction 2024-05-30 12:51:15 +02:00
bruvzg 2c9df769ad
Clean Input::frame_parsed_events before de-initialising scripting languages to ensure no script created events exist at the exit. 2024-05-30 13:23:00 +03:00
Jakub Marcowski d9f8ef68df
Update pre-commit hooks configuration to use `ruff` instead of `black` 2024-05-21 18:02:29 -05:00
Rémi Verschelde 1069d7b7c6
Merge pull request #88343 from Riteo/warped-mouse-float
Handle warped mouse motion as floating point
2024-05-06 15:14:46 +02:00
Radiant 789c6ebdfd Implement `amplitude` to Input.vibrate_handheld
Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com>
Co-authored-by: m4gr3d <m4gr3d@users.noreply.github.com>
2024-05-02 19:09:42 +03:00
Rémi Verschelde 1da02fa7be
Sync controller mappings DB with SDL 2 community repo
Synced with mdqinc/SDL_GameControllerDB@5b4efa3a20
2024-04-24 11:55:55 +02:00
Rémi Verschelde 6772047e50
Sync controller mappings DB with SDL 2 community repo
Synced with mdqinc/SDL_GameControllerDB@4c9b8dace8
2024-04-08 22:22:30 +02:00
Mark Wilson 41e70db8b1 Fix action_press() by clamping strength to 0, 1
Changed Input.action_press() treatment of strength parameter to match
behavior of InputEventAction and documentation, by clamping between 0
and 1. Fixes Input.get_action_strength() returning values over 1 when
large values are passed to Input.action_press().
2024-03-27 11:17:40 -04:00
Rémi Verschelde f371b7fb70 Merge pull request #87883 from TontonSancho/text-skip-occurence
Add 'Skip to next (text) occurrence' feature to text editor
2024-03-25 13:15:56 +01:00
Christophe Andral c988bec4b3 Add 'Skip to next (text) occurrence' feature to text editor
Adds `ui_text_skip_selection_for_next_occurrence` action and related implementation to text editor.
This action is bound `Ctrl+Alt+D` shorcut.

Used in conjonction with `ui_add_skip_selection_for_next_occurrence`, it gives the user the ability to select many occurrences of a selection
and avoid some of them.
Used without a previous selection, the action jumps to the next occurrence of the current word under the caret.
2024-03-25 11:12:28 +01:00
A Thousand Ships 4933fa8bf5
[Buildsystem] Fix encoding when reading files 2024-03-24 18:02:56 +01:00
Hugo Locurcio 6818e50adc Expose `DEVICE_ID_EMULATION` constant in InputEvent
This also improves the documentation related to emulated InputEvents.
2024-03-16 19:16:40 +01:00
Thaddeus Crews 5a6e3cbcb0
SCons: Remove `run_in_subprocess` dependency 2024-03-11 13:20:09 -05:00
Thaddeus Crews fb299d0fb1
SCons: Ensure `with` statement where applicable 2024-03-10 12:57:57 -05:00
Thaddeus Crews d9fa40f2df
Enforce `\n` eol for Python writes
• Ensure utf-8 encoding if previously unspecified
2024-03-09 14:29:24 -06:00
Thaddeus Crews 0ce9b6fd1d
Add two new COMSTR environment variables 2024-03-01 12:44:03 -06:00
Micky 70b428041b Add autocompletion for InputMap's methods 2024-03-01 16:44:26 +01:00
Micky cd2032a90b Optimise Object's `get_argument_options` 2024-02-29 18:00:54 +01:00
Riteo 759a32eb0c Handle warped mouse motion as floating point
Fixes certain issues where sub-pixel motions would get discarded while
the mouse is captured, such as when free look is enabled in the editor
(at least when turned on while holding right click).

Very slightly compat breaking, as actual public APIs are changed,
although with "compatible" types (Point2i->Point2).
2024-02-14 22:37:51 +01:00
Muller-Castro a8bc9f3e78 Add const lvalue ref to core/* container parameters 2024-02-14 11:20:36 -03:00
Markus Sauermann 2235a1cbd0 Add screen-related attributes to mouse input events 2024-02-05 23:30:15 +01:00
Rémi Verschelde 10445d80d8
Sync controller mappings DB with SDL2 community repo
Synced with gabomdq/SDL_GameControllerDB@232c738ce0
2024-01-30 15:14:27 +01:00
Mel Collins 8406e60522 Add InputEventKey.location to tell left from right
This adds a new enum `KeyLocation` and associated property
`InputEventKey.location`, which indicates the left/right location of key
events which may come from one of two physical keys, eg. Shift, Ctrl.

It also adds simulation of missing Shift KEYUP events for Windows.
When multiple Shifts are held down at the same time, Windows natively
only sends a KEYUP for the last one to be released.
2024-01-26 14:42:28 +01:00
Yuri Sizov 2ababdcc06 Merge pull request #87324 from jsjtxietian/action-exist
Check action exists in `Input.action_press` and `action_release`
2024-01-18 19:27:06 +01:00
jsjtxietian 4b3a12f4ee Check action exists in `Input.action_press` and `action_release` 2024-01-18 16:18:16 +08:00
Rémi Verschelde 0a7579b161
Fix `#if *_ENABLED` inconsistencies, should check if defined
Co-authored-by: Caroline Joy Bell <halotroop2288@proton.me>
2024-01-17 10:30:15 +01:00
Rémi Verschelde 6c390b620d
Merge pull request #84445 from Rubonnek/add-const-references-clang-tidy
Add const references detected by clang-tidy
2024-01-04 14:25:33 +01:00
Micky ca2f340384 Fix missing autocompletion for inheriting classes 2024-01-03 00:13:04 +01:00
Wilson E. Alvarez a3cb1b096f
Add const references detected by clang-tidy 2023-12-16 13:36:44 -05:00
CaTaTo 075a54bbcf Add bindings for setting and getting emulation mouse from touch and touch from mouse in input 2023-12-13 08:07:36 +03:00
Gilles Roudière 8cfcd36253 Rework action pressed state to support multiple controllers 2023-12-04 18:02:51 +01:00
kobewi d9d0cfaf38 Rework input actions to be reliable 2023-11-10 15:24:04 +01:00
Rémi Verschelde d3c0a7d598
Sync controller mappings DB with SDL2 community repo
Synced with gabomdq/SDL_GameControllerDB@eb831f75ab

Fixes #83552.
2023-10-23 16:11:38 +02:00
Rémi Verschelde e6e9b04aab
Merge pull request #81322 from johnnyw/android_fix_joypad_trigger_range
Android: Fix joypad trigger value range
2023-10-20 22:02:00 +02:00
John Watson d413a02079 Android: Fix joypad trigger value range
`Input::joy_axis` converts trigger values to be between 0.0f to 1.0f by default. This is not needed for Android, as values are already within that range, as per Android documentation: https://developer.android.com/reference/android/view/MotionEvent#AXIS_RTRIGGER

This patch prevents this conversion on Android, which caused L2 and R2 triggers to get stuck pressed. https://github.com/godotengine/godot/issues/79263
2023-10-20 11:30:20 -07:00
ErezShahaf ccb8ea613a
Fix `Input.is_action_just_pressed` flicker on joypad axes
Pressed tick assignments were in the wrong scope, resulting in updating
`pressed_frame` even when it shouldn't and therefore the `just_pressed`
would return true every time that the strength changes and not only when
there's a new valid press.

Fixes #81975.
2023-10-16 11:41:56 +02:00
Rémi Verschelde 0b4959bdf0
Merge pull request #82203 from KoBeWi/shortcuts_under_pressure
Make InputEventShortcut always pressed
2023-09-24 23:36:09 +02:00
Rémi Verschelde e40b0b3ed8
Sync controller mappings DB with SDL2 community repo
Synced with gabomdq/SDL_GameControllerDB@fc4b33c872
2023-09-24 15:51:12 +02:00
kobewi 90a0b19301 Make InputEventShortcut always pressed 2023-09-23 19:43:07 +02:00
Rémi Verschelde 5f5ca23586
Merge pull request #81170 from KoBeWi/step_input
Prevent axis-based actions from getting stuck
2023-09-11 15:37:42 +02:00
Rémi Verschelde 8de6405288
UWP: Remove platform port, needs to be redone from scratch for 4.x
The UWP platform port was never ported to the Godot 4.0+ API,
and it's now accumulating bitrot as it doesn't compile, and thus
we no longer propagate platform changes in it.

So we finally remove to acknowledge this state. There's still some
interest in reviving the UWP port eventually, especially as support
for Direct3D 12 will soon be merged, but when that happens it will
be easiest to redo it from scratch.
2023-09-07 15:01:59 +02:00