Forward rumble back to the guest controller (both backends)

The XInput hook used to swallow XInputSetState; now it records the requested
left/right motor speeds into the status back-channel (protocol v8->v9: per-slot
rumble_left/right in HookStatus). Each frame the host reads them and, only on
change, drives the guest's actuator via the active backend:
- XInput: XInputSetState on the guest's slot (the open question is whether Steam's
  RPT virtual pad accepts vibration and routes it to the guest -- needs live RPT);
- Steam Input: SteamInput TriggerVibration on the slot's controller handle, with the
  XInput fallback for slots Steam isn't driving.

InputSource gains a set_rumble(slot,left,right) hook (default no-op) implemented by
both backends; SteamInputSource now tracks per-slot controller handles + which slots
it drives.

Verified: hook_selftest (x64 + x86) now asserts the hook records the rumble from
XInputSetState into the status; full build x64 + x86 clean; ctest x64 9/9, x86 3/3.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-21 05:11:33 +02:00
parent 7673f186db
commit 056a478e19
13 changed files with 108 additions and 13 deletions

View File

@@ -12,7 +12,7 @@ namespace coop
// Bump whenever the layout of SharedBlock or CoopPadState changes. The hook
// refuses to attach to a host with a mismatched version.
inline constexpr std::uint32_t kProtocolVersion = 8;
inline constexpr std::uint32_t kProtocolVersion = 9;
// 'COOP' little-endian, used to sanity-check the mapping before trusting it.
inline constexpr std::uint32_t kProtocolMagic = 0x504F4F43u;
@@ -127,6 +127,12 @@ struct HookStatus
// call count. Lets the Injection panel list exactly what's hooked and how busy.
std::uint32_t hook_entry_count;
HookEntry hook_entries[kMaxHookEntries];
// Per-slot rumble the game last requested via XInputSetState (hook is sole
// writer). The host forwards it to the guest's controller. Plain POD like the
// other diagnostics -- benign cross-process races are fine.
std::uint16_t rumble_left[kMaxPads];
std::uint16_t rumble_right[kMaxPads];
};
// Host -> hook control channel. The host requests which hook subsystems should be