Phase 1a: focus spoofing + hook observability
Two problems surfaced in testing: (1) no way to tell whether the injected hook was actually the input source, and (2) the final design needs the tool window focused for Steam RPT capture, which would pause/silence games that react to focus loss. Both are addressed here. - Focus spoofing (hook/focus_spoof): find the game's main window, subclass it to rewrite/swallow WM_ACTIVATE/ACTIVATEAPP/NCACTIVATE/KILLFOCUS, and inline- hook GetForegroundWindow/GetActiveWindow/GetFocus to always report the game as active. The game keeps running and polling while unfocused. - Status back-channel (protocol v2): the DLL reports attached/focus-spoof flags, game pid/hwnd, a heartbeat, and a cumulative XInputGetState counter. The host overlay turns the counter into a live poll rate, so "is the hook working" is directly observable. - Synthetic test-input toggle in the host: forwards a known automated pattern (stick circle + periodic A) to prove forwarding independent of the physical pad. - hook_selftest extended to assert the status channel; passes. Documented the windowed/borderless requirement and the new observable test flow in the README. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
21
hook/src/focus_spoof.hpp
Normal file
21
hook/src/focus_spoof.hpp
Normal file
@@ -0,0 +1,21 @@
|
||||
// Makes the injected game believe it always has foreground focus, so it keeps
|
||||
// running and polling input while the tool's window holds the real OS focus
|
||||
// (required for Steam RPT to capture the tool). Without this, games that pause
|
||||
// or stop polling on focus loss are unusable in the final design.
|
||||
#pragma once
|
||||
|
||||
#include "ipc_client.hpp"
|
||||
|
||||
namespace coop::hook
|
||||
{
|
||||
|
||||
// Finds the game's main window, subclasses it to suppress deactivation messages,
|
||||
// and hooks the focus-query APIs to always report the game as active. Returns
|
||||
// true once spoofing is active; safe to retry until the window exists. Reports
|
||||
// status through `ipc`.
|
||||
bool install_focus_spoof(IpcClient& ipc);
|
||||
|
||||
// Restores the original window procedure and removes the focus API hooks.
|
||||
void remove_focus_spoof();
|
||||
|
||||
} // namespace coop::hook
|
||||
Reference in New Issue
Block a user