From 85707f1e49a796282d0ee1b1a79a3c89678069ad Mon Sep 17 00:00:00 2001 From: david Date: Thu, 16 Feb 2006 01:30:28 +0000 Subject: [PATCH] The "constrained" property for a mouse mode now actually constrains 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 | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/Input/input.cxx b/src/Input/input.cxx index 59f27bd89..a95c235fb 100644 --- a/src/Input/input.cxx +++ b/src/Input/input.cxx @@ -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; }