feat(libSceConvertKeycode): implement sceConvertKeycodeGetCharacterFromKeyboardData #10437

Merged
InfinitySpeed merged 2 commits from upstream-pr/10437 into main 2026-10-29 10:19:03 +00:00
InfinitySpeed commented 2026-10-24 00:19:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by InfinitySpeed on 2026-10-24T00:19:40Z.


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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4990917199 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10437). Originally posted by [InfinitySpeed](https://github.com/InfinitySpeed) on 2026-10-24T00:19:40Z. --- ### 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 <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [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 - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-24 00:22:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T00:22:12Z.

Review: CHANGES_REQUESTED


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.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5635788600 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10437#pullrequestreview-5635788600). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T00:22:12Z. **Review:** CHANGES_REQUESTED --- 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.
MarcZX10 commented 2026-10-24 00:24:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T00:24:06Z.

Review: DISMISSED


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.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5635796357 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10437#pullrequestreview-5635796357). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T00:24:06Z. **Review:** DISMISSED --- 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.
adriadam10 commented 2026-10-26 17:17:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-26T17:17:14Z.

Review: CHANGES_REQUESTED


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.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5656132432 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10437#pullrequestreview-5656132432). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-26T17:17:14Z. **Review:** CHANGES_REQUESTED --- 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.
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!10437
No description provided.