src/joystick/SDL_joystick.c


Log

Author Commit Date CI Message
Sam Lantinga 68544be4 2022-06-10T11:31:59 Added support for the Nintendo Online controllers
Sam Lantinga c7f41038 2022-06-09T13:47:29 Special case for k_eControllerType_XInputSwitchController in the raw input path
Sam Lantinga e6cb0822 2022-06-09T13:20:38 Fixed the default mapping on Windows for the HORI Fighting Commander
Christoph Reichenbach 3a20274d 2022-06-04T20:16:28 Refactoring: move GUID operations out of Joystick - SDL_JoystickGUID -> SDL_GUID (though we retain a type alias) - Operations for GUID <-> String ops are now in src/SDL_guid.c and include/SDL_guid.h - The corresponding Joystick operations delegate to SDL_guid.c - Added test/testguid.c
Sam Lantinga 423141bf 2022-06-03T18:49:41 Added a function to get the controller firmware version
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
Sam Lantinga b1cf3229 2022-05-19T16:49:47 Fixed HIDAPI PS4 controller being picked up when running under Steam Input with PS4 configuration enabled
Sam Lantinga 48b6cd8b 2022-05-16T07:23:30 Fixed whitespace
Sam Lantinga 94eeb587 2022-05-15T20:01:12 First pass at extending virtual controller functionality Added the ability to specify a name and the product VID/PID for a virtual controller Also added a test case to testgamecontroller, if you pass --virtual as a parameter
Sam Lantinga e551384a 2022-04-26T14:54:14 Added functions to get the platform dependent name for a joystick or game controller
meyraud705 3dcfe860 2022-02-02T13:59:49 Add joystick battery event
Kimplul 2398c43b 2022-03-24T14:34:37 add some Thrustmaster wheels
Ryan C. Gordon 4fe7b2cb 2022-03-24T11:00:43 static analysis: Fixed several complaints from codechecker. There are still some pending Objective-C specific issues. Reference issue #4600.
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 bcb0f1de 2022-03-17T08:52:31 Fixed build when events are disabled Fixes https://github.com/libsdl-org/SDL/issues/5413
Sam Lantinga 1b766937 2022-03-08T09:58:24 Fixed the SDL controller type for USB_PRODUCT_XBOX_ONE_XINPUT_CONTROLLER
Sam Lantinga af40cb6f 2022-02-23T15:49:10 Added support for the Razer Huntsman Analog keyboard in controller mode
Sam Lantinga 18032979 2022-02-15T13:07:51 Added the hint SDL_HINT_JOYSTICK_ROG_CHAKRAM to control whether ROG Chakram mice show up as joysticks This hint defaults off, but when it is enabled the mice will have a game controller mapping set up for Profile 3 (set in the Armoury Crate software)
Joshua Ashton 86b7a064 2022-02-04T16:40:05 Add additional VID/PIDs for Anne Pro II This thing changes its VID/PID on firmware revisions...
Vitaliy Zhmurikov 5b744592 2022-01-28T06:11:28 Update SDL_joystick.c Add Logitech Momo Racing Wheel VID & PID to SDL_IsJoystickProductWheel function
Cameron Gutman 419ae29d 2022-01-03T21:44:18 joystick: Move WGI driver initialization after Windows driver WGI calls SDL_DINPUT_JoystickPresent() so we need to be sure DInput remains initialized for the lifetime of the WGI driver to avoid a crash or duplicated joysticks between DInput and WGI.
Sam Lantinga 120c76c8 2022-01-03T09:40:00 Updated copyright for 2022
Ozkan Sezer 82fc67ae 2021-12-18T14:01:02 SDL_joystick.c: cast the arguments to nibble() to unsigned char.
Ozkan Sezer 47d3e96b 2021-12-18T14:01:02 SDL_joystick.c: (unsigned char) cast to SDL_tolower() parameters.
Sam Lantinga a6cbe0ab 2021-11-27T10:58:12 Controllers are always centered at zero using XInput and WGI
Sam Lantinga d8618204 2021-11-26T07:57:19 SDL_JoystickGetAttached() doesn't need to be noisy for NULL joystick Fixes https://github.com/libsdl-org/SDL/issues/5008
Cameron Gutman 1237142b 2021-11-18T19:52:34 joystick: Quit drivers in reverse order to ensure dependencies are not broken SDL_WINDOWS_JoystickDriver depends on callbacks in SDL_RAWINPUT_JoystickDriver and SDL_HIDAPI_JoystickDriver being available. It also manages the common WindowProc used for joystick detection in both WINDOWS and RAWINPUT drivers. If we don't tear them down backwards, there's a window of time where we could invoke RAWINPUT_WindowProc() after RAWINPUT_JoystickQuit() was called.
Cameron Gutman fe09a493 2021-11-11T15:53:11 joystick: Add APIs to query rumble support
Cameron Gutman 1ccfbf96 2021-11-11T11:13:08 joystick: Convert HasLED() into a generic GetCapabilities() function
Sam Lantinga 7681929c 2021-11-09T12:30:37 Don't send the initial joystick axis event if the application is in the background
Sam Lantinga d31f90d9 2021-11-09T12:09:01 Don't send game controller touchpad or sensor events unless the application has focus Fixes https://github.com/libsdl-org/SDL/issues/4891
Sam Lantinga 26706319 2021-10-30T05:53:12 Ignore the ASRock LED controller, it's not a joystick
Sam Lantinga a43d3f69 2021-10-20T15:19:22 Don't detect the ROG Chakram mouse as a joystick
Sam Lantinga 9706feac 2021-10-01T15:11:25 Update length after shortening string (thanks mayraud705!) Closes https://github.com/libsdl-org/SDL/pull/4698
Sam Lantinga 441fbcaa 2021-08-13T20:48:54 Added HIDAPI support for the Xbox Adaptive Controller
Sam Lantinga 907943a2 2021-08-12T17:51:08 Added support for the Xbox One S Controller with 5.x series firmware
Sam Lantinga 64882b24 2021-08-12T08:17:08 Added support for the Xbox One Elite 2 Controller with 5.x series firmware
Sam Lantinga 9fdb0645 2021-08-04T11:33:28 Added support for the Joy-Con Charging Grip when SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS is enabled
Sam Lantinga 16010f75 2021-07-30T18:23:43 Added support for the PowerA Nintendo Switch Fusion Arcade Stick
Sam Lantinga b33f4709 2021-07-30T18:23:42 Fixed detection of the PDP Afterglow Wireless Switch Controller over Bluetooth
Sam Lantinga 6af6950d 2021-07-30T18:23:42 Added support for the Victrix Gambit Tournament Controller
Sam Lantinga 243a8836 2021-07-30T18:23:41 The PowerA Nintendo Switch Fusion Pro Controller has a working USB mode, enabled via the switch on the underside of the controller.
Sam Lantinga a186a503 2021-07-29T06:43:39 Added SDL_GameControllerGetSensorDataRate() to get the sensor update rate for a controller.
Sam Lantinga 10ec4c86 2021-07-24T22:11:22 Added support for the PowerA Nintendo Switch Spectra Controller
Sam Lantinga 94b7a876 2021-07-24T09:10:18 Added SDL_GameControllerType enumerations for the Amazon Luna and Google Stadia controllers Fixes bug https://github.com/libsdl-org/SDL/issues/4019
Sam Lantinga 669714ca 2021-07-23T23:51:35 Added the ThrustMaster T.16000M as a flightstick
Sam Lantinga 422b053b 2021-07-23T16:32:35 Added support for the full line of current PowerA Xbox Series X controllers
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
Sam Lantinga 24e836b0 2021-07-06T10:00:09 Added controller mapping for the Nimbus+ controller on macOS when MFi support is not available
Joshua Ashton ca383599 2021-06-27T01:49:31 Fix Anne Pro II keyboard showing up as a joystick Having used this for a couple years, I can definitely confirm that it is not a joystick.
Sam Lantinga afd100f0 2021-06-18T17:37:46 Added support for the PowerA Fusion Pro 2 and the PDP Xbox Series X Afterglow and Blue controllers
Sam Lantinga d8dba5bc 2021-06-17T11:22:08 Added support for the Logitech G923 racing wheel
Paul Cercueil f3cf019e 2021-06-12T13:25:34 joystick: Add missing comma in joystick drivers list Without this comma it is impossible to enable both the Vita and Dummy drivers at the same time. Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Timo Gurr b63cb822 2021-05-30T01:57:56 Added T500RS to known wheel list
Kimplul 9e1d7bae 2021-05-12T17:43:39 Added T300RS to known wheel list
Sam Lantinga 2a20cc0f 2021-04-12T11:25:42 SDL: let through a SetLED command every 5sec to deall with situations where the controller loses power when a computer is suspended CR: SamL
Sam Lantinga 3377861a 2021-03-26T11:57:19 Added support for the Amazon Game Controller to the HIDAPI driver
Ivan Epifanov 73b545ed 2020-11-02T19:38:20 Fix joystick support
Sam Lantinga 1f7ec3fa 2021-02-11T17:27:22 Added support for the PowerA Xbox One Series X Wired Controller
Cameron Gutman f4d58689 2021-02-03T18:00:22 Fix Xbox Series X controller on macOS There were two different implementations of IsBluetoothXboxOneController(), one in SDL_hidapi_xbox360.c and one in SDL_hidapi_xboxone.c. The latter had been updated to include USB_PRODUCT_XBOX_ONE_SERIES_X_BLUETOOTH while the former had not. This mismatch led to the Xbox Series X failing on macOS only. We have special code for handling the 360Controller driver for macOS which requires us to use the Xbox 360 driver for wired Xbox One controllers, and the SDL_hidapi_xbox360 version of IsBluetoothXboxOneController() was used to determine which devices were wired. In addition to adding the missing USB_PRODUCT_XBOX_ONE_SERIES_X_BLUETOOTH, this change moves IsBluetoothXboxOneController() into a single shared function which will ensure this bug won't happen again.
Sam Lantinga 85235985 2021-02-02T11:53:31 Fixed detecting the paddles on the Xbox Elite Series 1 controller
Sam Lantinga 7e19c634 2021-01-28T14:53:59 Note that the Logitech G29 (PS4) is a racing wheel
JibbSmart 0f57864c 2021-01-18T19:57:29 Hint SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS added so we can recognise a Joy-Con as half a Pro Controller, so we can read its analog input and read its sensors just like we do a Pro Controller.
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 4a776557 2021-01-22T20:10:02 old os2 analogue joystick code ported from SDL-1.2. disabled by default, build-tested only.
Sam Lantinga 178ae70a 2021-01-20T12:18:10 Don't add paddle mappings for the Xbox One Elite Series 1 controller, since they can't be unmapped and read directly on that controller.
Sam Lantinga b2a0c712 2021-01-04T12:24:44 Allow setting the player index to -1, which turns off the player LED for PS5 controllers
Sam Lantinga 9130f7c3 2021-01-02T10:25:38 Updated copyright for 2021
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 3c07dd12 2020-11-25T10:28:48 Strip an extra '.' off of the HORI manufacturer name
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 feab9d42 2020-11-24T06:40:13 5363 - Memory leak of joystick->sensors in SDL_JoystickClose Mathieu Eyraud Joystick->sensors is never freed.
Sam Lantinga 62e39b5f 2020-11-23T20:57:14 Fixed building with an older SDK and macOS target
Sam Lantinga 179bd665 2020-11-23T18:27:43 Don't enable PS5 controller support if DS4Windows is running - they conflict.
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 51ea6a6d 2020-11-17T22:09:52 Don't send controller gyro and accelerometer updates if the values haven't changed. This keeps SDL_PollEvent() from returning data continuously when polling controller state.
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 d140d887 2020-11-16T17:36:47 Added SDL_JoystickGetSerial() and SDL_GameControllerGetSerial()
Sam Lantinga 7bbea0bb 2020-11-16T15:10:02 Fixed build warning
Ozkan Sezer c0f7325b 2020-11-15T17:10:15 SDL_PrivateJoystickForceRecentering: fix wrong loop counter usage. The typo seems to have been added by commit c7782fd6142b
Sam Lantinga 9f51fad3 2020-11-13T18:01:29 Added support for the touchpad on PS4 and PS5 controllers
Sam Lantinga 1e2caac5 2020-11-11T18:57:37 Added SDL_JoystickRumbleTriggers() and SDL_GameControllerRumbleTriggers()
Sam Lantinga e12457d8 2020-11-10T12:26:30 Added support for the Xbox Series X controller to the HIDAPI driver
Sam Lantinga c3dea231 2020-11-09T22:39:33 Added support for reading the paddles on a Xbox Elite Series 2 controller in Bluetooth mode
Sam Lantinga 3a3aaac2 2020-11-06T11:30:52 Added 4 auxiliary buttons to the game controller API Xbox Elite controllers use AUX1-AUX4 to represent the paddle buttons when using the HIDAPI driver PS4 and PS5 controllers use AUX1 to represent the touchpad button Nintendo Switch Pro controllers use AUX1 to represent the capture button
Sam Lantinga 4d79f966 2020-11-05T15:02:54 Added initial support for the Sony PS5 Controller
Sam Lantinga e555d453 2020-11-05T11:07:54 Added SDL_JoystickHasLED Currently, this is only supported by the PS4 HIDAPI driver.
Cameron Gutman 9d40a0f3 2020-08-29T16:50:26 Fix joystick device add events containing invalid device indexes This can happen if the application has not yet processed SDL_JOYDEVICEADD when the same joystick is removed. It may also happen if two joysticks are added and the second joystick is removed before the first joystick's SDL_JOYDEVICEADD has been processed by the application.
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 1a1f1704 2020-05-27T10:35:43 Don't include the iOS joystick driver if joysticks are disabled
Ethan Lee 83cddd2e 2020-04-30T11:57:29 Add SDL_JoystickSetLED. Currently, this is only supported by the PS4 HIDAPI driver.
Brendan Shanks 032fa681 2020-04-24T14:03:30 Add Logitech G29 to steering wheel list
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
Ryan C. Gordon 8c165add 2020-04-07T23:17:27 joystick: Remove force_centering flag; we handle this on disconnect now.
Ryan C. Gordon 07f231ee 2020-03-26T18:47:04 joystick: Make sure recentering events happen before disconnect events. Fixes Bugzilla #5063.
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.
David Ludwig b2296506 2020-03-15T15:05:36 virtual joysticks: MSVC support part 1/2, make driver's .c file be uniquely named
David Ludwig cc908756 2020-03-15T13:25:49 virtual joysticks: removed ball support (Bug 5028)
Sam Lantinga 2be75c6a 2020-03-13T19:08:45 Fixed bug 5028 - Virtual Joysticks (new joystick backend) David Ludwig I have created a new driver for SDL's Joystick and Game-Controller subsystem: a Virtual driver. This driver allows one to create a software-based joystick, which to SDL applications will look and react like a real joystick, but whose state can be set programmatically. A primary use case for this is to help enable developers to add touch-screen joysticks to their apps. The driver comes with a set of new, public APIs, with functions to attach and detach joysticks, set virtual-joystick state, and to determine if a joystick is a virtual-one. Use of virtual joysticks goes as such: 1. Attach one or more virtual joysticks by calling SDL_JoystickAttachVirtual. If successful, this returns the virtual-device's joystick-index. 2. Open the virtual joysticks (using indicies returned by SDL_JoystickAttachVirtual). 3. Call any of the SDL_JoystickSetVirtual* functions when joystick-state changes. Please note that virtual-joystick state will only get applied on the next call to SDL_JoystickUpdate, or when pumping or polling for SDL events (via SDL_PumpEvents or SDL_PollEvent). Here is a listing of the new, public APIs, at present and subject to change: ------------------------------------------------------------ /** * Attaches a new virtual joystick. * Returns the joystick's device index, or -1 if an error occurred. */ extern DECLSPEC int SDLCALL SDL_JoystickAttachVirtual(SDL_JoystickType type, int naxes, int nballs, int nbuttons, int nhats); /** * Detaches a virtual joystick * Returns 0 on success, or -1 if an error occurred. */ extern DECLSPEC int SDLCALL SDL_JoystickDetachVirtual(int device_index); /** * Indicates whether or not a virtual-joystick is at a given device index. */ extern DECLSPEC SDL_bool SDLCALL SDL_JoystickIsVirtual(int device_index); /** * Set values on an opened, virtual-joystick's controls. * Returns 0 on success, -1 on error. */ extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualAxis(SDL_Joystick * joystick, int axis, Sint16 value); extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualBall(SDL_Joystick * joystick, int ball, Sint16 xrel, Sint16 yrel); extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualButton(SDL_Joystick * joystick, int button, Uint8 value); extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualHat(SDL_Joystick * joystick, int hat, Uint8 value); ------------------------------------------------------------ Miscellaneous notes on the initial patch, which are also subject to change: 1. no test code is present in SDL, yet. This should, perhaps, change. Initial development was done with an ImGui-based app, which potentially is too thick for use in SDL-official. If tests are to be added, what kind of tests? Automated? Graphical? 2. virtual game controllers can be created by calling SDL_JoystickAttachVirtual with a joystick-type of SDL_JOYSTICK_TYPE_GAME_CONTROLLER, with naxes (num axes) set to SDL_CONTROLLER_AXIS_MAX, and with nbuttons (num buttons) set to SDL_CONTROLLER_BUTTON_MAX. When updating their state, values of type SDL_GameControllerAxis or SDL_GameControllerButton can be casted to an int and used for the control-index (in calls to SDL_JoystickSetVirtual* functions). 3. virtual joysticks' guids are mostly all-zeros with the exception of the last two bytes, the first of which is a 'v', to indicate that the guid is a virtual one, and the second of which is a SDL_JoystickType that has been converted into a Uint8. 4. virtual joysticks are ONLY turned into virtual game-controllers if and when their joystick-type is set to SDL_JOYSTICK_TYPE_GAMECONTROLLER. This is controlled by having SDL's default list of game-controllers have a single entry for a virtual game controller (of guid, "00000000000000000000000000007601", which is subject to the guid-encoding described above). 5. regarding having to call SDL_JoystickUpdate, either directly or indirectly via SDL_PumpEvents or SDL_PollEvents, before new virtual-joystick state becomes active (as specified via SDL_JoystickSetVirtual* function-calls), this was done to match behavior found in SDL's other joystick drivers, almost all of which will only update SDL-state during SDL_JoystickUpdate. 6. the initial patch is based off of SDL 2.0.12 7. the virtual joystick subsystem is disabled by default. It should be possible to enable it by building with SDL_JOYSTICK_VIRTUAL=1 Questions, comments, suggestions, or bug reports very welcome!
Sam Lantinga 6318765d 2020-03-13T13:05:43 Handle entirely duplicated joystick product names, as well as vendor and product names that start with the name of the vendor, but with different case (e.g. 8bitdo 8BitDo)