From d705864f8882039492133cb1e3e29bb06bf303b8 Mon Sep 17 00:00:00 2001 From: hultonha Date: Fri, 30 Apr 2021 13:09:23 +0100 Subject: [PATCH] fix for input being 'stuck' on --- .../AzFramework/Viewport/CameraInput.cpp | 13 ++++++------- .../AzFramework/AzFramework/Viewport/CameraInput.h | 5 +++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.cpp b/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.cpp index 851522c701..069c9d5fc9 100644 --- a/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.cpp +++ b/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.cpp @@ -276,7 +276,7 @@ namespace AzFramework } else if (input->m_state == InputChannel::State::Ended) { - m_translation ^= translationFromKey(input->m_channelId); + m_translation &= ~(translationFromKey(input->m_channelId)); if (m_translation == TranslationType::Nil) { EndActivation(); @@ -521,20 +521,19 @@ namespace AzFramework return button == inputChannelId; }); - if (inputChannelId == InputDeviceMouse::SystemCursorPosition) + if (inputChannelId == InputDeviceMouse::Movement::X || inputChannelId == InputDeviceMouse::Movement::Y) { - AZ::Vector2 systemCursorPositionNormalized = AZ::Vector2::CreateZero(); - InputSystemCursorRequestBus::EventResult( - systemCursorPositionNormalized, inputDeviceId, &InputSystemCursorRequestBus::Events::GetSystemCursorPositionNormalized); + const auto* position = inputChannel.GetCustomData(); + AZ_Assert(position, "Expected PositionData2D but found nullptr"); return CursorMotionEvent{ScreenPoint( - systemCursorPositionNormalized.GetX() * windowSize.m_width, systemCursorPositionNormalized.GetY() * windowSize.m_height)}; + position->m_normalizedPosition.GetX() * windowSize.m_width, position->m_normalizedPosition.GetY() * windowSize.m_height)}; } else if (inputChannelId == InputDeviceMouse::Movement::Z) { return ScrollEvent{inputChannel.GetValue()}; } - else if ((InputDeviceMouse::IsMouseDevice(inputDeviceId) && wasMouseButton) || InputDeviceKeyboard::IsKeyboardDevice(inputDeviceId)) + else if (wasMouseButton || InputDeviceKeyboard::IsKeyboardDevice(inputDeviceId)) { return DiscreteInputEvent{inputChannelId, inputChannel.GetState()}; } diff --git a/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.h b/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.h index 4c076b887d..dee8bcd600 100644 --- a/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.h +++ b/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.h @@ -372,6 +372,11 @@ namespace AzFramework return lhs; } + friend TranslationType operator~(const TranslationType lhs) + { + return static_cast(~static_cast>(lhs)); + } + static TranslationType translationFromKey(InputChannelId channelId); TranslationType m_translation = TranslationType::Nil;