mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-06 11:28:15 +00:00
Fixed 8BitDo Ultimate 2 Wireless controller on macOS
When connected for the first time over Bluetooth on macOS, the first few reads return 0, so retry a few times in that case.
This commit is contained in:
@@ -154,13 +154,22 @@ static bool HIDAPI_Driver8BitDo_InitDevice(SDL_HIDAPI_Device *device)
|
|||||||
if (device->product_id == USB_PRODUCT_8BITDO_ULTIMATE2_WIRELESS) {
|
if (device->product_id == USB_PRODUCT_8BITDO_ULTIMATE2_WIRELESS) {
|
||||||
// The Ultimate 2 Wireless v1.02 firmware has 12 byte reports, v1.03 firmware has 34 byte reports
|
// The Ultimate 2 Wireless v1.02 firmware has 12 byte reports, v1.03 firmware has 34 byte reports
|
||||||
const int ULTIMATE2_WIRELESS_V103_REPORT_SIZE = 34;
|
const int ULTIMATE2_WIRELESS_V103_REPORT_SIZE = 34;
|
||||||
|
const int MAX_ATTEMPTS = 3;
|
||||||
|
|
||||||
|
for (int attempt = 0; attempt < MAX_ATTEMPTS; ++attempt) {
|
||||||
Uint8 data[USB_PACKET_LENGTH];
|
Uint8 data[USB_PACKET_LENGTH];
|
||||||
int size = SDL_hid_read_timeout(device->dev, data, sizeof(data), 80);
|
int size = SDL_hid_read_timeout(device->dev, data, sizeof(data), 80);
|
||||||
|
if (size == 0) {
|
||||||
|
// Try again
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (size >= ULTIMATE2_WIRELESS_V103_REPORT_SIZE) {
|
if (size >= ULTIMATE2_WIRELESS_V103_REPORT_SIZE) {
|
||||||
ctx->sensors_supported = true;
|
ctx->sensors_supported = true;
|
||||||
ctx->rumble_supported = true;
|
ctx->rumble_supported = true;
|
||||||
ctx->powerstate_supported = true;
|
ctx->powerstate_supported = true;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Uint8 data[USB_PACKET_LENGTH];
|
Uint8 data[USB_PACKET_LENGTH];
|
||||||
int size = ReadFeatureReport(device->dev, SDL_8BITDO_FEATURE_REPORTID_ENABLE_SDL_REPORTID, data, sizeof(data));
|
int size = ReadFeatureReport(device->dev, SDL_8BITDO_FEATURE_REPORTID_ENABLE_SDL_REPORTID, data, sizeof(data));
|
||||||
|
Reference in New Issue
Block a user