Commit Graph

344 Commits

Author SHA1 Message Date
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 e92393d295
Merge pull request #67783 from EricEzaM/67715-input-event-action-as-text
Make InputEventAction as_text() return the text of the first valid event for the action.
2023-01-27 10:30:00 +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 57b5d112f7
[Input] Do not add key labels to the default actions, to display it correctly in the UI. 2023-01-24 14:49:11 +02: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
Rémi Verschelde 91a54cdbc1
Linux/BSD: Add LINUXBSD_ENABLED define for non X11-related checks 2023-01-16 17:01:35 +01:00
Eric M 7b66806dd3 Make InputEventAction as_text() return the text of the first valid event for the action. 2023-01-12 00:10:44 +10: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
Rémi Verschelde 5f35b1d516
Sync controller mappings DB with SDL2 community repo
Synced with gabomdq/SDL_GameControllerDB@adf7ec1edf
2022-12-12 13:43:15 +01:00
Rémi Verschelde 5d20dccade
Add MAKE_RESOURCE_TYPE_HINT macro to simplify binding arrays of resources 2022-11-24 14:06:00 +01: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
alcomposer 73db3b67df add controller_number & controller_value to allow printing of all MIDI event data 2022-11-14 21:55:43 +10:30
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
Alfred Reinold Baudisch a862583d05 Unified shortcut to clear carets and selections
Refactors`ui_text_remove_secondary_carets` from https://github.com/godotengine/godot/pull/68089 as `ui_text_clear_carets_and_selection`, with extra behaviour:

- If there's only one active caret active with a selection, clears the selection.
- In case there's more than one caret active, removes the secondary carets and clears selections.

With this change, `TextEdit` then imitates the behaviour of VSCode for clearing carets and selections.
2022-11-02 18:23:24 +01:00
Alfred Reinold Baudisch fcff978763 Shortcut and Bind to Remove Secondary Carets
Adds the bind `ui_text_remove_secondary_carets` to TextEdit, with ESC as the default shortcut.

When the bind is performed, if the TextEdit has multiple carets, `remove_secondary_carets` is called and secondary carets are removed.

This is useful when multiple selects are performed with `add_select_for_next_occurrence` #67644 or when multiple multiple carets are manually added, then it's possible to go back to a single caret with a shortcut.

Closes #67991
2022-10-31 17:44:47 +01:00
Rémi Verschelde 5947f22be9
Merge pull request #67578 from KoBeWi/GEDITOR
Unify usage of GLOBAL/EDITOR_GET
2022-10-31 13:15:58 +01:00
Rémi Verschelde 273410ba5a
Merge pull request #67139 from PucklaMotzer09/insert_caret_at_carets
Add Caret Insert Below and Above shortcuts to TextEdit
2022-10-31 10:32:07 +01:00
Clay John 0486810697
Merge pull request #67644 from alfredbaudisch/add-selection-next-occurrence
Add Selection and Caret for Next Occurrence of Selection
2022-10-27 17:21:49 -07: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
Alfred Reinold Baudisch 7d15ecc3af Add Selection and Caret for Next Occurrence of Selection
Adds the bind `add_selection_for_next_occurrence` to TextEdit, with CTRL+D as the default shortcut.

When the bind is performed, ff a selection is currently active with the last caret in text fields, searches for the next occurrence of the selection, adds a caret and selects the next occurrence.

If no selection is currently active with the last caret in text fields, selects the word currently under the caret.

The action can be performed sequentially for all occurrences of the selection of the last caret and for all existing carets. The viewport is adjusted to the latest newly added caret.

The bind and the behaviour is similar to VS Code's "Add Selection to Next Find Match" and JetBrains' "Add Selection for Next Occurrence". It takes advantage of the multi-caret API.

