author Sam Lantinga Mon, 02 Mar 2020 09:35:09 -0800 changeset 13569 af2f0ddf861a parent 13568 2c4ec356333e child 13570 bcbae957f9b1
Use SDL math functions in Steam Controller support
```     1.1 --- a/src/joystick/hidapi/SDL_hidapi_steam.c	Mon Mar 02 09:26:12 2020 -0800
1.2 +++ b/src/joystick/hidapi/SDL_hidapi_steam.c	Mon Mar 02 09:35:09 2020 -0800
1.3 @@ -635,15 +635,15 @@
1.4  {
1.5      short int origX = *pX, origY = *pY;
1.6
1.7 -    *pX = (int)( cosf( flAngleInRad ) * origX - sinf( flAngleInRad ) * origY );
1.8 -    *pY = (int)( sinf( flAngleInRad ) * origX + cosf( flAngleInRad ) * origY );
1.9 +    *pX = (int)( SDL_cosf( flAngleInRad ) * origX - SDL_sinf( flAngleInRad ) * origY );
1.10 +    *pY = (int)( SDL_sinf( flAngleInRad ) * origX + SDL_cosf( flAngleInRad ) * origY );
1.11  }
1.12  static void RotatePadShort( short *pX, short *pY, float flAngleInRad )
1.13  {
1.14      short int origX = *pX, origY = *pY;
1.15
1.16 -    *pX = (short)( cosf( flAngleInRad ) * origX - sinf( flAngleInRad ) * origY );
1.17 -    *pY = (short)( sinf( flAngleInRad ) * origX + cosf( flAngleInRad ) * origY );
1.18 +    *pX = (short)( SDL_cosf( flAngleInRad ) * origX - SDL_sinf( flAngleInRad ) * origY );
1.19 +    *pY = (short)( SDL_sinf( flAngleInRad ) * origX + SDL_cosf( flAngleInRad ) * origY );
1.20  }
1.21
1.22
1.23 @@ -1117,8 +1117,8 @@
1.24                      (ctx->m_state.sLeftPadX > kPadDeadZone) ? SDL_PRESSED : SDL_RELEASED);
1.25              }
1.26
1.27 -            SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERLEFT, ctx->m_state.sTriggerL * 2 - 32768);
1.28 -            SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERRIGHT, ctx->m_state.sTriggerR * 2 - 32768);
1.29 +            SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERLEFT, (int)ctx->m_state.sTriggerL * 2 - 32768);
1.30 +            SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERRIGHT, (int)ctx->m_state.sTriggerR * 2 - 32768);
1.31
1.32              SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTX, ctx->m_state.sLeftStickX);
1.33              SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTY, ~ctx->m_state.sLeftStickY);
```