upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/test/gameinput_test.cpp
diff options
context:
space:
mode:
authorDadaCap <167002618+DadaCap@users.noreply.github.com>2026-11-24 16:10:21 +0100
committerQemmHD <290605352+QemmHD@users.noreply.github.com>2026-11-24 21:45:32 -0500
commit0e5e33bc497dee9b01963576aecc3cc49bf28a13 (patch)
tree7bbfb1f9b79bc2700632a8c72602f41eced2342c /runtime/test/gameinput_test.cpp
parent2213d5cb8f68a874e9f885eaf799b6f7fb7192a1 (diff)
gameinput: report a missed press once to a slow reader (RT-GAMEINPUT-SLOW-READER)
A title that reads a pad with GetCurrentReading once a frame, at a few frames a second, never sees a press that came and went between two reads. A pad now keeps the newest reading that pressed a button the last read did not report; a read more than kSlowReaderUs (50 ms) after the previous one answers that press once, and the next read the pad's real state. Carried from DadaCap's boot-prototype fa497b930, split to the GameInput part (runtime/shims/gameinput.cpp and its test in runtime/test/gameinput_test.cpp); the other shims in that commit are not included. Applied unchanged. AI-assisted. Run on Windows 11, RTX 5080. No game data. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SR1Fv7eQNgZjM6miWPKjHf
Diffstat (limited to 'runtime/test/gameinput_test.cpp')
-rw-r--r--runtime/test/gameinput_test.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/runtime/test/gameinput_test.cpp b/runtime/test/gameinput_test.cpp
index b6658f51c..bb63e2df9 100644
--- a/runtime/test/gameinput_test.cpp
+++ b/runtime/test/gameinput_test.cpp
@@ -2229,6 +2229,22 @@ int main(int argc, char** argv) {
2229 release_all(seen); 2229 release_all(seen);
2230 if (pair_ref) pair_ref->Release(); 2230 if (pair_ref) pair_ref->Release();
2231 2231
2232 // A slow reader: a press that came and went between two reads of a pad is answered once, then the real state.
2233 if (IGameInputReading* r = current(input, dev)) r->Release();
2234 Sleep(80);
2235 SDL_SetJoystickVirtualButton(xbox2.js, SDL_GAMEPAD_BUTTON_WEST, true);
2236 rt::gameinput::poll();
2237 SDL_SetJoystickVirtualButton(xbox2.js, SDL_GAMEPAD_BUTTON_WEST, false);
2238 rt::gameinput::poll();
2239 {
2240 IGameInputReading* first = current(input, dev);
2241 IGameInputReading* second = current(input, dev);
2242 check(first && second && (buttons_of(first) & GameInputGamepadX) && !(buttons_of(second) & GameInputGamepadX),
2243 "a slow reader sees a missed press once");
2244 if (first) first->Release();
2245 if (second) second->Release();
2246 }
2247
2232 // Ageing: a reading leaves the history once the reading after it is more than half a second old. 2248 // Ageing: a reading leaves the history once the reading after it is more than half a second old.
2233 IGameInputReading* aged = current(input, dev); 2249 IGameInputReading* aged = current(input, dev);
2234 SDL_SetJoystickVirtualButton(xbox2.js, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, true); 2250 SDL_SetJoystickVirtualButton(xbox2.js, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, true);