mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-05 19:08:12 +00:00
Fixed Nintendo Switch Pro controllers that don't have readable user calibration
(cherry picked from commit9ee1200e6f
) (cherry picked from commit170428b107
)
This commit is contained in:
@@ -761,9 +761,8 @@ static SDL_bool LoadStickCalibration(SDL_DriverSwitch_Context *ctx)
|
|||||||
readUserParams.unAddress = k_unSPIStickUserCalibrationStartOffset;
|
readUserParams.unAddress = k_unSPIStickUserCalibrationStartOffset;
|
||||||
readUserParams.ucLength = k_unSPIStickUserCalibrationLength;
|
readUserParams.ucLength = k_unSPIStickUserCalibrationLength;
|
||||||
|
|
||||||
if (!WriteSubcommand(ctx, k_eSwitchSubcommandIDs_SPIFlashRead, (uint8_t *)&readUserParams, sizeof(readUserParams), &user_reply)) {
|
/* This isn't readable on all controllers, so ignore failure */
|
||||||
return SDL_FALSE;
|
WriteSubcommand(ctx, k_eSwitchSubcommandIDs_SPIFlashRead, (uint8_t *)&readUserParams, sizeof(readUserParams), &user_reply);
|
||||||
}
|
|
||||||
|
|
||||||
/* Read Factory Calibration Info */
|
/* Read Factory Calibration Info */
|
||||||
readFactoryParams.unAddress = k_unSPIStickFactoryCalibrationStartOffset;
|
readFactoryParams.unAddress = k_unSPIStickFactoryCalibrationStartOffset;
|
||||||
@@ -774,13 +773,13 @@ static SDL_bool LoadStickCalibration(SDL_DriverSwitch_Context *ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Automatically select the user calibration if magic bytes are set */
|
/* Automatically select the user calibration if magic bytes are set */
|
||||||
if (user_reply->stickUserCalibration.rgucLeftMagic[0] == 0xB2 && user_reply->stickUserCalibration.rgucLeftMagic[1] == 0xA1) {
|
if (user_reply && user_reply->stickUserCalibration.rgucLeftMagic[0] == 0xB2 && user_reply->stickUserCalibration.rgucLeftMagic[1] == 0xA1) {
|
||||||
pLeftStickCal = user_reply->stickUserCalibration.rgucLeftCalibration;
|
pLeftStickCal = user_reply->stickUserCalibration.rgucLeftCalibration;
|
||||||
} else {
|
} else {
|
||||||
pLeftStickCal = factory_reply->stickFactoryCalibration.rgucLeftCalibration;
|
pLeftStickCal = factory_reply->stickFactoryCalibration.rgucLeftCalibration;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user_reply->stickUserCalibration.rgucRightMagic[0] == 0xB2 && user_reply->stickUserCalibration.rgucRightMagic[1] == 0xA1) {
|
if (user_reply && user_reply->stickUserCalibration.rgucRightMagic[0] == 0xB2 && user_reply->stickUserCalibration.rgucRightMagic[1] == 0xA1) {
|
||||||
pRightStickCal = user_reply->stickUserCalibration.rgucRightCalibration;
|
pRightStickCal = user_reply->stickUserCalibration.rgucRightCalibration;
|
||||||
} else {
|
} else {
|
||||||
pRightStickCal = factory_reply->stickFactoryCalibration.rgucRightCalibration;
|
pRightStickCal = factory_reply->stickFactoryCalibration.rgucRightCalibration;
|
||||||
|
Reference in New Issue
Block a user