The default shortcut for `select_word_under_caret` has been changed to ALT+G, in order to give priority to CTRL+D for `add_selection_for_next_occurrence` to better align with popular IDEs and editors.
2022-10-21 08:26:53 +02:00
kobewi e48c5daddf Unify usage of GLOBAL/EDITOR_GET 2022-10-18 19:01:48 +02:00
PucklaMotzer09 e5354cacd0 Add Caret Insert Below and Above shortcuts to TextEdit 2022-10-18 10:38:53 +02: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
Fabio Alessandrelli 0fe0505f77 [Web] Add PS3 gamepad mapping for FF+Linux. 2022-10-03 13:06:50 +02:00
Jiri Suchan c5bd2f9dce ci: add Python static analysis check via mypy 2022-09-30 19:03:17 +07:00
Rémi Verschelde b33460c6ca Sync controller mappings DB with SDL2 community repo
Synced with gabomdq/SDL_GameControllerDB@81ddc73d17
2022-09-27 23:48:25 +02:00
Rémi Verschelde f3d763011f Merge pull request #63109 from OverloadedOrama/fix-input-event-action
Fix `InputEventAction`'s `is_match` method ignoring `exact_match` parameter
2022-09-25 11:06:38 +02:00
bruvzg 6f4d233062
Fix key mapping changes when moving from macOS to other platform
Removes separate `Command` key (use `Meta` instead).
Adds an event flag to automatically remap `Command` <-> `Control` (cannot be set alongside `Control` or `Meta`).
2022-09-07 18:45:35 +02:00
Andres Hernandez 9054399900 Updated gamecontrollerdb.txt to latest to include new mappings for various controllers, including Xbox One, Nintendo Switch, Steam Deck, and 8BitDo 2022-09-05 22:14:59 -07: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
Fabio Alessandrelli d20b32186f [Web] Rename JavaScript platform to Web.
Also rename export name from "HTML5" to "Web".
2022-08-29 11:52:00 +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
kobewi 1abdffe7a0 Replace Array return types with TypedArray 2 2022-08-23 23:21:32 +02:00
Rémi Verschelde 3f3ade9e5b
Merge pull request #64732 from RandomShaper/input_is_final
Consolidate the fact that `Input` is meant to be final
2022-08-23 08:53:49 +02:00
Yuri Sizov 1a24c9e14b Make `_validate_property` a multilevel method 2022-08-22 18:35:11 +03: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
Marcel Admiraal 61be617571 Fix axis mapped to DPad buttons not releasing opposite button 2022-08-17 09:12:47 +01:00
Haoyu Qiu 660c700f9c Fix action name completion for `Input` 2022-08-15 23:28:49 +08:00
Haoyu Qiu e061b1cc3c Use %s for bool value in vformat 2022-08-07 09:57:09 +08:00
Rémi Verschelde 86647c9e42 Sync controller mappings DB with SDL2 community repo
Synced with gabomdq/SDL_GameControllerDB@4896d2de6b
2022-08-05 02:59:03 +02:00
Fabio Alessandrelli 55845bac26 Fix some array size function definition mismatch. 2022-08-04 13:06:17 +02:00
Rémi Verschelde 90019676b0 Code quality: Fix header guards consistency
Adds `header_guards.sh` bash script, used in CI to validate future
changes. Can be run locally to fix invalid header guards.
2022-07-25 11:17:40 +02:00
bruvzg 8823eae328
Rename OSX to macOS and iPhoneOS to iOS. 2022-07-21 09:37:52 +03:00
Rémi Verschelde b70e4fc0f3 Sync controller mappings DB with SDL2 community repo
Synced with gabomdq/SDL_GameControllerDB@880abd09c9
2022-07-18 15:42:48 +02:00
Emmanouil Papadeas 38b51942d6 Fix `InputEventAction`'s `is_action` method ignoring `exact_match` parameter 2022-07-17 17:20:37 +03:00
Rémi Verschelde 344b42703b
Merge pull request #62212 from hansemro/eraser-detect-4
Add inversion/eraser-end property for tablet pens
2022-07-04 21:48:19 +02:00
Hansem Ro 6dcc9d1131 [macOS, Windows, X11] Add stylus inverted/eraser support to
InputEventMouseMotion event
2022-07-04 10:36:53 -07:00
Rémi Verschelde 00b3822306 Input: Re-enable input accumulation by default
I turned it off by mistake in #38697.
See also #62664 for details on this boolean's complex history :)
2022-07-03 12:16:16 +02:00
Marco F 0efa5d4cbd Input: Make `get_action_raw_strength` print error when the action doesn't exist 2022-06-28 15:58:26 +02:00
FireForge 4678736a39 Add suffixes to all nodes and resources 2022-06-11 09:41:05 -05:00
Rémi Verschelde ecde7ce834
Merge pull request #61669 from fire-forge/input
Make Input `mouse_mode` and `use_accumulated_input` properties
2022-06-04 15:52:34 +02:00
FireForge f16c33fff6 Make Input mouse_mode and use_accumulated_input properties 2022-06-03 14:19:38 -05:00
Raul Santos 3e53afd52c
Add array element type to `get_connected_joypads` 2022-06-03 20:37:46 +02:00
reduz 45af29da80 Add a new HashSet template
* Intended to replace RBSet in most cases.
* Optimized for iteration speed
2022-05-20 22:40:38 +02:00
reduz 746dddc067 Replace most uses of Map by HashMap
* Map is unnecessary and inefficient in almost every case.
* Replaced by the new HashMap.
* Renamed Map to RBMap and Set to RBSet for cases that still make sense
  (order matters) but use is discouraged.

