Skip to content

Commit

Permalink
Throttle tickle reports to PS4/PS5 controllers
Browse files Browse the repository at this point in the history
UpdateDevice() can be called at an arbitrary rate, so we need to
pace ourselves to avoid filling up the rumble queue with these.

(cherry picked from commit 6ec8b1a)
(cherry picked from commit 656b599)
  • Loading branch information
cgutman authored and slouken committed Sep 25, 2024
1 parent 5e90dd3 commit b653583
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/joystick/hidapi/SDL_hidapi_ps4.c
Original file line number Diff line number Diff line change
Expand Up @@ -1208,6 +1208,7 @@ static SDL_bool HIDAPI_DriverPS4_UpdateDevice(SDL_HIDAPI_Device *device)
if (SDL_TICKS_PASSED(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 */
Expand Down
1 change: 1 addition & 0 deletions src/joystick/hidapi/SDL_hidapi_ps5.c
Original file line number Diff line number Diff line change
Expand Up @@ -1500,6 +1500,7 @@ static SDL_bool HIDAPI_DriverPS5_UpdateDevice(SDL_HIDAPI_Device *device)
if (SDL_TICKS_PASSED(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 */
Expand Down

0 comments on commit b653583

Please sign in to comment.