src/joystick/SDL_joystick.c


Log

Author Commit Date CI Message
Makarenko Oleg e9ab663c 2023-09-04T22:11:13 Detect Simagic wheel bases as wheels (#8198) Simagic DirectDrive wheel bases have the same vendor + product id's (cherry picked from commit a2c1984d371e86e97bd6ffb176e835925e6afb3a) (cherry picked from commit 1d495351a0944c598e78c130b635f9447b5bc871)
Oleg c8d1de1a 2023-09-04T20:26:24 Detect Logitech G923 Playstation as wheel G923 have two different versions - Xbox version is already present in the wheel list, but not the PS version. (cherry picked from commit 266b91d2fd2b3362d1828f8a6b58589bdaa4f75d) (cherry picked from commit 365a36386ac18a2636c0d7b9597edb3644df0735)
Oleg bf8c9cd6 2023-09-04T20:46:09 Detect Logitech PRO Racing Wheel for Xbox (PC mode) as wheel Logitech PRO Racing Wheel have two different versions - for Playstation and Xbox. Vendor + Product ID for Playstation version already present in SDL sources, but not an Xbox version (cherry picked from commit cde67ea49ad812088bd5c8cfd67ef090ac1c1d86) (cherry picked from commit 242b25aba47871a571457bc6e71ff4c89bbafc3b)
Sam Lantinga ff4fd93f 2023-07-14T10:01:04 Fixed getting the CRC of virtual joysticks without a VID/PID (cherry picked from commit b40fb5c51e2a5350ba00fbf4db86b4ae1066db92) (cherry picked from commit 6089b35706171b950f55a010bc9df2114cd7a783)
Sam Lantinga 491fba1d 2023-06-24T15:38:38 SDL_FindFreePlayerIndex() will always return the next available player index Fixes https://github.com/libsdl-org/SDL/issues/7868 (cherry picked from commit 87e916dd214866af9cfd67eb4618918bc8b0f1b4) (cherry picked from commit 38619bb28db83bc5844d13d99b3072496adcd498)
Sam Lantinga 7db23f4e 2023-06-13T10:05:19 Fixed joystick vendor detection in Linux automatic gamepad mapping (cherry picked from commit 071d1e29dd4f80605932f320aa2e05fda383944c)
Sam Lantinga c77aaa5d 2023-06-12T15:39:57 Fixed n3ds build (cherry picked from commit d95dbe78bb7a5087ecfb8d301417b1108d868738)
Sam Lantinga e4e0a129 2023-06-12T15:26:34 Reduce the chance of destroying the joystick mutex while it's in use Fixes https://github.com/libsdl-org/SDL/issues/7811 (cherry picked from commit 6390165fd4c193631d6780758a4aeec0d02b90eb)
Ozkan Sezer a70964aa 2023-03-08T20:00:50 fix SDL_FindFreePlayerIndex so it can really return -1.
Sam Lantinga 35c13196 2023-03-08T08:40:38 Fixed uninitialized variable
Sam Lantinga 3dff5d3c 2023-02-06T20:14:12 Added support for the Turtle Beach REACT-R and Recon Xbox controllers (cherry picked from commit 5fded632d6fa532ac25e76ad9a676c9ea726dd02)
Sam Lantinga abe8dbbf 2023-02-20T15:14:20 Added support for the Razer Wolverine V2 controllers (cherry picked from commit 4994654d4f2d5c96a0faa972ebbb6c653f939d56)
Sam Lantinga f741adc8 2023-02-17T11:29:27 Added other names for the DragonRise Inc. Wired Wheel (thanks @felimwhiteley!) (cherry picked from commit eede2066fbcc342e96592fbbbfe94b2420feb524)
Sam Lantinga 0479df53 2023-01-09T09:48:21 Updated copyright for 2023
Sam Lantinga 2cb7a0a0 2023-01-03T15:12:18 Added support for the ThrustMaster eSwap PRO Controller Xbox (cherry picked from commit dacdb1c310d97ca3c3e6492cae0611f86b281b34)
Sam Lantinga 29a4c5eb 2022-12-28T12:51:36 Fixed getting the VID/PID of a virtual joystick (cherry picked from commit e40a96155fc488feaeeeb79f947eb43399faa481)
Sam Lantinga 6969b3be 2022-12-19T09:14:04 Don't send Razer devices the Sony third-party query feature report Some of them lock up or reset, and the vast majority of devices are not actually game controllers. Fixes https://github.com/libsdl-org/SDL/issues/6733 (cherry picked from commit 83b29f9ce1fe6caa06769544c3b5f6c10ea97a0f)
Sam Lantinga 3b0cd441 2022-12-17T06:51:02 Fixed compiler warning ``` ./src/joystick/SDL_joystick.c:105:12: warning: no previous extern declaration for non-static variable 'SDL_joystick_lock' [-Wmissing-variable-declarations] SDL_mutex *SDL_joystick_lock = NULL; /* This needs to support recursive locks */ ^ ./src/joystick/SDL_joystick.c:105:1: note: declare 'static' if the variable is not intended to be used outside of this translation unit SDL_mutex *SDL_joystick_lock = NULL; /* This needs to support recursive locks */ ^ ``` 1 warning generated.
Sam Lantinga e99b9ca9 2022-12-15T17:58:29 Note that the NACON Daija Arcade Stick is an arcade stick
Sam Lantinga d59caffe 2022-12-13T14:03:40 Added support for clang thread-safety analysis The annotations have been added to SDL_mutex.h and have been made public so applications can enable this for their own code. Clang assumes that locking and unlocking can't fail, but SDL has the concept of a NULL mutex, so the mutex functions have been changed not to report errors if a mutex hasn't been initialized. We do have mutexes that might be accessed when they are NULL, notably in the event system, so this is an important change. This commit cleans up a bunch of rare race conditions in the joystick and game controller code so now everything should be completely protected by the joystick lock. To test this, change the compiler to "clang -Wthread-safety -Werror=thread-safety -DSDL_THREAD_SAFETY_ANALYSIS"
Sam Lantinga 817454cf 2022-12-12T18:00:57 Don't try to open the Razer Huntsman Elite keyboard as a controller
Sam Lantinga b4d54790 2022-12-07T14:53:33 Use the correct name for the DualSense controllers (cherry picked from commit 9a6bcca6b8db999217f157dab8c44bf27b0a8eb4)
Sam Lantinga 4ee36a94 2022-12-07T14:25:53 Added support for the DualSense Edge paddles (cherry picked from commit 9339085593dc20b1f003f26b3c40615cf04504b0)
Max Bachmann 7ac66972 2022-12-03T09:45:04 Detect Logitech PRO Racing Wheel as wheel (cherry picked from commit 5650046f931e9b1d7d7f4a1867e6e1ed75a5e7c5)
Sam Lantinga 423c558e 2022-12-01T14:43:34 Detect the G923 (Xbox style) and PXN V900 (PS3 mode) as wheels (cherry picked from commit 7237c5649994d2b2c2b364c3b116a6db80ea671d)
Pierre Wendling d0bbfdbf 2022-12-01T16:07:03 Clang-Tidy fixes (#6725) (cherry picked from commit 3c501b963dd8f0605a6ce7978882df39ba76f9cd)
Sam Lantinga 01541bc3 2022-11-30T16:42:00 Added support for the HORIPAD Pro for Xbox Series X
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 89e9f7b4 2022-11-28T23:10:02 Added support for the Xbox Elite controller paddles with firmware version 5.13+
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 d167cd67 2022-11-21T09:02:10 Added the Gunfighter Mk.III ‘Space Combat Edition’ as a flight stick
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
meyraud705 3dc88da0 2022-11-08T13:27:56 Fix Dualshock 4 rumble stopping too early Dualshock 4 controller only rumbles for 5 seconds maximum. Resend rumble command every 2 seconds to make long rumble work.
Sam Lantinga 02bc359b 2022-11-07T19:31:18 Shorten "Bensussen Deutsch & Associates,Inc.(BDA)" to "BDA" for controller names
Sam Lantinga a6018ae5 2022-10-25T10:23:51 Added support for the NVIDIA SHIELD controller v1.03 to the HIDAPI driver
Sam Lantinga 5b8f830e 2022-10-22T09:24:28 Virtual joysticks don't need initial axis jitter protection Fixes https://github.com/libsdl-org/SDL/issues/6426
Sam Lantinga 333935ff 2022-10-17T11:10:53 Make sure we completely unlock joysticks when opening HIDAPI devices Also lock the joysticks when adding and removing Android joysticks
Sam Lantinga 120a957d 2022-10-14T09:57:02 Added support for the Qanba Drone Arcade Stick
Pierre Wendling 65527537 2021-03-30T04:32:39 N3DS port (squashed) A dedicated renderer using Citro3D would likely allow for better much better graphical performances.
Sam Lantinga 2c518747 2022-09-27T09:56:02 Added microsecond timestamp to sensor values for PS4 and PS5 controllers using the HIDAPI driver
Sam Lantinga 4ea64fee 2022-09-23T15:28:32 Fixed manufacturer/product name deduplication for the Razer Raiju Tournament Edition controller
Sam Lantinga 34f928ab 2022-09-23T09:26:18 Generate the correct name for ASTRO Gaming controllers Manufacturer "ASTRO Gaming" and product "ASTRO C40" turns into "ASTRO C40"
Sam Lantinga 6ddef7c2 2022-09-23T09:20:27 Generate the correct name for Qanba and Mad Catz controllers
Sam Lantinga b7940c29 2022-09-23T00:15:40 Allow HIDAPI controllers to override the default joystick type
Sam Lantinga fa2063fb 2022-09-22T23:42:25 Improved detection of third party PS4 and PS5 controllers
Sam Lantinga 2e9f5b59 2022-09-16T15:41:35 Added support for the HORI Fighting Commander OCTA (Xbox Series X and PS versions)
Sam Lantinga 12413ab3 2022-09-08T13:33:04 Lock joysticks while attaching a virtual one
Sam Lantinga 40715732 2022-09-08T11:50:56 Don't try to second guess DS4Windows, let it remap things as expected. DS4Windows can create both emulated Xbox and emulated PS4 controllers, and we don't know which the user has it doing, so don't try to second guess it, just let it do it's thing. Users should follow the remapping software recommendations on when to enable/disable it for various situations. Fixes https://github.com/libsdl-org/SDL/issues/6167
Sam Lantinga f398d8a4 2022-09-07T11:53:13 Note that the Logitech Extreme 3D is a flight stick
Sam Lantinga 0a05b281 2022-09-07T11:51:16 Make sure we hold the joystick lock when updating the device state while opening it
Sam Lantinga 1b4e08b8 2022-09-02T17:04:30 Added an entry for the Hori Fighting Stick mini 4 kai This is a PS3/PS4 arcade stick which becomes an Xbox 360 controller on PC
Sam Lantinga 92d3fc48 2022-08-30T12:58:38 Fixed deadlock when shutting down the Windows joystick system
Sam Lantinga 0e4baf1c 2022-08-30T12:39:23 Don't crash if SDL functions are passed a closed joystick or gamecontroller
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
Sam Lantinga b2ac758f 2022-08-29T17:33:00 Added support for the Hori Fighting Stick Alpha to the HIDAPI driver
Sam Lantinga 0b8b321f 2022-08-28T23:01:30 Allow the product version to be different when trying to find a controller mapping This is in the hope that revving the product version doesn't change the mapping, which is the case for some devices. In cases where it does, we just need to provide a mapping for each version of the product.
Sam Lantinga 32700294 2022-08-28T17:56:11 Don't crash if SDL_CreateJoystickGUID() is passed a NULL name
Sam Lantinga 3cbfd75d 2022-08-27T18:55:55 Re-added the CRC to the joystick guid This is now used as a crc field in the mapping rather than directly in mapping guids, for better mapping compatibility between versions of SDL. Added SDL_GetJoystickGUIDInfo() to get device information encoded in a joystick GUID, so that mapping programs can clear the CRC from the GUID when generating mappings. sort_controllers.py has been updated to extract the CRC from mappings created by older mapping programs and convert it into the new crc field. It will also take the CRC into account when checking for duplicate mappings. Also regenerated the GUIDs for the PS2/PSP/Vita controller mappings, fixing https://github.com/libsdl-org/SDL/issues/6151
Sam Lantinga 9a01eac5 2022-08-26T13:45:05 Temporarily disable joystick GUID CRCs
Sam Lantinga f6c2c22d 2022-08-25T22:25:25 Don't try to use the charging port for the PowerA wireless controller as an input device
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
Mathieu Eyraud c6c688ab 2022-08-14T14:55:32 Add SDL_JOYBATTERYUPDATED event to SDL_JoystickEventState()
Sam Lantinga 55882e43 2022-08-09T00:19:02 Fixed invalid read when SDL_GameControllerSetPlayerIndex() is passed a negative player_index
Sam Lantinga 593d20d9 2022-08-08T20:11:43 Removed debug logging
Sam Lantinga 6204ae50 2022-08-08T20:09:49 Restart the IMU if the controller stops sending gyro/accel data
Sam Lantinga ada55c69 2022-08-08T15:38:19 Fixed Joy-Con type detection for the Nintendo Joy-Con Charging Grip
Sam Lantinga 87825972 2022-08-08T08:22:20 Added SDL_GameControllerType enumeration for Nintendo Switch Joy-Con controllers
Sam Lantinga 4f19421e 2022-08-07T20:17:40 Fixed build
Sam Lantinga 29265d07 2022-08-07T18:49:30 Use SDL_GetStringBoolean() to parse the hint value
Sam Lantinga ea7fbf79 2022-08-03T19:39:37 Update in-flight SDL_CONTROLLERDEVICEADDED messages when a device is removed This fixes the application trying to open the wrong device index when a device is removed and another has just been added
Sam Lantinga 29cdb2c9 2022-08-03T18:01:10 Added support for the Nintendo Switch Joy-Con Charging Grip
Sam Lantinga a8120104 2022-08-03T13:53:49 The Nintendo Online classic controllers and Joy-Cons shouldn't show up as Switch Pro controllers
Sam Lantinga 41c363f7 2022-07-29T16:27:23 Note that the PDP Versus Fighting Pad is an arcade fighting pad
Sam Lantinga d8fd7873 2022-07-28T21:44:23 Added entry for the Nintendo Switch Joy-Con controller pair
Sam Lantinga 2fa2f9ff 2022-07-28T19:22:27 Greatly improved Nintendo Joy-Con support using the HIDAPI driver * Added support for mini-gamepad mode for Joy-Con controllers, matching the mapping for hid-nintendo on Linux and iOS 16 * Added the ability to merge left and right Joy-Con controllers into a single Pro-style controller * Added the hint SDL_HINT_JOYSTICK_HIDAPI_SWITCH_COMBINE_JOY_CONS to control this merging functionality * Removed the hint SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS
Sam Lantinga be3a945a 2022-07-20T11:05:55 Added support for the 8BitDo Ultimate Wired Controller for Xbox
Ozkan Sezer 4fa26533 2022-07-12T00:55:00 SDL_GetJoystickGUIDInfo: byte-swap vendor, product and version values. Reference issue: https://github.com/libsdl-org/SDL/issues/5907
Cameron Gutman 6e712d24 2022-07-09T22:55:36 joystick: Add HIDAPI driver for NVIDIA SHIELD 2017 controller Basic input already works using the OS HID driver, but this enables force feedback and battery state reporting.
chalonverse 3b191580 2022-06-27T17:19:39 Windows GDK Support (#5830) * Added GDK * Simplfied checks in SDL_config_wingdk.h * Added testgdk sample * Added GDK readme * Fixed error in merge of SDL_windows.h * Additional GDK fixes * OpenWatcom should not export _SDL_GDKGetTaskQueue * Formatting fixes * Moved initialization code into SDL_GDKRunApp
Francisco Javier Trujillo Mata 7fd46ec5 2022-06-18T17:40:53 Initial PS2_Joystick implementation
Sam Lantinga eb7e29a8 2022-06-17T17:43:14 Fixed crash when the joystick product name isn't available
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
Sam Lantinga a9cf313e 2022-06-15T17:28:29 Added the Qanba Obsidian and Dragon Arcade Sticks to the arcade stick list
Sam Lantinga 72fea0ed 2022-06-15T13:58:28 Added support for the Qanba Dragon Arcade Joystick
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.