Skip to content

fix(libSceVideoOut): coalesce controller output updates - #7632

Merged
adriadam10 merged 2 commits into
boykopovar:mainfrom
WallisSkill:fix/pad-output-coalesce
Oct 20, 2026
Merged

adriadam10 merged 2 commits into
boykopovar:mainfrom
WallisSkill:fix/pad-output-coalesce

Conversation

@WallisSkill

@WallisSkill WallisSkill commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

What

Every change of the pad output state sent a rumble, light bar and trigger effect update to SDL, and the trigger effect was sent again even when it had not changed. Titles that animate the light bar, or drive the trigger effect and rumble every frame, interleave different report kinds that do not merge in the queue of SDL's HIDAPI rumble thread, which sends at most one report per 10 ms. The backlog grew: rumble arrived later and later, and disconnecting the controller blocked the presenter inside HIDAPI_DelDevice until the queue drained.

  • The trigger effect is sent only when it changes or a controller connects, and it is cached only when SDL_GameControllerSendEffect succeeds, so a refused effect is sent again on the next update.
  • The light bar is sent only when its colour changes, at most every 30 ms and always with the latest colour. A colour that SDL_GameControllerSetLED refuses is retried after the interval.
  • Rumble is unchanged from main: it goes out on every output change, and SDL drops repeated values and merges consecutive rumble reports.

LightBarPacer and TriggerEffectCache (header-only, no SDL) hold these decisions. pad_output_pacing covers changes only, a refused first send followed by a successful retry, a reconnect, and a colour changed every frame at 120 Hz.

Tested

Windows 11, MinGW GCC 15.2.0, DualSense over Bluetooth, Dead Cells (PPSA15552) at 120 FPS.

  • Before: debug counters (not in this PR) showed about 110 SDL updates a second in combat. Rumble lagged, and disconnecting the controller froze the presenter (gdb: presenter in HIDAPI_DelDevice, rumble thread draining).
  • With this version, together with fix(libSceVideoOut): rumble a DualSense from haptic audio without a sound card #7633 and a local legacy vibration port change like fix(audio): route legacy vibration PCM with per-port timing #6860:
    • Short scePadSetVibration pulses, two within one second, both went out and stopped on time.
    • Haptic audio drove rumble at up to 120 updates a second with no light bar or effect report in between, so nothing backed up.
    • One trigger effect, with no failed sends.
  • Not covered in that run: the light bar changed only twice, and the controller was not disconnected. Those paths are covered by pad_output_pacing.
  • pad_output_pacing passes, and check_conventions passes. pr_overlap.py could not run here (no gh).

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a (pad output only; no GPU path changed)
  • AI-assisted: yes

🤖 Generated with Claude Code

Every change of the pad output state sent a rumble, light bar and trigger
effect update to SDL, and the trigger effect was sent again even when it
had not changed. Titles that animate the light bar or drive rumble from
haptic audio change that state every frame, so at 120 Hz about 110
reports a second were queued while SDL's HIDAPI rumble thread sends at
most one per 10 ms. Different report kinds do not merge in its queue, so
the backlog grew: rumble arrived ever later, and disconnecting the
controller blocked the presenter until the queue drained.

Updates now go out at most every 30 ms with the latest state, and the
trigger effect is sent only when it changes or a controller connects.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the prx label Oct 18, 2026
@github-actions

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 674 core/libs/prx/libSceVideoOut/CMakeLists.txt
core/libs/prx/libSceVideoOut/include/PadInput.hpp
core/libs/prx/libSceVideoOut/src/PadInput.cpp
PR 5021 core/libs/prx/libSceVideoOut/CMakeLists.txt
PR 6044 core/libs/prx/libSceVideoOut/CMakeLists.txt
PR 6977 core/libs/prx/libSceVideoOut/CMakeLists.txt
PR 7201 core/libs/prx/libSceVideoOut/CMakeLists.txt
PR 7499 core/libs/prx/libSceVideoOut/src/PadInput.cpp
PR 7881 core/libs/prx/libSceVideoOut/CMakeLists.txt
core/libs/prx/libSceVideoOut/include/PadInput.hpp
core/libs/prx/libSceVideoOut/src/PadInput.cpp

