mirror of https://github.com/sm64pc/sm64pc.git
Update rumble functions for SDL v2.0.18+ (#553)
This commit is contained in:
parent
951389ca84
commit
1502fb8f88
|
@ -264,13 +264,30 @@ static void controller_sdl_read(OSContPad *pad) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void controller_sdl_rumble_play(f32 strength, f32 length) {
|
static void controller_sdl_rumble_play(f32 strength, f32 length) {
|
||||||
if (sdl_haptic)
|
if (sdl_haptic) {
|
||||||
SDL_HapticRumblePlay(sdl_haptic, strength, (u32)(length * 1000.0f));
|
SDL_HapticRumblePlay(sdl_haptic, strength, (u32)(length * 1000.0f));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
#if SDL_VERSION_ATLEAST(2,0,18)
|
||||||
|
uint16_t scaled_strength = strength * pow(2, 16) - 1;
|
||||||
|
if (SDL_GameControllerHasRumble(sdl_cntrl) == SDL_TRUE) {
|
||||||
|
SDL_GameControllerRumble(sdl_cntrl, scaled_strength, scaled_strength, (u32)(length * 1000.0f));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void controller_sdl_rumble_stop(void) {
|
static void controller_sdl_rumble_stop(void) {
|
||||||
if (sdl_haptic)
|
if (sdl_haptic) {
|
||||||
SDL_HapticRumbleStop(sdl_haptic);
|
SDL_HapticRumbleStop(sdl_haptic);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
#if SDL_VERSION_ATLEAST(2,0,18)
|
||||||
|
if (SDL_GameControllerHasRumble(sdl_cntrl) == SDL_TRUE) {
|
||||||
|
SDL_GameControllerRumble(sdl_cntrl, 0, 0, 0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static u32 controller_sdl_rawkey(void) {
|
static u32 controller_sdl_rawkey(void) {
|
||||||
|
|
Loading…
Reference in New Issue