While holding right-mouse to look around in a perspective level editor viewport, rotation speed suddenly drops (or jumps) and later recovers. Framerate is unaffected, and it even happens in an empty level. It only happens when Windows pointer speed isn’t the default 10, or when “Enhance pointer precision” is on. Other drags that use the unbounded cursor (pan, orbit, dolly) behave the same way. We didn’t see this on 5.7, and I don’t appear to be alone with this issue, as it’s been reported elsewhere (eg. forum post and Github plugin with workaround).
FSceneViewport::UpdateCachedCursorPos (new in 5.8) tracks the unbounded cursor that UViewportClickDragBehavior passes to UViewportViewAngleInteraction as UnboundedMouseDelta2D. It updates that position in two different ways:
- Inside the viewport: from the OS cursor position delta. Windows scales that by pointer speed and acceleration, because high-precision mode doesn’t use RIDEV_NOLEGACY, so the hidden cursor keeps moving.
- On or outside the viewport edge: from InMouseEvent.GetCursorDelta(), which in high-precision mode is the raw WM_INPUT delta.
At any non-default pointer speed the two disagree, so speed changes whenever the hidden cursor crosses the edge band. The edge branch also multiplies the raw delta by ToViewportPixelScale, which includes the DPI scale. At display scaling other than 100% that branch is over-scaled as well.
Our fix is this:
In UpdateCachedCursorPos, while the viewport has mouse capture and the cursor is hidden, always accumulate the raw delta with the DPI scale removed. “Hidden” covers both ShowCursor(false) and a platform cursor type of EMouseCursor::None. The second case matters because the ITF viewport interactions hide the cursor with an EMouseCursor::None override while bIsCursorVisible stays true. Visible-cursor drags keep the existing logic.
if (CachedUnboundedCursorPos.IsSet())
{
// hidden captured cursor moves the unbounded cursor by raw deltas only, so it does not depend on the OS pointer speed
// Viewport interactions hide the cursor with an EMouseCursor::None shape while bIsCursorVisible stays true
const TSharedPtr<ICursor> PlatformCursor = FSlateApplication::Get().GetPlatformCursor();
const bool bCursorShapeHidden = PlatformCursor.IsValid() && PlatformCursor->GetType() == EMouseCursor::None;
const bool bHiddenCursorCaptured = (!bIsCursorVisible || bCursorShapeHidden) && !bIsSoftwareCursorVisible && ViewportWidget.IsValid() && ViewportWidget.Pin()->HasMouseCapture();
if (bHiddenCursorCaptured)
{
if (bIsMoveEvent)
{
// Cursor delta is in desktop pixels; ToViewportPixelScale includes the DPI scale, which must not apply here
const FIntPoint UnboundDelta = (InMouseEvent.GetCursorDelta() * ToViewportPixelScale / InGeometry.Scale).IntPoint();
CachedUnboundedCursorPos = CachedUnboundedCursorPos.GetValue() + UnboundDelta;
}
}
else if (NewPos.X > 0 && NewPos.X < PixelWidth - 1 && NewPos.Y > 0 && NewPos.Y < PixelHeight - 1)
{
//...
With this, camera drags ignore pointer speed and acceleration, as they did before 5.8. I’m not sure if this lines up with the intention behind the change in 5.8, but it fixes the issue for us so I thought it was worth sharing.