Skip to content

Commit e4475d1

Browse files
mitchellcairnsslouken
authored andcommitted
Fixed Nintendo Switch thumbstick calibration
(cherry picked from commit 3a6f9e0)
1 parent 6a71328 commit e4475d1

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
@@ -860,7 +860,7 @@ static SDL_bool LoadStickCalibration(SDL_DriverSwitch_Context *ctx)
860860
/* Stick calibration values are 12-bits each and are packed by bit
861861
* For whatever reason the fields are in a different order for each stick
862862
* Left: X-Max, Y-Max, X-Center, Y-Center, X-Min, Y-Min
863-
* Right: X-Center, Y-Center, X-Max, Y-Max, X-Min, Y-Min
863+
* Right: X-Center, Y-Center, X-Min, Y-Min, X-Max, Y-Max
864864
*/
865865

866866
/* Left stick */
@@ -874,10 +874,10 @@ static SDL_bool LoadStickCalibration(SDL_DriverSwitch_Context *ctx)
874874
/* Right stick */
875875
ctx->m_StickCalData[1].axis[0].sCenter = ((pRightStickCal[1] << 8) & 0xF00) | pRightStickCal[0]; /* X Axis center */
876876
ctx->m_StickCalData[1].axis[1].sCenter = (pRightStickCal[2] << 4) | (pRightStickCal[1] >> 4); /* Y Axis center */
877-
ctx->m_StickCalData[1].axis[0].sMax = ((pRightStickCal[4] << 8) & 0xF00) | pRightStickCal[3]; /* X Axis max above center */
878-
ctx->m_StickCalData[1].axis[1].sMax = (pRightStickCal[5] << 4) | (pRightStickCal[4] >> 4); /* Y Axis max above center */
879-
ctx->m_StickCalData[1].axis[0].sMin = ((pRightStickCal[7] << 8) & 0xF00) | pRightStickCal[6]; /* X Axis min below center */
880-
ctx->m_StickCalData[1].axis[1].sMin = (pRightStickCal[8] << 4) | (pRightStickCal[7] >> 4); /* Y Axis min below center */
877+
ctx->m_StickCalData[1].axis[0].sMin = ((pRightStickCal[4] << 8) & 0xF00) | pRightStickCal[3]; /* X Axis min below center */
878+
ctx->m_StickCalData[1].axis[1].sMin = (pRightStickCal[5] << 4) | (pRightStickCal[4] >> 4); /* Y Axis min below center */
879+
ctx->m_StickCalData[1].axis[0].sMax = ((pRightStickCal[7] << 8) & 0xF00) | pRightStickCal[6]; /* X Axis max above center */
880+
ctx->m_StickCalData[1].axis[1].sMax = (pRightStickCal[8] << 4) | (pRightStickCal[7] >> 4); /* Y Axis max above center */
881881

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

0 commit comments

Comments
 (0)