Mouse cursor show/hide issue

I’m trying to make 3d person character go to free-look mode with RMB pressed.
When starting an app I’m able to hold RMB and rotate camera as far as I want (no limit).

// Handle Mouse X
void AMainCharacter::Turn(float Value)
{
	if ((Controller != NULL) && (Value != 0.0f) && bIsMouseLookMode)
	{
		AddControllerYawInput(Value);
	}
}

// Handle Mouse Y
void AMainCharacter::LookUp(float Value)
{
	if ((Controller != NULL) && (Value != 0.0f) && bIsMouseLookMode)
	{
		AddControllerPitchInput(Value);
	}
}

// Handle RMB is pressed
void AMainCharacter::OnStartMouseLook()
{
	bIsMouseLookMode = true;

	APlayerController* MyController = GetWorld()->GetFirstPlayerController();

	MyController->bShowMouseCursor = false;
	MyController->bEnableClickEvents = false;
	MyController->bEnableMouseOverEvents = false;
}

// Handle RMB is released
void AMainCharacter::OnStopMouseLook()
{
	bIsMouseLookMode = false;

	APlayerController* MyController = GetWorld()->GetFirstPlayerController();

	MyController->bShowMouseCursor = true;
	MyController->bEnableClickEvents = true;
	MyController->bEnableMouseOverEvents = true;
}

However, once I show mouse cursor it can’t leave viewport area, so I can rotate my camera for a very limited degrees, even if I hide cursor again.

What I’m doing wrong? Is there any simple way to toggle mouse-look/mouse-click mode? Any help/advise is greatly appreciated.

For your question:

GEngine->GameViewport->Viewport->LockMouseToViewport(false);

However, you probably run into the same problem there; you hit the windows screen edge and can’t get anymore inputs from the mouse after that.

To solve the issue, you might give this a try (using your variable MyController here):

FInputModeGameOnly GameMode;         
MyController->SetInputMode(GameMode);

This SHOULD give you inputs even when you are at the edge of the screen.