Qt: Forward text input to aux render windows

Fixes text input in freecam window.
This commit is contained in:
Stenzek 2025-01-01 21:37:45 +10:00
parent dcd439e7d8
commit 1d63648d68
No known key found for this signature in database
3 changed files with 29 additions and 2 deletions

View File

@ -497,12 +497,32 @@ bool AuxiliaryDisplayWidget::event(QEvent* event)
case QEvent::KeyPress:
case QEvent::KeyRelease:
{
const QKeyEvent* key_event = static_cast<const QKeyEvent*>(event);
if (type == QEvent::KeyPress)
{
// note this won't work for emojis.. deal with that if it's ever needed
for (const QChar& ch : key_event->text())
{
// Don't forward backspace characters. We send the backspace as a normal key event,
// so if we send the character too, it double-deletes.
if (ch == QChar('\b'))
break;
g_emu_thread->queueAuxiliaryRenderWindowInputEvent(
m_userdata, Host::AuxiliaryRenderWindowEvent::TextEntered,
Host::AuxiliaryRenderWindowEventParam{.uint_param = static_cast<u32>(ch.unicode())});
}
}
if (key_event->isAutoRepeat())
return true;
g_emu_thread->queueAuxiliaryRenderWindowInputEvent(
m_userdata,
(type == QEvent::KeyPress) ? Host::AuxiliaryRenderWindowEvent::KeyPressed :
Host::AuxiliaryRenderWindowEvent::KeyReleased,
Host::AuxiliaryRenderWindowEventParam{.uint_param =
static_cast<u32>(static_cast<const QKeyEvent*>(event)->key())});
Host::AuxiliaryRenderWindowEventParam{.uint_param = static_cast<u32>(key_event->key())});
return true;
}

View File

@ -1534,6 +1534,12 @@ void ImGuiManager::ProcessAuxiliaryRenderWindowInputEvent(Host::AuxiliaryRenderW
}
break;
case Host::AuxiliaryRenderWindowEvent::TextEntered:
{
io.AddInputCharacter(param1.uint_param);
}
break;
case Host::AuxiliaryRenderWindowEvent::MouseMoved:
{
io.MousePos.x = param1.float_param;

View File

@ -33,6 +33,7 @@ enum class AuxiliaryRenderWindowEvent : u8
Resized,
KeyPressed,
KeyReleased,
TextEntered,
MouseMoved,
MousePressed,
MouseReleased,