Commit graph

139 commits

Author SHA1 Message Date
Sam Lantinga e4face7c1d Fixed the share button on the ThrustMaster eSwap PRO Controller Xbox 2023-02-10 16:46:21 -08:00
Sam Lantinga 00e02de77b Fixed mis-detecting the share button on the Xbox controller over NDIS 2023-02-08 14:16:21 -08:00
Sylvain Becker cb6b8b0132
Simplify flags testing (#7220) 2023-02-03 13:08:42 -08:00
Sam Lantinga c4db0725e4 Enable paddles on the Xbox Elite controller when connected over USB 2023-01-20 09:31:22 -08:00
Sam Lantinga fde78d12f2 Updated copyright for 2023 2023-01-09 09:41:41 -08:00
Sam Lantinga aaaf7423ac Fixed build 2023-01-03 16:17:10 -08:00
Sam Lantinga 32c077216c Fixed warnings 2023-01-03 15:59:35 -08:00
Sam Lantinga 49af0d1b89 Fixed build 2023-01-03 15:35:18 -08:00
Sam Lantinga dacdb1c310 Added support for the ThrustMaster eSwap PRO Controller Xbox 2023-01-03 15:12:18 -08:00
Sam Lantinga 36d4395c97 SDL API renaming: internal functions 2022-12-27 15:05:51 -08:00
Sam Lantinga 659abc721a SDL API renaming: SDL_gamecontroller.h
SDL_gamecontroller.h has been renamed SDL_gamepad.h, and all APIs have been renamed to match.

Fixes https://github.com/libsdl-org/SDL/issues/6885
2022-12-27 09:47:24 -08:00
Sam Lantinga fc478c1bc0 SDL API renaming: SDL_joystick.h
Fixes https://github.com/libsdl-org/SDL/issues/6881
2022-12-27 05:50:46 -08:00
Sam Lantinga 63724c113b Removed the vi format comments from the source
Vim users can use the [editorconfig plugin](https://github.com/editorconfig/editorconfig-vim) to automatically set tab spacing for the SDL coding style.

Fixes https://github.com/libsdl-org/SDL/issues/6903
2022-12-26 11:17:23 -08:00
Sam Lantinga 5c29b58e95 Added support for clang thread-safety analysis
The annotations have been added to SDL_mutex.h and have been made public so applications can enable this for their own code.

Clang assumes that locking and unlocking can't fail, but SDL has the concept of a NULL mutex, so the mutex functions have been changed not to report errors if a mutex hasn't been initialized. We do have mutexes that might be accessed when they are NULL, notably in the event system, so this is an important change.

This commit cleans up a bunch of rare race conditions in the joystick and game controller code so now everything should be completely protected by the joystick lock.

To test this, change the compiler to "clang -Wthread-safety -Werror=thread-safety -DSDL_THREAD_SAFETY_ANALYSIS"
2022-12-14 09:53:39 -08:00
Sam Lantinga 73f4aeee6a Pass the event timestamp for joystick events
This allows the application to get more fine grained information about controller event timing, and group events that happened together.
2022-12-04 09:29:28 -08:00
Sam Lantinga 8121bbd083 Convert ticks to 64-bit, added nanosecond precision to the API
Fixes https://github.com/libsdl-org/SDL/issues/5512
Fixes https://github.com/libsdl-org/SDL/issues/6731
2022-12-02 12:37:41 -08:00
Pierre Wendling 3c501b963d
Clang-Tidy fixes (#6725) 2022-12-01 13:07:03 -08:00
Sam Lantinga 5750bcb174
Update for SDL3 coding style (#6717)
I updated .clang-format and ran clang-format 14 over the src and test directories to standardize the code base.

In general I let clang-format have it's way, and added markup to prevent formatting of code that would break or be completely unreadable if formatted.

The script I ran for the src directory is added as build-scripts/clang-format-src.sh

This fixes:
#6592
#6593
#6594
2022-11-30 12:51:59 -08:00
Sam Lantinga c5790359fd
Added precompiled header support for Visual Studio and Xcode (#6710)
Fixes https://github.com/libsdl-org/SDL/issues/6704
2022-11-29 18:34:15 -08:00
Sam Lantinga b5076ef5e3 Added support for the Xbox Elite controller paddles with firmware version 5.13+ 2022-11-28 23:15:23 -08:00
Sylvain Becker 6a2200823c
Cleanup add brace (#6545)
* Add braces after if conditions

* More add braces after if conditions

* Add braces after while() conditions

* Fix compilation because of macro being modified

* Add braces to for loop

* Add braces after if/goto

* Move comments up

* Remove extra () in the 'return ...;' statements

* More remove extra () in the 'return ...;' statements

* More remove extra () in the 'return ...;' statements after merge

* Fix inconsistent patterns are xxx == NULL vs !xxx

* More "{}" for "if() break;"  and "if() continue;"

* More "{}" after if() short statement

* More "{}" after "if () return;" statement

* More fix inconsistent patterns are xxx == NULL vs !xxx

* Revert some modificaion on SDL_RLEaccel.c

* SDL_RLEaccel: no short statement

* Cleanup 'if' where the bracket is in a new line

* Cleanup 'while' where the bracket is in a new line

* Cleanup 'for' where the bracket is in a new line

* Cleanup 'else' where the bracket is in a new line
2022-11-27 08:38:43 -08:00
Sam Lantinga 0a48abc860 Switch header convention from #include "SDL.h" to #include <SDL3/SDLh>
I ran this script in the include directory:
```sh
sed -i '' -e 's,#include "\(SDL.*\)",#include <SDL3/\1>,' *.h
```

I ran this script in the src directory:
```sh
for i in ../include/SDL3/SDL*.h
do hdr=$(basename $i)
   if [ x"$(echo $hdr | egrep 'SDL_main|SDL_name|SDL_test|SDL_syswm|SDL_opengl|SDL_egl|SDL_vulkan')" != x ]; then
        find . -type f -exec sed -i '' -e 's,#include "\('$hdr'\)",#include <SDL3/\1>,' {} \;
    else
        find . -type f -exec sed -i '' -e '/#include "'$hdr'"/d' {} \;
    fi
done
```

Fixes https://github.com/libsdl-org/SDL/issues/6575
2022-11-26 22:15:18 -08:00
Sam Lantinga cc1f9eb983 Use Apple's nomenclature for macOS and iOS
Fixes https://github.com/libsdl-org/SDL/issues/6621
2022-11-25 16:00:06 -08:00
Sam Lantinga 9d1dbd2ad8 Added note about trigger rumble availability across third-party Xbox One controllers 2022-11-06 01:16:52 -08:00
Sam Lantinga e7a56323ab Make sure we wait after sending the rumble packet when initializing the PowerA Xbox One Mini Wired Controller 2022-11-06 01:43:05 -07:00
Sam Lantinga 6875e62af3 Make sure we don't send Xbox controllers rumble so quickly that it overwhelms the firmware
Fixes https://github.com/libsdl-org/SDL/issues/6435
2022-11-06 01:15:20 -07:00
Sam Lantinga e45cb5b1e2 Fixed initializing the PowerA Xbox One Mini Wired Controller 2022-11-06 01:15:18 -07:00
Sam Lantinga a4626dea8d Fixed initializing the PDP Xbox One and Victrix Gambit controllers 2022-11-05 14:24:41 -07:00
Sam Lantinga 7e11b09b3b The PowerA Xbox One Mini Wired Controller works with the HIDAPI driver now 2022-11-05 13:50:37 -07:00
Sam Lantinga 24cdebe464 Added the hint SDL_HINT_JOYSTICK_HIDAPI_XBOX_ONE_HOME_LED to control the brightness of the Xbox button LED on the Xbox One controller 2022-11-05 10:34:08 -07:00
Sam Lantinga fa2063fb44 Improved detection of third party PS4 and PS5 controllers 2022-09-22 23:42:25 -07:00
Sam Lantinga aa2e2f4843 Make sure HID devices can be opened before making them available to the application
This prevents a number of issues where devices are enumerated but not actually able to be opened, like https://github.com/libsdl-org/SDL/issues/5781.

We currently leave the devices open, allowing us to more easily do controller feature detection, protocol negotiation, detect dropped Bluetooth connections, etc. with the expectation that the application is likely to open the controllers shortly.
2022-09-22 18:27:38 -07:00
Sam Lantinga cdaafcec0d The Kinvoca Joy-Cons are handled by the Joy-Con driver, not the Switch Pro driver. 2022-08-30 14:56:11 -07:00
Sam Lantinga 52b6899a6b Added hints for more fine grained control over HIDAPI Xbox controller support 2022-08-19 11:11:23 -07:00
Cameron Gutman 3242265ff1 joystick: Fix endianness issues in Xbox HIDAPI drivers 2022-07-10 10:49:38 -07:00
chalonverse 3b191580c3
Windows GDK Support (#5830)
* Added GDK

* Simplfied checks in SDL_config_wingdk.h

* Added testgdk sample

* Added GDK readme

* Fixed error in merge of SDL_windows.h

* Additional GDK fixes

* OpenWatcom should not export _SDL_GDKGetTaskQueue

* Formatting fixes

* Moved initialization code into SDL_GDKRunApp
2022-06-27 10:19:39 -07:00
Sam Lantinga 68544be44b Added support for the Nintendo Online controllers 2022-06-10 11:31:59 -07:00
Sam Lantinga b06866ef97 Entirely remove Xbox axis filtering, we don't want this at all. 2022-01-16 09:44:28 -08:00
Sam Lantinga 85961b61a1 Disable Xbox axis deadzone handling by default
Fixes https://github.com/libsdl-org/SDL/issues/5227
2022-01-16 09:01:56 -08:00
Sam Lantinga 1a50334c46 Fixed Xbox One trigger axis zero point 2022-01-14 15:04:26 -08:00
Sam Lantinga 16f5b9e3c3 Filter jitter on Xbox One controllers when using raw input reports 2022-01-05 11:07:52 -08:00
Sam Lantinga 120c76c84b Updated copyright for 2022 2022-01-03 09:40:21 -08:00
Sam Lantinga 66058bbbd5 Fixed exception accessing Bluetooth devices on Android 12
Since accessing Bluetooth prompts the user for permission on both Android and iOS, and we only need it for Steam Controller support, we'll leave it off by default. You can enable it by setting the hint SDL_HINT_JOYSTICK_HIDAPI_STEAM to "1" before calling SDL_Init()

Fixes https://github.com/libsdl-org/SDL/issues/4952
2021-11-15 16:52:56 -08:00
Cameron Gutman afccabb881 joystick: Add capability flags for rumble and trigger rumble
When API limitations force us to guess, we favor a false positive (reporting
support when it doesn't exist) compared to a false negative.
2021-11-11 15:10:08 -08:00
Cameron Gutman 1ccfbf963e joystick: Convert HasLED() into a generic GetCapabilities() function 2021-11-11 15:10:08 -08:00
Sam Lantinga 5b646cd19e Build hidapi code into SDL as a new public API
This prevents conflicts with hidapi linked with applications, as well as allowing applications to make use of HIDAPI on Android and other platforms that might not normally have an implementation available.
2021-11-07 23:00:59 -08:00
Sam Lantinga 907943a236 Added support for the Xbox One S Controller with 5.x series firmware 2021-08-12 17:51:08 -07:00
Ozkan Sezer 7aec0b90ee SDL_hidapi_xboxone.c: fix bogus 'uninitialized' warning from clang.
The last 'size == 50' check is always true anyway.
2021-08-13 01:56:56 +03:00
Sam Lantinga 6eb4ebb502 Simplified the HIDAPI Xbox One controller initialization 2021-08-12 15:49:33 -07:00
Sam Lantinga 584b89abe6 Added support for the color LED on the Xbox Elite Series 2 controller 2021-08-12 08:17:10 -07:00