Commit graph

138 commits

Author SHA1 Message Date
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
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
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
jsjtxietian 4b3a12f4ee Check action exists in Input.action_press and action_release 2024-01-18 16:18:16 +08: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 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
kobewi a490fad82d Prevent axis-based actions from getting stuck 2023-09-04 15:47:26 +02:00
kobewi 5b95935e18 Remove debug print 2023-08-29 15:34:24 +02:00
kobewi ad1abca668 Fix action state when multiple events are assigned 2023-08-25 23:10:27 +02:00
Ricardo Subtil 1bb73b0689
Ensure joy_connection_changed is emitted on the main thread 2023-08-09 15:32:06 +01:00
Álex Román Núñez 3aa340d081 Add the ability to get per-platform information for joypads.
This adds the ability for games to obtain platform-specific information about joypads such as their vendor/product ID, their XInput gamepad index or the real name of the device before it gets swapped out by the gamecontrollerdb's name.

This PR also includes a rebased version of #76045, this is because this PR is intended to be mainly to help people implementing Steam Input, as having the gamepad index is essential.
2023-08-02 22:30:30 +02:00
Eoin O'Neill 8de98dbf21 Prevent double input events on gamepad when running through steam input
During GDC and general testing on Steam Deck units, we found that single
gamepads would often register inputs twice under certain circumstances.
This was caused by SteamInput creating a new virtual device, which Godot
registers as a second gamepad. This resulted in two gamepad devices
reporting the same button presses, often leading to buggy input response
on games with no multi-device logic and other-wise could cause intended
Steam rebindings to not work as intended (for example, swapping o and x
on a playstation pad if that feature isn't supported by the game.)

SDL gets around this by taking in a list of devices that are to be
ignored. When valve sees a controller that wants to be rebound via
SteamInput, they push a new VID/PID entry onto the environment
variable `SDL_GAMECONTROLLER_IGNORE_DEVICES` for the original gamepad
so that all game inputs can be read from the virtual gamepad instead.

This leverages the same logic as we are already using SDL gamepad
related HID mappings.
2023-07-10 15:26:33 -07:00
Rémi Verschelde 6fb391bc23
Fix various typos with codespell
And ignore some false positives introduced by recent versions of codespell.
2023-06-16 08:45:35 +02:00
Rémi Verschelde 35ff936b93
Merge pull request #77055 from lawnjelly/input_just_pressed_4
Input - fix just pressed and released with short presses
2023-06-12 14:13:52 +02:00
lawnjelly a3ef092f18 Input - fix just pressed and released with short presses
Previously if an action was both pressed and released on the same tick or frame, `is_action_just_pressed()` would return false, resulting in missed input.

This PR separately the timestamp for pressing and releasing so each can be tested independently.
2023-06-12 11:14:58 +01:00
Devan OBoyle ed02d515e0 Skip error messages for buttons that don't exist 2023-06-11 21:25:29 -07:00
Rémi Verschelde b0f49266f9
Merge pull request #76719 from m4gr3d/add_input_event_cancelled_state_main
Augment the `InputEvent` class with a `CANCELED` state
2023-05-17 11:25:21 +02:00
Fredia Huya-Kouadio 250749fa79 Augment the InputEvent class with a CANCELED state
The `InputEvent` class currently supports the `pressed` and `released` states, which given the binary nature, is represented by a `bool` field.
This commit introduced the `CANCELED` state, which signals that an ongoing input event has been canceled.
To represent all the states, the `InputEventState` enum is added and the `InputEvent` logic is refactored accordingly.
2023-05-15 11:48:25 -07:00
Fredia Huya-Kouadio 367061cf9c Follow up to https://github.com/godotengine/godot/pull/76399 to fix input ANR in the Godot Android editor 2023-05-11 19:06:03 -07:00
Pedro J. Estébanez f369ed9223 Allow concurrent buffering and dispatch of input events 2023-05-08 09:15:16 +02:00
Michael Alexsander 9a25d56ed9 Revert Input.get_vector() back to checking raw strength 2023-02-19 22:52:35 -03:00
Ricardo Subtil e841f13cdc Change message of unknown joypad property from error to warning 2023-02-13 14:30:57 +00:00
Ninni Pipping 29031700ba Perform early exit in Input::is_anything_pressed 2023-02-09 11:43:23 +01:00
Markus Sauermann 8748f4dcaa Fix mouse/drag/touch InputEvents having no device id
Some internally created emulated/instantiated events didn't have a
device id. This PR sets for these cases a device id.

Also rename `DEVICE_ID_TOUCH_MOUSE` to the more generic
`DEVICE_ID_EMULATION`.
2023-02-06 22:49:42 +01:00
Rémi Verschelde 394bb0ee2b
Fix various typos with codespell
Finally do the childs -> children rename too.
2023-02-01 08:45:41 +01:00
Rémi Verschelde 534369d267
Merge pull request #64423 from RandomShaper/safe_input_synth
Warn users about unsafe usage of `InputEvent`
2023-01-31 15:56:43 +01:00
Pedro J. Estébanez a2af839a59 Warn users about unsafe usage of InputEvent 2023-01-31 14:39:51 +01:00
Rémi Verschelde 93c650c10d
Merge pull request #69028 from YeldhamDev/its_raw_you_donkey
Make `Input.get_vector()` check for plain `strength` instead of the raw one
2023-01-25 09:15:45 +01:00
bruvzg daad4aed62
Cleanup and unify keyboard input.
- Unify keycode values (secondary label printed on a key), remove unused hardcoded Latin-1 codes.
- Unify IME behaviour, add inline composition string display on Windows and X11.
- Add key_label (localized label printed on a key) value to the key events, and allow mapping actions to the unshifted Unicode events.
- Add support for physical keyboard (Bluetooth or Sidecar) handling on iOS.
- Add support for media key handling on macOS.

Co-authored-by: Raul Santos <raulsntos@gmail.com>
2023-01-23 15:08:12 +02:00
Juan Linietsky 2b815df3c1 Use BitField<> in core type masks
* All core types masks are now correctly marked as bitfields.
* The enum hacks in MouseButtonMask and many other types are gone. This ensures that binders to other languages non C++ can actually implement type safe bitmasks.
* Most bitmask operations replaced by functions in BitField<>
* Key is still a problem because its enum and mask at the same time. While it kind of works in C++, this most likely can't be implemented safely in other languages and will have to be changed at some point. Mostly left as-is.
* Documentation and API dump updated to reflect bitfields in core types.
2023-01-08 22:17:40 +01:00
Rémi Verschelde d95794ec8a
One Copyright Update to rule them all
As many open source projects have started doing it, we're removing the
current year from the copyright notice, so that we don't need to bump
it every year.

It seems like only the first year of publication is technically
relevant for copyright notices, and even that seems to be something
that many companies stopped listing altogether (in a version controlled
codebase, the commits are a much better source of date of publication
than a hardcoded copyright statement).

We also now list Godot Engine contributors first as we're collectively
the current maintainers of the project, and we clarify that the
"exclusive" copyright of the co-founders covers the timespan before
opensourcing (their further contributions are included as part of Godot
Engine contributors).

Also fixed "cf." Frenchism - it's meant as "refer to / see".
2023-01-05 13:25:55 +01:00
bruvzg 223a612c0c
[iOS] Add Apple Pencil pressure and tilt support. 2022-12-23 23:44:10 +02:00
Michael Alexsander a4e2978352 Make Input.get_vector() check for plain strength instead of the raw one 2022-11-22 18:18:56 -03:00
Rémi Verschelde f7c611ab71
Style: Misc docs and comment style and language fixes
- Removed empty paragraphs in XML.
- Consistently use bold style for "Example:", on a new line.
- Fix usage of `[code]` when hyperlinks could be used (`[member]`, `[constant]`).
- Fix invalid usage of backticks for inline code in BBCode.
- Fix some American/British English spelling inconsistencies.
- Other minor fixes spotted along the way, including typo fixes with codespell.
- Don't specify `@GlobalScope` for `enum` and `constant`.
2022-11-02 19:01:18 +01:00
Fredia Huya-Kouadio 13e4770b97 Add double_tap attribute to InputEventScreenTouch
This provides parity with the `InputEventMouseButton` allowing for proper conversion between the two events.
2022-10-22 07:30:46 -07:00
bruvzg 0103af1ddd
Fix MSVC warnings, rename shadowed variables, fix uninitialized values, change warnings=all to use /W4. 2022-10-07 11:32:33 +03:00
Rémi Verschelde 8812f0c896
Merge pull request #64444 from timothyqiu/action-completion
Fix action name completion for `Input`
2022-09-01 08:20:20 +02:00
Rémi Verschelde d0a2a4c981
Merge pull request #64531 from madmiraal/fix-63972-2
Fix axis mapped to DPad buttons not releasing opposite button
2022-08-24 20:10:29 +02:00
Pedro J. Estébanez 99edd4b43d Consolidate the fact that Input is meant to be final
This reverts #38034 and removes the `iteration()` method.
2022-08-22 14:37:25 +02:00