SDL/src/joystick
Sam Lantinga cb8c91d956 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)
2020-03-22 11:01:14 -07:00
..
android Unified code to standardize joystick names 2020-03-12 19:47:30 -07:00
bsd Moved rumble expiration to the main joystick handling level, and prevent sending the driver layer duplicate rumble requests. 2020-02-04 12:48:53 -08:00
darwin Fix for Bug 5034 - Replugging in a controller crashes on macOS in SDL 2.0.12 2020-03-17 17:34:24 -04:00
dummy Moved rumble expiration to the main joystick handling level, and prevent sending the driver layer duplicate rumble requests. 2020-02-04 12:48:53 -08:00
emscripten Unified code to standardize joystick names 2020-03-12 19:47:30 -07:00
haiku Unified code to standardize joystick names 2020-03-12 19:47:30 -07:00
hidapi Fixed bug 5051 - Switch Pro Controller hidapi driver does not report battery levels when connected via Bluetooth 2020-03-22 11:01:14 -07:00
iphoneos Unified code to standardize joystick names 2020-03-12 19:47:30 -07:00
linux Unified code to standardize joystick names 2020-03-12 19:47:30 -07:00
psp Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
steam Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
virtual virtual joysticks: move variable decls to top of function (for C90 compat; Bug 5038) 2020-03-16 17:19:18 -04:00
windows Probable fix for compile errors on Mac OS and (non-VS) Win32 2020-03-20 19:49:19 -07:00
controller_type.h Fixed bug 4854 - Add a way to extend the values in controller_type.h 2020-03-02 10:37:28 -08:00
SDL_gamecontroller.c Fixed bug 4477 - Support more than 4 XInput-capable devices on Windows 2020-03-16 12:23:38 -07:00
SDL_gamecontrollerdb.h Fixed bug 5028 - Virtual Joysticks (new joystick backend) 2020-03-13 19:08:45 -07:00
SDL_joystick.c Fixed bug 4477 - Support more than 4 XInput-capable devices on Windows 2020-03-16 12:23:38 -07:00
SDL_joystick_c.h Fixed bug 4477 - Support more than 4 XInput-capable devices on Windows 2020-03-16 12:23:38 -07:00
SDL_sysjoystick.h Fixed bug 4477 - Support more than 4 XInput-capable devices on Windows 2020-03-16 12:23:38 -07:00
sort_controllers.py Added support for SDL hints in the game controller mapping database 2020-03-12 19:47:28 -07:00
usb_ids.h Fixed bug 5051 - Switch Pro Controller hidapi driver does not report battery levels when connected via Bluetooth 2020-03-22 11:01:14 -07:00