Move input polling to its own thread; fixed-width fast-changing UI numbers
Input thread: controller polling, pad publishing, and rumble forwarding were driven by the render loop, so a low/synced frame rate throttled how often guest input reached the game. New InputWorker owns the InputSource and runs poll + IPC publish + rumble on a dedicated ~1 kHz thread, independent of rendering. The UI thread reads a copy-safe InputSnapshot for the Controllers panel and relays the Steam-Input request/active/failed state to/from the worker (Steam init/shutdown now happen on the worker thread). IpcServer gained a mutex so the worker's publish() / hook_status() can't race the UI thread starting/stopping the shared-memory channel (use-after-unmap); InjectionPanel::test_input_ is now atomic. ControllersPanel::draw takes an InputSnapshot instead of the live InputSource. Fixed-width numbers: fast-changing readouts (menu-bar FPS/ms, Video pipeline rates + latency + graph legend, controller poll rates + round-trip sticks, audio buffered ms + frames/s) printed with %.0f etc., so they shifted/blurred as values crossed digit thresholds (99 -> 100) each frame. Padded them to fixed field widths so they stay put. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -67,12 +67,12 @@ void draw_pad(int index, const PadInfo& pad, bool debug_details)
|
||||
|
||||
} // namespace
|
||||
|
||||
void ControllersPanel::draw(const InputSource& input, const HookStatusView& status, bool debug_details)
|
||||
void ControllersPanel::draw(const InputSnapshot& input, const HookStatusView& status, bool debug_details)
|
||||
{
|
||||
apply_panel_layout(Panel::Controllers);
|
||||
ImGui::Begin("Controllers");
|
||||
|
||||
ImGui::Text("Input backend: %s", input.name());
|
||||
ImGui::Text("Input backend: %s", input.backend);
|
||||
ImGui::TextDisabled("This window is what Remote Play Together captures.");
|
||||
ImGui::TextDisabled("F1: hide overlay (clean mirror) Esc: quit");
|
||||
|
||||
@@ -108,7 +108,7 @@ void ControllersPanel::draw(const InputSource& input, const HookStatusView& stat
|
||||
|
||||
// --- Guest pads the host receives from RPT -----------------------------
|
||||
ImGui::SeparatorText("Incoming (host receives)");
|
||||
const auto& pads = input.pads();
|
||||
const auto& pads = input.pads;
|
||||
for (int i = 0; i < static_cast<int>(pads.size()); ++i)
|
||||
{
|
||||
draw_pad(i, pads[i], debug_details);
|
||||
@@ -145,7 +145,7 @@ void ControllersPanel::draw(const InputSource& input, const HookStatusView& stat
|
||||
}
|
||||
if (total_rate > 0.0)
|
||||
{
|
||||
ImGui::TextColored(kGreen, "Game reading controller: %.0f polls/s", total_rate);
|
||||
ImGui::TextColored(kGreen, "Game reading controller: %5.0f polls/s", total_rate);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -168,7 +168,7 @@ void ControllersPanel::draw(const InputSource& input, const HookStatusView& stat
|
||||
ImGui::TableNextColumn();
|
||||
if (state_rate_[i] > 0.0)
|
||||
{
|
||||
ImGui::TextColored(kGreen, "%.0f", state_rate_[i]);
|
||||
ImGui::TextColored(kGreen, "%5.0f", state_rate_[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -194,7 +194,7 @@ void ControllersPanel::draw(const InputSource& input, const HookStatusView& stat
|
||||
ImGui::TableSetupColumn("Forwarded btn / LX,LY");
|
||||
ImGui::TableSetupColumn("Game read btn / LX,LY");
|
||||
ImGui::TableHeadersRow();
|
||||
const auto& fwd = input.pads();
|
||||
const auto& fwd = input.pads;
|
||||
for (int i = 0; i < static_cast<int>(kMaxPads); ++i)
|
||||
{
|
||||
const CoopPadState& f = fwd[i].state;
|
||||
@@ -203,10 +203,10 @@ void ControllersPanel::draw(const InputSource& input, const HookStatusView& stat
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("%d", i);
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("0x%04X %d,%d", f.buttons, f.thumb_lx, f.thumb_ly);
|
||||
ImGui::Text("0x%04X %6d,%6d", f.buttons, f.thumb_lx, f.thumb_ly);
|
||||
ImGui::TableNextColumn();
|
||||
const bool match = f.buttons == r.buttons && f.thumb_lx == r.thumb_lx && f.thumb_ly == r.thumb_ly;
|
||||
ImGui::TextColored(match ? kGreen : kGrey, "0x%04X %d,%d", r.buttons, r.thumb_lx, r.thumb_ly);
|
||||
ImGui::TextColored(match ? kGreen : kGrey, "0x%04X %6d,%6d", r.buttons, r.thumb_lx, r.thumb_ly);
|
||||
}
|
||||
ImGui::EndTable();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user