Files
CoopAllTheThings/host/src/injection_panel.hpp
BlackMark 31390d8c15 Audio render-hook M4: audio panel source indicator + stream-count debug view
Surfaces the render-hook diagnostics in the Audio panel.

- HookStatusView / IpcServer::hook_status(): carry audio_streams_seen +
  audio_streams[] from the hook's back-channel.
- InjectionPanel: expose hook_status() so the audio panel can read the counts.
- AudioPanel::draw_ui(HookStatusView): show the active Source (green Hooked
  vs amber Loopback); only warn about the local echo on the loopback path. Add
  the required render-stream table: one row per stream with format, cumulative
  frames, the primary tagged, and a live/idle dot derived from frame-count
  deltas. Notes overflow when the game exceeds kMaxAudioStreams slots.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-19 12:05:28 +02:00

66 lines
1.5 KiB
C++

// ImGui panel that drives the input-forwarding pipeline: pick a target process,
// inject coop_hook.dll, and stream pad state to it over shared memory.
#pragma once
#include <array>
#include <string>
#include <vector>
#include <windows.h>
#include "coop/protocol.hpp"
#include "imgui.h"
#include "inject/process_list.hpp"
#include "ipc/ipc_server.hpp"
namespace coop
{
class InjectionPanel
{
public:
InjectionPanel();
void draw();
// Forward the latest pad snapshot to the injected hook (if connected). When
// test-input mode is on, a synthetic pattern is sent instead of `pads`.
void publish(const std::array<PadInfo, kMaxPads>& pads);
// The injected game's main window, as reported by the hook (null if none).
[[nodiscard]] HWND game_hwnd() const
{
return reinterpret_cast<HWND>(server_.hook_status().game_hwnd);
}
// The hook's full diagnostics back-channel (other panels read the audio
// render-stream counts from here).
[[nodiscard]] HookStatusView hook_status() const
{
return server_.hook_status();
}
private:
void refresh_processes();
void inject_selected();
void draw_hook_status();
std::vector<ProcessEntry> processes_;
char filter_[128] = {};
unsigned long selected_pid_ = 0;
std::wstring selected_name_;
IpcServer server_;
std::string status_;
ImVec4 status_color_;
bool test_input_ = false;
// Sampled to turn the hook's cumulative per-slot counters into poll rates.
unsigned long long last_state_count_[kMaxPads] = {};
double state_rate_[kMaxPads] = {};
double last_sample_time_ = 0.0;
};
} // namespace coop