Use synthetic keyboard and mouse devices instead of synthetic input channels

Signed-off-by: nvsickle <nvsickle@amazon.com>
This commit is contained in:
nvsickle
2021-07-01 14:07:04 -07:00
parent 8dc59a13da
commit 52ae7433b3
8 changed files with 239 additions and 187 deletions
@@ -38,21 +38,6 @@ namespace AtomToolsFramework
setUpdatesEnabled(false);
setFocusPolicy(Qt::FocusPolicy::WheelFocus);
setMouseTracking(true);
// Forward input events to our controller list.
QObject::connect(&m_inputChannelMapper, &AzToolsFramework::QtEventToAzInputMapper::InputChannelUpdated, this,
[this](const AzFramework::InputChannel* inputChannel, QEvent* event)
{
AzFramework::NativeWindowHandle windowId = reinterpret_cast<AzFramework::NativeWindowHandle>(winId());
if (m_controllerList->HandleInputChannelEvent({GetId(), windowId, *inputChannel}))
{
// If the controller handled the input event, mark the event as accepted so it doesn't continue to propagate.
if (event)
{
event->setAccepted(true);
}
}
});
}
bool RenderViewportWidget::InitializeViewportContext(AzFramework::ViewportId id)
@@ -96,6 +81,23 @@ namespace AtomToolsFramework
AZ::TickBus::Handler::BusConnect();
AzFramework::WindowRequestBus::Handler::BusConnect(params.windowHandle);
m_inputChannelMapper = new AzToolsFramework::QtEventToAzInputMapper(this, id);
// Forward input events to our controller list.
QObject::connect(m_inputChannelMapper, &AzToolsFramework::QtEventToAzInputMapper::InputChannelUpdated, this,
[this](const AzFramework::InputChannel* inputChannel, QEvent* event)
{
AzFramework::NativeWindowHandle windowId = reinterpret_cast<AzFramework::NativeWindowHandle>(winId());
if (m_controllerList->HandleInputChannelEvent({GetId(), windowId, *inputChannel}))
{
// If the controller handled the input event, mark the event as accepted so it doesn't continue to propagate.
if (event)
{
event->setAccepted(true);
}
}
});
return true;
}
@@ -172,7 +174,7 @@ namespace AtomToolsFramework
}
// Only forward channels that aren't covered by our Qt -> AZ event mapper
if (m_inputChannelMapper.HandlesInputEvent(inputChannel))
if (!m_inputChannelMapper || m_inputChannelMapper->HandlesInputEvent(inputChannel))
{
return false;
}