Per-subsystem hook control: install/remove input, focus, audio at runtime
Add a host->hook control channel (protocol v5 -> v6: HookControl in SharedBlock, per-subsystem "disabled" flags, 0 = install so the zero-filled default is unchanged). The worker now reconciles each subsystem every tick: install what's requested-and-missing, remove what's no longer wanted -- so the audio hooks re-attach the ring and republish format on a reinstall, and XInput/focus clear their stale status flags on removal. Injection panel: a checkbox per subsystem (input forwarding / focus spoof / audio render-hook) toggles it at runtime, showing the requested vs actual installed state from the registry, plus DLL heartbeat liveness. The hook-status section now keys off whether a DLL was injected (host-side) rather than the input-hook "attached" flag, so it stays visible with input unhooked. Guards for dependent features: the synthetic-input control is disabled when input forwarding is off, and the Audio panel explains that mirroring uses loopback (echo) when the render-hook is off. Verified against Phantom Brave via coop_audio_probe: starting with audio requested off installs only input+focus (8 hooks, no capture); re-enabling at runtime installs the audio hooks (13) and capture starts immediately. All four tests pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -44,6 +44,17 @@ public:
|
||||
return block_ != nullptr;
|
||||
}
|
||||
|
||||
// Host-requested install state for a subsystem (default = install, since the
|
||||
// mapping is zero-filled and 0 means "disabled flag clear" = install).
|
||||
[[nodiscard]] bool subsystem_install_requested(std::uint32_t subsystem) const
|
||||
{
|
||||
if (block_ == nullptr || subsystem >= HookSubsys_Count)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return block_->control.subsystem_disabled[subsystem].load(std::memory_order_acquire) == 0;
|
||||
}
|
||||
|
||||
// Copies a torn-free snapshot of all slots. Returns false only if the host
|
||||
// was mid-write for the whole spin window (caller should reuse its cache).
|
||||
bool snapshot(CoopPadState (&out)[kMaxPads], std::uint32_t& count) const
|
||||
@@ -91,6 +102,16 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
// XInput hooks were removed (host unhooked input): clear the attached flag so
|
||||
// the Controllers panel stops showing stale poll rates.
|
||||
void mark_detached()
|
||||
{
|
||||
if (block_ != nullptr)
|
||||
{
|
||||
block_->status.attached = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void mark_focus_spoof(bool active, std::uint64_t game_hwnd)
|
||||
{
|
||||
if (block_ != nullptr)
|
||||
|
||||
Reference in New Issue
Block a user