From 62df2d1d534061280ce24159598f45ccd01b209b Mon Sep 17 00:00:00 2001
From: david <david>
Date: Thu, 28 Mar 2002 15:57:02 +0000
Subject: [PATCH] Mouse changes suggested by Norm Vine.  Cursor always centres
 on mode changes, and wrap-around is smoother.

---
 src/Input/input.cxx | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/Input/input.cxx b/src/Input/input.cxx
index 7bd23cf8a..bebd60217 100644
--- a/src/Input/input.cxx
+++ b/src/Input/input.cxx
@@ -417,19 +417,19 @@ FGInput::doMouseMotion (int x, int y)
 				// Constrain the mouse if requested
   if (mode.constrained) {
     bool need_warp = false;
-    if (x < 0) {
-      x = xsize - 1;
+    if (x <= 0) {
+      x = xsize - 2;
       need_warp = true;
-    } else if (x >= xsize) {
-      x = 0;
+    } else if (x >= (xsize-1)) {
+      x = 1;
       need_warp = true;
     }
 
-    if (y < 0) {
-      y = ysize - 1;
+    if (y <= 0) {
+      y = ysize - 2;
       need_warp = true;
-    } else if (y >= ysize) {
-      y = 0;
+    } else if (y >= (ysize-1)) {
+      y = 1;
       need_warp = true;
     }
 
@@ -765,6 +765,8 @@ FGInput::_update_mouse ()
     m.current_mode = mode;
     if (mode >= 0 && mode < m.nModes) {
       glutSetCursor(m.modes[mode].cursor);
+      glutWarpPointer(fgGetInt("/sim/startup/xsize", 800) / 2,
+		      fgGetInt("/sim/startup/ysize", 600) / 2);
     } else {
       SG_LOG(SG_INPUT, SG_DEBUG, "Mouse mode " << mode << " out of range");
       glutSetCursor(GLUT_CURSOR_INHERIT);