]> git.mxchange.org Git - flightgear.git/commitdiff
The "constrained" property for a mouse mode now actually constrains
authordavid <david>
Thu, 16 Feb 2006 01:30:28 +0000 (01:30 +0000)
committerdavid <david>
Thu, 16 Feb 2006 01:30:28 +0000 (01:30 +0000)
the mouse rather than wrapping it.  Wrapping around to the other side
of the screen has very bad consequences when using the mouse for
flying or viewing -- it can result in sudden jumps in the controls or
the viewpoint when the mouse jumps to another side of the screen.

Right now, the mouse is constrained to stay between 25% and 75% of the
screen on both the X and Y axis -- whenever it hits an edge, it jumps
back to the centre of the screen again (which causes no control or
view jump).

src/Input/input.cxx

index 59f27bd89c0d13dd4339a017f2db3b1f88d64c42..a95c235fbb95202b75b0f841ea561689e165c2e2 100644 (file)
@@ -387,19 +387,13 @@ FGInput::doMouseMotion (int x, int y)
                                 // Constrain the mouse if requested
   if (mode.constrained) {
     bool need_warp = false;
-    if (x <= 0) {
-      x = xsize - 2;
-      need_warp = true;
-    } else if (x >= (xsize-1)) {
-      x = 1;
+    if (x <= (xsize * .25) || x >= (xsize * .75)) {
+      x = int(xsize * .5);
       need_warp = true;
     }
 
-    if (y <= 0) {
-      y = ysize - 2;
-      need_warp = true;
-    } else if (y >= (ysize-1)) {
-      y = 1;
+    if (y <= (ysize * .25) || y >= (ysize * .75)) {
+      y = int(ysize * .5);
       need_warp = true;
     }