1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-12-27 02:29:23 +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) {
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);
}
}