1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-26 14:38:34 +01:00

preserve position and scroll wheel value when the mouse is out of bounds

This commit is contained in:
Ell 2021-02-19 02:47:32 +01:00
parent 73eab1d41e
commit eb3194a0c1

View file

@ -181,11 +181,12 @@ namespace MLEM.Input {
if (this.HandleMouse) { if (this.HandleMouse) {
this.LastMouseState = this.MouseState; this.LastMouseState = this.MouseState;
this.MouseState = default;
if (active) {
var state = Mouse.GetState(); var state = Mouse.GetState();
if (this.Game.GraphicsDevice.Viewport.Bounds.Contains(state.Position)) if (active && this.Game.GraphicsDevice.Viewport.Bounds.Contains(state.Position)) {
this.MouseState = state; 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);
} }
} }