src/joystick/hidapi/SDL_hidapijoystick.c


Log

Author Commit Date CI Message
Sam Lantinga 80e5c689 2020-12-13T01:20:38 Fixed the PS5 controller not disconnecting when powered off
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 c9723c40 2020-12-07T09:38:21 Fixed potential hang in joystick close if the rumble thread is blocked for some reason It's still possible to hang when shutting down, if the rumble thread is still hung, but it won't block indefinitely at runtime.
Sam Lantinga 1031231b 2020-12-03T18:17:03 Fixed duplicating a device between XInput and HIDAPI
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 ce77966d 2020-11-27T10:44:49 Fixed RAWINPUT_IsDevicePresent() not returning TRUE for Xbox One 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 d140d887 2020-11-16T17:36:47 Added SDL_JoystickGetSerial() and SDL_GameControllerGetSerial()
Sam Lantinga 71e32f5e 2020-11-16T15:00:15 Added SDL_crc32()
Sam Lantinga c6c116e8 2020-11-16T10:51:13 Implemented setting the LED color on the PS5 controller
Sam Lantinga 78422fa3 2020-11-13T13:17:07 Added more detail on the PS5 controller state packet and enable full reports over Bluetooth
Sam Lantinga 1e2caac5 2020-11-11T18:57:37 Added SDL_JoystickRumbleTriggers() and SDL_GameControllerRumbleTriggers()
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 a22beef4 2020-11-05T17:03:28 Moved the PS5 controller driver to a separate file, as the advanced feature protocol is very different from that of the PS4
Sam Lantinga e555d453 2020-11-05T11:07:54 Added SDL_JoystickHasLED Currently, this is only supported by the PS4 HIDAPI driver.
Sam Lantinga d000c1cd 2020-05-29T21:22:11 Fixed bug 5155 - HIDAPI_JoystickDisconnected incorrect array shift Anthony Pesch I was looking into my own input bug and noticed an issue in the HIDAPI code while looking over it. I don't have a controller that goes down this path to test and try to provoke the issue, but it looks pretty straight forward. The memmove to shift the joystick id array on disconnect isn't scaling the size by sizeof(SDL_JoystickID), likely corrupting the ids on disconnect.
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.
Ethan Lee 83cddd2e 2020-04-30T11:57:29 Add SDL_JoystickSetLED. Currently, this is only supported by the PS4 HIDAPI driver.
Sam Lantinga b6afbe63 2020-04-07T09:38:57 Added SDL_log.h to SDL_internal.h so logging is available everywhere
Sam Lantinga f55cbdfd 2020-03-20T21:05:07 Allow Valve devices in driver check, we know they're well behaved controllers
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 d662a659 2020-03-13T19:00:22 Fixed crash if manufacturer or product string is NULL
Sam Lantinga c44473ba 2020-03-12T19:47:30 Unified code to standardize joystick names
Sam Lantinga 3b3ae4d1 2020-03-02T15:06:47 Possible fix for bug 5010 - SDL_Init with SDL_INIT_JOYSTICK hangs for 10 seconds when playing audio from another application Jake Breen When I run SDL_INIT with SDL_INIT_JOYSTICK it stalls for about 10 seconds (last report was 10,615ms), but only if I'm currently playing audio. (Like in Spotify for example.) querying something related to device access (last dll loaded) 'BabbysFirst64.exe' (Win32): Loaded 'C:\Windows\SysWOW64\deviceaccess.dll'. I use a USB DAC because my mobo's audio out is pretty not great. And I've noticed unplugging it seems to solve the issue. I haven't noticed any other issues that are caused by my DAC. My DAC is the Sound BlasterX G1 https://us.creative.com/p/gaming-headsets/sound-blasterx-g1 Vid = 041E PID = 3249 My system specs: - Windows 10 Pro - Ryzen 2700x - 16GB Ram - Nvidia 2070 RTX Additional USB devices plugged in: - Valve Index - Xbox One Elite Controller
Romain Roff? 53462163 2020-03-01T13:01:53 mac: Fix gamepad detection
Sam Lantinga 715f8d42 2020-02-14T16:15:46 Fixed bug 4986 - Memory leak in HIDAPI_JoystickConnected meyraud705 Memory allocated for device->joysticks on line 589 of SDL_hidapijoystick.c is never freed. Also, use memmove because memory is overlapping.
Sam Lantinga 1684606f 2020-02-04T15:26:56 Fixed long delay on main thread caused by blocking rumble writes in HIDAPI drivers There is now a thread that handles all HIDAPI rumble requests and a lock that guarantees that we're not reading and writing the device at the same time.
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 39a498c9 2020-01-31T13:09:20 Build the hidapi framework and weak link it on Mac OS X
Sam Lantinga 91121ee4 2020-01-31T10:45:04 Weak link the hidapi framework on iOS and tvOS
Sam Lantinga adb53d0b 2020-01-26T10:32:39 Fixed disabling the Xbox 360 wireless HIDAPI driver
Sam Lantinga 9c3d1602 2020-01-19T11:43:36 Refactored code so SDL_GetJoystickGameControllerType() is called less during controller detection
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 4e682461 2020-01-17T10:43:14 Reattach the kernel driver after closing USB controllers
Sam Lantinga a8780c6a 2020-01-16T20:49:25 Updated copyright date for 2020
Sam Lantinga 7775f7ce 2020-01-13T22:05:54 Fixed deadlock in HIDAPI joystick system
Sam Lantinga 47abe4e3 2020-01-09T14:53:30 Fixed crash when unplugging a HIDAPI controller
Sam Lantinga a9482a1d 2019-12-30T09:44:32 Added support for the Nintendo GameCube adapter, tested on Steam Link hardware
Zack Middleton f0cee3ed 2019-12-22T13:15:11 Fix shutting down HIDAPI device with multiple joysticks Using Wii U GameCube USB adapter with multiple controllers attached and restarting SDL input in a game results in extra joysticks with NULL name. HIDAPI_CleanupDeviceDriver() shut down joysticks by iterating through device->num_joysticks but each HIDAPI_JoystickDisconnected() decreases device->num_joysticks and shifts joysticks array down. Resulting in only half of controllers being shutdown. It worked with only 1 controller attached though. Disconnect HIDAPI device joystick 0 until there are none left.
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()
Sam Lantinga 2481ab93 2019-12-19T15:58:16 Fixed compiler warning
Sam Lantinga e22e77da 2019-12-19T15:01:35 Added an untested driver for the Nintendo GameCube adapter, based on code contributed by Ethan Lee
Sam Lantinga 15d30298 2019-12-19T15:01:32 Added support for wireless Xbox 360 controllers using the HIDAPI driver
Sam Lantinga e7f7e3f4 2019-12-19T15:01:30 Refactored HIDAPI controller code to support dongles and hubs that dynamically attach controllers
Sam Lantinga 0352814a 2019-12-13T16:07:25 Added general remapping of controller manufacturer
Sam Lantinga 0f529160 2019-12-11T17:47:01 Added custom names for some controllers
Sam Lantinga e029fdbb 2019-12-11T17:46:59 Shorten "Performance Designed Products" to "PDP"
Sam Lantinga 8b50dcb2 2019-12-11T17:46:54 Use the controller product string instead of hard-coding controller names
Sam Lantinga 3469481e 2019-12-10T10:00:49 Don't include the manufacturer if it's already included in the product string
Sam Lantinga 36265063 2019-12-09T13:54:03 Added some missing Xbox controller names
Sam Lantinga 43cb7b3c 2019-11-27T12:38:51 Added support for the Hori Fighting Commander
Sam Lantinga a76e5474 2019-11-27T12:38:48 Added support for the PowerA XB1 Fusion Fight Pad
Sam Lantinga a5e6b87c 2019-11-26T08:35:41 Added support for a variant of the PowerA FUSION Pro Controller
Sam Lantinga f3d95396 2019-11-25T15:02:54 Added some missing controller names
Sam Lantinga 8243a3e8 2019-11-25T15:02:50 Added support for the Hyperkin X91
Sam Lantinga 1e24a151 2019-11-18T11:51:39 Added names for some missing Xbox controllers
Sam Lantinga cf33f1f0 2019-11-13T21:53:01 Added a utility function to simplify the hint handling logic
Sam Lantinga 9da4bfc1 2019-10-22T10:57:07 Added support for the Power A Nintendo Switch Enhanced Wireless Controller
Sam Lantinga c10a8742 2019-07-31T10:20:37 Make sure HIDAPI is initialized whenever we call HIDAPI_IsDevicePresent()
Andrew Eikum c172f36b 2019-07-31T11:14:48 joystick: Ensure HIDAPI is initialized before calling it
Sam Lantinga dc714389 2019-07-25T15:21:44 Don't call hid_enumerate() if the HIDAPI drivers are all disabled
Sam Lantinga be6cda9f 2019-06-19T15:54:21 Rolling back GameCube HIDAPI support It causes the HIDAPI devices to always be opened on enumeration, which causes crashes in the Windows drivers when multiple applications are reading and writing at the same time. We can revisit this after 2.0.10 release.
Zack Middleton 82af4276 2019-06-08T13:36:59 hidapi: Use GameCube adapter controller port for player index The Nintendo USB GameCube adapter has four controller ports. Return the port number as 0 to 3 from SDL_JoystickGetPlayerIndex() and SDL_JoystickGetDevicePlayerIndex().
Ethan Lee c5286156 2019-03-12T20:27:54 hidapi: Add support for Wii U/Switch USB GameCube controller adapter. Note that a single USB device is responsible for all 4 joysticks, so a large rewrite of the DeviceDriver functions was necessary to allow a single device to produce multiple joysticks.
Sam Lantinga 5e13087b 2019-01-04T22:01:14 Updated copyright for 2019
Sam Lantinga 14c55ac8 2018-10-26T20:20:28 This change looks okay in the general case. If we run into problems where these events aren't dispatched (initialized on a different thread than the main thread?) we may need to create a separate thread to handle device notifications like we do with the windows joystick subsystem.
Ryan C. Gordon be8ef94f 2018-10-26T14:43:39 hidapi: Don't run a separate event loop for device notifications. Fixes Bugzilla #4286.
Sam Lantinga 14329256 2018-10-25T16:53:14 Generalized the XInput user index into a player index
Sam Lantinga 19445561 2018-10-02T20:51:33 Make sure we don't read and write to HIDAPI at the same time, it's not thread-safe on Windows
Ozkan Sezer 870c44bf 2018-09-25T09:20:56 safer this way, just in case..
Sam Lantinga cd90e2ca 2018-09-24T16:33:14 Fixed bug 4267 - linkage failure with --enable-hidapi because of missing libudev symbols Ozkan Sezer hidapi dynamic udev initial patch
Sam Lantinga 6a7b0c27 2018-09-14T12:41:29 Fixed crash launching under Steam on Mac OS X
Ozkan Sezer 33381d3d 2018-09-07T11:03:24 hidapi/SDL_hidapijoystick.c: fix build in C90 mode: src/joystick/hidapi/SDL_hidapijoystick.c: In function 'HIDAPI_InitializeDiscovery': src/joystick/hidapi/SDL_hidapijoystick.c:281: error: 'true' undeclared (first use in this function) src/joystick/hidapi/SDL_hidapijoystick.c:281: error: (Each undeclared identifier is reported only once src/joystick/hidapi/SDL_hidapijoystick.c:281: error: for each function it appears in.) src/joystick/hidapi/SDL_hidapijoystick.c: In function 'HIDAPI_UpdateDiscovery': src/joystick/hidapi/SDL_hidapijoystick.c:339: error: 'true' undeclared (first use in this function) src/joystick/hidapi/SDL_hidapijoystick.c:341: error: ISO C90 forbids mixed declarations and code
Sam Lantinga 34237b80 2018-08-31T18:10:21 Better fix to make sure we're only returning controllers from the HIDAPI joystick API
Sam Lantinga 16ccff3c 2018-08-29T20:23:36 Fixed whitespace
Sam Lantinga 3f5ff751 2018-08-15T23:14:43 Use a unified name list for Xbox 360 and Xbox One controllers for drivers that can handle both
Sam Lantinga 63107524 2018-08-15T19:53:34 Fixed input from the Steam Virtual Gamepad on Mac OS X
Sam Lantinga 0903e835 2018-08-15T19:53:31 Use SDL specific window class to avoid conflicting with Steam
Sam Lantinga c8866658 2018-08-15T19:53:30 Catch device removal as well as device arrival on Windows
Sam Lantinga 641c674f 2018-08-15T19:53:28 Turned off debug messages
Sam Lantinga 51902010 2018-08-15T19:53:26 Remove the HIDAPI device if we get a read error from it This fixes detecting PS4 controller disconnect on Mac OS X, where there isn't any device removed notification
Sam Lantinga dfbd7f65 2018-08-15T19:53:24 Fixed Mac OS X build
Sam Lantinga ec74c318 2018-08-15T19:53:22 Polling hid_enumerate() every 3 seconds causes freezes and stutters on some USB audio devices and mice. We'll only enumerate devices when we get notification that the system devices have changed
Sam Lantinga ab07ce11 2018-08-09T16:04:30 Don't update the device list for devices we know aren't supported This should reduce HID enumeration (hitting the USB bus) if for some reason we're getting spammed with false device insert/removal events
Sam Lantinga 888bf1af 2018-08-09T16:03:50 Worked around bug with Sony PS Now PS3 controller where DirectInput polling will continue to return success after the controller is unplugged. The code is now reliant on SDL_PrivateJoystickAdded() and SDL_PrivateJoystickRemoved() being called correctly when devices are added or removed on Windows
Sam Lantinga d2042e1e 2018-08-09T16:00:17 Added HIDAPI joystick drivers for more consistent support for Xbox, PS4 and Nintendo Switch Pro controller support across platforms. Added SDL_GameControllerRumble() and SDL_JoystickRumble() for simple force feedback outside of the SDL haptics API