From 6ec8b1a1735b5177f75f67e2cca595e763425319 Mon Sep 17 00:00:00 2001
From: Cameron Gutman <[EMAIL REDACTED]>
Date: Tue, 24 Sep 2024 22:05:12 -0500
Subject: [PATCH] Throttle tickle reports to PS4/PS5 controllers
UpdateDevice() can be called at an arbitrary rate, so we need to
pace ourselves to avoid filling up the rumble queue with these.
---
src/joystick/hidapi/SDL_hidapi_ps4.c | 1 +
src/joystick/hidapi/SDL_hidapi_ps5.c | 1 +
2 files changed, 2 insertions(+)
diff --git a/src/joystick/hidapi/SDL_hidapi_ps4.c b/src/joystick/hidapi/SDL_hidapi_ps4.c
index 196aafcc1e4d1..512187f83408d 100644
--- a/src/joystick/hidapi/SDL_hidapi_ps4.c
+++ b/src/joystick/hidapi/SDL_hidapi_ps4.c
@@ -1307,6 +1307,7 @@ static bool HIDAPI_DriverPS4_UpdateDevice(SDL_HIDAPI_Device *device)
if (now >= (ctx->last_packet + BLUETOOTH_DISCONNECT_TIMEOUT_MS)) {
// Send an empty output report to tickle the Bluetooth stack
HIDAPI_DriverPS4_TickleBluetooth(device);
+ ctx->last_packet = now;
}
} else {
// Reconnect the Bluetooth device once the USB device is gone
diff --git a/src/joystick/hidapi/SDL_hidapi_ps5.c b/src/joystick/hidapi/SDL_hidapi_ps5.c
index c0604152dab40..dc35636f88405 100644
--- a/src/joystick/hidapi/SDL_hidapi_ps5.c
+++ b/src/joystick/hidapi/SDL_hidapi_ps5.c
@@ -1553,6 +1553,7 @@ static bool HIDAPI_DriverPS5_UpdateDevice(SDL_HIDAPI_Device *device)
if (now >= (ctx->last_packet + BLUETOOTH_DISCONNECT_TIMEOUT_MS)) {
// Send an empty output report to tickle the Bluetooth stack
HIDAPI_DriverPS5_TickleBluetooth(device);
+ ctx->last_packet = now;
}
} else {
// Reconnect the Bluetooth device once the USB device is gone