From eb3194a0c1e83173935c20118183c590a90c2605 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Fri, 19 Feb 2021 02:47:32 +0100 Subject: [PATCH] preserve position and scroll wheel value when the mouse is out of bounds --- MLEM/Input/InputHandler.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/MLEM/Input/InputHandler.cs b/MLEM/Input/InputHandler.cs index ce2417d..8781dee 100644 --- a/MLEM/Input/InputHandler.cs +++ b/MLEM/Input/InputHandler.cs @@ -181,11 +181,12 @@ namespace MLEM.Input { if (this.HandleMouse) { this.LastMouseState = this.MouseState; - this.MouseState = default; - if (active) { - var state = Mouse.GetState(); - if (this.Game.GraphicsDevice.Viewport.Bounds.Contains(state.Position)) - this.MouseState = state; + var state = Mouse.GetState(); + if (active && this.Game.GraphicsDevice.Viewport.Bounds.Contains(state.Position)) { + this.MouseState = state; + } else { + // mouse position and scroll wheel value should be preserved when the mouse is out of bounds + this.MouseState = new MouseState(state.X, state.Y, state.ScrollWheelValue, 0, 0, 0, 0, 0, state.HorizontalScrollWheelValue); } }