mirror of https://github.com/encounter/SDL.git
Fixed rare infinite rumble in HIDAPI controller driver
This commit is contained in:
parent
25bd5070f5
commit
1db56619de
|
@ -280,6 +280,9 @@ HIDAPI_DriverGameCube_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *jo
|
||||||
}
|
}
|
||||||
if (val && duration_ms) {
|
if (val && duration_ms) {
|
||||||
ctx->rumbleExpiration[i] = SDL_GetTicks() + SDL_min(duration_ms, SDL_MAX_RUMBLE_DURATION_MS);
|
ctx->rumbleExpiration[i] = SDL_GetTicks() + SDL_min(duration_ms, SDL_MAX_RUMBLE_DURATION_MS);
|
||||||
|
if (!ctx->rumbleExpiration[i]) {
|
||||||
|
ctx->rumbleExpiration[i] = 1;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ctx->rumbleExpiration[i] = 0;
|
ctx->rumbleExpiration[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -312,6 +312,9 @@ HIDAPI_DriverPS4_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystic
|
||||||
|
|
||||||
if ((low_frequency_rumble || high_frequency_rumble) && duration_ms) {
|
if ((low_frequency_rumble || high_frequency_rumble) && duration_ms) {
|
||||||
ctx->rumble_expiration = SDL_GetTicks() + SDL_min(duration_ms, SDL_MAX_RUMBLE_DURATION_MS);
|
ctx->rumble_expiration = SDL_GetTicks() + SDL_min(duration_ms, SDL_MAX_RUMBLE_DURATION_MS);
|
||||||
|
if (!ctx->rumble_expiration) {
|
||||||
|
ctx->rumble_expiration = 1;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ctx->rumble_expiration = 0;
|
ctx->rumble_expiration = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -760,7 +760,10 @@ HIDAPI_DriverSwitch_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joys
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((low_frequency_rumble || high_frequency_rumble) && duration_ms) {
|
if ((low_frequency_rumble || high_frequency_rumble) && duration_ms) {
|
||||||
ctx->m_nRumbleExpiration = SDL_GetTicks() + duration_ms;
|
ctx->m_nRumbleExpiration = SDL_GetTicks() + SDL_min(duration_ms, SDL_MAX_RUMBLE_DURATION_MS);
|
||||||
|
if (!ctx->m_nRumbleExpiration) {
|
||||||
|
ctx->m_nRumbleExpiration = 1;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ctx->m_nRumbleExpiration = 0;
|
ctx->m_nRumbleExpiration = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -400,6 +400,9 @@ HIDAPI_DriverXbox360_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joy
|
||||||
|
|
||||||
if ((low_frequency_rumble || high_frequency_rumble) && duration_ms) {
|
if ((low_frequency_rumble || high_frequency_rumble) && duration_ms) {
|
||||||
ctx->rumble_expiration = SDL_GetTicks() + SDL_min(duration_ms, SDL_MAX_RUMBLE_DURATION_MS);
|
ctx->rumble_expiration = SDL_GetTicks() + SDL_min(duration_ms, SDL_MAX_RUMBLE_DURATION_MS);
|
||||||
|
if (!ctx->rumble_expiration) {
|
||||||
|
ctx->rumble_expiration = 1;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ctx->rumble_expiration = 0;
|
ctx->rumble_expiration = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,6 +149,9 @@ HIDAPI_DriverXbox360W_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *jo
|
||||||
|
|
||||||
if ((low_frequency_rumble || high_frequency_rumble) && duration_ms) {
|
if ((low_frequency_rumble || high_frequency_rumble) && duration_ms) {
|
||||||
ctx->rumble_expiration = SDL_GetTicks() + SDL_min(duration_ms, SDL_MAX_RUMBLE_DURATION_MS);
|
ctx->rumble_expiration = SDL_GetTicks() + SDL_min(duration_ms, SDL_MAX_RUMBLE_DURATION_MS);
|
||||||
|
if (!ctx->rumble_expiration) {
|
||||||
|
ctx->rumble_expiration = 1;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ctx->rumble_expiration = 0;
|
ctx->rumble_expiration = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -312,6 +312,9 @@ HIDAPI_DriverXboxOne_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joy
|
||||||
|
|
||||||
if ((low_frequency_rumble || high_frequency_rumble) && duration_ms) {
|
if ((low_frequency_rumble || high_frequency_rumble) && duration_ms) {
|
||||||
ctx->rumble_expiration = SDL_GetTicks() + SDL_min(duration_ms, SDL_MAX_RUMBLE_DURATION_MS);
|
ctx->rumble_expiration = SDL_GetTicks() + SDL_min(duration_ms, SDL_MAX_RUMBLE_DURATION_MS);
|
||||||
|
if (!ctx->rumble_expiration) {
|
||||||
|
ctx->rumble_expiration = 1;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ctx->rumble_expiration = 0;
|
ctx->rumble_expiration = 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue