Joystick: Add trigger rumble resend
This was already present for regular rumble to ensure that controllers would
continue rumbling for extended periods, but was missing for trigger rumble. I
don't know if this affects any controllers at the moment, but it's helpful for
future-proofing.
(cherry picked from commit ceb9fecfc1)
This commit is contained in:
1 parent
3c2d7ecdd6
commit
3a8f1cb7c5
2 files changed
+19
No files matched your search
@@ -1817,6 +1817,14 @@ bool SDL_RumbleJoystickTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint
|
|||||||
result = true;
|
result = true;
|
||||||
} else {
|
} else {
|
||||||
result = joystick->driver->RumbleTriggers(joystick, left_rumble, right_rumble);
|
result = joystick->driver->RumbleTriggers(joystick, left_rumble, right_rumble);
|
||||||
|
if (result) {
|
||||||
|
joystick->trigger_rumble_resend = SDL_GetTicks() + SDL_RUMBLE_RESEND_MS;
|
||||||
|
if (joystick->trigger_rumble_resend == 0) {
|
||||||
|
joystick->trigger_rumble_resend = 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
joystick->trigger_rumble_resend = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
@@ -1827,6 +1835,7 @@ bool SDL_RumbleJoystickTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint
|
|||||||
joystick->trigger_rumble_expiration = SDL_GetTicks() + SDL_min(duration_ms, SDL_MAX_RUMBLE_DURATION_MS);
|
joystick->trigger_rumble_expiration = SDL_GetTicks() + SDL_min(duration_ms, SDL_MAX_RUMBLE_DURATION_MS);
|
||||||
} else {
|
} else {
|
||||||
joystick->trigger_rumble_expiration = 0;
|
joystick->trigger_rumble_expiration = 0;
|
||||||
|
joystick->trigger_rumble_resend = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2481,6 +2490,15 @@ void SDL_UpdateJoysticks(void)
|
|||||||
|
|
||||||
if (joystick->trigger_rumble_expiration && now >= joystick->trigger_rumble_expiration) {
|
if (joystick->trigger_rumble_expiration && now >= joystick->trigger_rumble_expiration) {
|
||||||
SDL_RumbleJoystickTriggers(joystick, 0, 0, 0);
|
SDL_RumbleJoystickTriggers(joystick, 0, 0, 0);
|
||||||
|
joystick->trigger_rumble_resend = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (joystick->trigger_rumble_resend && now >= joystick->trigger_rumble_resend) {
|
||||||
|
joystick->driver->RumbleTriggers(joystick, joystick->left_trigger_rumble, joystick->right_trigger_rumble);
|
||||||
|
joystick->trigger_rumble_resend = now + SDL_RUMBLE_RESEND_MS;
|
||||||
|
if (joystick->trigger_rumble_resend == 0) {
|
||||||
|
joystick->trigger_rumble_resend = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -113,6 +113,7 @@ struct SDL_Joystick
|
|||||||
Uint16 left_trigger_rumble _guarded;
|
Uint16 left_trigger_rumble _guarded;
|
||||||
Uint16 right_trigger_rumble _guarded;
|
Uint16 right_trigger_rumble _guarded;
|
||||||
Uint64 trigger_rumble_expiration _guarded;
|
Uint64 trigger_rumble_expiration _guarded;
|
||||||
|
Uint64 trigger_rumble_resend _guarded;
|
||||||
|
|
||||||
Uint8 led_red _guarded;
|
Uint8 led_red _guarded;
|
||||||
Uint8 led_green _guarded;
|
Uint8 led_green _guarded;
|
||||||
|
|||||||
Reference in new issue
Block a user