src/joystick/windows


Log

Author Commit Date CI Message
Sam Lantinga 9d457aa4 2021-07-29T14:24:40 Don't uninitialize COM because of what appears to be a bug in Microsoft WGI reference counting. This fixes https://github.com/libsdl-org/SDL/issues/4488
Sam Lantinga d4ac6b5e 2021-07-24T15:58:33 Detect buffer overflow when getting DirectInput device state This fixes bug https://github.com/libsdl-org/SDL/issues/4528
Sam Lantinga adb75d64 2021-07-23T23:45:18 Fixed hotplug detection not working on UWP or when SDL isn't pumping Windows events This fixes bugs: https://github.com/libsdl-org/SDL/issues/4321 https://github.com/libsdl-org/SDL/issues/4147 Thanks to DJm00n for the suggestion!
Sam Lantinga 24059a19 2021-07-09T18:11:42 The RAWINPUT driver is no longer tied to HIDAPI in any way
Sam Lantinga d135c076 2021-07-08T13:22:41 Added SDL_GameControllerSendEffect() and SDL_JoystickSendEffect() to allow applications to send custom effects to the PS4 and PS5 controllers See testgamecontroller.c for an example of a custom PS5 trigger effect
Dimitriy Ryazantcev 39302c92 2021-06-02T14:28:33 Add Steam Virtual Gamepad and Xbox 360 Wired Controller defines instead of magic values See https://partner.steamgames.com/doc/features/steam_controller/steam_input_gamepad_emulation_bestpractices for details on what is Steam Virtual Gamepad.
Sam Lantinga 205b951b 2021-06-25T14:20:08 SDL_DINPUT_JoystickPresent() needs to do the full device enumeration It is called from WGI before the normal joystick detection has been run, so it needs to actually enumerate currently connected devices. We can skip the logic checking for other drivers also supporting this device, because that logic is duplicated from the call site.
Dimitriy Ryazantcev f5122377 2021-06-10T14:06:32 Move SDL_IsXInputDevice check above actual joystick allocation
Dimitriy Ryazantcev 766d81ec 2021-06-10T14:01:04 Rewrite SDL_DINPUT_JoystickPresent method to avoid costly IDirectInput8_CreateDevice calls
Dimitriy Ryazantcev a6da2fbf 2021-05-25T12:33:23 Rename haptic methods to avoid confusion with joystick: `SDL_DINPUT_MaybeAddDevice`->`SDL_DINPUT_HapticMaybeAddDevice` `SDL_DINPUT_MaybeRemoveDevice`->`SDL_DINPUT_HapticMaybeRemoveDevice` `SDL_XINPUT_MaybeAddDevice`->`SDL_XINPUT_HapticMaybeAddDevice` `SDL_XINPUT_MaybeRemoveDevice`->`SDL_XINPUT_HapticMaybeRemoveDevice`
Dimitriy Ryazantcev 73dc68a7 2021-05-19T17:52:08 Simplify and cleanup DirectInput joystick backend code: - Do not call IDirectInputDevice8_QueryInterface(device, &IID_IDirectInputDevice8,...) on DIRECTINPUTDEVICE8 device - Get joystick VendorID and ProductID via IDirectInputDevice8_GetProperty(.., DIPROP_VIDPID, ..) call instead of messing with DIDEVICEINSTANCE.guidProduct - Normalize HID device interface path to upper case for stable operation of XInput check - Remove useless RawInput calls in SDL_IsXInputDevice() - just check for "IG_" string in HID device interface path that we already have There shouldn't be any observable behavior changes.
Dimitriy Ryazantcev f2f759dc 2021-02-26T15:34:34 Remove not used DirectInput ignored_devices list
Dimitriy Ryazantcev adc2d362 2021-02-26T15:33:41 Remove outdated and not used WIN_IsXInputDevice code
Ozkan Sezer f498c281 2021-06-02T14:10:50 fixed build with SDL_JOYSTICK_RAWINPUT enabled after commit b81969d46f4b See: https://github.com/libsdl-org/SDL/pull/4388#issuecomment-852713792
Ethan Lee 40210f89 2021-04-26T15:54:14 winrt: Always use a thread for joystick support
Sam Lantinga fadfa510 2021-02-01T09:21:11 Don't uncorrelate while rumble is active and stay correlated longer in case raw input messages are lagging a bit.
Ozkan Sezer fd65aaa9 2021-01-23T17:30:50 move outdated winmm and psp joystick codes to struct _SDL_JoystickDriver build-tested only. (bug #5472.)
Ozkan Sezer 11fce321 2021-01-22T20:20:02 SDL_dinputjoystick.c: fixes to dfDIJoystick2[] array from Wine git. Fix V/A/FSlider dwOfs values in c_dfDIJoystick2 https://source.winehq.org/git/wine.git/commitdiff/af2f4194263702a946c65d255580176ee50b5914 Add missing ASPECT flags for c_dfDIJoystick2 https://source.winehq.org/git/wine.git/commitdiff/e2e100272ffede3c720da7bbd11b53ac0bcee8eb Closes bug #5474.
Ozkan Sezer f3835702 2021-01-17T05:00:50 fix build with --disable-directx
Ozkan Sezer a594b850 2021-01-04T10:00:30 use WIN_StringToUTF8W macro instead of WIN_StringToUTF8, where needed: i.e. where the string is known guaranteed to be WCHAR*, in: - SDL_dinputjoystick.c (WIN_IsXInputDevice): VARIANT->var is BSTR (WCHAR*) - SDL_rawinputjoystick.c (RAWINPUT_AddDevice): string is WCHAR* - SDL_windows_gaming_input.c (IEventHandler_CRawGameControllerVtbl_InvokeAdded): string is WCHAR* There should be more of these..
Ozkan Sezer f2bd861c 2021-01-04T08:50:00 move SDL_tcsstr definition to core/windows/SDL_windows.h
Ozkan Sezer ae18109a 2021-01-04T01:23:50 SDL_windowsjoystick.c (SDL_CreateDeviceNotification): use L, not TEXT() cf. bug #5435.
Ozkan Sezer 398d2764 2021-01-04T01:23:50 RAWINPUT_InitWindowsGamingInput: change pNamespace from LPTSTR to PCWSTR because WindowsCreateStringReference specifically accepts const WCHAR * - WGI_JoystickInit(): ditto. cf. bug #5435.
Ozkan Sezer f09e0af7 2021-01-04T01:23:50 SDL_dinputjoystick.c (IsXInputDevice): adjust to be ANSI/UNICODE-agnostic cf. bug #5435.
Sam Lantinga 9130f7c3 2021-01-02T10:25:38 Updated copyright for 2021
Sam Lantinga cbe13d23 2020-12-18T13:10:36 Fixed controller hotplug detection when joystick thread is not enabled
Ozkan Sezer 90456670 2020-12-17T14:11:00 more "'for' loop initial declarations are only allowed in C99 mode" fixes
Sam Lantinga 9ee0e888 2020-12-12T22:11:00 Whoops, make the hint actually default to false
Sam Lantinga 13a4caf1 2020-12-12T22:08:02 Fixed bug 4286 - Joystick subsystem causes "not responding" when app is in the background Added a hint to control whether a separate thread should be used for joystick events. This is off by default because dispatching messages in other threads appears to cause problems on some versions of Windows.
Sam Lantinga 797a6910 2020-12-09T20:28:51 Fixed bug 5375 - WGI: Fix HSTRING memory leak. Joel Linn TLDR; https://godbolt.org/z/43fd8G Let's deduce this from C++ reference code: https://docs.microsoft.com/en-us/cpp/cppcx/wrl/how-to-activate-and-use-a-windows-runtime-component-using-wrl?view=msvc-160 At the bottom of the page there is this snippet: ``` int wmain() { /* ... more code ... */ // Get the domain part of the URI. HString domainName; hr = uri->get_Domain(domainName.GetAddressOf()); if (FAILED(hr)) { return PrintError(__LINE__, hr); } // Print the domain name and return. wprintf_s(L"Domain name: %s\n", domainName.GetRawBuffer(nullptr)); // All smart pointers and RAII objects go out of scope here. } ``` `HString` is defined in `corewrappers.h` and the call chain for the destructor is: `~HString() -> Release() -> ::WindowsDeleteString()` QED
Sam Lantinga a77a0715 2020-12-09T07:50:15 Disabled raw input debug output
Sam Lantinga cb361896 2020-12-09T07:16:22 Fixed bug 5235 - All internal sources should include SDL_assert.h Ryan C. Gordon We should really stick this in SDL_internal.h or something so it's always available.
Sam Lantinga f2fff217 2020-12-09T06:24:40 Fixed bug 5374 - WGI: Use fast-pass strings. Joel Linn Eliminate additional heap allocation for short-lived HSTRINGs. Uses `WindowsCreateStringReference()` to disable reference counting and memory management by the Window Runtime.
Sam Lantinga 1031231b 2020-12-03T18:17:03 Fixed duplicating a device between XInput and HIDAPI
Sam Lantinga c78ca2d1 2020-12-01T13:38:42 Fixed bug 5371 - Rawinput: Fix truncating cast of string length. Joel Linn Fixes an implicit truncation of a string length on 64bit systems.
Sam Lantinga a3ccf9ad 2020-12-01T13:36:41 Fixed bug 5373 - [PATCH] Rawinput: Get correlated XInput battery info Joel Linn Currently the rawinput driver always reports a device as "wired". This changes that to "unknown" and updates it once the device is correlated with xinput.
Sam Lantinga 1f2f536b 2020-11-27T18:57:40 Fixed XInput correlation for raw input controllers after hotplug events
Sam Lantinga 1c865c46 2020-11-27T18:57:36 Load the raw input device list at init time so it's available when DirectInput is doing device detection
Sam Lantinga a0c5bfa3 2020-11-27T13:08:40 Moved raw input event processing from the main thread to the joystick thread This allows fast joystick event delivery regardless of what the main thread is doing.
Sam Lantinga 4fbefbe2 2020-11-27T11:33:53 Sort the raw input axes by usage, so X comes before Y, etc.
Sam Lantinga 4ddac485 2020-11-27T11:33:51 Backed out minor optimization that prevented correlation_id from being set
Sam Lantinga 8973a258 2020-11-27T10:44:56 Enable dispatching of WM_INPUT_DEVICE_CHANGE events directly, in case the application hasn't created a window with the normal message loop
Sam Lantinga e8adc648 2020-11-27T10:44:55 Enable dispatching of WM_INPUT events directly, in case the application hasn't created a window with the normal message loop
Sam Lantinga 0252235e 2020-11-27T10:44:53 Recheck devices if another API queries raw input for a new device
Sam Lantinga a7dede7e 2020-11-27T10:44:51 Re-enable axis correlation for raw input controllers, for twin stick shooters that don't need face buttons
Sam Lantinga ce77966d 2020-11-27T10:44:49 Fixed RAWINPUT_IsDevicePresent() not returning TRUE for Xbox One controllers
Sam Lantinga 8a449de2 2020-11-27T10:44:47 Fixed Xbox 360 wireless controller being picked up by WGI when it's being managed by RAWINPUT
Sam Lantinga 37c9e4af 2020-11-27T06:03:15 Fixed processing WM_INPUT_DEVICE_CHANGE at startup
Sam Lantinga 248fc75b 2020-11-27T05:53:56 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.
Sam Lantinga e7e615de 2020-11-27T05:53:54 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.
Sam Lantinga 2931eccd 2020-11-27T05:53:52 Fixed detecting Bluetooth raw input devices, which have device names longer than 128 characters
Sam Lantinga 849ce803 2020-11-27T05:53:50 Renamed SDL_JOYSTICK_RAWINPUT_GAMING_INPUT to SDL_JOYSTICK_RAWINPUT_WGI
Sam Lantinga 219a28dd 2020-11-27T03:45:05 Fixed D-pad uncorrelating raw input controllers (thanks Jimbly!)
Ozkan Sezer 3fbff2a4 2020-11-26T10:47:33 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'
Sam Lantinga 845b9033 2020-11-25T16:46:42 Implemented trigger rumble for raw input controllers
Sam Lantinga 9ec2cf56 2020-11-25T10:31:59 Fixed building with Windows.Gaming.Input enabled
Sam Lantinga 9fc4a4c9 2020-11-24T22:25:26 Revamped Xbox One HIDAPI init sequence Added support for querying the controller serial number on newer firmware
Sam Lantinga 268aa456 2020-11-23T20:26:28 Fixed compiling with SDL_JOYSTICK_RAWINPUT disabled
Sam Lantinga 5b3616c3 2020-11-23T18:24:05 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.
Sam Lantinga fcb21aa8 2020-11-17T10:30:20 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
Sam Lantinga 8e312a6a 2020-11-12T15:56:33 Fixed detecting Bluetooth XInput controllers on Windows
Sam Lantinga e0018d08 2020-11-12T14:23:56 Fixed Windows build
Sam Lantinga 3160c7d6 2020-11-11T19:43:02 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.
Sam Lantinga 502cfe31 2020-11-11T19:39:46 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.
Sam Lantinga 1e2caac5 2020-11-11T18:57:37 Added SDL_JoystickRumbleTriggers() and SDL_GameControllerRumbleTriggers()
Sam Lantinga b6238c87 2020-11-11T14:48:23 Don't try to build the RAWINPUT driver if HIDAPI is disabled
Sam Lantinga 4ea1a10b 2020-11-07T02:49:22 Added stub controller LED functions for WGI and RAWINPUT (thanks meyraud!)
Sam Lantinga e555d453 2020-11-05T11:07:54 Added SDL_JoystickHasLED Currently, this is only supported by the PS4 HIDAPI driver.
Sam Lantinga ddc0727b 2020-10-27T09:00:42 Fixed implicit memcpy() when building for ARM64 on Windows (thanks Seigo!)
stfx b1626295 2020-07-08T17:28:34 cmake: Fix building with -DSDL_HAPTIC=Off
stfx efe09359 2020-06-15T10:31:16 Fix compile without DIRECTX
Sam Lantinga eea0b0e0 2020-06-02T17:08:31 Fixed bug 5168 - Memory leak in RAWINPUT_JoystickOpen meyraud705 Variable 'hwdata' is not freed in RAWINPUT_JoystickOpen if device->driver->OpenJoystick() fails.
Sam Lantinga ac1f174a 2020-06-02T17:02:37 Fixed bug 5167 - Memory leak in GuessXInputDevice meyraud705 Variable 'devices' is not freed if function GuessXInputDevice, in SDL_xinputjoystick.c, return early.
Sam Lantinga 2db04947 2020-05-29T14:48:05 Fixed variable names to be consistent across functions
Sam Lantinga 345b4d7e 2020-05-29T13:37:21 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.
Ryan C. Gordon 68777406 2020-05-20T16:58:33 windows: Fix calls to CoCreateInstance() so last parameter is a LPVOID *.
Ethan Lee 83cddd2e 2020-04-30T11:57:29 Add SDL_JoystickSetLED. Currently, this is only supported by the PS4 HIDAPI driver.
Sam Lantinga 01fd8130 2020-04-23T11:13:02 Fixed compiler warning
Sam Lantinga 4727f794 2020-04-23T10:13:17 Don't use the WGI driver if another driver is already handling the joystick
Sam Lantinga 6ca7f510 2020-04-23T09:35:32 Fixed crash trying to get battery status on some devices
Sam Lantinga aba27928 2020-04-18T21:41:37 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
Sam Lantinga c302c1ab 2020-04-13T13:24:19 Fixed build
Sam Lantinga bf87604e 2020-04-13T12:33:29 Fixed rare crash when unplugging Xbox controller on Windows
Sam Lantinga 3cb62d52 2020-04-07T11:17:52 Fixed setting the controller name for the RAWINPUT driver
Sam Lantinga 88cecee4 2020-04-07T10:14:12 Fixed build warning
Sam Lantinga 50cb8e0f 2020-04-07T10:13:08 Fixed deadlock in new raw input joystick code The appropriate locking is done elsewhere, this prevents inverted lock acquisition
Sam Lantinga b6afbe63 2020-04-07T09:38:57 Added SDL_log.h to SDL_internal.h so logging is available everywhere
Jimb Esser 417713a7 2020-03-20T19:49:19 Probable fix for compile errors on Mac OS and (non-VS) Win32
Sam Lantinga dc36f133 2020-03-20T19:49:15 Backed out changeset c29d04c3fa49
Sam Lantinga 2db65a7f 2020-03-20T19:47:46 Fixed compile warnings
Sam Lantinga 543994b1 2020-03-16T12:25:02 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.
Sam Lantinga 4dea340c 2020-03-16T12:23:38 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.
Sam Lantinga 80d075a0 2020-03-13T09:43:48 Fixed compiler warnings
Sam Lantinga c44473ba 2020-03-12T19:47:30 Unified code to standardize joystick names
Sam Lantinga 6efebf17 2020-02-04T12:48:53 Moved rumble expiration to the main joystick handling level, and prevent sending the driver layer duplicate rumble requests.
Sam Lantinga 7ea3f5b4 2020-01-26T12:48:35 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.
Sam Lantinga 43aa1fa9 2020-01-18T11:21:14 Added support for detecting previously unknown Xbox 360 and Xbox One controllers using the HIDAPI driver with libusb and Android
Sam Lantinga a8780c6a 2020-01-16T20:49:25 Updated copyright date for 2020
Sam Lantinga d000a592 2019-12-21T22:33:21 Fixed windows build
Sam Lantinga 46e1377d 2019-12-20T20:12:03 Automatically assign player indexes to game controllers, and allow changing the player index for game controllers and joysticks. Added the functions SDL_JoystickFromPlayerIndex(), SDL_JoystickSetPlayerIndex(), SDL_GameControllerFromPlayerIndex(), and SDL_GameControllerSetPlayerIndex()