src/joystick/hidapi


Log

Author Commit Date CI Message
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.
Ryan C. Gordon 5fe34a40 2020-05-20T17:01:25 hidapi: Fix compiler warning.
Cameron Gutman 134362e7 2020-04-25T19:15:51 Enable Xbox One HIDAPI driver on macOS The Xbox One HIDAPI driver is required on macOS for Xbox One S Bluetooth support since https://hg.libsdl.org/SDL/rev/10c3a10908e9
Sam Lantinga b90b5927 2020-04-17T21:30:58 Added support for the Razer Atrox Arcade Stick
Sam Lantinga dbcda0b2 2020-04-17T21:30:56 Added support for the Razer Wolverine Ultimate
Sam Lantinga 2b323855 2020-04-17T15:08:48 Don't send rumble packets too quickly to Nintendo Switch Pro controllers over Bluetooth
Sam Lantinga c02f54a0 2020-04-17T15:08:46 Fixed the default face button mapping for Nintendo Switch Pro controllers
Sam Lantinga 50b1c195 2020-04-14T09:55:33 Fixed bug 5091 - Suspicious condition in HIDAPI_DriverXbox360_UpdateXInput meyraud705 On line 220 of SDL_hidapi_xbox360.c https://hg.libsdl.org/SDL/file/4608f0e6e8e3/src/joystick/hidapi/SDL_hidapi_xbox360.c#l220 if (!XINPUTGETSTATE(user_index, &xinput_state[user_index].state) == ERROR_SUCCESS) { logical not is only applied to the left hand side of this comparison. I think you mean: if (XINPUTGETSTATE(user_index, &xinput_state[user_index].state) != ERROR_SUCCESS) {
Sam Lantinga f34d2c60 2020-04-14T07:35:35 Added zlib license for Steam Controller headers
Sam Lantinga 55515a8c 2020-04-08T08:42:15 SDL: ps4 controller trigger bits on other controllers just mean that there's some activity, not saturation - only force it on if the analog value is 0.
Sam Lantinga b6afbe63 2020-04-07T09:38:57 Added SDL_log.h to SDL_internal.h so logging is available everywhere
Sam Lantinga 3154d924 2020-03-30T14:26:21 SDL: plumb previously unused digital trigger bits for PS4 controllers. Victrix fight stick only sets these bits and doesn't send the analog values CR: SamL
Sam Lantinga cb8c91d9 2020-03-22T11:01:14 Fixed bug 5051 - Switch Pro Controller hidapi driver does not report battery levels when connected via Bluetooth bluenaxela+sdl I've noticed that the Switch Pro Controller hidapi driver does not report battery levels when connected via Bluetooth, despite having code for setting joystick->epowerlevel. This is caused by the driver always using k_eSwitchInputReportIDs_SimpleControllerState via Bluetooth. Using that mode means that the state reports you get back from the controller do not include battery state. Not using the full controller state over Bluetooth effectively makes this driver's support for setting joystick->epowerlevel entirely pointless, only ever reporting SDL_JOYSTICK_POWER_WIRED. Is there a reason this was set to only use SimpleControllerState via Bluetooth? I've attached a patch I'm using to allow getting battery level for the Switch Pro Controller. A couple notes about this patch: 1) It changes LoadStickCalibration to accept the input_mode that is selected, because that's really what should determine what is used for stick extents, since stick extents differ between the modes. 2) In my patch I only use FullControllerState when the vid/pid matches the official Switch Pro Controller, as a cautionary measure in case some third-party controllers have problems with FullControllerState mode via Bluetooth (I noticed a HORI Wireless Switch Pad I had seemed to not read controller calibration correctly for stick extents. Maybe it's calibration data was uninitialized on account of having never been used with a Switch? I'm unsure, though if that guess is right maybe SDL2 should be detecting an uninitiated calibration state and using some sensible defaults)
Sam Lantinga f55cbdfd 2020-03-20T21:05:07 Allow Valve devices in driver check, we know they're well behaved controllers
Sam Lantinga 106ffd57 2020-03-20T20:45:30 Fixed bug 5049 - HORI Wireless Switch Pad does not connect properly via Bluetooth bluenaxela+sdl The HORI Wireless Switch Pad does not properly connect via bluetooth. I did some debugging and found that the code that tries to control the Home LED causes this controller to disconnect.
Sam Lantinga 9b879a08 2020-03-16T19:15:28 Fixed compiler warning
Jimb Esser c2c5d0b3 2020-03-16T16:52:49 Fix compile error
Jimb Esser 47da53b9 2020-03-16T14:49:20 Fix compiler warnings
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 879f137a 2020-03-13T19:00:24 Added support for the older Xbox One S Bluetooth controller report format
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 9fdc6cf3 2020-03-10T18:34:33 Removed Xbox HIDAPI debug code
Sam Lantinga fe979921 2020-03-10T17:35:14 Read the buttons on Nintendo Switch and GameCube controllers as they are labeled, and swap them if the applications wants positional button data instead.
Sam Lantinga 4caa6a06 2020-03-10T16:41:42 Fixed bug 4921 - Do not swap B/X buttons on GameCube controller unless it's requested Ethan Lee Basically replicating the solution of the Switch Controller's button label issue. Physical layout should take priority unless it's explicitly requested by the user or application!
Cameron Gutman 467434b9 2020-03-07T13:17:28 Added support for indicating player index on DS4 controllers
Sam Lantinga e9bc21fb 2020-03-04T17:10:37 Fixed rumble for third-party Nintento Switch Pro controllers The 8BitDo SF30 Pro Gamepad will generate a single motor pulse for each rumble message, so we need to do this frequently to have continous rumble on this device.
Sam Lantinga 428cfddb 2020-03-04T14:59:44 Fixed crash when a controller is disconnected while rumble is pending
Sam Lantinga 281d05a6 2020-03-04T09:42:10 Fixed handling the guide button with both V1 and V2 of the Xbox One Bluetooth wireless protocols
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
Sam Lantinga eb19631a 2020-03-02T10:57:57 This controller firmware is supported on Windows, and is covered by the Bluetooth check on Mac OSX
Sam Lantinga 27f346a0 2020-03-02T09:46:37 Fixed compile warning
Sam Lantinga 52be6633 2020-03-02T09:35:09 Use SDL math functions in Steam Controller support
Sam Lantinga 756d2073 2020-03-02T09:26:12 Updated the HIDAPI Xbox One driver with support for Bluetooth Xbox One controllers
Sam Lantinga 6590d078 2020-03-01T14:52:49 Fixed bug 4996 - Mac: XBoxOne Bluetooth rumble isn't working rofferom I have an annoying issue on MacOS about XBoxOne Bluetooth rumble (Vendor: 0x045e, Product: 0x02fd). When 360controller is installed, rumble is working correctly. However, Bluetooth rumble isn't working at all, with or without 360controller installed (although it is working with Chrome + https://html5gamepad.com). I looked at the code, and it seems that XBox controllers are managed in MacOS in this file: SDL_hidapi_xbox360.c. The XBoxOne file is disabled for MacOS in SDL_hidjoystick_c.h. The function HIDAPI_DriverXbox360_Rumble() is called correctly, and hid_write() returns no error. I have tried a stupid test. I took the rumble packet from 360controller: https://github.com/360Controller/360Controller/blob/ec4e88eb2d2535e9b32561c702f42fb22b0a7f99/XBOBTFF/FFDriver.cpp#L620. With the patch I have attached, I manage to have rumble working on Bluetooth (with some stupid vibration level, but it proves it can if the packet is changed). But it breaks the USB rumble with 360controller. A comment in the function makes an explicit reference to 360controller, I think that's why I have broken this specific usecase. I don't know what is the correct way to fix this, but it seems that the current implementation has a missing case for Bluetooth support. Note that I also tested master this morning, and I have another issue: if (!device->ffservice) { return SDL_Unsupported(); } test fails in DARWIN_JoystickRumble(). This test has been done quickly, I'm not totaly confident about its accuracy.
Romain Roff? 53462163 2020-03-01T13:01:53 mac: Fix gamepad detection
Sam Lantinga 1af31a26 2020-02-27T13:53:32 Fixed trying to handle the HORI Wireless Switch Pad when connected via USB
Sam Lantinga 20d67446 2020-02-27T09:33:32 Xbox One controller rumble doesn't need synchronization if you use a packet counter of 0
Sam Lantinga 8d146363 2020-02-19T08:26:00 Fixed support for third party Xbox 360 wireless controller dongle
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 833f76ab 2020-02-07T11:49:56 Fixed bug 4968 - NULL passed to memcpy in WriteProprietary in SDL_hidapi_switch.c meyraud705 In SDL_hidapi_switch.c line 443: Function BTrySetupUSB call WriteProprietary with pBuf=NULL and ucLen=0 line 376: WriteProprietary check its input (!pBuf && ucLen > 0) || ucLen > sizeof(packet.rgucProprietaryData): ucLen is 0 so it passes line 382: WriteProprietary call memcpy with pBuf=NULL
Sam Lantinga 8ba77b35 2020-02-07T11:44:57 Use the asynchronous HIDAPI rumble code for Nintendo Switch Pro controllers
Sam Lantinga 81256207 2020-02-07T11:02:34 Update for bug 4923 - Calling SDL_GameControllerRumble() often takes 8 ms meyraud705 Dualshock4 on bluetooth need 78 bytes for the rumble data while SDL_HIDAPI_RumbleRequest can only hold 64 bytes. 'volatile' is not meant for thread synchronization. The list of rumble request could grow infinitely if user call SDL_JoystickRumble too much. The documentation says "Each call to this function cancels any previous rumble effect", so overwriting pending request seem like a good idea.
Sam Lantinga 1d1a35ef 2020-02-04T16:05:39 Fixed Visual Studio build
Sam Lantinga 1bd12026 2020-02-04T15:42:49 Added SDL_hidapi_rumble.c to the macOS, iOS and tvOS builds
Sam Lantinga 02108cf7 2020-02-04T15:27:25 Added missing files from previous commit
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 212609b3 2020-01-31T14:09:23 Map the right pad on the Steam Controller to the right stick in the game controller API
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 0641711e 2020-01-29T20:09:59 Added missing file from previous commit
Sam Lantinga 355f0b54 2020-01-29T20:09:11 Added support for the Steam Controller on mobile devices
Sam Lantinga adb53d0b 2020-01-26T10:32:39 Fixed disabling the Xbox 360 wireless HIDAPI driver
Sam Lantinga c9f672fd 2020-01-23T22:24:24 Fixed compiler warnings
Sam Lantinga 443bce74 2020-01-22T11:28:35 Added support for the paddles on the Xbox One Elite Series 1 controller
Sam Lantinga 25c88ea9 2020-01-20T13:53:40 The Xbox One 0x01 initialization packet is an ack packet
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 c6817a2c 2020-01-16T15:32:41 Added support for the paddles on the Xbox One Elite Series 2 controller
Sam Lantinga 4e1cc124 2020-01-16T15:32:39 Improved Xbox One controller initialization
Sam Lantinga 669729a8 2020-01-15T22:18:31 Improved Xbox One controller initialization sequence This sequence works across Microsoft, PowerA, PDP, and HORI controllers. The newer Microsoft XBox firmware requires synchronizing the rumble sequence number, when SDL sees it after the initial connect The Razer Wildcat controller requires waiting for init responses before continuing the initialization sequence. The PDP Battlefield 1 controller takes over a second to be ready for initialization, and if initialization is attempted before then, it will fail.
Sam Lantinga 7775f7ce 2020-01-13T22:05:54 Fixed deadlock in HIDAPI joystick system
Sam Lantinga 3a796d6a 2020-01-13T15:35:54 Free the joystick player index when the joystick is removed
Sam Lantinga d2cda502 2020-01-12T17:22:24 Send the full Xbox One controller sequence for Microsoft controllers This switches Bluetooth controllers back into USB report mode for the latest Xbox One S and Xbox One Elite Series 2 firmware
Sam Lantinga 5d28c315 2020-01-09T14:53:34 Only initialize Xbox One controllers once they're ready for initialization (or if they are silent until init) This fixes the Hyperkin Duke Xbox One controller showing the Xbox startup animation every time an SDL application launches
Sam Lantinga 47abe4e3 2020-01-09T14:53:30 Fixed crash when unplugging a HIDAPI controller
Sam Lantinga a56aaea1 2020-01-07T16:47:56 Fixed handling the 8BitDo M30 in Nintendo Switch mode
Sam Lantinga 4c9628a0 2019-12-30T17:56:56 Fixed GameCube controller axis and trigger ranges and X and B button being swapped
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 6b767872 2019-12-19T21:45:44 Make sure the Xbox 360 driver doesn't try to talk to the wireless controllers
Sam Lantinga 1db56619 2019-12-19T18:03:28 Fixed rare infinite rumble in HIDAPI controller driver
Sam Lantinga 25bd5070 2019-12-19T18:00:08 Fixed GameCube rumble
Sam Lantinga 2481ab93 2019-12-19T15:58:16 Fixed compiler warning
Sam Lantinga fead0b24 2019-12-19T15:02:12 Added missing files from previous commits
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 52b6ab21 2019-12-16T17:11:23 Added support for the SteelSeries Stratus Duo
Sam Lantinga a7ae9175 2019-12-16T10:20:03 Fixed bug 4898 - No rumble because of integer overflow in SDL_JoystickRumble meyraud705 On a Dualshock 4 controller using hidapi driver, calling SDL_JoystickRumble with a duration too long (SDL_HAPTIC_INFINITY for example) causes the rumble to stop immediately. This happens because of integer overflow on line 301 of SDL_hidapi_ps4.c (https://hg.libsdl.org/SDL/file/a3077169ad23/src/joystick/hidapi/SDL_hidapi_ps4.c#l301), which sets expiration time in the past.
Sam Lantinga c2b6d6f9 2019-12-13T16:12:37 Enable the LED on PowerA Xbox One controllers
Sam Lantinga 0352814a 2019-12-13T16:07:25 Added general remapping of controller manufacturer
Sam Lantinga 1ac7eaba 2019-12-12T14:25:02 Fixed comment typo
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 82d2c357 2019-12-09T16:52:11 Fixed rumble after Xbox controller initialization When we initialize the controller it has an internal rumble sequence number, and if our rumble sequence number doesn't match that, rumble won't happen. To fix that we cycle through the range of sequence numbers, and at some point we'll match up with the controller's sequence number and it'll roll forward until it matches our next rumble sequence number.
Sam Lantinga 3d34750c 2019-12-09T13:54:05 The PowerA Mini controller blocks while writing feature reports, so don't try to use the HIDAPI driver for it on Linux
Sam Lantinga 36265063 2019-12-09T13:54:03 Added some missing Xbox controller names
Sam Lantinga 2fd3f756 2019-11-28T11:44:17 Fixed trying to use the HIDAPI driver for the original Xbox One S Bluetooth controller
Sam Lantinga 4a776138 2019-11-27T18:26:57 Added the full Xbox One Elite Series 2 controller initialization sequence, to start input reports after switching out of Bluetooth mode.
Sam Lantinga 0b863f8a 2019-11-27T15:27:19 Sorted controller entries by type and VID/PID to more easily find entries in the list
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