Repository navigation
feat(ime): show host IME composition in the dialog and paste the clipboard - #12596
Conversation
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
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.
|
|
@MarcZX10 I have a separate local IME inventory change declaring two unidentified NIDs, AI-assisted: yes. |
…for host text The host keyboard path decodes SDL text with a strict decoder that throws, which suits the 32-byte text events but not text that comes from outside the window. Add header-only helpers that decode without throwing (invalid bytes become U+FFFD, an incomplete tail can be dropped for text cut at a fixed size), strip control characters, normalise line breaks and bound a clipboard to 64 KiB on a code point boundary.
Check valid and invalid UTF-8, the incomplete tail of a cut preedit, control and line-break handling for single-line and multi-line fields, and that a huge clipboard is bounded without splitting a code point or a surrogate pair.
Add the two kinds and the start and length a composition event carries to ImeHostInput. Both session and dialog consumers accept them and do nothing yet, so typed input is unchanged.
A composition (preedit) is text the input method still owns. Keep it apart from committed text: it records the cursor and selection as UTF-16 offsets converted from the character counts SDL reports, and a routing function decides what the dialog does with each host input while one is shown. A commit ends it; Enter and Escape discard it instead of accepting or cancelling the dialog; editing keys and paste are left to the input method until it ends.
A sceImeOpen session has no panel to show a composition in, so the preedit is only tracked: it never enters the text, the input and work buffers, the text filter or the events the title receives. While one is active Enter and Escape discard it instead of sending press-enter or press-close, and the editing keys are left to the input method. A commit (SDL text input) ends it and is inserted as usual.
Edit, edit, commit, discard with Escape and Enter, edit keys left to the input method, a close that drops the composition, and a malformed or cut preedit. A preedit never reaches the text, the buffers, the filter or the events.
Add ImePublishPaste, which turns a clipboard into UTF-16 (invalid bytes replaced, controls stripped, line breaks kept only for a multi-line session, bounded to 64 KiB) and queues it as one input. It is inserted at the caret like typed text: one text filter call, one text update event, the session's maximum length, and a cut that never splits a surrogate pair. It is ignored while no session or dialog captures the keyboard.
Insert at the caret as one update, single-line and multi-line breaks, control characters, the maximum length and surrogate pair boundaries, the text filter running once, a clipboard of megabytes, invalid UTF-8, a paste while nothing captures the keyboard and a paste while the input method holds a composition.
A dialog has no sceImeOpen session to queue into, so it needs the composition delivered the way it gets typed text: through a registered sink. The sink receives the decoded preedit and the cursor and selection SDL reported, and is only called while no session is open.
Add the preedit text with its cursor and selection (UTF-16 offsets into the preedit) to ImeKeyboardView. Empty means no composition, which leaves the view as it was.
The dialog registers a preedit sink and keeps the composition in its own state, shown through the keyboard view and never inserted into the text or the buffer the title reads. A commit ends it; Enter and Escape discard it instead of accepting or cancelling; editing keys wait for the input method. Finishing or closing the dialog drops it.
A paste is inserted like typed text: the dialog's maximum length applies and a cut never splits a surrogate pair, and line breaks are dropped as they are for typed text.
Edit, edit, commit, then discard with Enter and Escape; editing keys waiting for the input method; cursor and selection offsets counted in characters and clamped; a composition dropped when the dialog finishes, closes or is force-closed; malformed and cut preedits. The title's buffer only ever holds the accepted committed text.
Insert at the caret, line breaks and controls, the maximum length and surrogate pair boundaries, a clipboard of megabytes, invalid UTF-8, a paste while no dialog captures the keyboard and while a composition is shown.
Draw the composition at the caret between the committed text before and after it, underlined, with the selected segment underlined twice and in the text colour. The caret bar sits at the composition's cursor, and the field scrolls to keep it visible. Characters the overlay font does not have, which includes CJK, still draw as its replacement box. A view with no composition lays out exactly as before.
An empty composition leaves the layout unchanged; a composition is laid out between the text around the caret with one underline per character, the selected segment marked, a surrogate pair counted once, characters the font lacks drawn as the replacement box, the caret kept in view in a long field, and offsets past the composition rejected.
SDL reports the text an input method is still composing as SDL_TEXTEDITING with the cursor and selection in characters. Forward it to the IME as a Preedit input, from the game window only. SDL starts text input when video starts, so the events already arrive while an IME is active.
While an IME dialog or session captures the keyboard, Ctrl+V (Command+V on macOS, Ctrl+Shift+V too) and Shift+Insert read the clipboard through a provider the window installs and hand it to the IME as one paste. Key repeat, Alt combinations and any press while nothing captures the keyboard do nothing, and the clipboard is not read in those cases. With no provider installed nothing is pasted.
Install the SDL clipboard as the provider of the window's IME text input on the main thread.
…e IME Drive ImeTextInput with injected SDL events and an injected clipboard provider, no window and no real input method: text editing events become the shown preedit and a commit ends it; Ctrl+V, Shift+Insert and Ctrl+Shift+V paste while a dialog or session captures the keyboard; repeats, Alt, other modifiers, key releases, other windows and Ctrl+C, Ctrl+X read nothing; nothing reads the clipboard while no dialog captures the keyboard or no provider is installed; a clipboard of megabytes stops at the dialog limit.
8b459f3 to
9bb324e
Compare
✅ NVIDIA GPU test: passedPR head
Unstable on main (3, these also failed in recent main runs on this machine; not counted against this PR)Failing on main too (3, not counted against this PR)Validation IDs already present on main (5 IDs in 715 tests)Skipped (51)ReproduceAutomated build and test on a contributor's NVIDIA machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs. |
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — landing order is your call, two NIDs overlap with kyon-eth follow-up
kyon-eth asks whether #12596 can land first; this head already declares the two NIDs that kyon-eth says their follow-up declares, so the overlap is in the code, not only in the debt file.
What I ran
Live head: 9bb324e (OPEN, same as the batch file). Read the comments and reviews with gh api (repos/boykopovar/AnyPS5/issues|pulls/12596/...). Read files with git -C /marc/AnyPS5 show 9bb324e6…:<path> and git grep for the two NIDs. Read mergeability and the hosted check rollup with gh pr view. Nothing was built or run.
Results
| Check | Result | Note |
|---|---|---|
| mergeability | MERGEABLE, CLEAN | GitHub's view at this head |
| conventions | SUCCESS (rerun) | an earlier run was CANCELLED; the later run is SUCCESS, its head was not checked |
| windows, library-portability | SUCCESS | hosted |
| NVIDIA GPU test (TechLevelZero comment, 2026-11-01 12:00 UTC) | passed | 3,027 passed, 6 failed, 0 new |
Findings
- kyon-eth, 2026-10-30 16:03 UTC: asks if you agree to land #12596 first, with their follow-up reconciled afterwards. Their local branch is not visible to me, so I cannot verify their merge preview or the debt-file conflict. What I can verify: this head already declares
NbbzN9GRg+candaChMGUoc7QIas stubs (core/libs/prx/libSceIme/Export.cpp L897-L905) and lists both as Unknown in docs/dev/debt/libSceIme.md L5-L10. Their follow-up declares the same two NIDs, so the overlap is real. The order is your decision; the code does not settle it. - The NVIDIA result is a pass with 0 new failures, so it does not block the order question.
Sources
AnyPS5/core/libs/prx/libSceIme/Export.cpp
Lines 897 to 905 in 9bb324e
AnyPS5/docs/dev/debt/libSceIme.md
Lines 5 to 10 in 9bb324e
Not verified
- kyon-eth's local inventory and their merge preview: not visible here.
- Which conventions run belongs to this head: I took the later SUCCESS run on trust from the rollup and did not read its headSha.
- The NVIDIA numbers are as posted by the CI comment; not re-run.
What
Two host-side additions to the real-keyboard IME (the PC keyboard replaces the PS5 on-screen keyboard). The title sees ordinary text updates exactly as for typed characters; nothing here is console behaviour.
Gap on
upstream/main: nothing usedSDL_TEXTEDITINGor the clipboard (grep SDL_TEXTEDITING SDL_GetClipboardText SDL_SetTextInputRect SDL_StartTextInputfinds only theSDL_TEXTINPUTforwarder). SDL starts text input when video starts (SDL_video.c), so a commit from an input method already arrived as text, but the composition was invisible, and Ctrl+V did nothing.SDL_TEXTEDITINGImeTextInputforwards it as a newPreeditinput (text, start, length), from the game window only.ImeCompositionkeeps the composition apart from committed text. A commit (SDL_TEXTINPUT) ends it; Enter and Escape discard it instead of accepting or cancelling; editing keys and paste are left to the input method while one is active.sceImeDialogInit: shown in the overlay field at the caret, underlined, selected segment underlined twice, caret at the composition cursor. Never in the buffer the title reads before accept.sceImeOpen: no panel exists, so the composition is only tracked; it never reaches the text, the buffers, the text filter or the events.ImeTextInput::SetClipboardProvider); the window installs the SDL clipboard. The text is converted to UTF-16 (invalid bytes become U+FFFD), controls stripped, line breaks dropped (LF kept for a multi-linesceImeOpensession), bounded to 64 KiB, then inserted through the same path as typed text: max length, one text filter call, one update event, a cut that never splits a surrogate pair.Not done, on purpose: copy and cut (no selection model exists);
SDL_SetTextInputRect(SDL's own candidate UI is off by default and the overlay is the UI, so placing the system window needs a layout-to-window mapping that cannot be tested headless);SDL_StopTextInputoutside dialogs (would change today's behaviour); a clipboard opt-out variable (the clipboard is read only on an explicit key press inside a dialog, so I left it out; one could be added if wanted). Password and panel type are not modelled by the host today, so there is nothing to mask or filter beyond the title's own text filter. The overlay font has no CJK glyphs, so CJK shows as the replacement box (debt entry).Commits (25): helpers, then composition state, session wiring, paste, preedit sink, view fields, dialog wiring, overlay and SDL forwarding, each followed by its test commit, then four one-statement debt commits.
Overlap with open PRs: #12379 edits
KeyboardOverlay.hpp/.cpp,tests/KeyboardOverlay.cpp,VideoOutDriver.cppandlibSceIme/CMakeLists.txt; #12536 and #12569 touchVideoOutDriver.cpp. No code reused from any PR.Tested
Linux x86-64 (Xeon E5-1620 v2, patched CPU gate in the throwaway archive build), GCC 12,
run_tests.sh.319621ba2e, second tree) and after, same 8 existing tests, all pass in both:agc_keyboard_overlay,guest_ime_parameters,guest_ime_pad_route,guest_ime_keyboard,guest_ime_filter_text,guest_ime_open,ime_dialog_pad_keyboard,guest_ime_dialog.ime_host_text,ime_composition,guest_ime_composition,guest_ime_paste,guest_ime_dialog_composition,guest_ime_dialog_paste,guest_ime_text_input, plus the newcompositionTestsinsideagc_keyboard_overlay.libSceVideoOutandagc_performance_overlay_testscompile.ImeTextInput, 6 of the overlay layout, each failed the intended new test and was restored. Mutations that did not fail a test and are equivalent through the public interface: dialogFinishnot clearing the composition,ReleaseInputnot clearing the preedit sink (both guarded by the dialog status and reset by init), publishing an empty paste (dropped later), and aPastesurrogate guard shared with typed text (also caught byguest_ime_open).check_conventions.py --base upstream/main,git diff --check,test_public_headers.py --audit-onlyandenv_reference.py --checkclean. No environment variable added.libSceVideoOutand the keyboard overlay): configured with-DANYPS5_VIDEO_OUT_TEST_DRIVER=x11, run on the branch and on upstream/main319621ba2e(second tree) withANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation xvfb-run -a ctest -R '^(video_out_|agc_keyboard_overlay|agc_performance_overlay|guest_ime|ime_|guest_video_out)' -V. Device: llvmpipe (LLVM 15.0.6, 256 bits) under Xvfb, Vulkan API 1.3 (software, no hardware GPU).was not found but was requested by env var VK_INSTANCE_LAYERS: 0 occurrences on both.VUID-lines: 0 on main, 0 on the branch (no new validation errors).video_out_26/26 and 26/26;agc_keyboard_overlay1/1 and 1/1;agc_performance_overlay4/4 and 4/4;guest_ime6/6 and 11/11 (five new);ime_1/1 and 3/3 (two new);guest_video_out6/7 and 6/7 (guest_video_out_high_frame_rateskips with status 77 on both). Whole run: 45 tests on main, 52 on the branch, no failures on either.cc26ab44380db3cd7b53715b84f13945227ce28bat head9bb324e63a7e4aa9140f536115c205938ef1075f. The build, tests, GPU runs and mutation controls above were performed on pre-rebase head8b459f3d0853d368a042a0e378d018334a237b11against base319621ba2e578bd053b0baba2877fe70520e0737; they have not been rerun on the rebased head. The rebase retained newer main test registrations and dialog input initialization alongside this PR’s additions.NOT RUN: Windows, macOS (the
__APPLE__modifier branch is unbuilt), a real CJK input method on any platform, the real SDL clipboard (only an injected provider), a hardware GPU (llvmpipe only) or the overlay seen on screen (layout tested through rectangles and the llvmpipe runs above), a console, a title. Each commit was not built on its own; the final tree was. How each platform fillsstartandlengthofSDL_TEXTEDITINGis assumed (characters), recorded in debt.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)