private void OnWinformsMouseMove(object sender, MouseEventArgs e) { if (!_mouseCaptured) { return; } if (_skipNextMouseMove) { _skipNextMouseMove = false; return; } // // Calclate the center of the window. // Point middle = new Point(DisplayBox.Width / 2, DisplayBox.Height / 2); int dx = e.X - middle.X; int dy = e.Y - middle.Y; if (dx != 0 || dy != 0) { _system.IOP.Mouse.MouseMove(dx, dy); // Don't handle the very next Mouse Move event (which will just be the motion we caused in the // below line...) _skipNextMouseMove = true; Cursor.Position = DisplayBox.PointToScreen(middle); } }
private void HackMouseMove() { Point middle = new Point(DisplayBox.Width / 2, DisplayBox.Height / 2); // Force (invisible) cursor to middle of window Cursor.Position = DisplayBox.PointToScreen(middle); }
private void OnDisplayMouseMove(object sender, MouseEventArgs e) { // Short-circuit if a script is playing. if (ScriptManager.IsPlaying) { return; } if (!_mouseCaptured) { // We do nothing with mouse input unless we have capture. return; } if (_skipNextMouseMove) { _skipNextMouseMove = false; return; } // We implement a crude "mouse capture" behavior by forcing the mouse cursor to the // center of the display window and taking the delta of the last movement and using it // to move the Alto's mouse. // In this way the Windows cursor never leaves our window (important in order to prevent // other programs from getting clicked on while Missile Command is being played) and we // still get motion events. Point middle = new Point(DisplayBox.Width / 2, DisplayBox.Height / 2); int dx = e.X - middle.X; int dy = e.Y - middle.Y; if (dx != 0 || dy != 0) { _system.MouseAndKeyset.MouseMove(dx, dy); // Don't handle the very next Mouse Move event (which will just be the motion we caused in the // below line...) _skipNextMouseMove = true; Cursor.Position = DisplayBox.PointToScreen(middle); } }