[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.
This commit is contained in:
Sylpheed RE agent
2026-08-19 08:43:43 +00:00
parent f9170fd3fe
commit 8d3299975e

View File

@@ -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} "