Wii: don't bother reading the extension type for the Wii U Pro controller, we already know what it is
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
diff --git a/src/joystick/hidapi/SDL_hidapi_wii.c b/src/joystick/hidapi/SDL_hidapi_wii.c
index 45d2fad..ed42c4d 100644
--- a/src/joystick/hidapi/SDL_hidapi_wii.c
+++ b/src/joystick/hidapi/SDL_hidapi_wii.c
@@ -501,7 +501,7 @@ static void SDLCALL SDL_PlayerLEDHintChanged(void *userdata, const char *name, c
}
static EWiiExtensionControllerType
-ReadControllerType(SDL_HIDAPI_Device *device)
+ReadExtensionControllerType(SDL_HIDAPI_Device *device)
{
EWiiExtensionControllerType eExtensionControllerType = k_eWiiExtensionControllerType_Unknown;
@@ -572,7 +572,13 @@ static SDL_bool
HIDAPI_DriverWii_InitDevice(SDL_HIDAPI_Device *device)
{
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;
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
HIDAPI_DriverWii_UpdateDevice(SDL_HIDAPI_Device *device)
{
@@ -1160,19 +1164,22 @@ HIDAPI_DriverWii_UpdateDevice(SDL_HIDAPI_Device *device)
/* Bluetooth may have disconnected, try reopening the controller */
size = -1;
}
- }
- /* Request a status update periodically to make sure our battery value is up to date */
- if (!ctx->m_unLastStatus ||
- SDL_TICKS_PASSED(now, ctx->m_unLastStatus + FIFTEEN_MINUTES_IN_MS) ||
- ctx->m_eCommState == k_eWiiCommunicationState_Error) {
- Uint8 data[2];
+ } else {
+ const Uint32 FIFTEEN_MINUTES_IN_MS = 15 * 60 * 1000;
- data[0] = k_eWiiOutputReportIDs_StatusRequest;
- data[1] = ctx->m_bRumbleActive;
- WriteOutput(ctx, data, sizeof(data), SDL_FALSE);
+ /* Request a status update periodically to make sure our battery value is up to date */
+ if (!ctx->m_unLastStatus ||
+ SDL_TICKS_PASSED(now, ctx->m_unLastStatus + FIFTEEN_MINUTES_IN_MS) ||
+ ctx->m_eCommState == k_eWiiCommunicationState_Error) {
+ Uint8 data[2];
- ctx->m_unLastStatus = now;
+ data[0] = k_eWiiOutputReportIDs_StatusRequest;
+ data[1] = ctx->m_bRumbleActive;
+ WriteOutput(ctx, data, sizeof(data), SDL_FALSE);
+
+ ctx->m_unLastStatus = now;
+ }
}
if (size < 0) {