Skip to content

Commit b4f7948

Browse files
8BitDoslouken
authored andcommitted
Ensure that report 06 command reads normally
Ensure that report 06 command reads normally
1 parent e3d44cd commit b4f7948

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/joystick/hidapi/SDL_hidapi_8bitdo.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,20 @@ static bool HIDAPI_Driver8BitDo_InitDevice(SDL_HIDAPI_Device *device)
172172
}
173173
} else {
174174
Uint8 data[USB_PACKET_LENGTH];
175-
int size = ReadFeatureReport(device->dev, SDL_8BITDO_FEATURE_REPORTID_ENABLE_SDL_REPORTID, data, sizeof(data));
176-
if (size > 0) {
177-
ctx->sensors_supported = true;
178-
ctx->rumble_supported = true;
179-
ctx->powerstate_supported = true;
175+
const int MAX_ATTEMPTS = 5;
176+
for (int attempt = 0; attempt < MAX_ATTEMPTS; ++attempt) {
177+
int size = ReadFeatureReport(device->dev, SDL_8BITDO_FEATURE_REPORTID_ENABLE_SDL_REPORTID, data, sizeof(data));
178+
if (size <= 0) {
179+
SDL_Delay(10);
180+
// Try again
181+
continue;
182+
}
183+
if (size > 0) {
184+
ctx->sensors_supported = true;
185+
ctx->rumble_supported = true;
186+
ctx->powerstate_supported = true;
187+
}
188+
break;
180189
}
181190
}
182191

0 commit comments

Comments
 (0)