Skip to content

feat(libSceConvertKeycode): implement sceConvertKeycodeGetCharacterFromKeyboardData - #10437

Merged
adriadam10 merged 2 commits into
boykopovar:mainfrom
InfinitySpeed:feat/libSceConvertKeycode-character
Oct 29, 2026
Merged

adriadam10 merged 2 commits into
boykopovar:mainfrom
InfinitySpeed:feat/libSceConvertKeycode-character

Conversation

@InfinitySpeed

@InfinitySpeed InfinitySpeed commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

What

Implement sceConvertKeycodeGetCharacterFromKeyboardData in libSceConvertKeycode:

  • Validate pointers keyData and character, returning kErrInvalidAddress if null.
  • Validate keyboardType range (1..39), returning kErrInvalidKeyboardType.
  • Validate index bounds against keyData->length and KEYBOARD_MAX_KEYCODES.
  • Extract keycode and convert character via ConvertCharacter(keycode, state, keyboardType).
  • Brings libSceConvertKeycode to 4/4 (100.0%) completion.
  • Extend GuestConvertKeycode test suite covering invalid pointers, out-of-bounds indices, invalid keyboard types, and character resolution.

Tested

  • GuestConvertKeycode test covers invalid address rejection, out-of-bounds index, keyboard layout validation, and successful UTF-16 character translation (both unshifted and shifted).
  • python tools/check_conventions.py --base origin/main passes.
  • python tools/progress.py --module libSceConvertKeycode reports 4/4 functions (100.0% complete).

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
  • 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
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation uses the existing ConvertCharacter path and bounds the array index by both KeyboardData::length and KEYBOARD_MAX_KEYCODES, which is the right shape for avoiding an out-of-bounds read. I found two items to resolve before this is ready:

  1. The required PR template is not filled in. The hosted conventions check fails on this exact head because What, Tested, and Checklist are missing. Please copy .github/pull_request_template.md into the body, preserve every line, and complete the required fields (including Depends on, Unblocks, GPUs tested, and AI-assisted).
  2. No regression test was added for the new export. Please exercise a normal conversion and the boundary cases introduced here (null keyData/output, negative index, index at/above length, and a length larger than the fixed 16-entry array). The existing sceConvertKeycodeGetCharacter behavior provides the conversion path, but does not test this entry point's data and index validation.

I checked the exact diff and the existing KeyboardData definition: length is signed and key_code has 16 entries, so both bounds are relevant. I did not find a public primary source establishing additional console-specific error semantics, and I am not claiming hardware verification. The hosted conventions failure is directly reproducible from the reported check log; product tests have not run for this change.

@InfinitySpeed
InfinitySpeed force-pushed the feat/libSceConvertKeycode-character branch from 2a6b9dd to 9870149 Compare October 24, 2026 00:22

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for completing the required PR template; the conventions check now passes on head 9870149ee560936b299da388e7453099c2f73d95.

The implementation change is otherwise unchanged, and I still do not see regression tests for the new export. The PR now reports “Tested on Windows 11 host” but does not identify a test command or test cases; the hosted checks shown for this head are conventions and labels only. Please add focused coverage for a normal conversion and the validation paths introduced here: null keyData, null output, negative index, index equal to length, index at the 16-entry array bound, and a declared length greater than 16. This makes the pointer/index behavior reviewable and checks that the shared ConvertCharacter helper receives the selected keycode.

I did not run a local product test: CMake configuration stops because SDL2 development package configuration is missing. The exact current diff and the existing signed-length/16-element KeyboardData definition were reviewed.

@InfinitySpeed
InfinitySpeed force-pushed the feat/libSceConvertKeycode-character branch 2 times, most recently from 2f4ae6c to 3b0bf99 Compare October 24, 2026 00:45
@InfinitySpeed

Copy link
Copy Markdown
Contributor Author

@MarcZX10 Focused regression tests added in GuestConvertKeycode.cpp exercising boundary validation (null keyData/output, negative index, index at/above length, index at 16-entry array bound) and character resolution.

@github-actions github-actions Bot added the prx label Oct 24, 2026
@amazedturnip

Copy link
Copy Markdown
Contributor

Built and verified on Linux (Ubuntu 24.04 on WSL2, GCC 13.3.0, AMD Ryzen 7 9800X3D):

  • Build: \libSceConvertKeycode.prx\ and \ ests/guest_convert_keycode_tests\ compiled cleanly.
  • Test execution: \guest_convert_keycode_tests\ passes 100%, validating null pointer rejection (\kErrInvalidAddress), keyboard type boundaries (0 and 40 return \kErrInvalidKeyboardType), index bounds checking against \keyData->length, and UTF-16 character translation (\u'a'\ and \u'A').
  • Conventions & Overlap: \python3 tools/check_conventions.py --base upstream/main\ passes with 0 errors, and \ ools/pr_overlap.py\ reports zero conflicting files with other open PRs.

Clean completion of the module exports. LGTM!

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 24, 2026
@adriadam10 adriadam10 self-assigned this Oct 26, 2026
@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Progress report (750cf6c → 0a07101)

