From 9a4d29699db3cf4bb0b0520d2ef78167e5cdb069 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 27 Dec 2024 13:57:53 -0800 Subject: [PATCH] Don't use connection state from the Nintendo Switch Pro report This isn't reliable for third party controllers like the 8BitDo Pro 2. Fixes https://github.com/libsdl-org/SDL/issues/10862 --- src/joystick/hidapi/SDL_hidapi_switch.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/joystick/hidapi/SDL_hidapi_switch.c b/src/joystick/hidapi/SDL_hidapi_switch.c index ea43af30cb..2010e7b464 100644 --- a/src/joystick/hidapi/SDL_hidapi_switch.c +++ b/src/joystick/hidapi/SDL_hidapi_switch.c @@ -2433,7 +2433,7 @@ static void HandleFullControllerState(SDL_Joystick *joystick, SDL_DriverSwitch_C SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTY, ~axis); } - /* High nibble of battery/connection byte is battery level, low nibble is connection status + /* High nibble of battery/connection byte is battery level, low nibble is connection status (always 0 on 8BitDo Pro 2) * LSB of connection nibble is USB/Switch connection status * LSB of the battery nibble is used to report charging. * The battery level is reported from 0(empty)-8(full) @@ -2443,12 +2443,6 @@ static void HandleFullControllerState(SDL_Joystick *joystick, SDL_DriverSwitch_C int level = (packet->controllerState.ucBatteryAndConnection & 0xE0) >> 4; int percent = (int)SDL_roundf((level / 8.0f) * 100.0f); - if (packet->controllerState.ucBatteryAndConnection & 0x01) { - joystick->connection_state = SDL_JOYSTICK_CONNECTION_WIRED; - } else { - joystick->connection_state = SDL_JOYSTICK_CONNECTION_WIRELESS; - } - if (charging) { if (level == 8) { state = SDL_POWERSTATE_CHARGED;