From e91bf12a3d3bd0b027a40661d4b07e4a278cd6ea Mon Sep 17 00:00:00 2001 From: daniel Date: Sat, 3 Jan 2026 19:15:02 +0100 Subject: [PATCH] improved mouse behaviour if it leaves the window --- src/EngineSharp.Core/EngineSharp.Core/InputService.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/EngineSharp.Core/EngineSharp.Core/InputService.cs b/src/EngineSharp.Core/EngineSharp.Core/InputService.cs index a2b46d0..7cbe62d 100644 --- a/src/EngineSharp.Core/EngineSharp.Core/InputService.cs +++ b/src/EngineSharp.Core/EngineSharp.Core/InputService.cs @@ -86,14 +86,15 @@ public class InputService } var delta = _currentMousePosition.Value - newPosition; + _currentMousePosition = newPosition; - // TODO: Very very bad solution! I need to find a good way to determine if the cursor has left the window and now has re-entered it - if (Math.Abs(delta.X) <= 100 || Math.Abs(delta.Y) <= 100) + // TODO: Bad solution! I need to find a good way to determine if the cursor has left the window and now has re-entered it + if (delta.Length() > 50) { - _currentMouseDelta = new Vector2D(-delta.X, delta.Y); + return; } - _currentMousePosition = newPosition; + _currentMouseDelta = new Vector2D(-delta.X, delta.Y); } private void OnDeviceConnectionChanges(IInputDevice device, bool connected)