Wii: don't bother reading the extension type for the Wii U Pro controller, we already know what it is

This commit is contained in:
Sam Lantinga 2022-09-02 08:58:21 -07:00
parent c3ecb9d099
commit a35642fa3e
1 changed files with 21 additions and 14 deletions

View File

@ -501,7 +501,7 @@ static void SDLCALL SDL_PlayerLEDHintChanged(void *userdata, const char *name, c
} }
static EWiiExtensionControllerType static EWiiExtensionControllerType
ReadControllerType(SDL_HIDAPI_Device *device) ReadExtensionControllerType(SDL_HIDAPI_Device *device)
{ {
EWiiExtensionControllerType eExtensionControllerType = k_eWiiExtensionControllerType_Unknown; EWiiExtensionControllerType eExtensionControllerType = k_eWiiExtensionControllerType_Unknown;
@ -572,7 +572,13 @@ static SDL_bool
HIDAPI_DriverWii_InitDevice(SDL_HIDAPI_Device *device) HIDAPI_DriverWii_InitDevice(SDL_HIDAPI_Device *device)
{ {
if (device->vendor_id == USB_VENDOR_NINTENDO) { if (device->vendor_id == USB_VENDOR_NINTENDO) {
EWiiExtensionControllerType eExtensionControllerType = ReadControllerType(device); EWiiExtensionControllerType eExtensionControllerType;
if (device->product_id == USB_PRODUCT_NINTENDO_WII_PRO) {
eExtensionControllerType = k_eWiiExtensionControllerType_WiiUPro;
} else {
eExtensionControllerType = ReadExtensionControllerType(device);
}
device->guid.data[15] = eExtensionControllerType; device->guid.data[15] = eExtensionControllerType;
UpdateDeviceIdentity(device); UpdateDeviceIdentity(device);
} }
@ -1125,8 +1131,6 @@ static void HandleInput(SDL_DriverWii_Context *ctx, SDL_Joystick *joystick)
} }
} }
static const Uint32 FIFTEEN_MINUTES_IN_MS = 15 * 60 * 1000;
static SDL_bool static SDL_bool
HIDAPI_DriverWii_UpdateDevice(SDL_HIDAPI_Device *device) HIDAPI_DriverWii_UpdateDevice(SDL_HIDAPI_Device *device)
{ {
@ -1160,7 +1164,9 @@ HIDAPI_DriverWii_UpdateDevice(SDL_HIDAPI_Device *device)
/* Bluetooth may have disconnected, try reopening the controller */ /* Bluetooth may have disconnected, try reopening the controller */
size = -1; size = -1;
} }
}
} else {
const Uint32 FIFTEEN_MINUTES_IN_MS = 15 * 60 * 1000;
/* Request a status update periodically to make sure our battery value is up to date */ /* Request a status update periodically to make sure our battery value is up to date */
if (!ctx->m_unLastStatus || if (!ctx->m_unLastStatus ||
@ -1174,6 +1180,7 @@ HIDAPI_DriverWii_UpdateDevice(SDL_HIDAPI_Device *device)
ctx->m_unLastStatus = now; ctx->m_unLastStatus = now;
} }
}
if (size < 0) { if (size < 0) {
/* Read error, device is disconnected */ /* Read error, device is disconnected */