engine: platform: add improved Platform_Vibrate2 function, that allows to control vibration strength
This commit is contained in:
parent
694c630b44
commit
1b44d7733e
2 changed files with 23 additions and 11 deletions
|
@ -199,7 +199,8 @@ static inline void Sys_RestoreCrashHandler( void )
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
*/
|
*/
|
||||||
void Platform_Vibrate( float life, char flags );
|
void Platform_Vibrate( float life, char flags ); // left for compatibility
|
||||||
|
void Platform_Vibrate2( float time, int low_freq, int high_freq, uint flags );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
==============================================================================
|
==============================================================================
|
||||||
|
|
|
@ -196,6 +196,26 @@ void SDLash_HandleGameControllerEvent( SDL_Event *ev )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Platform_Vibrate2( float time, int val1, int val2, uint flags )
|
||||||
|
{
|
||||||
|
#if SDL_VERSION_ATLEAST( 2, 0, 9 )
|
||||||
|
SDL_GameController *gc = g_current_gamepad;
|
||||||
|
Uint32 ms;
|
||||||
|
|
||||||
|
if( g_current_gamepad_id < 0 || !gc )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if( val1 < 0 )
|
||||||
|
val1 = COM_RandomLong( 0x7FFF, 0xFFFF );
|
||||||
|
|
||||||
|
if( val2 < 0 )
|
||||||
|
val2 = COM_RandomLong( 0x7FFF, 0xFFFF );
|
||||||
|
|
||||||
|
ms = (Uint32)ceil( time );
|
||||||
|
SDL_GameControllerRumble( gc, val1, val2, ms );
|
||||||
|
#endif // SDL_VERSION_ATLEAST( 2, 0, 9 )
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=============
|
=============
|
||||||
Platform_Vibrate
|
Platform_Vibrate
|
||||||
|
@ -204,16 +224,7 @@ Platform_Vibrate
|
||||||
*/
|
*/
|
||||||
void Platform_Vibrate( float time, char flags )
|
void Platform_Vibrate( float time, char flags )
|
||||||
{
|
{
|
||||||
#if SDL_VERSION_ATLEAST( 2, 0, 9 )
|
Platform_Vibrate2( time, -1, -1, flags );
|
||||||
SDL_GameController *gc = g_current_gamepad;
|
|
||||||
|
|
||||||
if( g_current_gamepad_id < 0 || !gc )
|
|
||||||
return;
|
|
||||||
|
|
||||||
// a1ba: time is in milliseconds but might be not enough
|
|
||||||
// to spin up rumble
|
|
||||||
SDL_GameControllerRumble( gc, 0xFFFF, 0xFFFF, (int)floor( time ));
|
|
||||||
#endif // SDL_VERSION_ATLEAST( 2, 0, 9 )
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Reference in a new issue