Commit Graph

109 Commits

Author SHA1 Message Date
Sam Lantinga
8a449de20d Fixed Xbox 360 wireless controller being picked up by WGI when it's being managed by RAWINPUT 2020-11-27 10:44:47 -08:00
Sam Lantinga
37c9e4afa3 Fixed processing WM_INPUT_DEVICE_CHANGE at startup 2020-11-27 06:03:15 -08:00
Sam Lantinga
248fc75bd2 Correlate just based on buttons, joystick axes are not as precise and could potentially cause incorrect uncorrelation.
It's okay if the triggers aren't precise until someone presses a button on their controller.
2020-11-27 05:53:56 -08:00
Sam Lantinga
e7e615de26 Removed extraneous windows message pumping
Most of the raw input events are dispatched in the main windows message loop. We only dispatch device change messages separately when we need them to be completely up to date.
2020-11-27 05:53:54 -08:00
Sam Lantinga
2931eccd84 Fixed detecting Bluetooth raw input devices, which have device names longer than 128 characters 2020-11-27 05:53:52 -08:00
Sam Lantinga
849ce80376 Renamed SDL_JOYSTICK_RAWINPUT_GAMING_INPUT to SDL_JOYSTICK_RAWINPUT_WGI 2020-11-27 05:53:50 -08:00
Sam Lantinga
219a28dd8a Fixed D-pad uncorrelating raw input controllers (thanks Jimbly!) 2020-11-27 03:45:05 -08:00
Ozkan Sezer
3fbff2a45b SDL_rawinputjoystick.c: fix ambiguous 'else' warning
src/joystick/windows/SDL_rawinputjoystick.c: In function 'RAWINPUT_HandleStatePacket':
src/joystick/windows/SDL_rawinputjoystick.c:1343:9: warning: suggest explicit braces to avoid ambiguous 'else'
2020-11-26 10:47:33 +03:00
Sam Lantinga
845b903324 Implemented trigger rumble for raw input controllers 2020-11-25 16:46:42 -08:00
Sam Lantinga
9ec2cf5629 Fixed building with Windows.Gaming.Input enabled 2020-11-25 10:31:59 -08:00
Sam Lantinga
9fc4a4c92c Revamped Xbox One HIDAPI init sequence
Added support for querying the controller serial number on newer firmware
2020-11-24 22:25:26 -08:00
Sam Lantinga
268aa45645 Fixed compiling with SDL_JOYSTICK_RAWINPUT disabled 2020-11-23 20:26:28 -08:00
Sam Lantinga
5b3616c325 Generalized the raw input controller driver and moved XInput/WGI detection into it for XInput devices
This fixes bad report parsing for various newer Xbox controllers, and this driver is now preferred over XInput, since it handles more than 4 controllers.
2020-11-23 18:24:05 -08:00
Sam Lantinga
fcb21aa883 Added API for sensors on game controllers
Added support for the PS4 controller gyro and accelerometer on iOS and HIDAPI drivers

Also fixed an issue with the accelerometer on iOS having inverted axes
2020-11-17 10:30:20 -08:00
Sam Lantinga
8e312a6a59 Fixed detecting Bluetooth XInput controllers on Windows 2020-11-12 15:56:33 -08:00
Sam Lantinga
e0018d0869 Fixed Windows build 2020-11-12 14:23:56 -08:00
Sam Lantinga
3160c7d66f Fixed bug 5327 - When direct input fails to load, but a controlller is plugged in through another api, an access violation happens.
Bart van der Werf

When directinput fails to load, but a controlller is plugged in, an access violation happens.
This is due to IEventHandler_CRawGameControllerVtbl_InvokeAdded calling SDL_DINPUT_JoystickPresent which does not check if dinput is assigned signalling initialization of directinput.
2020-11-11 19:43:02 -08:00
Sam Lantinga
502cfe314a Fixed bug 5332 - WGI: Fix wrong level of indirection and implicit truncating cast.
Joel Linn

This fixes two types of MSVC compiler warnings.

