Files
CoopAllTheThings/tools/steam_input_probe/main.cpp
BlackMark 30eccf749d Apply clang-format across the whole tree
Run clang-format (the repo's .clang-format: LLVM base, 120 cols, tabs,
Allman functions) over every source file so the tree is formatter-clean.
Whitespace only -- no behavior change; full x64 + x86 suites pass.

Also set SortIncludes: false in .clang-format. Windows include order is
load-bearing (windows.h must precede tlhelp32.h / mmreg.h / xinput.h /
dinput.h; winsock2.h must precede windows.h), and the default
alphabetical sort reorders tlhelp32.h ahead of windows.h -- a build
break. Leaving order alone keeps the manual, correct grouping.
2026-07-12 11:52:53 +02:00

54 lines
1.6 KiB
C++

// coop_steam_input_probe -- console smoke test for SteamInputSource. Brings up
// Steam Input via the shipping host code (no GUI), prints whether it initialized,
// how many Steam controllers are connected, and a few polled snapshots, then
// exits. Needs Steam running and an appid context: either launch it under Steam,
// or drop a steam_appid.txt (e.g. "480") next to the exe. Built only when the
// Steamworks SDK is vendored.
#include <cstdio>
#include <windows.h>
#include "input/steam_input_source.hpp"
namespace {
std::string manifest_path()
{
char buffer[MAX_PATH] = {};
const DWORD len = GetModuleFileNameA(nullptr, buffer, MAX_PATH);
std::string path(buffer, len);
const std::size_t slash = path.find_last_of("\\/");
if (slash != std::string::npos) {
path.resize(slash + 1);
}
return path + "steam_input_actions.vdf";
}
} // namespace
int main()
{
coop::SteamInputSource src;
const bool ok = src.init(manifest_path());
std::printf("init=%d steam_active=%d backend=\"%s\"\n", ok ? 1 : 0, src.steam_active() ? 1 : 0, src.name());
for (int frame = 0; frame < 20; ++frame) {
src.poll();
Sleep(50);
}
std::printf("steam_controllers=%d\n", src.steam_controllers());
const auto& pads = src.pads();
for (std::uint32_t i = 0; i < coop::kMaxPads; ++i) {
const coop::PadInfo& p = pads[i];
if (p.connected) {
std::printf(" slot %u: source=\"%s\" buttons=0x%04X LX=%d LY=%d LT=%u RT=%u\n", i, p.source.c_str(),
p.state.buttons, p.state.thumb_lx, p.state.thumb_ly, p.state.left_trigger,
p.state.right_trigger);
}
}
src.shutdown();
std::printf("done.\n");
return 0;
}