feat(libSceVideoOut): add ANYPS5_RUMBLE to scale or turn off host controller vibration #12686

Merged
MarcZX10 merged 11 commits from upstream-pr/12686 into main 2026-10-29 22:46:18 +00:00
MarcZX10 commented 2026-10-29 02:09:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T02:09:00Z.


What

Adds ANYPS5_RUMBLE=<0..100>, a host-side comfort setting for how strongly a title's vibration reaches a physical controller. There was no way to reduce or disable it. Unset or 100 is a bypass that builds exactly the command built before; 0 never hands the host a nonzero amplitude and stops a running rumble; values in between scale the 16-bit motor amplitudes with exact integer arithmetic (round half up, never amplifying). It applies to every connected controller. An invalid value (empty, signed, fractional, above 100) throws when the pad input starts, with an error naming ANYPS5_RUMBLE. This is not console behaviour and is documented as such; there is no overlay entry or hotkey.

Paths considered:

  • SDL motor rumble (SDL_GameControllerRumble): scaled.
  • Impulse-trigger rumble of non-DualSense controllers (SDL_GameControllerRumbleTriggers): scaled, since it is vibration to the user.
  • Vibration played as audio and turned into motor rumble when no controller sound card plays it: reaches the motor path above, scaled once there.
  • Vibration PCM written to a DualSense's own sound card (legacy AudioOut and AudioOut2): only the two actuator channels are scaled linearly, silence at 0; speaker channels are never touched. Left alone, 0 would still shake a DualSense on USB.
  • Not covered on purpose: DualSense adaptive trigger effects (SDL_GameControllerSendEffect). They are resistance and force profiles, not only vibration, and scaling them means decoding the effect formats, which is unmeasured here. Documented in USAGE.md.

Commits:

  1. feat(libScePad) header-only PadRumbleIntensity.hpp: scale, command builder, sink helper, parser, cached env read.
  2. test(libScePad) its test.
  3. feat(libSceVideoOut) PadInput.cpp builds both rumble commands through the helper (about 10 changed lines).
  4. feat(libSceAudioOut) trailing percentage parameter (default 100) on AudioOut2WritePadFrames; 5. its test; 6-7. one commit per caller (AudioOut.cpp, AudioOut2Context.cpp).
    8-10. docs: ENVIRONMENT.md row, USAGE.md section, INPUT_MAPPING.md pointer.

Overlaps with open PRs (no code reused): #12569 edits PadInput.cpp, AudioOut.cpp, AudioOut2Context.cpp, libSceAudioOut/CMakeLists.txt, ENVIRONMENT.md, USAGE.md and INPUT_MAPPING.md, so a mechanical conflict is possible in those files; my edits there are small and separate. #9154 (Bluetooth DualSense haptics reports) and #10112 (adaptive triggers) add host output paths that this setting does not cover until they adopt Pad::RumblePercent().

Tested

Debian 12, g++ 12, Ninja, base 3a2b919816 after rebase (tests were built before a clean rebase onto it; the upstream commits in between touch none of the files changed here).

  • New pad_rumble_intensity: scale checked against an independent exact reference for every amplitude 0..65535 at every percentage 0..100 (bounds, monotonic in both), the 100 percent command byte for byte (memcmp) against the old formula for all 256x256 motor pairs, 0 percent with a recording sink for all 65536 pairs (exactly one call, always 0,0,0), stop after a full-strength rumble, intermediate values, parser accept (0 1 50 99 100 007 000) and refuse ("" 101 999 1000 -1 +5 " 5" "5 " 1.5 abc 0x10 50% 5a 1e1), env read once, invalid value keeps failing. Passed.
  • New audio_out2_pad_haptic_intensity: quad and pulse layouts, 100 and above byte-identical to the call without the parameter, 0 silences exactly the actuator channels (also non-finite samples), 50 and 99 scale, speaker and unmapped channels untouched. Passed.
  • Existing tests, branch vs upstream/main in a second tree, same targets: 44 passed on baseline, 47 on branch; per-test diff is only the 3 new tests (plus audio_out2_pad_mix, which I had not built on the baseline and ran there separately: passed on both). All audio_out_vibration_*, guest_pad, guest_pad_vibration_mode, pad_output_pacing, pad_input_mapping, pad_keyboard_mouse, pad_sdl pass on both. Targets I did not build are Not Run on both sides.
  • Video-out and pad tests under Xvfb: ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation xvfb-run -a ctest -R 'video_out|pad_' -V with -DANYPS5_VIDEO_OUT_TEST_DRIVER=x11: layer-not-found lines 0 on both, VUID- lines 0 on branch and 0 on baseline, 0 failures on both (the same 14 unbuilt tests are Not Run on both).
  • Negative controls (scratch copies, restored): rounding down, truncating, rounding up, wrong divisor, bypass using *256, no bypass above 100, 0 percent skipping the sink or leaving a nonzero duration, duration not zeroed, parser accepting empty / 101 / a sign, error not naming the variable, env not cached; audio: speaker channels scaled, wrong gain, scaling at 100 and above, 99 not scaled, 0 not silencing a NaN sample. Each fails at its intended assertion. Not negative-controllable: removing the 100 percent branch (the scaled formula is exactly the identity at 100, so behaviour is equal by construction; the byte-for-byte test catches any non-identity bypass).
  • Checks clean: check_conventions.py --base upstream/main, git diff --check, header audit, env_reference.py --check.