There were very few cases where replacing by HashMap was undesired because
keeping the key order was intended.
I tried to keep those (as RBMap) as much as possible, but might have missed
some. Review appreciated!
2022-05-16 10:37:48 +02:00
reduz 8b7c7f5a75 Add a new HashMap implementation
Adds a new, cleaned up, HashMap implementation.

* Uses Robin Hood Hashing (https://en.wikipedia.org/wiki/Hash_table#Robin_Hood_hashing).
* Keeps elements in a double linked list for simpler, ordered, iteration.
* Allows keeping iterators for later use in removal (Unlike Map<>, it does not do much
  for performance vs keeping the key, but helps replace old code).
* Uses a more modern C++ iterator API, deprecates the old one.
* Supports custom allocator (in case there is a wish to use a paged one).

This class aims to unify all the associative template usage and replace it by this one:
* Map<> (whereas key order does not matter, which is 99% of cases)
* HashMap<>
* OrderedHashMap<>
* OAHashMap<>
2022-05-12 11:21:29 +02:00
Rémi Verschelde 30fbb8964d Sync controller mappings DB with SDL2 community repo
Synced with gabomdq/SDL_GameControllerDB@b7d126eb71
2022-05-05 14:12:55 +02:00
Hugo Locurcio 180e5d3028
Remove `RES` and `REF` typedefs in favor of spelled out `Ref<>`
These typedefs don't save much typing compared to the full `Ref<Resource>`
and `Ref<RefCounted>`, yet they sometimes introduce confusion among
new contributors.
2022-05-03 01:43:50 +02:00
Rémi Verschelde c273ddc3ee Style: Partially apply clang-tidy's `cppcoreguidelines-pro-type-member-init`
Didn't commit all the changes where it wants to initialize a struct
with `{}`. Should be reviewed in a separate PR.

Option `IgnoreArrays` enabled for now to be conservative, can be
disabled to see if it proposes more useful changes.

Also fixed manually a handful of other missing initializations / moved
some from constructors.
2022-05-02 16:28:25 +02:00
Paulb23 5e4e4967fe Use Input::push_input for tests plus extra mouse testing 2022-04-22 17:39:12 +01:00
Rémi Verschelde bd9ba4bd10
Merge pull request #60208 from Magorx/input-set-custom-mouse-cursor-fix
Added p_shape check to avoid engine crash in DisplayServer
2022-04-14 00:12:51 +02:00
KingCakeTheFruity 29a2809d21 Added p_shape check to avoid engine crush 2022-04-13 14:50:30 +03:00
bruvzg f851c4aa33
Fix some issues found by cppcheck. 2022-04-06 14:34:37 +03:00
Rémi Verschelde 7119d355eb String: Remove TTR and DTR defines in non-tools build
This ensures we don't use TTR in runtime code, as it's specifically meant
to source translations for the editor.
2022-03-28 20:26:35 +02:00
Markus Sauermann 0494e024d8 Rename warp mouse functions to warp_mouse 2022-03-27 14:12:01 +02:00
Marcel Admiraal ea20049afc Ensure minimum modifiers are pressed when matching actions 2022-03-20 08:02:54 +00:00
Haoyu Qiu d1ca29cd8c Remove `TTRC()` with empty string
Fixes "duplicate message definition" when extracting messages.
2022-03-02 17:02:10 +08:00
Rémi Verschelde e3d89a76f7 Sync controller mappings DB with SDL2 community repo
Synced with gabomdq/SDL_GameControllerDB@94b76208bc
2022-02-20 12:20:17 +01:00
Powerbyte7 b8a7ea034c
[HTML5] Add Stadia controller to database
Add web support for the Stadia controller.
2022-02-19 23:01:41 +01:00
Rémi Verschelde b8b4580448
Style: Cleanup single-line blocks, semicolons, dead code
Remove currently unused implementation of TextureBasisU, could be re-added
later on if needed and ported.
2022-02-16 14:06:29 +01:00
Rémi Verschelde bf0253bab9
Merge pull request #56764 from madmiraal/fix-45592-2 2022-02-03 18:10:30 +01:00
Nathan Franke 8a0a3accee
simplify formatting scripts, add a clang-tidy script, and run clang-tidy 2022-01-29 04:41:03 -06:00
Rémi Verschelde d74d4cbdff
Merge pull request #54173 from nathanfranke/fix-exact-match 2022-01-26 13:35:36 +01:00
Nathan Franke dc1c4cfbfa
Fix action exact match 2022-01-24 05:55:37 -06:00
Rémi Verschelde 57a057f7ff
Merge pull request #56754 from madmiraal/fix-45592 2022-01-24 10:05:42 +01:00
Andrii Doroshenko (Xrayez) 5d17fe7d0f Add `Input.is_anything_pressed` method 2022-01-20 20:55:14 +02:00
Marcel Admiraal f41c72c538 Fix Actions mapped to triggers not using the full range 2022-01-14 15:36:20 +00:00
Marcel Admiraal 5c3600b29f Fix mouse velocity not changing fast enough
- Uses all accumulated movements when calculating velocity
- Discards old accumulated movements
- Sets last mouse velocity to zero when there is no movement
2022-01-13 18:51:34 +00:00
Marcel Admiraal 5250cdd150 Use mouse event relative motion to calculate mouse velocity 2022-01-13 15:23:21 +00:00
Rémi Verschelde 46624388d4
Merge pull request #56322 from madmiraal/fix-42450 2022-01-11 11:33:59 +01:00
bruvzg 61ea8f8337
Add joystick button index boundary check. Increase max. button number to 128 (max. buttons supported by DirectInput). 2022-01-10 14:39:05 +02:00
Aaron Franke de9adcf045
Document InputEventMIDI and add some missing 0xF MIDI messages 2022-01-04 05:30:43 -08:00
Rémi Verschelde fe52458154
Update copyright statements to 2022
Happy new year to the wonderful Godot community!
2022-01-03 21:27:34 +01:00
Marcel Admiraal 3105d9b1f3 Rename speed to velocity when it's a directional Vector 2021-12-29 15:35:26 +00:00
Marcel Admiraal 39136ce3e0
Revert "Fixed event spam when using the Nintendo Switch controller" 2021-12-17 17:14:07 +00:00
Rémi Verschelde ed395c6b99
Sync controller mappings DB with SDL2 community repo
Synced with gabomdq/SDL_GameControllerDB@265b43b789.
2021-12-17 00:14:44 +01:00
Sam Lantinga 313815f818 Fixed event spam when using the Nintendo Switch controller
There is no filtering on the Nintendo Switch Pro controller thumbstick, so there will frequently be events with very slight change. These are turned into "not pressed" events, which cancel "pressed" events from keys and buttons.

This change filters out up to 5% jitter, but it might be worth revisiting whether "not pressed" events should cancel "pressed" events.
2021-12-16 09:04:58 -08:00
Rémi Verschelde 03e105f677
Sync controller mappings DB with SDL2 community repo
Synced with gabomdq/SDL_GameControllerDB@348cfa347f.
2021-12-10 10:59:30 +01:00
Nathan Franke 49403cbfa0
Replace String comparisons with "", String() to is_empty()
Also:
- Adds two stress tests to test_string.h
- Changes to .empty() on std::strings
2021-12-09 04:48:38 -06:00
kobewi cb2bdcd286 Unexpose joy_connection_changed method 2021-12-06 13:10:17 +01:00
Lightning_A e078f970db Rename `remove()` to `remove_at()` when removing by index 2021-11-23 18:58:57 -07:00
bruvzg 9877d91c4a
Add Input.is_physical_key_pressed method. 2021-11-23 11:14:19 +02:00
Hugo Locurcio 8fb7e622a6
Rename built-in `SGN()` macro to `SIGN()`
This matches the name of the GDScript function (except it's uppercase
here).
2021-11-16 20:40:49 +01:00
Aaron Franke 3c0fdcc8ac
Use "enum class" for input enums 2021-11-12 15:37:54 -06:00
Rémi Verschelde 4b247e7ffa
Sync controller mappings DB with SDL2 community repo
Synced with gabomdq/SDL_GameControllerDB@322aac4bb7.

Also improve parser errors to allow identifying the problematic mappings.
2021-11-03 19:55:52 +01:00
Rémi Verschelde 3a6be64c12
clang-format: Various fixes to comments alignment from `clang-format` 13
All reviewed manually and occasionally rewritten to avoid bad auto formatting.
2021-10-28 15:43:36 +02:00
Rémi Verschelde 3b11e33a09
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 15:19:35 +02:00
Rémi Verschelde 6c35e74228
Merge pull request #53812 from RandomShaper/expose_flush_input 2021-10-22 17:20:33 +02:00
Pedro J. Estébanez 6dc3fae201 Expose Input::flush_buffered_events() 2021-10-22 14:28:48 +02:00
Marcel Admiraal 87a4ba492e Remove unimplemented methods 2021-10-21 18:44:25 +01:00
bruvzg a975682ef6 Fix handling multiple "physical key" events in the single input map action. 2021-10-19 22:19:41 +03:00
Rémi Verschelde f4d9749e23
Merge pull request #53741 from DmitriySalnikov/exposed_sensor_setters_master 2021-10-18 23:00:56 +02:00
Rémi Verschelde c133480531
SCons: List `.gen.cpp` sources explicitly to avoid globbing errors
Whenever we change the name (or remove) generated cpp files with the `.gen.cpp`
extension, users run into build issues when switching between branches (i.e.
switching before and after the name change/removal). This is because we glob
`*.cpp` so if a now-obsolete file from a previous build is present, we'll
include it too, potentially leading to bugs or compilation failure (due to
missing headers or invalid code).

So globbing patterns in `add_source_files` will now skip files ending with
`.gen.cpp`, which should instead be passed explicitly where they're used.
2021-10-15 22:14:11 +02:00
Дмитрий Сальников 9b38e04fff Exposed setters for sensor values in Input class 2021-10-12 23:26:03 +03:00
Rémi Verschelde b85dfd990e
GDScript completion: Handle quote style ad-hoc to remove editor dependency
`core` and `scene` shouldn't depend on `editor`, so they can't query this style
setting in `get_argument_options`. But we can handle it after the fact in
GDScript's completion code.

Also cleans up a couple extra unused invalid includes in `core`.
2021-10-04 16:16:05 +02:00
Eric M ad30b0a8dd Allow shortcuts to have any number of bindings. Updated UI as required. 2021-10-01 18:04:28 +10:00
Lightning_A c63b18507d Use range iterators for `Map` 2021-09-30 15:09:12 -06:00
LATRio 41c1cfe28e InputEventJoypadMotion::set_axis - reject invalid axis 2021-09-30 19:32:21 +09:00
fabriceci e4cfcfc424 Replace auto completion shortcut for mac 2021-09-28 11:25:11 +02:00
LATRio eae7f1c1ae validate 'shortcut' in InputEventShortcut 2021-09-26 11:06:16 +09:00
Eric M 28b7c1be80 Improve implementation of builtin action overrides 2021-09-21 22:25:31 +10:00
Rémi Verschelde 07a58230ea
InputMap: Fixup `macos` feature tag overrides after #52291
Fixes #52691.
2021-09-15 11:48:54 +02:00
Hugo Locurcio 9b1986fb9c
Rename `osx` to `macos` in input map feature tag handling
This follows the general feature tag rename for 4.0.
2021-09-15 03:12:18 +02:00
Rémi Verschelde 70ba366743
Merge pull request #50375 from Paulb23/code_edit_unit_tests 2021-09-13 21:51:20 +02:00
Paulb23 d186862338 Fix InputMap and display server not nulling singleton on free 2021-09-01 16:46:04 +01:00
Hugo Locurcio 2daaf0fdc3
Make platform feature tag names lowercase
Feature tag names are still case-sensitive, but this makes built-in
feature tags more consistent.

- `Windows` -> `windows`
- `OSX` -> `osx`
- `LinuxBSD` -> `linuxbsd`
- `Android` -> `android`
- `iOS` -> `ios`
- `HTML5` -> `html5`
- `JavaScript` -> `javascript`
- `UWP` -> `uwp`
2021-08-31 20:34:44 +02:00
Max Hilbrunner ae306665d3
Merge pull request #51750 from jmb462/inputmap_action_suggestions
Adding InputMap action error suggestions for Input singleton (Fix #51634)
2021-08-23 15:19:20 +02:00
reduz 5cecdfa8af Entirely removes BIND_VMETHOD in favor of GDVIRTUAL
* `_gui_input`, `_input`, `_unhandled_input` and `_unhandled_key_input` are now regular C++ virutal functions.
* Everything else converted to GDVIRTUAL
* BIND_VMETHOD is gone, always use the new syntax from now on.

Creating `_gui_input` method and using the binder to register events will no longer work, simply override the virtual function now.
2021-08-23 08:10:13 -03:00
jmb462 a3b9842616 Adding InputMap action error suggestion for Input singleton 2021-08-16 20:54:37 +02:00
Mai Lavelle ce43781cb3 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-16 00:53:01 -04:00
Rémi Verschelde 81512a3732
Style: Cleanup code using `text_editor/completion/use_single_quotes` 2021-08-13 21:27:57 +02:00
Pedro J. Estébanez dc187324be 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-13 11:19:19 +02:00
Pedro J. Estébanez 7c864d41c9 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-13 11:19:19 +02:00
Aaron Franke fa3a32a2d6
Use Key enum instead of plain integers 2021-08-10 16:26:55 -05:00
Bhuvan Vemula a0a019a998 Added EditorCommandPalette 2021-08-09 17:41:50 +05:30
Julien Nguyen daee3c316f Fix action_get_events returning booleans instead of InputKey entries 2021-08-07 21:17:55 +02:00
Rémi Verschelde ac3322b0af
Use const references where possible for List range iterators 2021-07-25 12:22:25 +02:00
Aaron Franke 4e6efd1b07
Use C++ iterators for Lists in many situations 2021-07-23 17:38:28 -04:00
Aaron Franke 4147c67bb0
Fix Input get_action_raw_strength 2021-07-22 21:05:44 -04:00
Rémi Verschelde a98677181b
Sync controller mappings DB with SDL2 community repo
Synced with gabomdq/SDL_GameControllerDB@241fed0a44.
2021-07-20 13:08:50 +02:00
reduz 6631f66c2a Optimize StringName usage
* Added a new macro SNAME() that constructs and caches a local stringname.
* Subsequent usages use the cached version.
* Since these use a global static variable, a second refcounter of static usages need to be kept for cleanup time.
* Replaced all theme usages by this new macro.
* Replace all signal emission usages by this new macro.
* Replace all call_deferred usages by this new macro.

This is part of ongoing work to optimize GUI and the editor.
2021-07-18 21:20:02 -03:00
Fabio Alessandrelli 5717118bcc [HTML5] Add 2 controllers to the godot database.
Sony PlayStation DualShock 4 (054c:05c4 first gen).
Unofficial Switch controller.
2021-07-17 23:51:48 +02:00
Eric M c2ba7464b6 Added EditorInspectorPlugin to aid in editing InputEvents in resources and shortcuts 2021-07-06 23:50:33 +10:00
Nick H c6f28ed62b Add `get_dead_zone()` method to `InputMap`
This commit adds a new method to the `InputMap`, allowing the user to get the value of an action's dead zone as a float.
2021-07-02 03:07:37 -04:00
Aaron Franke 0ce49800ac
Use mouse and joypad enums instead of plain integers
Also MIDIMessage
2021-06-20 11:54:24 -04:00
Aaron Franke e919d894f8
Move many input enums to their own file 2021-06-20 11:53:01 -04:00
Lightning_A e28fd07b2b Rename `instance()`->`instantiate()` when it's a verb 2021-06-19 20:49:18 -06:00
Rémi Verschelde 4effadc0ba
Merge pull request #48696 from madmiraal/fix-48692
Fix `InputMap.action_erase_event()` failing to erase events correctly.
2021-06-20 00:29:42 +02:00
Gregory Basile 8ab13f8ace Documentation search fixes
Updates rich_text_label so that the built-in documentation can be searched
Previously, it would only find the first result and would not select other results
Renames "_entered" functions to "_submitted"
2021-06-16 09:43:34 -07:00
SpaghettiCoder01 5b81af09dc Added Input_Map entry for backspacing using Shift+Backspace 2021-06-15 04:30:49 +01:00
Haoyu Qiu c727d40507 Fix `InputEventJoypadButton::as_text` crash for invalid button index 2021-06-13 13:53:11 +08: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
Paulb23 1c16673798 Move and expose AutoComplete in CodeEdit 2021-06-01 15:38:45 +01:00
Hugo Locurcio 80f4e407b2
Add a keyboard shortcut to select the word under cursor in TextEdit
This also acts as a general-purpose "deselect" shortcut since pressing
it a second time will deselect text.

This is available both in the script editor and in TextEdit fields
in use, both in the editor and projects.

The Duplicate Line script editor shortcut was moved to Ctrl + Shift + D
since it conflicts with the new shortcut (Ctrl + D). The rationale for
doing so is that Duplicate Line is a less commonly used action, and
its behavior can be replicated by copying and pasting the current line
anyway. (With no selection active, the whole line will be copied.)
2021-05-22 23:47:43 +02:00
Tomasz Chabora b1859510ab Change behavior of String.right 2021-05-20 23:07:57 +02:00