]> git.mxchange.org Git - flightgear.git/commitdiff
Mouse changes suggested by Norm Vine. Cursor always centres on mode
authordavid <david>
Thu, 28 Mar 2002 15:57:02 +0000 (15:57 +0000)
committerdavid <david>
Thu, 28 Mar 2002 15:57:02 +0000 (15:57 +0000)
changes, and wrap-around is smoother.

src/Input/input.cxx

index 7bd23cf8a79cdcb2fc5373296d1ac0d683719288..bebd60217b13888afac41a424ca801f7778c8dc0 100644 (file)
@@ -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);