diff --git a/engine/platform/platform.h b/engine/platform/platform.h index 4024d7ad6..5ea883135 100644 --- a/engine/platform/platform.h +++ b/engine/platform/platform.h @@ -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 ); /* ============================================================================== diff --git a/engine/platform/sdl/joy_sdl.c b/engine/platform/sdl/joy_sdl.c index e48a61cc1..b776da7be 100644 --- a/engine/platform/sdl/joy_sdl.c +++ b/engine/platform/sdl/joy_sdl.c @@ -196,26 +196,37 @@ void SDLash_HandleGameControllerEvent( SDL_Event *ev ) } } -/* -============= -Platform_Vibrate - -============= -*/ -void Platform_Vibrate( float time, char flags ) +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; - // a1ba: time is in milliseconds but might be not enough - // to spin up rumble - SDL_GameControllerRumble( gc, 0xFFFF, 0xFFFF, (int)floor( time )); + 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 + +============= +*/ +void Platform_Vibrate( float time, char flags ) +{ + Platform_Vibrate2( time, -1, -1, flags ); +} + /* ============= Platform_JoyInit