src/joystick/windows/SDL_rawinputjoystick.c


Log

Author Commit Date CI Message
Ozkan Sezer 714502d3 2022-06-13T22:15:56 minor windows warning fixes.
Sam Lantinga b28d304b 2022-05-24T17:24:03 Only include controller_type.h in SDL_joystick.c It has a huge array of controllers and we only want it instantiated once
Cameron Cawley 0cca71a8 2022-05-18T22:12:05 Use SDLCALL for callbacks in public APIs
Ozkan Sezer 3f813cf1 2022-05-04T10:05:56 SDL_rawinputjoystick.c: fixed -Werror=declaration-after-statement
Jan200101 bb0b6dd4 2022-05-02T20:12:13 Fixed using WGI without XInput
Sam Lantinga e551384a 2022-04-26T14:54:14 Added functions to get the platform dependent name for a joystick or game controller
Dimitriy Ryazantcev c39df2fb 2021-12-22T18:27:10 joystick: get HID top-level collection preparsed data directly from RawInput API.
Mathieu Eyraud 0b2a55ea 2022-02-02T14:58:33 Fix typo
meyraud705 0964c84d 2022-02-02T11:21:32 Always use SDL_PrivateJoystickBatteryLevel to update battery level But do not use it for initialisation.
Sam Lantinga 04bf7c94 2022-04-22T09:36:39 Fixed build
Sam Lantinga d9b5805b 2022-04-22T09:12:48 Return a correlation error when trigger rumble is attempted without correlation
Ozkan Sezer 312c899f 2022-04-02T03:32:10 attempt to fix uwp build
Sam Lantinga 8ebef12d 2022-04-01T14:58:33 Use RoInitialize/RoUninitialize for Windows.Gaming.Input Thanks @walbourn! Fixes https://github.com/libsdl-org/SDL/issues/5270
Sam Lantinga 1868c5b5 2022-03-17T18:25:50 Start rumbling once a raw input controller has been correlated Fixes https://github.com/libsdl-org/SDL/issues/5351
Sam Lantinga b22ce2b5 2022-03-17T17:10:40 Workaround for bug in Microsoft WGI support Fixes https://github.com/libsdl-org/SDL/issues/5270
Cameron Gutman 677dc101 2022-03-09T19:43:29 rawinput: Fix double detection of gamepads on some 3rd party X360 wireless receivers The name that the Raw Input joystick driver pulls from the HID stack comes from USB string descriptors contained on the device. For official wireless receivers, this always contains "Xbox 360 Wireless Receiver for Windows" which matches the friendly name that WGI provides. 3rd party Xbox 360 wireless receivers may have different strings in their USB string descriptors (one uses "XBOX 360 For Windows" instead). This fails to match WGI's name and causes Raw Input and WGI to both report the same gamepad. Since wireless Xbox 360 controllers seem to have a consistent VID/PID regardless of the adapter enumerating them, we can also match on that to catch these. The duplicate case reported to me was: Controller (XBOX 360 For Windows) - 030000005e040000a102000000007200 Xbox 360 Wireless Receiver for Windows - 030000005e0400000000000000007701
Sam Lantinga 9299a3e7 2022-02-21T16:24:45 Workaround for crash in CoUninitialize()
Sam Lantinga 67cb548b 2022-01-20T19:31:54 Fixed build error with C90 compilers
Carl Glave a23b3c76 2022-01-20T17:21:28 Add support for correlating trigger input
Sam Lantinga 120c76c8 2022-01-03T09:40:00 Updated copyright for 2022
Mathieu Eyraud 02021ae7 2021-11-27T13:17:04 Return capabitlities from RawInput joystick
Sam Lantinga 67b5de5b 2021-11-26T10:18:08 Fixed build warnings
Sylvain 6fb50bd0 2021-11-22T11:16:23 Don't use "exp" as a name so that it's doesn´t show up with searching for the function
Cameron Gutman 881a6749 2021-11-18T19:58:04 rawinput: Only access SDL_RAWINPUT_mutex if initialized We can also ditch the lock in RAWINPUT_JoystickQuit() now that the joystick subsystem quits drivers in reverse order. There's no chance of a racing call to RAWINPUT_WindowProc() anymore.
Ozkan Sezer 3eb9bfac 2021-11-14T22:22:50 win32 rawinput & wgi joystick: avoid -Werror=declaration-after-statement
Cameron Gutman afccabb8 2021-11-11T12:12:05 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.
Cameron Gutman 1ccfbf96 2021-11-11T11:13:08 joystick: Convert HasLED() into a generic GetCapabilities() function
Cameron Gutman 2371b247 2021-10-31T18:27:51 windows: improve feature detection consistency between CMake and non-CMake builds
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
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
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 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 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.
Sam Lantinga 9130f7c3 2021-01-02T10:25:38 Updated copyright for 2021
Ozkan Sezer 90456670 2020-12-17T14:11:00 more "'for' loop initial declarations are only allowed in C99 mode" fixes
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 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 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 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 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 e0018d08 2020-11-12T14:23:56 Fixed Windows build
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 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 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.
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.