Make Viewport input events fully Qt based (#2142)
* Make Viewport input events fully Qt based. This should fix an issue with Qt touch event -> mouse event translation in the Editor, and may also fix issues with the Mac Editor and remote desktop (though, lacking the requisite hardware, I can test precisely none of these things personally). See https://github.com/o3de/o3de/issues/1889 - Adapted LegacyViewportCameraController to use Movement::X & Y (mostly for testing purposes, it's on the slate for being removed soon) - Moved cursor capture logic from RenderViewportWidget into QtEventToAzInputManager so that it can make sure it generates correct movement deltas - Removed ViewportMouseCursorRequests::PreviousViewportCursorScreenPosition to have our viewport controllers use our dedicated Movement::X and Y channels instead, which will work in the launcher Signed-off-by: nvsickle <nvsickle@amazon.com> * Address review feedback Signed-off-by: nvsickle <nvsickle@amazon.com> * Fix Linux build Signed-off-by: nvsickle <nvsickle@amazon.com>
This commit is contained in:
committed by
GitHub
parent
11327b59ea
commit
867ae23664
-3
@@ -109,7 +109,6 @@ namespace AtomToolsFramework
|
||||
void BeginCursorCapture() override;
|
||||
void EndCursorCapture() override;
|
||||
AzFramework::ScreenPoint ViewportCursorScreenPosition() override;
|
||||
AZStd::optional<AzFramework::ScreenPoint> PreviousViewportCursorScreenPosition() override;
|
||||
bool IsMouseOver() const override;
|
||||
|
||||
// AzFramework::WindowRequestBus::Handler ...
|
||||
@@ -160,8 +159,6 @@ namespace AtomToolsFramework
|
||||
AZ::ScriptTimePoint m_time;
|
||||
// Whether the Viewport is currently hiding and capturing the cursor position.
|
||||
bool m_capturingCursor = false;
|
||||
// The last known position of the mouse cursor, if one is available.
|
||||
AZStd::optional<QPoint> m_lastCursorPosition;
|
||||
// The viewport settings (e.g. grid snapping, grid size) for this viewport.
|
||||
const AzToolsFramework::ViewportInteraction::ViewportSettings* m_viewportSettings = nullptr;
|
||||
// Maps our internal Qt events into AzFramework InputChannels for our ViewportControllerList.
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
#include <AzCore/Math/MathUtils.h>
|
||||
#include <Atom/RHI/RHISystemInterface.h>
|
||||
#include <Atom/Bootstrap/BootstrapRequestBus.h>
|
||||
#include <AzQtComponents/Utilities/QtWindowUtilities.h>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QCursor>
|
||||
@@ -234,18 +233,6 @@ namespace AtomToolsFramework
|
||||
void RenderViewportWidget::mouseMoveEvent(QMouseEvent* event)
|
||||
{
|
||||
m_mousePosition = event->localPos();
|
||||
|
||||
if (m_capturingCursor && m_lastCursorPosition.has_value())
|
||||
{
|
||||
AzQtComponents::SetCursorPos(m_lastCursorPosition.value());
|
||||
// Even though we just set the cursor position, there are edge cases such as remote desktop that will leave
|
||||
// the cursor position unchanged. For safety, we re-cache our last cursor position for delta generation.
|
||||
m_lastCursorPosition = QCursor::pos();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_lastCursorPosition = event->globalPos();
|
||||
}
|
||||
}
|
||||
|
||||
void RenderViewportWidget::SendWindowResizeEvent()
|
||||
@@ -420,13 +407,6 @@ namespace AtomToolsFramework
|
||||
return AzToolsFramework::ViewportInteraction::ScreenPointFromQPoint(m_mousePosition.toPoint());
|
||||
}
|
||||
|
||||
AZStd::optional<AzFramework::ScreenPoint> RenderViewportWidget::PreviousViewportCursorScreenPosition()
|
||||
{
|
||||
using AzToolsFramework::ViewportInteraction::ScreenPointFromQPoint;
|
||||
return m_lastCursorPosition.has_value() ? ScreenPointFromQPoint(mapFromGlobal(m_lastCursorPosition.value()))
|
||||
: AZStd::optional<AzFramework::ScreenPoint>{};
|
||||
}
|
||||
|
||||
bool RenderViewportWidget::IsMouseOver() const
|
||||
{
|
||||
return m_mouseOver;
|
||||
@@ -434,24 +414,12 @@ namespace AtomToolsFramework
|
||||
|
||||
void RenderViewportWidget::BeginCursorCapture()
|
||||
{
|
||||
if (m_capturingCursor)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
qApp->setOverrideCursor(Qt::BlankCursor);
|
||||
m_capturingCursor = true;
|
||||
m_inputChannelMapper->SetCursorCaptureEnabled(true);
|
||||
}
|
||||
|
||||
void RenderViewportWidget::EndCursorCapture()
|
||||
{
|
||||
if (!m_capturingCursor)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
qApp->restoreOverrideCursor();
|
||||
m_capturingCursor = false;
|
||||
m_inputChannelMapper->SetCursorCaptureEnabled(false);
|
||||
}
|
||||
|
||||
void RenderViewportWidget::SetWindowTitle(const AZStd::string& title)
|
||||
|
||||
Reference in New Issue
Block a user