diff options
| author | ZroFreaks <42916282+ZroIsHere@users.noreply.github.com> | 2026-11-26 17:49:58 +0100 |
|---|---|---|
| committer | ZroFreaks <42916282+ZroIsHere@users.noreply.github.com> | 2026-11-26 17:49:58 +0100 |
| commit | ee470192461a2911aa204cfecf9fdccb265a8b5f (patch) | |
| tree | 6e5d5d405e17e6160d6ac3fa6c1491535bb6acf8 /runtime/shims/gameinput.cpp | |
| parent | 4e93ea9ef3fd48431bee7d17705f62a69023ab57 (diff) | |
Improve first-run input diagnostics
Diffstat (limited to 'runtime/shims/gameinput.cpp')
| -rw-r--r-- | runtime/shims/gameinput.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/runtime/shims/gameinput.cpp b/runtime/shims/gameinput.cpp index 5abb2a2fe..c989daff4 100644 --- a/runtime/shims/gameinput.cpp +++ b/runtime/shims/gameinput.cpp | |||
| @@ -2495,13 +2495,13 @@ public: | |||
| 2495 | struct Stats { | 2495 | struct Stats { |
| 2496 | std::mutex mu; | 2496 | std::mutex mu; |
| 2497 | uint64_t calls[3][3] = {}; // method x (null, aggregate, a device) | 2497 | uint64_t calls[3][3] = {}; // method x (null, aggregate, a device) |
| 2498 | uint64_t found[3] = {}, pressed[3] = {}; | 2498 | uint64_t found[3] = {}, pressed[3] = {}, a_pressed[3] = {}; |
| 2499 | std::map<std::string, std::pair<uint64_t, uint64_t>> by_device; // name -> (readings, with buttons) | 2499 | std::map<std::string, std::pair<uint64_t, uint64_t>> by_device; // name -> (readings, with buttons) |
| 2500 | uint64_t since = 0; | 2500 | uint64_t since = 0; |
| 2501 | }; | 2501 | }; |
| 2502 | static Stats st; | 2502 | static Stats st; |
| 2503 | std::string name; | 2503 | std::string name; |
| 2504 | bool buttons = false; | 2504 | bool buttons = false, a_button = false; |
| 2505 | if (SUCCEEDED(hr) && got) { | 2505 | if (SUCCEEDED(hr) && got) { |
| 2506 | IGameInputDevice* d = nullptr; | 2506 | IGameInputDevice* d = nullptr; |
| 2507 | got->GetDevice(&d); | 2507 | got->GetDevice(&d); |
| @@ -2510,7 +2510,10 @@ public: | |||
| 2510 | d->Release(); | 2510 | d->Release(); |
| 2511 | } | 2511 | } |
| 2512 | GameInputGamepadState g{}; | 2512 | GameInputGamepadState g{}; |
| 2513 | if (got->GetGamepadState(&g)) buttons = g.buttons != 0; | 2513 | if (got->GetGamepadState(&g)) { |
| 2514 | buttons = g.buttons != 0; | ||
| 2515 | a_button = (g.buttons & GameInputGamepadA) != 0; | ||
| 2516 | } | ||
| 2514 | } | 2517 | } |
| 2515 | const int arg = !asked ? 0 : as_device(asked)->info.deviceFamily == GameInputFamilyAggregate ? 1 : 2; | 2518 | const int arg = !asked ? 0 : as_device(asked)->info.deviceFamily == GameInputFamilyAggregate ? 1 : 2; |
| 2516 | std::lock_guard lock(st.mu); | 2519 | std::lock_guard lock(st.mu); |
| @@ -2518,6 +2521,7 @@ public: | |||
| 2518 | if (SUCCEEDED(hr) && got) { | 2521 | if (SUCCEEDED(hr) && got) { |
| 2519 | ++st.found[method]; | 2522 | ++st.found[method]; |
| 2520 | st.pressed[method] += buttons; | 2523 | st.pressed[method] += buttons; |
| 2524 | st.a_pressed[method] += a_button; | ||
| 2521 | auto& e = st.by_device[name]; | 2525 | auto& e = st.by_device[name]; |
| 2522 | ++e.first; | 2526 | ++e.first; |
| 2523 | e.second += buttons; | 2527 | e.second += buttons; |
| @@ -2529,10 +2533,10 @@ public: | |||
| 2529 | std::string line; | 2533 | std::string line; |
| 2530 | for (int m = 0; m < 3; ++m) { | 2534 | for (int m = 0; m < 3; ++m) { |
| 2531 | char t[200]; | 2535 | char t[200]; |
| 2532 | std::snprintf(t, sizeof(t), " %s %llu/%llu/%llu found %llu pressed %llu;", methods[m], | 2536 | std::snprintf(t, sizeof(t), " %s %llu/%llu/%llu found %llu pressed %llu A %llu;", methods[m], |
| 2533 | (unsigned long long)st.calls[m][0], (unsigned long long)st.calls[m][1], | 2537 | (unsigned long long)st.calls[m][0], (unsigned long long)st.calls[m][1], |
| 2534 | (unsigned long long)st.calls[m][2], (unsigned long long)st.found[m], | 2538 | (unsigned long long)st.calls[m][2], (unsigned long long)st.found[m], |
| 2535 | (unsigned long long)st.pressed[m]); | 2539 | (unsigned long long)st.pressed[m], (unsigned long long)st.a_pressed[m]); |
| 2536 | line += t; | 2540 | line += t; |
| 2537 | } | 2541 | } |
| 2538 | for (const auto& [n, c] : st.by_device) { | 2542 | for (const auto& [n, c] : st.by_device) { |
| @@ -2545,6 +2549,7 @@ public: | |||
| 2545 | std::memset(st.calls, 0, sizeof(st.calls)); | 2549 | std::memset(st.calls, 0, sizeof(st.calls)); |
| 2546 | std::memset(st.found, 0, sizeof(st.found)); | 2550 | std::memset(st.found, 0, sizeof(st.found)); |
| 2547 | std::memset(st.pressed, 0, sizeof(st.pressed)); | 2551 | std::memset(st.pressed, 0, sizeof(st.pressed)); |
| 2552 | std::memset(st.a_pressed, 0, sizeof(st.a_pressed)); | ||
| 2548 | st.by_device.clear(); | 2553 | st.by_device.clear(); |
| 2549 | st.since = now; | 2554 | st.since = now; |
| 2550 | } | 2555 | } |