From 8d3299975ebf14772addef997489302d19136b3c Mon Sep 17 00:00:00 2001 From: Sylpheed RE agent Date: Wed, 19 Aug 2026 08:43:43 +0000 Subject: [PATCH] [RE] xam_input: test X_ERROR_SUCCESS exactly, not XSUCCEEDED X_ERROR_EMPTY is 0x10D2 and XSUCCEEDED is ((s & 0xC0000000) == 0), so an empty keystroke poll passes it. The first run of this instrumentation therefore logged every empty poll: 6499 lines of vk=0000 burying the two that mattered. The pre-existing assignment above shares the quirk - it writes user_index_ptr on an empty poll too. Left alone: it is upstream's and harmless, since the struct is zeroed first. The measurement itself survives, and is worth stating: at the title screen the game polls constantly and receives EXACTLY the two events sent - vk=5800 flags=0001 (KEYDOWN) and flags=0002 (KEYUP). Input delivery is not the problem. --- src/xenia/kernel/xam/xam_input.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/xenia/kernel/xam/xam_input.cc b/src/xenia/kernel/xam/xam_input.cc index 2034e35b1..c355b3a8e 100644 --- a/src/xenia/kernel/xam/xam_input.cc +++ b/src/xenia/kernel/xam/xam_input.cc @@ -254,6 +254,13 @@ dword_result_t XamInputGetKeystrokeEx_entry( if (XSUCCEEDED(result)) { *user_index_ptr = keystroke->user_index; + } + // Test the code EXACTLY, not with XSUCCEEDED. `X_ERROR_EMPTY` is `0x10D2` + // and XSUCCEEDED is `(s & 0xC0000000) == 0`, so an empty poll "succeeds" — + // logging on XSUCCEEDED buried two real keystrokes under 6 499 empties in + // the first run of this instrumentation. (The assignment above shares the + // quirk; it is upstream's and harmless, since the struct is zeroed.) + if (result == X_ERROR_SUCCESS) { // Rare by construction — one per physical press — so log every one. XELOGI( "[RE-INPUT] XamInputGetKeystrokeEx -> user={} vk={:04X} flags={:04X} "