controller: forward guest vibration to SDL rumble #365

Manually merged
github merged 1 commit from gh-pr/365/head into gh-pr/365/base 2026-11-26 09:17:58 +00:00
Owner

@⁠MehmetCambaz on GitHub · 2026-08-28 22:24 UTC · original
MehmetCambaz:feat/controller-rumble → main · +27 −0 · 1 files · 1 commits · merged 2026-08-29 00:49 UTC

Summary

  • scePadSetVibration logged the requested motor levels and then discarded them, so guest rumble never reached the pad. Forward both motors to SDL_GameControllerRumble.
  • large_motor drives SDL's low frequency motor and small_motor the high frequency one, scaled from the guest's 8 bit levels to SDL's 16 bit range (0xff -> 0xffff).
  • The guest API holds the motors until the guest changes them, while SDL rumble always expires. SDL clamps the duration to 0xffff ms internally, so that maximum is requested and an explicit zero level stops the motors early instead.
  • Keyboard and mouse input is mapped onto a virtual pad that has no motors, so that path returns early.

Test plan

Windows 11 25H2, clang-cl 20.1.8, RTX 2060, DualShock 4 v2 (CUH-ZCT2) over Bluetooth.

  • ctest: 31/31, three consecutive runs.
  • The guest call resolves a live SDL_GameController* rather than the virtual keyboard pad (checked with temporary logging, since removed).
  • SDL reports no error for the resulting rumble call.
  • The motors physically run when a non-zero level is sent through this path.
    Not verified: rumble driven by real gameplay. The only title I have (Tetris Forever, PPSA25646) calls scePadSetVibration(0, 0) once at startup and never again, so I could not exercise a game-driven effect. I confirmed the motors with a forced non-zero call through the same code path instead.

An automated test did not seem practical here, since the behaviour only shows up as physical motor output on real hardware. Happy to add one if you have a preferred approach.

Only Windows and a DualShock 4 were tested. Adaptive triggers are untouched: that is DualSense-only hardware and scePadSetTriggerEffect remains a stub.

AI use

Developed with AI assistance (Claude). It located the stub, wrote the change, and ran the builds, tests and logging on my machine. I reviewed the diff, checked the motor scaling and that the SDL calls used here lock internally so they are safe from the guest thread, and ran the emulator with my own controller to confirm the rumble fires.

**@⁠MehmetCambaz** on GitHub · 2026-08-28 22:24 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/365) `MehmetCambaz:feat/controller-rumble` → `main` · +27 −0 · 1 files · 1 commits · merged 2026-08-29 00:49 UTC ## Summary - `scePadSetVibration` logged the requested motor levels and then discarded them, so guest rumble never reached the pad. Forward both motors to `SDL_GameControllerRumble`. - `large_motor` drives SDL's low frequency motor and `small_motor` the high frequency one, scaled from the guest's 8 bit levels to SDL's 16 bit range (`0xff` -> `0xffff`). - The guest API holds the motors until the guest changes them, while SDL rumble always expires. SDL clamps the duration to `0xffff` ms internally, so that maximum is requested and an explicit zero level stops the motors early instead. - Keyboard and mouse input is mapped onto a virtual pad that has no motors, so that path returns early. ## Test plan Windows 11 25H2, clang-cl 20.1.8, RTX 2060, DualShock 4 v2 (CUH-ZCT2) over Bluetooth. - [x] `ctest`: 31/31, three consecutive runs. - [x] The guest call resolves a live `SDL_GameController*` rather than the virtual keyboard pad (checked with temporary logging, since removed). - [x] SDL reports no error for the resulting rumble call. - [x] The motors physically run when a non-zero level is sent through this path. **Not verified:** rumble driven by real gameplay. The only title I have (Tetris Forever, PPSA25646) calls `scePadSetVibration(0, 0)` once at startup and never again, so I could not exercise a game-driven effect. I confirmed the motors with a forced non-zero call through the same code path instead. An automated test did not seem practical here, since the behaviour only shows up as physical motor output on real hardware. Happy to add one if you have a preferred approach. Only Windows and a DualShock 4 were tested. Adaptive triggers are untouched: that is DualSense-only hardware and `scePadSetTriggerEffect` remains a stub. ## AI use Developed with AI assistance (Claude). It located the stub, wrote the change, and ran the builds, tests and logging on my machine. I reviewed the diff, checked the motor scaling and that the SDL calls used here lock internally so they are safe from the guest thread, and ran the emulator with my own controller to confirm the rumble fires.
Scale the SDK 8-bit motor levels to SDL’s 16-bit range and use SDL’s maximum effect duration. Keep lookup and rumble under the controller lock so hot unplug cannot invalidate the SDL pointer.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:17:55 +00:00
github manually merged commit 9c934370a8 into gh-pr/365/base 2026-11-26 09:17:58 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.