- One parameter in the function signatures of two WGI event handlers had one level of indirection too much (and did not match Windows SDK headers). The indirection was cast away so it still worked.
- size_t was implicitly cast to UINT32 for a number of (constant) string lengths.
2020-11-11 19:39:46 -08:00
Sam Lantinga
1e2caac58b Added SDL_JoystickRumbleTriggers() and SDL_GameControllerRumbleTriggers() 2020-11-11 18:57:37 -08:00
Sam Lantinga
b6238c87e4 Don't try to build the RAWINPUT driver if HIDAPI is disabled 2020-11-11 14:48:23 -08:00
Sam Lantinga
4ea1a10bd2 Added stub controller LED functions for WGI and RAWINPUT (thanks meyraud!) 2020-11-07 02:49:22 -08:00
Sam Lantinga
e555d45331 Added SDL_JoystickHasLED
Currently, this is only supported by the PS4 HIDAPI driver.
2020-11-05 11:07:54 -08:00
Ethan Lee
83cddd2ebc Add SDL_JoystickSetLED.
Currently, this is only supported by the PS4 HIDAPI driver.
2020-04-30 11:57:29 -04:00
Sam Lantinga
ddc0727bba Fixed implicit memcpy() when building for ARM64 on Windows (thanks Seigo!) 2020-10-27 09:00:42 -07:00
stfx
b162629546 cmake: Fix building with -DSDL_HAPTIC=Off 2020-07-08 17:28:34 +02:00
stfx
efe0935904 Fix compile without DIRECTX 2020-06-15 10:31:16 +02:00
Sam Lantinga
eea0b0e088 Fixed bug 5168 - Memory leak in RAWINPUT_JoystickOpen
meyraud705

Variable 'hwdata' is not freed in RAWINPUT_JoystickOpen if device->driver->OpenJoystick() fails.
2020-06-02 17:08:31 -07:00
Sam Lantinga
ac1f174ad5 Fixed bug 5167 - Memory leak in GuessXInputDevice
meyraud705

Variable 'devices' is not freed if function GuessXInputDevice, in SDL_xinputjoystick.c, return early.
2020-06-02 17:02:37 -07:00
Sam Lantinga
2db049473b Fixed variable names to be consistent across functions 2020-05-29 14:48:05 -07:00
Sam Lantinga
345b4d7e14 Fixed bug 5161 - Autodetect controller mappings based on the Linux Gamepad Specification
Jan Bujak