NOT RUN: Windows, macOS, a real controller or DualSense (the wiring in PadInput::applyOutput and the sound-card gain are covered by the helper tests and compile, not by a device; the haptic gain being linear is not felt-tested), a hardware GPU, a console.

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: llvmpipe (LLVM 15.0.6) via Xvfb with the Khronos validation layer; no hardware GPU
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5060857242 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12686). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-29T02:09:00Z. --- ### What Adds `ANYPS5_RUMBLE=<0..100>`, a host-side comfort setting for how strongly a title's vibration reaches a physical controller. There was no way to reduce or disable it. Unset or `100` is a bypass that builds exactly the command built before; `0` never hands the host a nonzero amplitude and stops a running rumble; values in between scale the 16-bit motor amplitudes with exact integer arithmetic (round half up, never amplifying). It applies to every connected controller. An invalid value (empty, signed, fractional, above 100) throws when the pad input starts, with an error naming `ANYPS5_RUMBLE`. This is not console behaviour and is documented as such; there is no overlay entry or hotkey. Paths considered: - SDL motor rumble (`SDL_GameControllerRumble`): scaled. - Impulse-trigger rumble of non-DualSense controllers (`SDL_GameControllerRumbleTriggers`): scaled, since it is vibration to the user. - Vibration played as audio and turned into motor rumble when no controller sound card plays it: reaches the motor path above, scaled once there. - Vibration PCM written to a DualSense's own sound card (legacy AudioOut and AudioOut2): only the two actuator channels are scaled linearly, silence at 0; speaker channels are never touched. Left alone, `0` would still shake a DualSense on USB. - Not covered on purpose: DualSense adaptive trigger effects (`SDL_GameControllerSendEffect`). They are resistance and force profiles, not only vibration, and scaling them means decoding the effect formats, which is unmeasured here. Documented in USAGE.md. Commits: 1. `feat(libScePad)` header-only `PadRumbleIntensity.hpp`: scale, command builder, sink helper, parser, cached env read. 2. `test(libScePad)` its test. 3. `feat(libSceVideoOut)` PadInput.cpp builds both rumble commands through the helper (about 10 changed lines). 4. `feat(libSceAudioOut)` trailing percentage parameter (default 100) on `AudioOut2WritePadFrames`; 5. its test; 6-7. one commit per caller (`AudioOut.cpp`, `AudioOut2Context.cpp`). 8-10. docs: ENVIRONMENT.md row, USAGE.md section, INPUT_MAPPING.md pointer. Overlaps with open PRs (no code reused): #12569 edits `PadInput.cpp`, `AudioOut.cpp`, `AudioOut2Context.cpp`, `libSceAudioOut/CMakeLists.txt`, ENVIRONMENT.md, USAGE.md and INPUT_MAPPING.md, so a mechanical conflict is possible in those files; my edits there are small and separate. #9154 (Bluetooth DualSense haptics reports) and #10112 (adaptive triggers) add host output paths that this setting does not cover until they adopt `Pad::RumblePercent()`. ### Tested Debian 12, g++ 12, Ninja, base `3a2b919816` after rebase (tests were built before a clean rebase onto it; the upstream commits in between touch none of the files changed here). - New `pad_rumble_intensity`: scale checked against an independent exact reference for every amplitude 0..65535 at every percentage 0..100 (bounds, monotonic in both), the 100 percent command byte for byte (memcmp) against the old formula for all 256x256 motor pairs, 0 percent with a recording sink for all 65536 pairs (exactly one call, always `0,0,0`), stop after a full-strength rumble, intermediate values, parser accept (`0 1 50 99 100 007 000`) and refuse (`"" 101 999 1000 -1 +5 " 5" "5 " 1.5 abc 0x10 50% 5a 1e1`), env read once, invalid value keeps failing. Passed. - New `audio_out2_pad_haptic_intensity`: quad and pulse layouts, 100 and above byte-identical to the call without the parameter, 0 silences exactly the actuator channels (also non-finite samples), 50 and 99 scale, speaker and unmapped channels untouched. Passed. - Existing tests, branch vs `upstream/main` in a second tree, same targets: 44 passed on baseline, 47 on branch; per-test diff is only the 3 new tests (plus `audio_out2_pad_mix`, which I had not built on the baseline and ran there separately: passed on both). All `audio_out_vibration_*`, `guest_pad`, `guest_pad_vibration_mode`, `pad_output_pacing`, `pad_input_mapping`, `pad_keyboard_mouse`, `pad_sdl` pass on both. Targets I did not build are `Not Run` on both sides. - Video-out and pad tests under Xvfb: `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation xvfb-run -a ctest -R 'video_out|pad_' -V` with `-DANYPS5_VIDEO_OUT_TEST_DRIVER=x11`: layer-not-found lines 0 on both, `VUID-` lines 0 on branch and 0 on baseline, 0 failures on both (the same 14 unbuilt tests are `Not Run` on both). - Negative controls (scratch copies, restored): rounding down, truncating, rounding up, wrong divisor, bypass using `*256`, no bypass above 100, 0 percent skipping the sink or leaving a nonzero duration, duration not zeroed, parser accepting empty / 101 / a sign, error not naming the variable, env not cached; audio: speaker channels scaled, wrong gain, scaling at 100 and above, 99 not scaled, 0 not silencing a NaN sample. Each fails at its intended assertion. Not negative-controllable: removing the 100 percent branch (the scaled formula is exactly the identity at 100, so behaviour is equal by construction; the byte-for-byte test catches any non-identity bypass). - Checks clean: `check_conventions.py --base upstream/main`, `git diff --check`, header audit, `env_reference.py --check`. NOT RUN: Windows, macOS, a real controller or DualSense (the wiring in `PadInput::applyOutput` and the sound-card gain are covered by the helper tests and compile, not by a device; the haptic gain being linear is not felt-tested), a hardware GPU, a console. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: llvmpipe (LLVM 15.0.6) via Xvfb with the Khronos validation layer; no hardware GPU - [x] AI-assisted: yes
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!12686
No description provided.