protected internal override void Update() { timeSinceMouseRefresh += Time.Delta; if (timeSinceMouseRefresh >= MouseRefreshTime) { timeSinceMouseRefresh = 0.0D; Vector2I pos = InputWrapper.GetMousePosition(); if (Graphics.Window == null) { MouseDelta = Vector2D.Zero; } else { Vector2I s = Graphics.Window.SurfaceResolution; Vector2I winpos = Graphics.Window.SurfacePosition; Vector2I centre = new Vector2I((int)(winpos.X + s.X / 2f), (int)(winpos.Y + s.Y / 2f)); if (!Graphics.Window.Focused) { IgnoreNextFocusFrame = true; } if (!firstTime) { MouseDelta = Graphics.Window.Focused && Input.LockMode == CursorLockModes.Lock ? (IgnoreNextFocusFrame ? Vector2D.Zero : (Vector2D)(centre - pos)) : Vector2D.Zero; if (Graphics.Window.Focused && IgnoreNextFocusFrame) { IgnoreNextFocusFrame = false; } MousePosition = Graphics.Window.Focused && Input.LockMode == CursorLockModes.Free ? /*centre - pos*/ Graphics.Window.ScreenToWindow(pos) : Vector2I.Zero; } if (Input.LockMode == CursorLockModes.Lock && Graphics.Window.Focused) { InputWrapper.SetMousePosition(centre); } if (firstTime) { InputWrapper.SetMousePosition(centre); } firstTime = false; } } if (Graphics.Window != null) { UpdateKeysStates(); } }