Commit graph

258 commits

Author SHA1 Message Date
Sam Lantinga 7237c56499 Detect the G923 (Xbox style) and PXN V900 (PS3 mode) as wheels 2022-12-01 14:43:34 -08:00
Pierre Wendling 3c501b963d
Clang-Tidy fixes (#6725) 2022-12-01 13:07:03 -08:00
Sam Lantinga 4f9c2b3e2e Added support for the HORIPAD Pro for Xbox Series X 2022-11-30 17:17:44 -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 a635a485bc Re-added WinRT support until we're sure that it's no longer being used 2022-11-23 10:41:43 -08:00
Ozkan Sezer dc2a3e06e9 removed WinRT support. 2022-11-22 23:36:24 +03:00
Ozkan Sezer 8d6fda4810 removed os2 support & support for building SDL with watcom. 2022-11-22 19:18:47 +03:00
Sam Lantinga d167cd6715 Added the Gunfighter Mk.III ‘Space Combat Edition’ as a flight stick 2022-11-21 09:02:10 -08:00
Sam Lantinga 8b20b568b0 Don't report battery level for disconnected batteries
Fixes https://github.com/libsdl-org/SDL/issues/6536
2022-11-21 07:42:14 -08:00
ulatekh ec58a817ef Fixes made in response to running a static code analyzer under MS Windows.
Most of these are probably harmless, but the changes to SDL_immdevice.c and SDL_pixels.c appear to have fixed genuine bugs.

SDL_audiocvt.c: By separating the calculation of the divisor, I got rid of the suspicion that dividing a double by an integer led to loss of precision.
SDL_immdevice.c: Added a missing test, one that could have otherwise led to dereferencing a null pointer.
SDL_events.c, SDL_gamecontroller.c, SDL_joystick.c, SDL_malloc.c, SDL_video.c: Made it clear the return values weren't used.
SDL_hidapi_shield.c: The size is zero, so nothing bad would have happened, but the SDL_memset() was still being given an address outside of the array's range.
SDL_dinputjoystick.c: Initialize local data, just in case IDirectInputDevice8_GetProperty() isn't guaranteed to write to it.
SDL_render_sw.c: drawstate.viewport could be null (as seen on line 691).
SDL.c: SDL_MostSignificantBitIndex32() could return -1, though I don't know if you want to cope with that (what I did) or SDL_assert() that it can't happen.
SDL_hints.c: Replaced boolean tests on pointer values with comparisons to NULL.
SDL_pixels.c: Looks like the switch is genuinely missing a break!
SDL_rect_impl.h: The MacOS static checker pointed out issues with the X comparisons that were handled by assertions; I added assertions for the Y comparisons.
SDL_yuv.c, SDL_windowskeyboard.c, SDL_windowswindow.c: Checked error-result returns.
2022-11-16 12:43:20 -05:00
Sam Lantinga b7e65a81f1 Fixed incorrect WGI controller state when the application loses focus
Recenter the controller elements when WGI stops reporting valid state

Fixes https://github.com/libsdl-org/SDL/issues/5261
2022-11-11 08:58:27 -08:00
meyraud705 3dc88da022 Fix Dualshock 4 rumble stopping too early
Dualshock 4 controller only rumbles for 5 seconds maximum. Resend
rumble command every 2 seconds to make long rumble work.
2022-11-08 10:30:11 -08:00
Sam Lantinga 02bc359b64 Shorten "Bensussen Deutsch & Associates,Inc.(BDA)" to "BDA" for controller names 2022-11-07 19:31:18 -08:00
Sam Lantinga a6018ae57f Added support for the NVIDIA SHIELD controller v1.03 to the HIDAPI driver 2022-10-25 10:23:51 -07:00
Sam Lantinga 5b8f830e34 Virtual joysticks don't need initial axis jitter protection
Fixes https://github.com/libsdl-org/SDL/issues/6426
2022-10-22 09:25:09 -07:00
Sam Lantinga 333935ff3f Make sure we completely unlock joysticks when opening HIDAPI devices
Also lock the joysticks when adding and removing Android joysticks
2022-10-17 11:10:53 -07:00
Sam Lantinga 120a957d07 Added support for the Qanba Drone Arcade Stick 2022-10-14 09:57:02 -07:00
Pierre Wendling 655275378d N3DS port (squashed)
A dedicated renderer using Citro3D would likely allow for better
much better graphical performances.
2022-10-10 08:50:59 -07:00
Sam Lantinga 2c518747b9 Added microsecond timestamp to sensor values for PS4 and PS5 controllers using the HIDAPI driver 2022-09-27 09:56:49 -07:00
Sam Lantinga 4ea64fee9f Fixed manufacturer/product name deduplication for the Razer Raiju Tournament Edition controller 2022-09-23 15:29:00 -07:00
Sam Lantinga 34f928abb7 Generate the correct name for ASTRO Gaming controllers
Manufacturer "ASTRO Gaming" and product "ASTRO C40" turns into "ASTRO C40"
2022-09-23 09:26:18 -07:00
Sam Lantinga 6ddef7c234 Generate the correct name for Qanba and Mad Catz controllers 2022-09-23 09:20:27 -07:00
Sam Lantinga b7940c29cc Allow HIDAPI controllers to override the default joystick type 2022-09-23 00:15:40 -07:00
Sam Lantinga fa2063fb44 Improved detection of third party PS4 and PS5 controllers 2022-09-22 23:42:25 -07:00
Sam Lantinga 2e9f5b5989 Added support for the HORI Fighting Commander OCTA (Xbox Series X and PS versions) 2022-09-16 15:41:35 -07:00
Sam Lantinga 12413ab31f Lock joysticks while attaching a virtual one 2022-09-08 13:33:21 -07:00
Sam Lantinga 4071573241 Don't try to second guess DS4Windows, let it remap things as expected.
DS4Windows can create both emulated Xbox and emulated PS4 controllers, and we don't know which the user has it doing, so don't try to second guess it, just let it do it's thing. Users should follow the remapping software recommendations on when to enable/disable it for various situations.

Fixes https://github.com/libsdl-org/SDL/issues/6167
2022-09-08 11:50:56 -07:00
Sam Lantinga f398d8a424 Note that the Logitech Extreme 3D is a flight stick 2022-09-07 11:53:13 -07:00
Sam Lantinga 0a05b281f2 Make sure we hold the joystick lock when updating the device state while opening it 2022-09-07 11:51:51 -07:00
Sam Lantinga 1b4e08b89e Added an entry for the Hori Fighting Stick mini 4 kai
This is a PS3/PS4 arcade stick which becomes an Xbox 360 controller on PC
2022-09-02 17:04:53 -07:00
Sam Lantinga 92d3fc4883 Fixed deadlock when shutting down the Windows joystick system 2022-08-30 12:59:02 -07:00
Sam Lantinga 0e4baf1c4e Don't crash if SDL functions are passed a closed joystick or gamecontroller 2022-08-30 12:39:23 -07:00
Sam Lantinga 40bd4feedc Revamped joystick locking
This makes the joystick locking more robust by holding the lock while updating joysticks.

The lock should be held when calling any SDL joystick function on a different thread than the one calling SDL_PumpEvents() and SDL_JoystickUpdate().

It is now possible to hold the lock while reinitializing the joystick subsystem, however any open joysticks will become invalid and potentially cause crashes if used afterwards.

Fixes https://github.com/libsdl-org/SDL/issues/6063
2022-08-30 11:42:13 -07:00
Sam Lantinga b2ac758f61 Added support for the Hori Fighting Stick Alpha to the HIDAPI driver 2022-08-29 17:33:00 -07:00
Sam Lantinga 0b8b321f9e Allow the product version to be different when trying to find a controller mapping
This is in the hope that revving the product version doesn't change the mapping, which is the case for some devices. In cases where it does, we just need to provide a mapping for each version of the product.
2022-08-28 23:01:30 -07:00
Sam Lantinga 32700294e2 Don't crash if SDL_CreateJoystickGUID() is passed a NULL name 2022-08-28 18:20:54 -07:00
Sam Lantinga 3cbfd75d0f Re-added the CRC to the joystick guid
This is now used as a crc field in the mapping rather than directly in mapping guids, for better mapping compatibility between versions of SDL.

Added SDL_GetJoystickGUIDInfo() to get device information encoded in a joystick GUID, so that mapping programs can clear the CRC from the GUID when generating mappings.

sort_controllers.py has been updated to extract the CRC from mappings created by older mapping programs and convert it into the new crc field. It will also take the CRC into account when checking for duplicate mappings.

Also regenerated the GUIDs for the PS2/PSP/Vita controller mappings, fixing https://github.com/libsdl-org/SDL/issues/6151
2022-08-27 19:00:31 -07:00
Sam Lantinga 9a01eac57d Temporarily disable joystick GUID CRCs 2022-08-26 13:45:05 -07:00
Sam Lantinga f6c2c22d38 Don't try to use the charging port for the PowerA wireless controller as an input device 2022-08-25 22:25:25 -07:00
Sam Lantinga 277b033e78 Refactor joystick GUID creation 2022-08-22 19:44:14 -07:00
Sam Lantinga c1e0873940 Added the CRC of the joystick name to the GUID
This will make it possible to have mappings for different controllers
that have the same VID/PID. This happens frequently with some generic
controller boards that have been reused in many products.

Fixes https://github.com/libsdl-org/SDL/issues/6004
2022-08-22 18:22:35 -07:00
Mathieu Eyraud c6c688ab01 Add SDL_JOYBATTERYUPDATED event to SDL_JoystickEventState() 2022-08-14 07:00:12 -07:00
Sam Lantinga 55882e43c4 Fixed invalid read when SDL_GameControllerSetPlayerIndex() is passed a negative player_index 2022-08-09 00:19:02 -07:00
Sam Lantinga 593d20d9cc Removed debug logging 2022-08-08 20:11:43 -07:00
Sam Lantinga 6204ae5002 Restart the IMU if the controller stops sending gyro/accel data 2022-08-08 20:10:12 -07:00