src/joystick/windows

Branch


Log

Author Commit Date CI Message
Sam Lantinga 7ebfaa0e 2023-11-02T08:33:15 Check to make sure the Windows joystick device has buttons and axes This reverts commit e5a15f94e2f1a8fbbffb25ea9932cda9679a68fd. It turns out removing this check allows mice like the ROG PUGIO II to show up as game controllers. We need to find a different way to differentiate between gaming mice and pedals. Since these mice show up as controllers, and potentially causing games to use them instead of real controllers, we'll go ahead revert this change for now. Reopens https://github.com/libsdl-org/SDL/issues/8227 (cherry picked from commit ad0af488837e44cbea0f0eab3b2f73b50a74bff4) (cherry picked from commit 20ecd2afcb6a4ef6acb39505d307d42390e6a345)
Sam Lantinga 2ca041d2 2023-10-22T09:10:14 Revert "Check to make sure the Windows joystick device has buttons and axes" This reverts commit 642504bc5993a6acd4d9c1d4c1314c6b1cf6e4e1. We have SDL_HINT_JOYSTICK_ROG_CHAKRAM to ignore or allow the ROG Chakram X mouse to be used as a joystick. Fixes https://github.com/libsdl-org/SDL/issues/8227 (cherry picked from commit e5a15f94e2f1a8fbbffb25ea9932cda9679a68fd) (cherry picked from commit e3e41b69a1060d87dfe635a35ed56cba23574aaa)
Sam Lantinga cb4b41dd 2023-07-11T10:50:43 RAWINPUT_RegisterNotifications() should return int, for consistency (cherry picked from commit 1903d7b1bf6c73ef23e4d6934c9fec5246dd0b2e) (cherry picked from commit e8b6edd5a081d0b45c2ac39ab690e584a6b95a84)
Sam Lantinga 5a2d165b 2023-07-11T07:56:07 Improved RAWINPUT <-> XInput/WGI device correlation If there is only one controller slot available, assume that's the one matching new RAWINPUt devices. This will be right most of the time, and uncorrelation will fix any bad guesses. (cherry picked from commit 41882a1acb6054dc7a56fd5ff7f0a279ba1144c0) (cherry picked from commit 34c5bde3554d2a78d14eb73c14d971cee20f3108)
Sam Lantinga 11022c23 2023-07-11T10:17:02 Fixed crash if RAWINPUT is not initialized We shouldn't be doing any of this work in that case (cherry picked from commit dfc5e6964eca0a0813768518d08cf1c80136e896) (cherry picked from commit 9117b2e3000da4d9066dd5f2cfb1c9cbbbee6861)
Sam Lantinga bb3997d8 2023-07-08T10:24:00 Added WGI gamepad added/removed listeners for RAWINPUT This fixes WGI correlation on startup when the WGI gamepad list isn't populated yet (cherry picked from commit f047e178b610c6888212c3096c10eb3f64f31a15) (cherry picked from commit f8a0135edfb07ebe7201b764fd0aba42d600b99c)
Sam Lantinga f2d016e3 2023-07-07T14:43:57 Lazily initialize the WGI gamepad support Initializing "Windows.Gaming.Input.Gamepad" will put Bluetooth PS4 controllers into enhanced report mode, which breaks any game using DirectInput. Let's wait to do this until absolutely necessary. (cherry picked from commit 785f57eb9102206e74ac7f9b363a37cbf037cf9d) (cherry picked from commit de849d5e6f23a7621471befb69f1b036bc346f5e)
Sam Lantinga b8582428 2023-07-08T09:32:24 Added the hint SDL_HINT_JOYSTICK_WGI to control whether to use Windows.Gaming.Input for controllers (cherry picked from commit a6228e7aafb66075fe8f4aaf411314fc92340499)
Sam Lantinga 46927b13 2023-07-07T09:47:03 Prefer using XInput for rumble over WGI, as it allows rumble in the background (cherry picked from commit e16a83d393ae1784040519f42c482e2641b971a2)
Sam Lantinga 3bee5cf5 2023-07-07T09:33:53 Continue running XInput detection while RAWINPUT is active This allows us to re-enable XInput correlation for RAWINPUT devices without reintroducing the controller shutdown bug for controllers using the wireless adapter in https://github.com/libsdl-org/SDL/issues/3468. Fixes https://github.com/libsdl-org/SDL/issues/7940 (cherry picked from commit a0a3957eb65e22721a124476072af0f6f5a7ca18)
Sam Lantinga 1cdd6dc8 2023-06-09T14:34:59 Fixed reading input from the Razer Atrox Arcade Stick using Windows Gaming Input (cherry picked from commit 172cfca51332a845abf9c141ae56aa121fe4ada5)
Sam Lantinga c89a4606 2023-06-02T11:20:31 Fixed build if SDL_JOYSTICK_RAWINPUT_MATCHING isn't enabled (cherry picked from commit 7c55845c804e2272df8bc111dea5d3e9d11670a0)
Sam Lantinga e3bfacde 2023-06-02T11:16:07 Don't use raw input while Remote Desktop is active Raw input will not send game controller events while Remote Desktop is active, so dynamically switch between XInput and raw input when Remote Desktop state changes. Fixes https://github.com/libsdl-org/SDL/issues/7759 (cherry picked from commit 767507fcf6f4607edb413acb53a6c029863701ed)
Sam Lantinga 9c05098e 2023-06-02T09:38:18 Fixed WGI immediately being correlated with raw input devices with no input The at rest match state is 0x0000008800000000, not 0 (cherry picked from commit e8b5b4881c8eb31bb7de5adef3479305a73fb0bf)
Sam Lantinga 5007b963 2023-05-28T19:23:56 Fixed build warning
Sam Lantinga b2e88ecf 2023-05-28T18:41:21 Disable SDL_JOYSTICK_RAWINPUT_XINPUT Apparently when using the Xbox One Wireless Adapter, using XInput at the same time as raw input will cause the controller to turn off immediately after connecting. This appears to be a bug in the Windows 11 driver stack, but since WGI provides all the extended functionality we need, this can be turned off for now. Fixes https://github.com/libsdl-org/SDL/issues/3468
Sam Lantinga 3f1fd5ab 2023-05-23T10:59:03 Updated source to match SDL function prototype style
Sam Lantinga d42c303b 2023-05-15T21:43:16 Check to make sure the Windows joystick device has buttons and axes This fixes incorrectly detecting the ROG CHAKRAM X mouse as a game controller on Windows 10 (cherry picked from commit 642504bc5993a6acd4d9c1d4c1314c6b1cf6e4e1)
Sam Lantinga 0d763800 2023-03-09T15:10:00 Code style: changed "sizeof foo" to "sizeof(foo)" (thanks @sezero!) (cherry picked from commit c6443d86c92e962683a1efe5f123a144988875b5)
Sylvain 17515f4a 2023-02-04T15:51:37 Backport simplify flags PR #7220
happyharryh 2cb42236 2023-01-10T20:36:13 Fixed the hat_map to avoid segmentation fault (cherry picked from commit 57e78f4cf53b0fc84900a047120263c3c71e721c)
Sam Lantinga 0479df53 2023-01-09T09:48:21 Updated copyright for 2023
Sam Lantinga ebc2fb41 2023-01-08T09:32:31 Fixed infinite loop shutting down WGI controllers We are guaranteed that the lock will be held during shutdown, so if we are in InvokeRemoved(), it's because we're shutting down controllers and need to remove them from our internal list. Fixes https://github.com/libsdl-org/SDL/issues/7016 (cherry picked from commit ac99db9fc8d528a79abb98a5641e0fd94aa20a9e)
Sam Lantinga d1b48105 2022-12-05T13:36:51 Fixed centering the D-pad on some joysticks Fixes https://github.com/libsdl-org/SDL/issues/6767
Pierre Wendling d0bbfdbf 2022-12-01T16:07:03 Clang-Tidy fixes (#6725) (cherry picked from commit 3c501b963dd8f0605a6ce7978882df39ba76f9cd)
Sam Lantinga b8d85c69 2022-11-30T12:51:59 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 (cherry picked from commit 5750bcb174300011b91d1de20edb288fcca70f8c)
Sam Lantinga 2d24baaa 2022-11-29T09:26:29 Fixed building on Windows with SDL_VIDEO=OFF Fixes https://github.com/libsdl-org/SDL/issues/6562
Sylvain Becker fb0ce375 2022-11-27T17:38:43 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 (cherry picked from commit 6a2200823c66e53bd3cda4a25f0206b834392652 to reduce conflicts merging between SDL2 and SDL3)
Sam Lantinga 8b20b568 2022-11-21T07:41:35 Don't report battery level for disconnected batteries Fixes https://github.com/libsdl-org/SDL/issues/6536
ulatekh ec58a817 2022-10-05T19:26:09 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.
Sam Lantinga b7e65a81 2022-11-11T08:57:07 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
Steven Noonan 3d35c085 2022-10-02T17:30:03 fix a few 'unused but set variable' and 'unused function' warnings
Sam Lantinga 0bc852ce 2022-10-17T17:43:06 Revert "Disable the RAWINPUT joystick driver by default" Disabling RAWINPUT on Windows 10 causes these issues: * All Xbox controllers are named "XInput Controller". * Trigger rumble no longer works. * "XInput Controllers" are now also listed as separate haptic devices
Sam Lantinga 47ba997f 2022-10-17T07:39:52 Disable the RAWINPUT joystick driver by default It's only needed to support more than 4 Xbox controllers, and adds significant complexity to the joystick processing, and we regularly get bugs from people who aren't using an SDL window who need to turn on SDL_HINT_JOYSTICK_THREAD.
Sam Lantinga 5025f240 2022-10-17T07:32:44 Don't use RAWINPUT joystick driver on Windows XP Fixes https://github.com/libsdl-org/SDL/issues/6400
Sam Lantinga 3607f831 2022-10-03T11:00:50 Find out if a controller is wireless using WGI (thanks @DJm00n!) Confirmed using an Xbox Series X controller over USB and Bluetooth Fixes https://github.com/libsdl-org/SDL/issues/6322
Sam Lantinga a3900a75 2022-09-08T13:59:25 Lock joysticks when removing a controller on the WGI thread
Sam Lantinga 0ad8d9d2 2022-09-07T15:31:24 SDL_IsXInputDevice() shouldn't return true if XInput isn't enabled
Sam Lantinga e5f161bd 2022-08-30T19:12:22 Restored accidentally removed code to guess XInput device
Ozkan Sezer 973a677a 2022-08-31T02:32:28 SDL_xinputjoystick.c: commented out GuessXInputDevice() Not used since commit 277b033e78235d6ffad7525a1fb9acfef3a43433.
Shawn Hoffman 42d09a8f 2022-08-30T13:54:32 wgi: refcount the delegate objects
Shawn Hoffman ca915b18 2022-08-30T13:54:58 WGI_JoystickUpdate: bounds-check array sizes
Sam Lantinga 92d3fc48 2022-08-30T12:58:38 Fixed deadlock when shutting down the Windows joystick system
Sam Lantinga 675d90c7 2022-08-30T12:09:07 Revert "wgi: refcount the delegate objects" This reverts commit ff233fe3060e51706937a7b366438403bce774a4. This doesn't compile cleanly with Visual Studio and I don't want to introduce any subtle issues because we're passing the wrong types of pointers to WGI functions.
Sam Lantinga 40bd4fee 2022-08-30T11:42:13 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
Shawn Hoffman ff233fe3 2022-08-28T22:20:58 wgi: refcount the delegate objects assert if calls become unbalanced.
Cameron Gutman b7c1fbf9 2022-08-28T17:38:02 WGI: Fix a couple of reference leaks
Sam Lantinga 277b033e 2022-08-22T19:28:21 Refactor joystick GUID creation
Sam Lantinga c1e08739 2022-08-22T16:46:55 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
Your Name cfbeb438 2022-08-12T21:05:37 fix a bug if XINPUTGETBATTERYINFORMATION is nullptr
Shawn Hoffman 5aa438e8 2022-08-08T14:52:19 WGI: fix interop with applications that have their own WGI code QI for Added/Removed events need to handle IAgileObject
Sam Lantinga 12aa4d56 2022-08-01T11:11:25 Added header needed for SDL_Delay()
Sam Lantinga aeb27514 2022-08-01T10:38:31 Poll DirectInput devices to get their initial state Fixes https://github.com/libsdl-org/SDL/issues/3816
chalonverse f317d619 2022-07-01T13:59:14 Xbox GDKX support (#5869) * Xbox GDK support (14 squashed commits) * Added basic keyboard testing * Update readme * Code review fixes * Fixed issue where controller add/removal wasn't working (since the device notification events don't work on Xbox, have to use the joystick thread to poll XInput)
Jade Macho 6a2e6c82 2022-06-28T21:03:16 Add SDL_HINT_DIRECTINPUT_ENABLED (on by default)
Sam Lantinga 16f55fbd 2022-06-15T20:44:43 Separate the controller protocol from the controller style This allows us to handle controllers that use the Xbox protocol but look like Nintendo Switch or Playstation controllers, like the Qanba Dragon Arcade Stick in PC mode
Ozkan Sezer 714502d3 2022-06-13T22:15:56 minor windows warning fixes.
Sam Lantinga d2c4d74d 2022-05-27T15:49:35 Fixed build with MinGW-64 windows.devices.power.h The MinGW-64 header defines the parameters as ABI::Windows::Foundation::IReference<INT32 > **, but the Windows header defines the parameters as __FIReference_1_int**
Sam Lantinga bd22ca76 2022-05-27T15:40:50 Revert "Workaround for compiling with MinGW-w64" This reverts commit efdf43aa9b4f4d623ffba01f503d9793d5021330. The broken mingw headers aren't in an official release yet, so reporting this upstream.
Sam Lantinga efdf43aa 2022-05-27T15:34:45 Workaround for compiling with MinGW-w64 Fixes bug https://github.com/libsdl-org/SDL/issues/5589
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
Cameron Gutman 145824f6 2022-04-21T01:38:53 WGI: Only call RoUninitialize() if RoInitialize() succeeded
Cameron Gutman 00b2e10a 2022-04-20T20:58:29 WGI: Keep a reference to the MTA to avoid crashing on COM teardown Fixes #5552 Fixes #5270
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 006aafab 2022-03-22T20:23:09 Fixed freeing a constant string (thanks @gnrlwart)
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 f97a29f6 2022-02-11T22:10:33 Use the real device VID/PID when seeing the Steam virtual controller
Ryan C. Gordon 43f0271b 2022-01-24T08:56:33 Revert "fix compiler warnings in SDL_windows_gaming_input.c" This reverts commit ca36cdb185f2f26241598068927821896f36b904. The older Windows SDK's headers are wrong, and this change would crash if you hotplug a device.
pionere d7110b44 2022-01-08T12:07:16 fix compiler warnings in SDL_windows_gaming_input.c
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
Cameron Gutman d73bd0d2 2022-01-03T21:39:30 dinput: Don't crash in SDL_DINPUT_JoystickPresent if DInput init failed The WGI driver will call this regardless of whether our init succeeded.
Sam Lantinga 120c76c8 2022-01-03T09:40:00 Updated copyright for 2022
Sam Lantinga dd2f9111 2021-11-27T20:18:29 Fixed warnings with Windows SDK 10.0.19041 Fixes https://github.com/libsdl-org/SDL/issues/4998 Also breaks https://github.com/libsdl-org/SDL/issues/4998 for older SDKs, but we're going to ignore them, they're just incorrect.
Sam Lantinga c2904c8c 2021-11-27T11:16:15 Fixed compile warnings and errors Fixes https://github.com/libsdl-org/SDL/issues/4998
Sam Lantinga 09b7ca27 2021-11-27T10:53:20 Get the current WGI controller list at startup On Win32 this list is empty and we always get controller added events. On UWP, this list is populated and we don't get controlle added events for currently connected controllers.
Sam Lantinga 12895eca 2021-11-27T10:52:58 Fixed WGI initialization on Win32
Sam Lantinga 110e4e13 2021-11-27T10:24:32 Use WGI instead of XInput for Windows 10 UWP apps Fixes https://github.com/libsdl-org/SDL/issues/5017
Mathieu Eyraud 02021ae7 2021-11-27T13:17:04 Return capabitlities from RawInput joystick
Sam Lantinga 67b5de5b 2021-11-26T10:18:08 Fixed build warnings
Sam Lantinga 2ca2ad76 2021-11-26T10:13:45 Fixed build warnings
Ozkan Sezer f8900583 2021-11-23T17:04:40 removed windows winmm joystick driver
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
Sam Lantinga c2dd50a9 2021-11-12T08:28:02 Fixed whitespace
Cameron Gutman 50971577 2021-11-11T22:35:41 dinput: Fix memory leak when SDL_DINPUT_JoystickPresent() returns true