Skip to content

Commit ea2d536

Browse files
committed
Added check whether the cursor is constrained or not
Signed-off-by: Patryk Antosz <[email protected]>
1 parent 9ffd602 commit ea2d536

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Gems/RobotecSpectatorCamera/Code/Source/SpectatorCamera/SpectatorCameraComponent.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,12 @@ namespace RobotecSpectatorCamera
108108

109109
if (channelId == AzFramework::InputDeviceMouse::Button::Right || m_configuration.m_cameraMode == CameraMode::FreeFlying)
110110
{
111+
AzFramework::SystemCursorState currentCursorState;
112+
AzFramework::InputSystemCursorRequestBus::EventResult(
113+
currentCursorState, AzFramework::InputDeviceMouse::Id, &AzFramework::InputSystemCursorRequests::GetSystemCursorState);
114+
const bool isConstrained = // flag to do not lose information whether the cursor is constrained or not
115+
(currentCursorState == AzFramework::SystemCursorState::ConstrainedAndHidden ||
116+
currentCursorState == AzFramework::SystemCursorState::ConstrainedAndVisible);
111117
if (inputChannel.IsStateBegan())
112118
{
113119
m_isRightMouseButtonPressed = true;
@@ -118,7 +124,8 @@ namespace RobotecSpectatorCamera
118124
AzFramework::InputSystemCursorRequestBus::Event(
119125
AzFramework::InputDeviceMouse::Id,
120126
&AzFramework::InputSystemCursorRequests::SetSystemCursorState,
121-
AzFramework::SystemCursorState::ConstrainedAndHidden);
127+
isConstrained ? AzFramework::SystemCursorState::ConstrainedAndHidden
128+
: AzFramework::SystemCursorState::UnconstrainedAndHidden);
122129
}
123130
else if (inputChannel.IsStateEnded())
124131
{
@@ -135,7 +142,8 @@ namespace RobotecSpectatorCamera
135142
AzFramework::InputSystemCursorRequestBus::Event(
136143
AzFramework::InputDeviceMouse::Id,
137144
&AzFramework::InputSystemCursorRequests::SetSystemCursorState,
138-
AzFramework::SystemCursorState::ConstrainedAndVisible);
145+
isConstrained ? AzFramework::SystemCursorState::ConstrainedAndVisible
146+
: AzFramework::SystemCursorState::UnconstrainedAndVisible);
139147
}
140148
}
141149

0 commit comments

Comments
 (0)