📈 System libraries: 46.66% (+0.01%, +1 implemented functions)

✅ 1 implemented
Library Name
libSceConvertKeycode sceConvertKeycodeGetCharacterFromKeyboardData

Changed libraries (implemented exports)

Library Before After Change
libSceConvertKeycode 3/4 (75.00%) 4/4 (100.00%) +25.00 pp

@adriadam10 adriadam10 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the tests. Items before this can merge:

  • core/libs/prx/libSceConvertKeycode/Export.cpp:2442-2444: the result for an index outside keyData->length / KEYBOARD_MAX_KEYCODES is kErrInvalidAddress, but none of the references (shadPS4, fpPS4 only list the name; KytyPS5 and prosper don't implement it) give the real error code or validation order. Please cite where it comes from, or throw for that case and record it in docs/dev/debt/libSceConvertKeycode.md.
  • Export.cpp:2441: the new keyboardType >= 31 throw is not covered by the test, and the debt file only names GetVirtualKeycode and GetCharacter; add sceConvertKeycodeGetCharacterFromKeyboardData there.
  • The branch conflicts with main in core/libs/tests/GuestConvertKeycode.cpp (adjacent test additions); please rebase.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

@InfinitySpeed thanks. Two small things for sceConvertKeycodeGetCharacterFromKeyboardData:

  1. Please say where the signature and the two error codes (0x80BC0031, 0x80BC001D) come from (upstream source or measurement).
  2. The keyboardType >= 31 path throws "guest sdk version is unavailable" and has no test or stated source. Either cite why it must throw, or handle it as the console does.

@adriadam10
adriadam10 force-pushed the feat/libSceConvertKeycode-character branch from 9336d16 to 0a07101 Compare October 28, 2026 13:40
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 28, 2026
@adriadam10
adriadam10 dismissed MarcZX10’s stale review October 28, 2026 14:03

Dismissing a stale review: the requested changes were addressed after it (new head) and the merge queue blocks on it. Please request changes again if anything is still open.

@adriadam10
adriadam10 merged commit f48ef6a into boykopovar:main Oct 29, 2026
10 checks passed
@adriadam10

Copy link
Copy Markdown
Collaborator

Thanks for the PR. The changes points had no push in 24 h, so we added them on your branch:

  • Rebased onto main (conflict in GuestConvertKeycode.cpp; the declarations now live in Api.hpp).
  • An index outside keyData->length / KEYBOARD_MAX_KEYCODES now throws instead of returning kErrInvalidAddress: no reference gives that result, so it is recorded in docs/dev/debt/libSceConvertKeycode.md. Test covers indices -1, 1 and 16.
  • Added a test for the layouts 31 and 39 throw, and listed the function in the debt entry for layouts 31–39.
  • 0x80BC0031 / 0x80BC001D are the same invalid-address / invalid-keyboard-type codes the other exports in this file already return.

Merged.

BunnyFl added a commit to BunnyFl/AnyPS5 that referenced this pull request Oct 29, 2026
Resolves the debt-entry conflict with boykopovar#10437 and applies the same layout rules to sceConvertKeycodeGetCharacterFromKeyboardData.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tibzejoker

Copy link
Copy Markdown
Contributor

@adriadam10 heads-up: this merge (f48ef6a) brought three submodule pointers back to older revisions on main. They came with 0a07101649 ("docs(libSceConvertKeycode): fix debt entry punctuation"), whose diff touches 3rdparty/SPIRV-Headers, 3rdparty/SPIRV-Tools and 3rdparty/vorbis alongside the doc line. Most likely they were committed from a checkout whose submodules were not updated.

submodule before the merge (f48ef6a076^1) main now change that is undone
3rdparty/SPIRV-Tools 262bdab481 (v2025.5) 7f2d9ee926 (v2025.4) #11184 / 03bc1d1aa6
3rdparty/SPIRV-Headers b824a462d4 01e0577914 #11184 / 03bc1d1aa6
3rdparty/vorbis 86b05e981c aee69dec85 d21fb108e4 (stop shifting a negative bark bound)

Each "now" value is exactly the value from before the change it undoes (1db31b9c9e for the SPIR-V pins, a542a13f00 for vorbis). This is the same thing #11184 had to fix after #6134. It matters for #11265: OpFmaKHR needs the restored pins, and a rebase onto current main would silently take v2025.4.

The fix is to set the three pointers back to 262bdab481, b824a462d4 and 86b05e981c. I can open that as a build(deps) PR if you'd rather not do it in a merge commit.

AI-assisted: yes (Claude Code)

@tibzejoker

Copy link
Copy Markdown
Contributor

@adriadam10 opened as #13053 (the three gitlinks only). TechLevelZero's NVIDIA CI on #11265 shows the effect: CapabilityFMAKHR is missing from main's headers, so #11265 no longer builds on main.

AI-assisted: yes (Claude Code)

oneandonlydean pushed a commit that referenced this pull request Oct 30, 2026
f48ef6a (#10437) brought back the pointers from before 03bc1d1 and d21fb10.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V1W4jdNSKTV7xwuS6xQPJV
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants