src/joystick/hidapi/SDL_hidapi_switch.c


Log

Author Commit Date CI Message
Sam Lantinga df537a7c 2022-08-09T00:18:19 SDL_GameControllerSetPlayerIndex(gamecontroller, -1) means turn off the player LED if possible
Sam Lantinga 6204ae50 2022-08-08T20:09:49 Restart the IMU if the controller stops sending gyro/accel data
Sam Lantinga d58bec72 2022-08-08T17:19:12 Fixed Joy-Con gyro axes in mini-gamepad mode
Sam Lantinga 87825972 2022-08-08T08:22:20 Added SDL_GameControllerType enumeration for Nintendo Switch Joy-Con controllers
Sam Lantinga 52bf5b1d 2022-08-06T10:34:19 Added the hint SDL_HINT_JOYSTICK_HIDAPI_SWITCH_PLAYER_LED to control whether the player LED is set on Nintendo Switch controllers
Sam Lantinga 4a9ceb7b 2022-08-04T11:33:36 The HORIPAD S uses the Xbox 360 protocol on all platforms and shows up as multiple styles of controller, depending on what model you have.
Sam Lantinga 28c01955 2022-08-04T10:46:37 Fixed button mapping for the HORIPAD S This controller actually comes in at least two flavors: a GameCube controller and an arcade pad, neither of which should have the face buttons remapped.
Sam Lantinga 43b90484 2022-08-04T00:40:38 Retry a little longer when writing to the Nintendo Joy-Con Charging Grip
Sam Lantinga dfd2c574 2022-08-03T22:27:43 Removed unused variable
Sam Lantinga c84dea09 2022-08-03T22:12:21 Fixed detecting the controller type of controllers over USB
Sam Lantinga ba297f12 2022-08-03T21:46:01 Use the Nintendo controller type to determine whether to always use button labels
Sam Lantinga 946f4777 2022-08-03T21:33:38 Don't set Bluetooth controllers to wired power level
Sam Lantinga 57c3b2c9 2022-08-03T21:31:12 Don't rely on the device VID/PID to get the Nintendo controller type The Nintendo Online Sega Genesis controller reports the SNES VID/PID over Bluetooth. This is a more robust way of handling future controllers as well, so let's go with this instead. Also use full reports over Bluetooth, and don't report gyro for Nintendo Online classic controllers.
Sam Lantinga b6aadb16 2022-08-03T20:38:33 Added k_eSwitchDeviceInfoControllerType_N64 to ESwitchDeviceInfoControllerType
Sam Lantinga bdfb32de 2022-08-03T20:30:58 Added some additional Nintendo controller types to ESwitchDeviceInfoControllerType
Sam Lantinga 5d50fa52 2022-08-03T19:39:36 Fixed timeout opening the Nintendo Joy-Con Charging Grip Sometimes opening the right Joy-Con takes a little longer for some reason
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 bcdef4aa 2022-08-03T13:07:47 Added separate hints for Nintendo Online classic controllers and Joy-Cons This allows them to be enabled/disabled separately from Switch Pro HIDAPI support
Mathieu Eyraud 59a104b8 2022-08-02T15:00:55 Do not pass NULL to memcpy ReadJoyConControllerType calls WriteSubcommandSync with pbuf=NULL
Sam Lantinga 875b737c 2022-07-28T21:39:32 Added support for the Nintendo Online NES Controllers to the HIDAPI driver
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 def60ce6 2022-07-27T19:20:42 Fixed the name of the HIDAPI Joy-Con controller for consistency with other drivers
Sam Lantinga a169259f 2022-07-27T09:05:02 Actually we don't need to unlock to send k_eSwitchProprietaryCommandIDs_ForceUSB since we don't wait for reply
Sam Lantinga c51464d9 2022-07-27T09:00:39 Put the Nintendo Switch Pro controller back into enhanced mode as needed Fixes https://github.com/libsdl-org/SDL/issues/3450
Sam Lantinga a423848e 2022-07-25T11:26:18 Allow floating point values for SDL_HINT_JOYSTICK_HIDAPI_SWITCH_HOME_LED This allows setting the brightness of the home LED on Nintendo Switch Pro controllers, in the range 0.0 - 1.0. This can be updated at runtime by setting the hint dynamically. Fixes https://github.com/libsdl-org/SDL/issues/3787
Sam Lantinga 68544be4 2022-06-10T11:31:59 Added support for the Nintendo Online controllers
Jibb Smart d7c07d6b 2022-04-27T00:57:17 Read motion sensor scale from Switch controllers (#5555) * Read IMU scale data from Switch controllers. Up until now, SDL has used hard-coded scaling which isn't correct with some supported controllers. * Moved declarations to beginning of code blocks to better fit with SDL style requirements
meyraud705 0964c84d 2022-02-02T11:21:32 Always use SDL_PrivateJoystickBatteryLevel to update battery level But do not use it for initialisation.
pionere 60deadba 2022-01-17T17:22:30 re-use return value of SDL_SetError/WIN_SetErrorFromHRESULT/SDL_OutOfMemory
Sam Lantinga 120c76c8 2022-01-03T09:40:00 Updated copyright for 2022
Sam Lantinga 66058bbb 2021-11-15T16:52:56 Fixed exception accessing Bluetooth devices on Android 12 Since accessing Bluetooth prompts the user for permission on both Android and iOS, and we only need it for Steam Controller support, we'll leave it off by default. You can enable it by setting the hint SDL_HINT_JOYSTICK_HIDAPI_STEAM to "1" before calling SDL_Init() Fixes https://github.com/libsdl-org/SDL/issues/4952
Ozkan Sezer a2c27d39 2021-11-13T17:56:28 SDL_hidapi_switch.c (ConstructSubcommand): lose use of '&' on rumbleData SwitchCommonOutputPacket_t->rumbleData is an array.
Cameron Gutman afccabb8 2021-11-11T12:12:05 joystick: Add capability flags for rumble and trigger rumble When API limitations force us to guess, we favor a false positive (reporting support when it doesn't exist) compared to a false negative.
Cameron Gutman 1ccfbf96 2021-11-11T11:13:08 joystick: Convert HasLED() into a generic GetCapabilities() function
Sam Lantinga 5b646cd1 2021-11-07T22:58:44 Build hidapi code into SDL as a new public API This prevents conflicts with hidapi linked with applications, as well as allowing applications to make use of HIDAPI on Android and other platforms that might not normally have an implementation available.
Sam Lantinga fe2fe290 2021-11-07T11:48:16 Backed out accidentally committed PR https://github.com/libsdl-org/SDL/pull/4849
Sam Lantinga 86bc65a7 2021-11-07T11:35:12 Fixed non-Apple builds
Sam Lantinga 345c161f 2021-09-22T09:06:45 Fixed some accidental uses of external C runtime functions
Sam Lantinga 503ea8e8 2021-08-25T14:41:58 Don't modify the Nintendo Switch home LED state by default
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 b3a0174b 2021-07-29T14:23:15 Scale the values correctly based on the sensor type (thanks @meyraud705)
Sam Lantinga a186a503 2021-07-29T06:43:39 Added SDL_GameControllerGetSensorDataRate() to get the sensor update rate for a controller.
Sam Lantinga 8d527def 2021-07-26T10:18:18 Revert "hidapi_switch: Implement HD rumble effect (#4538)" This reverts commit 19082b115b8ba3fff93e1c317c380718086a509c, which broke rumble on the Nintendo Switch Pro controller
Narr the Reg 19082b11 2021-07-26T12:00:53 hidapi_switch: Implement HD rumble effect (#4538)
Sam Lantinga 3c9559f7 2021-07-24T19:43:56 Don't try to rumble third-party Nintendo Switch Pro controllers Sending rumble to the PowerA Spectra Nintendo Switch controller hangs input reports for a couple of seconds.
german77 e6e8fe6d 2021-07-23T10:45:03 hidapi_switch: Implement analog rumble
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 3fcaf5b4 2021-05-25T10:33:30 Fixed incorrect axis scaling for Nintendo Switch controllers
JibbSmart c287087f 2021-02-23T09:26:03 Only change joystick->nbuttons for Joy-Cons, since they're the only ones that have these "paddles"
JibbSmart ee52624f 2021-02-22T17:23:13 Switch Joy-Con SL and SR buttons are now mapped to matching paddle positions so that all buttons can be accessed when using SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS
Sam Lantinga ac72a2ba 2021-01-25T20:38:50 Fixed bug 5493 - Hint to let the user opt out of having Switch controllers' Home button lit when opened jibb New hint to let the user opt out of having Switch controllers' Home button lit when opened. This is more consistent with the Switch itself (which doesn't light the button normally) and may be preferred by users who may disconnect their controller without letting the application close it. I think this warrants a Switch-specific hint because the default behaviour is unusual (inconsistent with using a Switch controller on a Switch itself or with some other programs on PC), and because of that it's distinct from other lights (the player number on Switch controllers and the player colour on PlayStation controllers).
Sam Lantinga c857b5e0 2021-01-23T11:21:01 Minor cleanup
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 bdb3e6b8 2021-01-15T12:40:00 SDL_hidapi_switch.c: fix build with older compilers
Sam Lantinga e3dbae50 2021-01-14T23:49:41 Get the serial number for the Nintendo Switch Pro controller
Sam Lantinga 5fc743c4 2021-01-14T23:49:37 Phantom Nintendo Switch Pro Controller initialization problem
Sam Lantinga 92742306 2021-01-14T23:49:33 Fixed rumble reset failing for Switch Pro controllers in USB mode
Sam Lantinga e2f46ed8 2021-01-14T23:49:20 Always lock the HIDAPI device when closing, in case rumble is pending
JibbSmart e9887045 2021-01-11T15:36:40 Gyro and Accel sensor support for Switch Pro Controller. Note that axes are changed to match the axes we're using with PlayStation controllers, since users will appreciate consistent behaviour across devices.
Sam Lantinga 9130f7c3 2021-01-02T10:25:38 Updated copyright for 2021
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.