diff --git a/src/duckstation-qt/displaywidget.cpp b/src/duckstation-qt/displaywidget.cpp index 15beea1a5..5ecf31ed2 100644 --- a/src/duckstation-qt/displaywidget.cpp +++ b/src/duckstation-qt/displaywidget.cpp @@ -497,12 +497,32 @@ bool AuxiliaryDisplayWidget::event(QEvent* event) case QEvent::KeyPress: case QEvent::KeyRelease: { + const QKeyEvent* key_event = static_cast(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(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(static_cast(event)->key())}); + Host::AuxiliaryRenderWindowEventParam{.uint_param = static_cast(key_event->key())}); return true; } diff --git a/src/util/imgui_manager.cpp b/src/util/imgui_manager.cpp index 2d8b196d8..0ab840685 100644 --- a/src/util/imgui_manager.cpp +++ b/src/util/imgui_manager.cpp @@ -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; diff --git a/src/util/imgui_manager.h b/src/util/imgui_manager.h index 785a5617f..5b61b5116 100644 --- a/src/util/imgui_manager.h +++ b/src/util/imgui_manager.h @@ -33,6 +33,7 @@ enum class AuxiliaryRenderWindowEvent : u8 Resized, KeyPressed, KeyReleased, + TextEntered, MouseMoved, MousePressed, MouseReleased,