summaryrefslogtreecommitdiffstats
path: root/platform/linuxbsd/joypad_linux.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix copyright headers referring to GodotSpartan3222024-10-271-2/+2
|
* Rebrand preambles to RedotSpartan3222024-10-131-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | (cherry picked from commit e8542b06acca3c1bdeee4b528411771f0819f084) Credits: Co-authored-by: Skogi <skogi.b@gmail.com> Co-authored-by: Spartan322 <Megacake1234@gmail.com> Co-authored-by: swashberry <swashdev@pm.me> Co-authored-by: Christoffer Sundbom <christoffer_karlsson@live.se> Co-authored-by: Dubhghlas McLaughlin <103212704+mcdubhghlas@users.noreply.github.com> Co-authored-by: McDubh <103212704+mcdubhghlas@users.noreply.github.com> Co-authored-by: Dubhghlas McLaughlin <103212704+mcdubhghlas@users.noreply.github.com> Co-authored-by: radenthefolf <radenthefolf@gmail.com> Co-authored-by: John Knight <80524176+Tekisasu-JohnK@users.noreply.github.com> Co-authored-by: Adam Vondersaar <adam.vondersaar@uphold.com> Co-authored-by: decryptedchaos <nixgod@gmail.com> Co-authored-by: zaftnotameni <122100803+zaftnotameni@users.noreply.github.com> Co-authored-by: Aaron Benjamin <lifeartstudios@gmail.com> Co-authored-by: wesam <108880473+wesamdev@users.noreply.github.com> Co-authored-by: Mister Puma <MisterPuma80@gmail.com> Co-authored-by: Aaron Benjamin <lifeartstudios@gmail.com> Co-authored-by: SingleError <isaaconeoneone@gmail.com> Co-authored-by: Bioblaze Payne <BioblazePayne@gmail.com>
* Fix trackpads and graphics tablets being recognized as controllers on Linux/*BSDHugo Locurcio2024-07-061-0/+6
|
* Use `OS::delay_usec()` to avoid using deprecated `usleep()` on LinuxHugo Locurcio2024-05-211-3/+3
| | | | | | | | | usleep(3) was declared obsolete in POSIX.1-2001 and removed in POSIX.1-2008. nanosleep(2) was recommended to be used instead. `OS::delay_usec()` internally uses `nanosleep()`. This also uses large number separators for improved readability.
* Replace `find` with `contains/has` where applicableA Thousand Ships2024-05-081-3/+3
| | | | | | | * Replaces `find(...) != -1` with `contains` for `String` * Replaces `find(...) == -1` with `!contains` for `String` * Replaces `find(...) != -1` with `has` for containers * Replaces `find(...) == -1` with `!has` for containers
* [Linux/Freedesktop] Implement native file selection dialog support.bruvzg2023-08-171-23/+1
|
* Add the ability to get per-platform information for joypads.Álex Román Núñez2023-08-021-1/+24
| | | | | | 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.
* Merge pull request #76045 from Eoin-ONeill-Yokai/steaminput-fixYuri Sizov2023-07-121-4/+10
|\ | | | | | | Prevent double input events on gamepad when running through steam input
| * Prevent double input events on gamepad when running through steam inputEoin O'Neill2023-07-101-4/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Linux: Fix build with `use_sowrap=no` and various warnings/errorsRémi Verschelde2023-07-101-9/+11
|/
* Build `JoypadLinux` sandbox detection method only with udevRiteo2023-05-251-0/+2
| | | | Fixes an `unused-function` warning when building with `udev=no`.
* Linux: Don't use udev for joypad hotloading when running in a sandboxRémi Verschelde2023-05-121-9/+39
| | | | | | | | | | | udev doesn't work in sandboxes, notably the new Steam container runtime as found notably on the Steam Deck, and in Flatpak/Snap packages. Like SDL does, when we detect such a containerized environment, we fall back to parsing `/dev/input` directly. See smcv's comments in #76879 for details. Fixes #76879.
* [Linux/BSD] Add dynamically loaded library version checks.bruvzg2023-03-201-1/+7
|
* [Linux] Make SO wrapper usage optional.bruvzg2023-02-161-0/+6
|
* Use BitField<> in core type masksJuan Linietsky2023-01-081-9/+15
| | | | | | | | * 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.
* One Copyright Update to rule them allRémi Verschelde2023-01-051-29/+29
| | | | | | | | | | | | | | | | | | | | 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".
* Fix burning CPU with udev disabled on Flatpaknyanpasu642022-12-031-1/+1
| | | Fixes #67355.
* Read and store joypad events in a separate thread on x11 platformMarcel Admiraal2022-05-051-162/+174
|
* Fix some issues found by cppcheck.bruvzg2022-04-061-1/+1
|
* Style: Cleanup single-line blocks, semicolons, dead codeRémi Verschelde2022-02-161-3/+3
| | | | | Remove currently unused implementation of TextureBasisU, could be re-added later on if needed and ported.
* Improve detection of gamepads on LinuxMai Lavelle2022-02-031-2/+3
| | | | Some devices (Nintendo Switch Right Joy-Con) report only a right stick.
* Fix Actions mapped to triggers not using the full rangeMarcel Admiraal2022-01-141-21/+5
|
* Update copyright statements to 2022Rémi Verschelde2022-01-031-2/+2
| | | | Happy new year to the wonderful Godot community!
* Rename `remove()` to `remove_at()` when removing by indexLightning_A2021-11-231-1/+1
|
* Use "enum class" for input enumsAaron Franke2021-11-121-7/+7
|
* Use mouse and joypad enums instead of plain integersAaron Franke2021-06-201-8/+8
| | | | Also MIDIMessage
* Move many input enums to their own fileAaron Franke2021-06-201-6/+6
|
* Style: Apply clang-tidy's `readability-braces-around-statements`Rémi Verschelde2021-04-051-2/+3
|
* Style: Apply clang-tidy's `modernize-use-nullptr`Rémi Verschelde2021-04-051-2/+2
|
* Rename some more global enums (Key, Joy, MIDI)Aaron Franke2021-03-231-4/+4
|
* An update to the dylibloader for older inttypesHein-Pieter van Braam-Stewart2021-02-201-1/+6
| | | | | | | | This #define's older inttypes to their newer versions and #includes <stdint.h> in the generated files. This will help with older glibc/compiler versions using headers generated on newer systems. This closes #46223
* Modernize atomicsPedro J. Estébanez2021-02-181-3/+3
| | | | | | | | | | - Based on C++11's `atomic` - Reworked `SafeRefCount` (based on the rewrite by @hpvb) - Replaced free atomic functions by the new `SafeNumeric<T>` - Replaced wrong cases of `volatile bool` by the new `SafeFlag` - Platform-specific implementations no longer needed Co-authored-by: Hein-Pieter van Braam-Stewart <hp@tmm.cx>
* Linux: Fix fallback logic when udev fails creating a contextRémi Verschelde2021-02-181-4/+6
| | | | Thanks to Noshyaar for pointing out the bug.
* Dynamically load libudev.so.1 on Linux if `udev=yes`Rémi Verschelde2021-02-171-10/+26
| | | | | | | | | | | | | | | | | | | This makes it possibly to run Linux binaries compiled with udev support on Linux systems which do not provide udev (typically systemd-less distros). If udev is missing, we fall back to parsing `/dev/input` like when compiled without udev support (`udev=no`). Also adding some verbose debug statements to know which method we're using when debugging Linux joypad issues. The libudev so wrappers were generated on Mageia 8 with libudev 246.9 using https://github.com/hpvb/dynload-wrapper: ``` ./generate-wrapper.py --include /usr/include/libudev.h --sys-include '<libudev.h>' \ --soname libudev.so.1 --init-name libudev --omit-prefix gnu_ \ --output-header libudev-so_wrap.h --output-implementation libudev-so_wrap.c ```
* Merge pull request #45315 from RandomShaper/modernize_threadRémi Verschelde2021-01-311-3/+2
|\ | | | | Modernize Thread
| * Modernize ThreadPedro J. Estébanez2021-01-291-3/+2
| | | | | | | | | | | | | | | | | | - Based on C++11's `thread` and `thread_local` - No more need to allocate-deallocate or check for null - No pointer anymore, just a member variable - Platform-specific implementations no longer needed (except for the few cases of non-portable functions) - Simpler for `NO_THREADS` - Thread ids are now the same across platforms (main is 1; others follow)
* | Go through all event devices, not just event[0-32]Jari Ronkainen2021-01-271-4/+15
|/ | | | | | | | | | | | | There are no guarantees that joypads are in event0-event32 range. Some devices, such as laptops with detachable keyboards and wacom can reserve events all the way up to 32. Some udev rules with e.g. custom controller firmwares may load the device as /dev/input/eventX, where X is greater than 32. This patch uses POSIX dirent to enumerate the event devices, so entries outside 0-32 range are not skipped.
* Update copyright statements to 2021Rémi Verschelde2021-01-011-2/+2
| | | | | | | | | | | | | | Happy new year to the wonderful Godot community! 2020 has been a tough year for most of us personally, but a good year for Godot development nonetheless with a huge amount of work done towards Godot 4.0 and great improvements backported to the long-lived 3.2 branch. We've had close to 400 contributors to engine code this year, authoring near 7,000 commit! (And that's only for the `master` branch and for the engine code, there's a lot more when counting docs, demos and other first-party repos.) Here's to a great year 2021 for all Godot users 🎆
* Initialize class/struct variables with default values in platform/ and editor/Rafał Mikrut2020-12-021-9/+0
|
* Fix for linux joypad D-pad zeroingConnor Lirot2020-11-111-4/+4
| | | | | | | | | | | | | | | | | | | | Some controllers (notably those made by 8bitdo) do not always emit an event to zero out a D-pad axis before flipping direction. For example, when rolling around aggressively the D-pad of an 8bitdo SN30 Pro/Pro+, the following may be observed: ``` ABS_HAT0X : -1 ABS_HAT0Y : -1 ABS_HAT0Y : 0 ABS_HAT0Y : 1 ABS_HAT0X : 1 ``` Notable here is that no event for `ABS_HAT0X: 0` is emitted between the events for `ABS_HAT0X: -1` and `ABS_HAT0X: 1`. Consequently, the game engine believes that both the negative _and_ positive x-axis directions of the D-pad are activated simultaneously (i.e `is_joy_button_pressed()` returns `true` for both `JOY_BUTTON_DPAD_LEFT` and `JOY_BUTTON_DPAD_RIGHT`), which should be impossible. This issue is _not_ reproducible on all controllers. The Xbox One controller in particular will not exhibit this problem (it always emits zeroing out events for an axis before flipping direction). The fix is to always zero out the opposite direction on the D-pad axis in question when processing an event with a nonzero value. This unfortunately wastes a small number of CPU cycles on controllers that behave nicely. **I have verified this issue is also reproducible in the stable 3.2 branch**
* Update Linux gamepad detection to match SDL.Marcel Admiraal2020-07-221-9/+2
|
* Style: Enforce braces around if blocks and loopsRémi Verschelde2020-05-141-10/+18
| | | | | Using clang-tidy's `readability-braces-around-statements`. https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html
* Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocksRémi Verschelde2020-05-141-30/+0
| | | | | | | | | | | | | | Which means that reduz' beloved style which we all became used to will now be changed automatically to remove the first empty line. This makes us lean closer to 1TBS (the one true brace style) instead of hybridating it with some Allman-inspired spacing. There's still the case of braces around single-statement blocks that needs to be addressed (but clang-format can't help with that, but clang-tidy may if we agree about it). Part of #33027.
* Style: clang-format: Disable AllowShortIfStatementsOnASingleLineRémi Verschelde2020-05-101-1/+2
| | | | | | | Part of #33027, also discussed in #29848. Enforcing the use of brackets even on single line statements would be preferred, but `clang-format` doesn't have this functionality yet.
* Rename InputFilter back to InputRémi Verschelde2020-04-281-11/+11
| | | | | | | | | | | | | | | | It changed name as part of the DisplayServer and input refactoring in #37317, with the rationale that input no longer goes through the main loop, so the previous Input singleton now only does filtering. But the gains in consistency are quite limited in the renaming, and it breaks compatibility for all scripts and tutorials that access the Input singleton via the scripting language. A temporary option was suggested to keep the scripting singleton named `Input` even if its type is `InputFilter`, but that adds inconsistency and breaks C#. Fixes godotengine/godot-proposals#639. Fixes #37319. Fixes #37690.
* Replace NULL with nullptrlupoDharkael2020-04-021-5/+5
|
* Refactored input, goes all via windows now.Juan Linietsky2020-03-261-11/+11
| | | | Also renamed Input to InputFilter because all it does is filter events.
* Effective DisplayServer separation, rename X11 -> LinuxBSDJuan Linietsky2020-03-261-0/+554