src/joystick/hidapi/SDL_hidapi_switch.c


Log

Author Commit Date CI Message
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 1e2caac5 2020-11-11T18:57:37 Added SDL_JoystickRumbleTriggers() and SDL_GameControllerRumbleTriggers()
Sam Lantinga d1e10c31 2020-11-11T14:38:14 Removed debug output
Sam Lantinga 009b62f1 2020-11-07T02:22:15 Be explicit about mapping the new game controller paddle buttons
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 e555d453 2020-11-05T11:07:54 Added SDL_JoystickHasLED Currently, this is only supported by the PS4 HIDAPI driver.
Ethan Lee 83cddd2e 2020-04-30T11:57:29 Add SDL_JoystickSetLED. Currently, this is only supported by the PS4 HIDAPI driver.
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 b6afbe63 2020-04-07T09:38:57 Added SDL_log.h to SDL_internal.h so logging is available everywhere
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 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.
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 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 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 1af31a26 2020-02-27T13:53:32 Fixed trying to handle the HORI Wireless Switch Pad when connected via USB
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 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 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 a8780c6a 2020-01-16T20:49:25 Updated copyright date for 2020
Sam Lantinga a56aaea1 2020-01-07T16:47:56 Fixed handling the 8BitDo M30 in Nintendo Switch mode
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 1db56619 2019-12-19T18:03:28 Fixed rare infinite rumble in HIDAPI controller driver
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 e7f7e3f4 2019-12-19T15:01:30 Refactored HIDAPI controller code to support dongles and hubs that dynamically attach controllers
Sam Lantinga 733f2525 2019-11-22T14:09:24 Fixed build
Sam Lantinga cf33f1f0 2019-11-13T21:53:01 Added a utility function to simplify the hint handling logic
Sam Lantinga 9a76bebf 2019-11-13T14:24:48 SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS defaults to true, to match Steam's default behavior
Sam Lantinga 9da4bfc1 2019-10-22T10:57:07 Added support for the Power A Nintendo Switch Enhanced Wireless Controller
Sam Lantinga b3470f04 2019-10-17T17:32:47 Added the hint SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS to control whether Nintendo Switch controllers use their button labels or button positions for game controller button reporting.
Sam Lantinga e6ac16ef 2019-10-17T16:59:05 Added support for third party Nintendo Switch controllers that don't support the full protocol
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 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 63107524 2018-08-15T19:53:34 Fixed input from the Steam Virtual Gamepad on Mac OS X
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 31b02243 2018-08-09T16:04:45 Added notes that this code was contributed by Valve
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