Skip to content

Commit 3a6f9e0

Browse files
mitchellcairnsslouken
authored andcommitted
Fixed Nintendo Switch thumbstick calibration
1 parent 038a380 commit 3a6f9e0

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/joystick/hidapi/SDL_hidapi_switch.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,7 @@ static bool LoadStickCalibration(SDL_DriverSwitch_Context *ctx)
979979
/* Stick calibration values are 12-bits each and are packed by bit
980980
* For whatever reason the fields are in a different order for each stick
981981
* Left: X-Max, Y-Max, X-Center, Y-Center, X-Min, Y-Min
982-
* Right: X-Center, Y-Center, X-Max, Y-Max, X-Min, Y-Min
982+
* Right: X-Center, Y-Center, X-Min, Y-Min, X-Max, Y-Max
983983
*/
984984

985985
// Left stick
@@ -993,10 +993,10 @@ static bool LoadStickCalibration(SDL_DriverSwitch_Context *ctx)
993993
// Right stick
994994
ctx->m_StickCalData[1].axis[0].sCenter = ((pRightStickCal[1] << 8) & 0xF00) | pRightStickCal[0]; // X Axis center
995995
ctx->m_StickCalData[1].axis[1].sCenter = (pRightStickCal[2] << 4) | (pRightStickCal[1] >> 4); // Y Axis center
996-
ctx->m_StickCalData[1].axis[0].sMax = ((pRightStickCal[4] << 8) & 0xF00) | pRightStickCal[3]; // X Axis max above center
997-
ctx->m_StickCalData[1].axis[1].sMax = (pRightStickCal[5] << 4) | (pRightStickCal[4] >> 4); // Y Axis max above center
998-
ctx->m_StickCalData[1].axis[0].sMin = ((pRightStickCal[7] << 8) & 0xF00) | pRightStickCal[6]; // X Axis min below center
999-
ctx->m_StickCalData[1].axis[1].sMin = (pRightStickCal[8] << 4) | (pRightStickCal[7] >> 4); // Y Axis min below center
996+
ctx->m_StickCalData[1].axis[0].sMin = ((pRightStickCal[4] << 8) & 0xF00) | pRightStickCal[3]; // X Axis min below center
997+
ctx->m_StickCalData[1].axis[1].sMin = (pRightStickCal[5] << 4) | (pRightStickCal[4] >> 4); // Y Axis min below center
998+
ctx->m_StickCalData[1].axis[0].sMax = ((pRightStickCal[7] << 8) & 0xF00) | pRightStickCal[6]; // X Axis max above center
999+
ctx->m_StickCalData[1].axis[1].sMax = (pRightStickCal[8] << 4) | (pRightStickCal[7] >> 4); // Y Axis max above center
10001000

10011001
// Filter out any values that were uninitialized (0xFFF) in the SPI read
10021002
for (stick = 0; stick < 2; ++stick) {

0 commit comments

Comments
 (0)