From 23e007d3b7c8f8f5ccd99e58cd52bb5636fc8d04 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Wed, 14 Jun 2023 00:02:32 -0700
Subject: [PATCH] Fixed third party Nintendo Switch Pro Controller resetting
when being sent an unsupported command to set the Home LED
Tested with the PowerA Fusion Pro Wireless Controller in Bluetooth mode
---
src/joystick/hidapi/SDL_hidapi_switch.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/joystick/hidapi/SDL_hidapi_switch.c b/src/joystick/hidapi/SDL_hidapi_switch.c
index e01f13dafa24..57bbdd914ca0 100644
--- a/src/joystick/hidapi/SDL_hidapi_switch.c
+++ b/src/joystick/hidapi/SDL_hidapi_switch.c
@@ -1596,6 +1596,10 @@ static int HIDAPI_DriverSwitch_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL
/* Going into simple mode over USB disables input reports, so don't do that */
return 0;
}
+ if (cmd == k_eSwitchSubcommandIDs_SetHomeLight && !HasHomeLED(ctx)) {
+ /* Setting the home LED when it's not supported can cause the controller to reset */
+ return 0;
+ }
if (!WriteSubcommand(ctx, cmd, &payload[1], (Uint8)(size - 1), NULL)) {
return -1;