Sync keyboard text buffer from Flash before processing physical input

The native keyboard scene maintained a separate C++ buffer
(m_win64TextBuffer) for physical keyboard input, which was pushed
to the Flash text field via setLabel(). However, when the user typed
with the on-screen controller buttons, Flash updated its text field
directly through ActionScript without updating the C++ buffer.

This caused a desync: switching back to the physical keyboard would
overwrite any text entered via controller, since m_win64TextBuffer
still held the old value before the controller edits.

Fix: read the current Flash text field into m_win64TextBuffer at the
start of each tick(), before consuming new physical keyboard chars.
This ensures both input methods always operate on the same state.
This commit is contained in:
MrTheShy 2026-03-05 21:17:36 +01:00
parent aadb511504
commit 9ec08e0af8

View file

@ -163,6 +163,12 @@ void UIScene_Keyboard::tick()
{
UIScene::tick();
// Sync our buffer from Flash so we pick up changes made via controller/on-screen buttons.
// Without this, switching between controller and keyboard would use stale text.
const wchar_t* flashText = m_KeyboardTextInput.getLabel();
if (flashText)
m_win64TextBuffer = flashText;
// Accumulate physical keyboard chars into our own buffer, then push to Flash via setLabel.
// This bypasses Iggy's focus system (char events only route to the focused element).
// The char buffer is cleared on open so Enter/clicks from the triggering action don't leak in.