diff --git a/src/duckstation-qt/qthostinterface.cpp b/src/duckstation-qt/qthostinterface.cpp index b638c7b90..ed7340bd2 100644 --- a/src/duckstation-qt/qthostinterface.cpp +++ b/src/duckstation-qt/qthostinterface.cpp @@ -268,13 +268,35 @@ void QtHostInterface::onDisplayWindowMouseMoveEvent(int x, int y) { // display might be null here if the event happened after shutdown DebugAssert(isOnWorkerThread()); - if (m_display) - m_display->SetMousePosition(x, y); + if (!m_display) + return; + + m_display->SetMousePosition(x, y); + + if (ImGui::GetCurrentContext()) + { + ImGuiIO& io = ImGui::GetIO(); + io.MousePos[0] = static_cast(x); + io.MousePos[1] = static_cast(y); + } } void QtHostInterface::onDisplayWindowMouseButtonEvent(int button, bool pressed) { DebugAssert(isOnWorkerThread()); + + if (ImGui::GetCurrentContext() && (button > 0 && button <= countof(ImGuiIO::MouseDown))) + { + ImGuiIO& io = ImGui::GetIO(); + io.MouseDown[button - 1] = pressed; + + if (io.WantCaptureMouse) + { + // don't consume input events if it's hitting the UI instead + return; + } + } + HandleHostMouseEvent(button, pressed); }