@MarcZX10

Copy link
Copy Markdown
Contributor

The report says the trigger-effect deduplication fixed the SDL queue backlog, but the 30 ms limiter itself has not been run with the title. Since nextOutputAllowed gates the entire applyOutput() path, it also throttles rumble amplitude and light-bar updates to at most about 33 Hz. Could you validate the limiter with changing haptic audio/rumble and a short pulse followed by stop, and report the worst stop latency and whether the light-bar animation still behaves acceptably? The current before/after title result appears to isolate the benefit of trigger-effect deduplication, so it does not yet establish that this additional 30 ms gate preserves dynamic output behavior.

@MarcZX10

Copy link
Copy Markdown
Contributor

One retry edge in the new deduplication: SDL_GameControllerSendEffect returns -1 when the controller/driver does not support effect packets, but this code sets sentTriggerEffect = effect and triggerEffectSent = true regardless of the result. If the first send fails transiently, later output updates with the same effect are suppressed, whereas the previous per-update send would retry. Could you cache the effect only after a successful return (or otherwise keep a retry pending) and add a small test seam for a failed first send followed by a successful retry?

SDL2 documents the return contract here: https://wiki.libsdl.org/SDL2/SDL_GameControllerSendEffect

The 30 ms limit gated all controller output, so a rumble pulse shorter
than the interval could be lost and a stop could wait up to 30 ms.
Rumble goes out on every output change again, as on main; SDL already
skips repeated values and merges consecutive rumble reports. Only the
light bar is paced: a changed colour is sent at most every 30 ms, always
the latest one, and a colour SDL refuses is retried after the interval.

The trigger effect is cached only when SDL_GameControllerSendEffect
succeeds, so a refused effect is sent again on the next update as it was
before. LightBarPacer and TriggerEffectCache hold these decisions;
pad_output_pacing covers changes, retries, a new controller and a light
bar animated every frame at 120 Hz.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@WallisSkill

Copy link
Copy Markdown
Contributor Author

@MarcZX10 thanks, both points were right; pushed 8540328.

  • The 30 ms gate no longer applies to rumble. Rumble goes out on every output change again, as on main (SDL drops repeated values and merges consecutive rumble reports), so this PR neither delays nor drops a short pulse or its stop. Only the light bar is paced: a changed colour goes out at most every 30 ms, always the latest one.
  • The trigger effect is cached only when SDL_GameControllerSendEffect returns 0, so a refused effect is sent again on the next output update. The light bar does the same with SDL_GameControllerSetLED, retrying after the interval.
  • LightBarPacer and TriggerEffectCache (header-only, no SDL) hold these decisions, and pad_output_pacing tests them: changes only, a refused first send then a successful retry, a reconnect, and a colour changed every frame at 120 Hz (30 sends in a second, and the last colour still goes out).

Ran Dead Cells (PPSA15552) on Windows 11, DualSense over Bluetooth, with this version, #7633, and a local legacy vibration port change like #6860. Short scePadSetVibration pulses, two within one second, both went out and stopped on time. Haptic audio drove rumble at up to 120 updates a second with no light bar or effect report in between, so SDL merged them and nothing backed up. One trigger effect, no SendEffect failures. The light bar changed only twice in that run and I did not disconnect the controller, so the light bar pacing and the disconnect case are covered only by the test so far.

On the overlap notice: #4891 touches only HandleEvent and publish. #674 adds two lines at the end of openController, next to the two reset lines here, so whichever lands second needs a small textual merge. Neither touches applyOutput.

@github-actions github-actions Bot added the build label Oct 18, 2026
@adriadam10 adriadam10 self-assigned this Oct 19, 2026
@adriadam10
adriadam10 merged commit 36b72ad into boykopovar:main Oct 20, 2026
12 checks passed
@adriadam10

Copy link
Copy Markdown
Collaborator

Checked the light bar pacing and the trigger effect cache in PadInput::applyOutput (state reset on connect, effects cached only on SDL success, rumble path unchanged from main), the new pad_output_pacing test and its ctest/Windows registration, and the points @MarcZX10 raised; merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants