From 6e7032f2aeedb503002effcbb2e0d5145baa1ac6 Mon Sep 17 00:00:00 2001 From: nilllzz Date: Fri, 11 Jan 2019 20:22:01 +0100 Subject: [PATCH] only reset mouse pos when needed --- P3D/Overworld/OverworldCamera.vb | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/P3D/Overworld/OverworldCamera.vb b/P3D/Overworld/OverworldCamera.vb index 28f9e4b6d..21f8aab32 100644 --- a/P3D/Overworld/OverworldCamera.vb +++ b/P3D/Overworld/OverworldCamera.vb @@ -377,9 +377,27 @@ Public Class OverworldCamera Public Sub ResetCursor() If GameInstance.IsActive = True Then - Mouse.SetPosition(CInt(windowSize.Width / 2), CInt(windowSize.Height / 2)) - oldX = CInt(windowSize.Width / 2) - oldY = CInt(windowSize.Height / 2) + ' Only reset the mouse position when it's "close" to the border of the client rect + Dim horizontalCutoff = windowSize.Width / 10.0F + Dim verticalCutoff = windowSize.Height / 10.0F + Dim mousePos = Mouse.GetState().Position.ToVector2() + + If mousePos.X <= horizontalCutoff OrElse + mousePos.X >= windowSize.Width - horizontalCutoff OrElse + mousePos.Y <= verticalCutoff OrElse + mousePos.Y >= windowSize.Height - verticalCutoff Then + + Mouse.SetPosition(CInt(windowSize.Width / 2), CInt(windowSize.Height / 2)) + oldX = CInt(windowSize.Width / 2) + oldY = CInt(windowSize.Height / 2) + + Else + + oldX = mousePos.X + oldY = mousePos.Y + + End If + End If End Sub