From 52be663380fbedf2f9c6dddbcb6ec84e04532424 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 2 Mar 2020 09:35:09 -0800 Subject: [PATCH] Use SDL math functions in Steam Controller support --- src/joystick/hidapi/SDL_hidapi_steam.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/joystick/hidapi/SDL_hidapi_steam.c b/src/joystick/hidapi/SDL_hidapi_steam.c index 8c3fec468bc76..e0e1dce86a641 100644 --- a/src/joystick/hidapi/SDL_hidapi_steam.c +++ b/src/joystick/hidapi/SDL_hidapi_steam.c @@ -635,15 +635,15 @@ static void RotatePad( int *pX, int *pY, float flAngleInRad ) { short int origX = *pX, origY = *pY; - *pX = (int)( cosf( flAngleInRad ) * origX - sinf( flAngleInRad ) * origY ); - *pY = (int)( sinf( flAngleInRad ) * origX + cosf( flAngleInRad ) * origY ); + *pX = (int)( SDL_cosf( flAngleInRad ) * origX - SDL_sinf( flAngleInRad ) * origY ); + *pY = (int)( SDL_sinf( flAngleInRad ) * origX + SDL_cosf( flAngleInRad ) * origY ); } static void RotatePadShort( short *pX, short *pY, float flAngleInRad ) { short int origX = *pX, origY = *pY; - *pX = (short)( cosf( flAngleInRad ) * origX - sinf( flAngleInRad ) * origY ); - *pY = (short)( sinf( flAngleInRad ) * origX + cosf( flAngleInRad ) * origY ); + *pX = (short)( SDL_cosf( flAngleInRad ) * origX - SDL_sinf( flAngleInRad ) * origY ); + *pY = (short)( SDL_sinf( flAngleInRad ) * origX + SDL_cosf( flAngleInRad ) * origY ); } @@ -1117,8 +1117,8 @@ HIDAPI_DriverSteam_UpdateDevice(SDL_HIDAPI_Device *device) (ctx->m_state.sLeftPadX > kPadDeadZone) ? SDL_PRESSED : SDL_RELEASED); } - SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERLEFT, ctx->m_state.sTriggerL * 2 - 32768); - SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERRIGHT, ctx->m_state.sTriggerR * 2 - 32768); + SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERLEFT, (int)ctx->m_state.sTriggerL * 2 - 32768); + SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERRIGHT, (int)ctx->m_state.sTriggerR * 2 - 32768); SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTX, ctx->m_state.sLeftStickX); SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTY, ~ctx->m_state.sLeftStickY);