Removed 100 ms hitch when querying third party Nintendo Switch controllers that don't respond to request for info
(cherry picked from commit 8acf729650)
This commit is contained in:
1 parent
1429e525fb
commit
c27f3ead7c
1 file changed
+5
-4
@@ -998,7 +998,9 @@ static ESwitchDeviceInfoControllerType ReadJoyConControllerType(SDL_HIDAPI_Devic
|
|||||||
ctx->m_bSyncWrite = SDL_TRUE;
|
ctx->m_bSyncWrite = SDL_TRUE;
|
||||||
ctx->m_nMaxWriteAttempts = GetMaxWriteAttempts(device);
|
ctx->m_nMaxWriteAttempts = GetMaxWriteAttempts(device);
|
||||||
|
|
||||||
for (attempts = 0; attempts < MAX_ATTEMPTS; ++attempts) {
|
for ( ; ; ) {
|
||||||
|
++attempts;
|
||||||
|
device->is_bluetooth = SDL_FALSE;
|
||||||
if (WriteProprietary(ctx, k_eSwitchProprietaryCommandIDs_Status, NULL, 0, SDL_TRUE)) {
|
if (WriteProprietary(ctx, k_eSwitchProprietaryCommandIDs_Status, NULL, 0, SDL_TRUE)) {
|
||||||
SwitchProprietaryStatusPacket_t *status = (SwitchProprietaryStatusPacket_t *)&ctx->m_rgucReadBuffer[0];
|
SwitchProprietaryStatusPacket_t *status = (SwitchProprietaryStatusPacket_t *)&ctx->m_rgucReadBuffer[0];
|
||||||
|
|
||||||
@@ -1011,13 +1013,12 @@ static ESwitchDeviceInfoControllerType ReadJoyConControllerType(SDL_HIDAPI_Devic
|
|||||||
eControllerType = CalculateControllerType(ctx, (ESwitchDeviceInfoControllerType)reply->deviceInfo.ucDeviceType);
|
eControllerType = CalculateControllerType(ctx, (ESwitchDeviceInfoControllerType)reply->deviceInfo.ucDeviceType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (eControllerType == k_eSwitchDeviceInfoControllerType_Unknown) {
|
if (eControllerType == k_eSwitchDeviceInfoControllerType_Unknown && attempts < MAX_ATTEMPTS) {
|
||||||
/* Wait a bit and try again */
|
/* Wait a bit and try again */
|
||||||
SDL_Delay(100);
|
SDL_Delay(100);
|
||||||
continue;
|
continue;
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
SDL_free(ctx);
|
SDL_free(ctx);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user