Address a few more review things

Signed-off-by: nvsickle <nvsickle@amazon.com>
This commit is contained in:
nvsickle
2021-07-02 15:26:16 -07:00
parent 049ef81fe9
commit 4babf69361
6 changed files with 41 additions and 7 deletions
@@ -200,8 +200,24 @@ namespace AzToolsFramework
deviceId.GetNameCrc32() == AzFramework::InputDeviceKeyboard::Id.GetNameCrc32();
}
void QtEventToAzInputMapper::SetEnabled(bool enabled)
{
m_enabled = enabled;
if (!enabled)
{
// Send an internal focus change event to reset our input state to fresh if we're disabled.
HandleFocusChange(nullptr);
}
}
bool QtEventToAzInputMapper::eventFilter(QObject* object, QEvent* event)
{
// Abort if processing isn't enabled.
if (!m_enabled)
{
return false;
}
// Because there's no "end" to mouse movement and wheel events, we reset mouse movement channels that have been opened
// during the next processed non-mouse event.
if (m_mouseChannelsNeedUpdate && event->type() != QEvent::Type::MouseMove && event->type() != QEvent::Type::Wheel)
@@ -268,14 +284,14 @@ namespace AzToolsFramework
{
auto systemCursorChannel =
GetInputChannel<AzFramework::InputChannelDeltaWithSharedPosition2D>(AzFramework::InputDeviceMouse::SystemCursorPosition);
auto cursorZChannel =
auto mouseWheelChannel =
GetInputChannel<AzFramework::InputChannelDeltaWithSharedPosition2D>(AzFramework::InputDeviceMouse::Movement::Z);
systemCursorChannel->ProcessRawInputEvent(m_cursorPosition->m_normalizedPositionDelta.GetLength());
cursorZChannel->ProcessRawInputEvent(0.f);
mouseWheelChannel->ProcessRawInputEvent(0.f);
NotifyUpdateChannelIfNotIdle(systemCursorChannel, nullptr);
NotifyUpdateChannelIfNotIdle(cursorZChannel, nullptr);
NotifyUpdateChannelIfNotIdle(mouseWheelChannel, nullptr);
}
void QtEventToAzInputMapper::HandleMouseButtonEvent(QMouseEvent* mouseEvent)
@@ -44,6 +44,9 @@ namespace AzToolsFramework
//! \returns true if the channel is handled by MapQtEventToAzInput.
bool HandlesInputEvent(const AzFramework::InputChannel& channel) const;
//! Sets whether or not this input mapper should be updating its input channels from Qt events.
void SetEnabled(bool enabled);
// QObject overrides...
bool eventFilter(QObject* object, QEvent* event) override;
@@ -64,7 +67,7 @@ namespace AzToolsFramework
{
return static_cast<TInputChannel*>(channelIt->second);
}
return {};
return nullptr;
}
// Adds channels from the specified channel container to our input channel ID -> input channel lookup table.
@@ -139,6 +142,8 @@ namespace AzToolsFramework
QWidget* m_sourceWidget;
// Flags when mouse movement channels have been opened and may need to be closed (as there are no movement ended events).
bool m_mouseChannelsNeedUpdate = false;
// Flags whether or not Qt events should currently be processed.
bool m_enabled = true;
// Our viewport-specific AZ devices. We control their internal input channel states.
AZStd::unique_ptr<EditorQtMouseDevice> m_mouseDevice;