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.
This commit is contained in:
@@ -15,8 +15,7 @@
|
||||
|
||||
using namespace coop;
|
||||
|
||||
namespace
|
||||
{
|
||||
namespace {
|
||||
|
||||
constexpr std::uint16_t kButtonA = 0x1000;
|
||||
constexpr std::uint16_t kButtonB = 0x2000;
|
||||
@@ -25,8 +24,7 @@ int g_failures = 0;
|
||||
|
||||
void check(bool ok, const char* what)
|
||||
{
|
||||
if (!ok)
|
||||
{
|
||||
if (!ok) {
|
||||
std::printf(" FAIL: %s\n", what);
|
||||
++g_failures;
|
||||
}
|
||||
@@ -41,8 +39,7 @@ void check(bool ok, const char* what)
|
||||
void exercise_dll(const wchar_t* dll_name)
|
||||
{
|
||||
HMODULE m = GetModuleHandleW(dll_name);
|
||||
if (m == nullptr)
|
||||
{
|
||||
if (m == nullptr) {
|
||||
return; // not loaded on this machine; nothing to exercise
|
||||
}
|
||||
char tag[96];
|
||||
@@ -56,26 +53,22 @@ void exercise_dll(const wchar_t* dll_name)
|
||||
auto get_caps = reinterpret_cast<GetCaps_t>(GetProcAddress(m, "XInputGetCapabilities"));
|
||||
auto set_state = reinterpret_cast<SetState_t>(GetProcAddress(m, "XInputSetState"));
|
||||
|
||||
if (get_state != nullptr)
|
||||
{
|
||||
if (get_state != nullptr) {
|
||||
XINPUT_STATE s = {};
|
||||
std::snprintf(tag, sizeof(tag), "%ls XInputGetState forwards state", dll_name);
|
||||
check(get_state(0, &s) == ERROR_SUCCESS && s.dwPacketNumber == 7, tag);
|
||||
}
|
||||
if (get_state_ex != nullptr)
|
||||
{
|
||||
if (get_state_ex != nullptr) {
|
||||
XINPUT_STATE s = {};
|
||||
std::snprintf(tag, sizeof(tag), "%ls XInputGetStateEx (ord 100) forwards state", dll_name);
|
||||
check(get_state_ex(0, &s) == ERROR_SUCCESS && s.dwPacketNumber == 7, tag);
|
||||
}
|
||||
if (get_caps != nullptr)
|
||||
{
|
||||
if (get_caps != nullptr) {
|
||||
XINPUT_CAPABILITIES c = {};
|
||||
std::snprintf(tag, sizeof(tag), "%ls XInputGetCapabilities reports gamepad", dll_name);
|
||||
check(get_caps(0, 0, &c) == ERROR_SUCCESS && c.Type == XINPUT_DEVTYPE_GAMEPAD, tag);
|
||||
}
|
||||
if (set_state != nullptr)
|
||||
{
|
||||
if (set_state != nullptr) {
|
||||
// A game commonly rumbles in response to a button press; this is the call
|
||||
// path "crashes as soon as a button is pressed" pointed at.
|
||||
XINPUT_VIBRATION v = {};
|
||||
@@ -89,9 +82,9 @@ void exercise_dll(const wchar_t* dll_name)
|
||||
void dump_layout()
|
||||
{
|
||||
std::printf("LAYOUT sizeof(SharedBlock)=%zu CoopPadState=%zu\n", sizeof(SharedBlock), sizeof(CoopPadState));
|
||||
std::printf("LAYOUT off pads=%zu sequence=%zu status=%zu control=%zu video=%zu\n",
|
||||
offsetof(SharedBlock, pads), offsetof(SharedBlock, sequence), offsetof(SharedBlock, status),
|
||||
offsetof(SharedBlock, control), offsetof(SharedBlock, video));
|
||||
std::printf("LAYOUT off pads=%zu sequence=%zu status=%zu control=%zu video=%zu\n", offsetof(SharedBlock, pads),
|
||||
offsetof(SharedBlock, sequence), offsetof(SharedBlock, status), offsetof(SharedBlock, control),
|
||||
offsetof(SharedBlock, video));
|
||||
std::printf("LAYOUT HookStatus sizeof=%zu get_state_calls=%zu attached=%zu audio_streams=%zu hook_entries=%zu\n",
|
||||
sizeof(HookStatus), offsetof(HookStatus, get_state_calls), offsetof(HookStatus, attached),
|
||||
offsetof(HookStatus, audio_streams), offsetof(HookStatus, hook_entries));
|
||||
@@ -118,8 +111,7 @@ int main()
|
||||
|
||||
// --- Host side: create the section (named by our pid) and publish a pad. ---
|
||||
SharedMemory shm;
|
||||
if (!shm.create(shared_memory_name(GetCurrentProcessId()), sizeof(SharedBlock)))
|
||||
{
|
||||
if (!shm.create(shared_memory_name(GetCurrentProcessId()), sizeof(SharedBlock))) {
|
||||
std::printf("FAIL: could not create shared memory\n");
|
||||
return 1;
|
||||
}
|
||||
@@ -143,8 +135,7 @@ int main()
|
||||
// loads exactly one, but which one varies by game age -- and the 32-bit crash
|
||||
// only reproduces over the specific DLL the game uses.
|
||||
const wchar_t* xinput_modules[] = {L"xinput1_4.dll", L"xinput1_3.dll", L"xinput9_1_0.dll", L"xinputuap.dll"};
|
||||
for (const wchar_t* name : xinput_modules)
|
||||
{
|
||||
for (const wchar_t* name : xinput_modules) {
|
||||
LoadLibraryW(name); // best-effort; absent variants stay unloaded
|
||||
}
|
||||
|
||||
@@ -172,8 +163,7 @@ int main()
|
||||
// Now drive every loaded variant's full export set (GetState, ordinal-100
|
||||
// GetStateEx, GetCapabilities, and the rumble SetState a game calls on a button
|
||||
// press) so each DLL's hooked prologue/trampoline is actually run.
|
||||
for (const wchar_t* name : xinput_modules)
|
||||
{
|
||||
for (const wchar_t* name : xinput_modules) {
|
||||
exercise_dll(name);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user