I wrote a new driver for my gamepad on Linux. I'd like SDL to support it out-of-box, as currently it just treats it as a generic joystick instead of a gamepad. From what I can see the only way to do that is to either 1) pick one of the already supported controllers' PID, VID and button layouts and have my driver send that (effectively lying that it's something else), or 2) submit a preconfigured, hardcoded mapping to SDL.

Both of those, in my opinion, are silly when we already have the Linux Gamepad Specification which standarizes this:

https://www.kernel.org/doc/html/v4.15/input/gamepad.html

Unfortunately SDL doesn't make use of it currently. So I've took it upon myself to add it; patch is in the attachments.

Basically what the patch does is that if SDL finds no built-it controller mappings for a given joystick it then asks the joystick backend to autodetect it, and that uses the relevant evdev bits to figure out which button/axis is which. (See the specs for more details.)

With this patch applied my own driver for my controller works out-of-box with SDL with no extra configuration and is correctly recognized as a gamepad; this is also going to be the case for any other driver which follows the Linux Gamepad Specification.
2020-05-29 13:37:21 -07:00
Ryan C. Gordon
68777406e5 windows: Fix calls to CoCreateInstance() so last parameter is a LPVOID *. 2020-05-20 16:58:33 -04:00
Sam Lantinga
01fd8130fd Fixed compiler warning 2020-04-23 11:13:02 -07:00
Sam Lantinga
4727f79416 Don't use the WGI driver if another driver is already handling the joystick 2020-04-23 10:13:17 -07:00
Sam Lantinga
6ca7f510ae Fixed crash trying to get battery status on some devices 2020-04-23 09:35:32 -07:00
Sam Lantinga
aba2792896 Added a Windows Gaming Input joystick driver
This driver supports the Razer Atrox Arcade Stick

Some of the quirks of this driver, inherent in Windows Gaming Input:
* There will never appear to be controllers connected at startup. You must support hot-plugging in order to see these controllers.
* You can't read the state of the guide button
* You can't get controller events in the background
2020-04-18 21:41:37 -07:00
Sam Lantinga
c302c1abb8 Fixed build 2020-04-13 13:24:19 -07:00
Sam Lantinga
bf87604ef1 Fixed rare crash when unplugging Xbox controller on Windows 2020-04-13 12:33:29 -07:00
Sam Lantinga
3cb62d5265 Fixed setting the controller name for the RAWINPUT driver 2020-04-07 11:17:52 -07:00
Sam Lantinga
88cecee495 Fixed build warning 2020-04-07 10:14:12 -07:00
Sam Lantinga
50cb8e0f04 Fixed deadlock in new raw input joystick code
The appropriate locking is done elsewhere, this prevents inverted lock acquisition
2020-04-07 10:13:08 -07:00
Sam Lantinga
b6afbe6317 Added SDL_log.h to SDL_internal.h so logging is available everywhere 2020-04-07 09:38:57 -07:00
Jimb Esser
417713a75c Probable fix for compile errors on Mac OS and (non-VS) Win32 2020-03-20 19:49:19 -07:00
Sam Lantinga
dc36f133b4 Backed out changeset c29d04c3fa49 2020-03-20 19:49:15 -07:00
Sam Lantinga
2db65a7fe7 Fixed compile warnings 2020-03-20 19:47:46 -07:00
Sam Lantinga
543994b193 Fixed bug 4477 - Support more than 4 XInput-capable devices on Windows
Jimb Esser

Add new RawInput controller API, and improved correlation with XInput/WGI

Reorder joystick init so drivers can ask the others if they handle a device reliably
Do not poll disconnected XInput devices (major perf issue)
Fix various cases where incorrect correlation could happen
Simple mechanism for propagating unhandled Guide button presses even before guaranteed correlation
Correlate by axis motion as well as button presses
Fix failing to zero other trigger
Fix SDL_HINT_JOYSTICK_HIDAPI not working if set before calling SDL_Init()
Add missing device to device names
Disable RawInput if we have a mismatch of XInput-capable but not RawInput-capable devices

Updated to SDL 2.0.13 code with the following notes:
New HID driver: xbox360w - no idea what that is, hopefully urelated
SDL_hidapijoystick.c had been refactored to couple data handling logic with device opening logic and device lists caused some problems, yields slightly uglier integration than previously when the 360 HID device driver was just handling the data.
SDL_hidapijoystick.c now often pulls the device off of the joystick_hwdata structure for some rumble logic, but it appears that code path is never reached, so probably not a problem.
Looks like joystick_hwdata was refactored to not include a mutex in other drivers, maintainers may want to do the same refactor here if that's useful for some reason.
Something changed in how devices get names, so getting generic names.
Had to fix a (new?) bug where removing an XInput controller caused existing controllers (that moved to a new XInput index) to get identified as 0x045e/0x02fd ("it's probably Bluetooth" in code), rendering the existing HIDAPI_IsDevicePresent and new RAWINPUT_IsDevicePresent unreliable.
2020-03-16 12:25:02 -07:00
Sam Lantinga
4dea340ca7 Fixed bug 4477 - Support more than 4 XInput-capable devices on Windows
Jimb Esser

Add new RawInput controller API, and improved correlation with XInput/WGI

Reorder joystick init so drivers can ask the others if they handle a device reliably
Do not poll disconnected XInput devices (major perf issue)
Fix various cases where incorrect correlation could happen
Simple mechanism for propagating unhandled Guide button presses even before guaranteed correlation
Correlate by axis motion as well as button presses
Fix failing to zero other trigger
Fix SDL_HINT_JOYSTICK_HIDAPI not working if set before calling SDL_Init()
Add missing device to device names
Disable RawInput if we have a mismatch of XInput-capable but not RawInput-capable devices

Updated to SDL 2.0.13 code with the following notes:
New HID driver: xbox360w - no idea what that is, hopefully urelated
SDL_hidapijoystick.c had been refactored to couple data handling logic with device opening logic and device lists caused some problems, yields slightly uglier integration than previously when the 360 HID device driver was just handling the data.
SDL_hidapijoystick.c now often pulls the device off of the joystick_hwdata structure for some rumble logic, but it appears that code path is never reached, so probably not a problem.
Looks like joystick_hwdata was refactored to not include a mutex in other drivers, maintainers may want to do the same refactor here if that's useful for some reason.
Something changed in how devices get names, so getting generic names.
Had to fix a (new?) bug where removing an XInput controller caused existing controllers (that moved to a new XInput index) to get identified as 0x045e/0x02fd ("it's probably Bluetooth" in code), rendering the existing HIDAPI_IsDevicePresent and new RAWINPUT_IsDevicePresent unreliable.
2020-03-16 12:23:38 -07:00
Sam Lantinga
80d075a01a Fixed compiler warnings 2020-03-13 09:43:48 -07:00
Sam Lantinga
c44473ba73 Unified code to standardize joystick names 2020-03-12 19:47:30 -07:00
Sam Lantinga
6efebf1768 Moved rumble expiration to the main joystick handling level, and prevent sending the driver layer duplicate rumble requests. 2020-02-04 12:48:53 -08:00
Sam Lantinga
7ea3f5b464 Fixed bug 4898 - No rumble because of integer overflow in SDL_JoystickRumble
meyraud705

Switch hidapi and xinput also need to check for overflow, attached a patch for them.
2020-01-26 12:48:35 -08:00