fix(libSceConvertKeycode): ignore the state bit 0x4000000 RE Engine titles pass #5776

Merged
simonbronk merged 1 commit from upstream-pr/5776 into main 2026-10-15 16:50:02 +00:00
simonbronk commented 2026-10-14 10:06:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by simonbronk on 2026-10-14T10:06:04Z.


What

PRAGMATA (PPSA02530, #5726) and Onimusha: Way of the Sword (PPSA27836, #5769) stop at boot with:

what():  sceConvertKeycodeGetCharacter: unsupported state 67108864

In Onimusha the caller (ELF address 0x16e2b70, app.exe+0x16f2b70 when relinked with --windows-fixed-base 0x400000000) is a loop over keycodes 0 to 0x8F that builds a table of key names. The second argument is the constant 0x4000000, not a value read from the keyboard:

mov    edx,DWORD PTR [rbp-0x44]   ; type from sceConvertKeycodeGetImeKeyboardType
movzx  edi,r15w                   ; keycode, the loop counter
mov    esi,0x4000000
mov    rcx,r12                    ; zeroed 6-byte buffer
call   sceConvertKeycodeGetCharacter
test   eax,eax
jne    next_keycode
cmp    WORD PTR [rbp-0x38],0x0
je     next_keycode

It then upper-cases a to z itself before mapping the character to its own key id, so it expects the unshifted character. The bit is now ignored and the call returns the US-layout character as for state 0. Any other bit still throws. The meaning of the bit is still unknown; the debt entry says so and records the evidence.

Tested

  • Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release, on main 0b97f8b9f: full ctest -j 8, 1142/1142 pass.
  • guest_convert_keycode gains sceConvertKeycodeGetCharacter checks with state 0 and 0x4000000 (a, 1, and 0 for F1). With main's Export.cpp it fails; with the change it passes.
  • PPSA27836 01.000.001 on Windows (RTX 5070), with #5770, #5771 and #5188: APS5_TRACE_CALLS=libSceConvertKeycode shows 113 sceConvertKeycodeGetCharacter calls and no stop; the title goes on to shader preparation and stops at the per-lane T# described in #5769.
  • PRAGMATA not run here; the reporter's message in #5726 is the same.
  • python tools/check_conventions.py --base upstream/main: passes.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file — not applicable, no stub
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source — not applicable
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: PPSA27836 #5769 (stop 4), PPSA02530 #5726 (same stop; no Game bring-up discussion found for it)
  • GPUs tested: n/a (no AGC, shader recompiler or VideoOut change)
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4856234815 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5776). Originally posted by [simonbronk](https://github.com/simonbronk) on 2026-10-14T10:06:04Z. --- ### What PRAGMATA (PPSA02530, #5726) and Onimusha: Way of the Sword (PPSA27836, #5769) stop at boot with: ``` what(): sceConvertKeycodeGetCharacter: unsupported state 67108864 ``` In Onimusha the caller (ELF address `0x16e2b70`, `app.exe+0x16f2b70` when relinked with `--windows-fixed-base 0x400000000`) is a loop over keycodes 0 to 0x8F that builds a table of key names. The second argument is the constant `0x4000000`, not a value read from the keyboard: ``` mov edx,DWORD PTR [rbp-0x44] ; type from sceConvertKeycodeGetImeKeyboardType movzx edi,r15w ; keycode, the loop counter mov esi,0x4000000 mov rcx,r12 ; zeroed 6-byte buffer call sceConvertKeycodeGetCharacter test eax,eax jne next_keycode cmp WORD PTR [rbp-0x38],0x0 je next_keycode ``` It then upper-cases `a` to `z` itself before mapping the character to its own key id, so it expects the unshifted character. The bit is now ignored and the call returns the US-layout character as for state 0. Any other bit still throws. The meaning of the bit is still unknown; the debt entry says so and records the evidence. ### Tested - Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release, on `main` 0b97f8b9f: full `ctest -j 8`, 1142/1142 pass. - `guest_convert_keycode` gains `sceConvertKeycodeGetCharacter` checks with state 0 and `0x4000000` (`a`, `1`, and 0 for F1). With `main`'s `Export.cpp` it fails; with the change it passes. - PPSA27836 01.000.001 on Windows (RTX 5070), with #5770, #5771 and #5188: `APS5_TRACE_CALLS=libSceConvertKeycode` shows 113 `sceConvertKeycodeGetCharacter` calls and no stop; the title goes on to shader preparation and stops at the per-lane T# described in #5769. - PRAGMATA not run here; the reporter's message in #5726 is the same. - `python tools/check_conventions.py --base upstream/main`: passes. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's technical debt file — not applicable, no stub - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source — not applicable - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: PPSA27836 #5769 (stop 4), PPSA02530 #5726 (same stop; no Game bring-up discussion found for it) - [x] GPUs tested: n/a (no AGC, shader recompiler or VideoOut change) - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
xXPBSXx commented 2026-10-14 10:48:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-14T10:48:34Z.


Tested on head 378ac6178 (the current head of this pull request on GitHub, same SHA).

PPSA02530 (PRAGMATA v01.200.000) gets past sceConvertKeycodeGetCharacter with this pull request.

  • Without it (main 0b97f8b9f): the run ends at what(): sceConvertKeycodeGetCharacter: unsupported state 67108864 (PPSA02530_rQ2/run_113916.err line 111 of 607; 67108864 = 0x4000000, the value the title passes as state).
  • With it (main 3e577edac + 378ac6178, merge 57789cc4d, clean merge): that message does not appear any more (0 lines with ConvertKeycode in the 824 lines of PPSA02530_rZ5/run_123537.err). The title goes on and ends at line 219 with what(): shader 0x2234455200 stage 5: ShaderRecompiler::Recompile: GetImageResource dword 0 is not a valid runtime value; chain: ReadConstBuffer@pc=0x00000568(... (a GPU/shader-recompiler stop, not related to this pull request).

Test conditions

  • Windows 10 (19045), MinGW-w64 GCC 15.2.0, Release. Tree main 3e577edac + this head (merge 57789cc4d).
  • ninja -C build -j4 relinker plus all 126 core/libs/libs/*.prx of that tree, finished 12:34:11 local time (libSceAgcDriver.prx 12:34:10, libkernel.prx 11:54:00 - ninja found it up to date); relinker.exe 2026-10-14 12:34:03.
  • Relink: relink_title_trace.ps1 -Id PPSA02530 -ElfDir <eboot.bin and sce_module of the title> -Repo <that tree> = relinker.exe --windows --registry --trace-imports; no -ModuleDir, no --windows-fixed-base. Run: run_title.ps1 -Seconds 90, APS5_TRACE_CALLS=all, start 12:35:36.

Limits

One title, one run per tree. I did not check what the title does with the characters it gets, and I did not run this pull request's own tests.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6166636183 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5776#issuecomment-6166636183). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-14T10:48:34Z. --- Tested on head `378ac6178` (the current head of this pull request on GitHub, same SHA). PPSA02530 (PRAGMATA v01.200.000) gets past `sceConvertKeycodeGetCharacter` with this pull request. - Without it (`main` `0b97f8b9f`): the run ends at `what(): sceConvertKeycodeGetCharacter: unsupported state 67108864` (`PPSA02530_rQ2/run_113916.err` line 111 of 607; 67108864 = `0x4000000`, the value the title passes as `state`). - With it (`main` `3e577edac` + `378ac6178`, merge `57789cc4d`, clean merge): that message does not appear any more (0 lines with `ConvertKeycode` in the 824 lines of `PPSA02530_rZ5/run_123537.err`). The title goes on and ends at line 219 with `what(): shader 0x2234455200 stage 5: ShaderRecompiler::Recompile: GetImageResource dword 0 is not a valid runtime value; chain: ReadConstBuffer@pc=0x00000568(...` (a GPU/shader-recompiler stop, not related to this pull request). ### Test conditions - Windows 10 (19045), MinGW-w64 GCC 15.2.0, Release. Tree `main` `3e577edac` + this head (merge `57789cc4d`). - `ninja -C build -j4 relinker` plus all 126 `core/libs/libs/*.prx` of that tree, finished 12:34:11 local time (`libSceAgcDriver.prx` 12:34:10, `libkernel.prx` 11:54:00 - ninja found it up to date); `relinker.exe` 2026-10-14 12:34:03. - Relink: `relink_title_trace.ps1 -Id PPSA02530 -ElfDir <eboot.bin and sce_module of the title> -Repo <that tree>` = `relinker.exe --windows --registry --trace-imports`; no `-ModuleDir`, no `--windows-fixed-base`. Run: `run_title.ps1 -Seconds 90`, `APS5_TRACE_CALLS=all`, start 12:35:36. ### Limits One title, one run per tree. I did not check what the title does with the characters it gets, and I did not run this pull request's own tests. AI-assisted (Claude Code).
github-actions[bot] commented 2026-10-15 12:09:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:09:31Z.


Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 6044 core/libs/tests/GuestConvertKeycode.cpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6191702373 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5776#issuecomment-6191702373). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-15T12:09:31Z. --- <!-- pr-overlap --> Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/tests/GuestConvertKeycode.cpp` |
adriadam10 commented 2026-10-15 12:50:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-15T12:50:23Z.


Checked the diff, the debt entry and the new guest_convert_keycode rows (state 0 and 0x4000000); the test fails without the Export.cpp change, and build + ctest pass on main merged with this PR. PPSA02530 confirmed past this export by @xXPBSXx. Merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6192467896 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5776#issuecomment-6192467896). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-15T12:50:23Z. --- Checked the diff, the debt entry and the new `guest_convert_keycode` rows (state 0 and `0x4000000`); the test fails without the `Export.cpp` change, and build + ctest pass on main merged with this PR. PPSA02530 confirmed past this export by @xXPBSXx. Merging.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!5776
No description provided.