Hi All, When using the mouse in view-direction mode, the mouse warps back to the centre of the screen (0,0) when it reaches half-way towards any edge. This is good as it stops the window losing focus on X windows.
However, because it warped back to (0,0), the warp had the effect or reseting the other coordinate. For example, if you were rotating a view above an aircraft, when the mouse reached the X-limit, the mouse is warped back to the center, reseting the Y value to 0 and causing the view to return to the Y=0 plane. The patch below fixes this behaviour on OSG by warping the mouse properly. Note that this changes the arguments for fgWarpMouse from the pixel coordinate system to a normalized one where (0.0, 0.0) is the centre of the screen. I have fixed all the references to fgWarpMouse, but some of these are in #ifdefs that don't apply to my platform (Windows), so I would appreciate if someone who compiles with X_CURSOR_TWEAKS could test the behaviour on their system. Could someone please review it, and assuming it meets with approval, commit it. Thanks, -Stuart Index: src/GUI/mouse.cxx =================================================================== RCS file: /var/cvs/FlightGear-0.9/source/src/GUI/mouse.cxx,v retrieving revision 1.16 diff -u -r1.16 mouse.cxx --- src/GUI/mouse.cxx 9 May 2007 20:41:08 -0000 1.16 +++ src/GUI/mouse.cxx 17 Aug 2007 20:34:05 -0000 @@ -123,7 +123,7 @@ } #endif #if defined(X_CURSOR_TWEAKS) - fgWarpMouse( MOUSE_XSIZE/2, MOUSE_YSIZE/2 ); + fgWarpMouse(0.0f,0.0f); #endif } @@ -133,7 +133,7 @@ #if defined(WIN32_CURSOR_TWEAKS) fgSetMouseCursor(MOUSE_CURSOR_NONE); #elif defined(X_CURSOR_TWEAKS) - fgWarpMouse( MOUSE_XSIZE, MOUSE_YSIZE ); + fgWarpMouse(1.0f,1.0f); #endif } Index: src/Input/input.cxx =================================================================== RCS file: /var/cvs/FlightGear-0.9/source/src/Input/input.cxx,v retrieving revision 1.95 diff -u -r1.95 input.cxx --- src/Input/input.cxx 13 Jul 2007 10:15:48 -0000 1.95 +++ src/Input/input.cxx 17 Aug 2007 21:04:19 -0000 @@ -373,7 +373,12 @@ } if (need_warp) - fgWarpMouse(x, y); + { + // Convert to normalized values from -1.0 to 1.0. Y-values are reversed. + float normx = (2.0f * ((float) x) /((float) xsize)) - 1.0f; + float normy = 1.0f - (2.0f * ((float) y) /((float) ysize)); + fgWarpMouse(normx, normy); + } } if (m.x != x) @@ -849,9 +854,7 @@ m.timeout = fgGetDouble( "/sim/mouse/cursor-timeout-sec", 10.0 ); if (mode >= 0 && mode < m.nModes) { fgSetMouseCursor(m.modes[mode].cursor); - m.x = fgGetInt("/sim/startup/xsize", 800) / 2; - m.y = fgGetInt("/sim/startup/ysize", 600) / 2; - fgWarpMouse(m.x, m.y); + fgWarpMouse(0.0f, 0.0f); } else { SG_LOG(SG_INPUT, SG_DEBUG, "Mouse mode " << mode << " out of range"); fgSetMouseCursor(MOUSE_CURSOR_POINTER); Index: src/Main/fg_os.hxx =================================================================== RCS file: /var/cvs/FlightGear-0.9/source/src/Main/fg_os.hxx,v retrieving revision 1.8 diff -u -r1.8 fg_os.hxx --- src/Main/fg_os.hxx 26 May 2007 13:53:46 -0000 1.8 +++ src/Main/fg_os.hxx 17 Aug 2007 20:34:08 -0000 @@ -50,7 +50,7 @@ void fgSetMouseCursor(int cursor); int fgGetMouseCursor(); -void fgWarpMouse(int x, int y); +void fgWarpMouse(float x, float y); int fgGetKeyModifiers(); Index: src/Main/fg_os_osgviewer.cxx =================================================================== RCS file: /var/cvs/FlightGear-0.9/source/src/Main/fg_os_osgviewer.cxx,v retrieving revision 1.7 diff -u -r1.7 fg_os_osgviewer.cxx --- src/Main/fg_os_osgviewer.cxx 1 Jul 2007 16:39:52 -0000 1.7 +++ src/Main/fg_os_osgviewer.cxx 17 Aug 2007 20:29:46 -0000 @@ -248,10 +248,9 @@ return globals->get_renderer()->getManipulator()->getCurrentModifiers(); } -void fgWarpMouse(int x, int y) +void fgWarpMouse(float x, float y) { - // Hack, currently the pointer is just recentered. So, we know the relative coordinates ... - viewer->requestWarpPointer(0, 0); + viewer->requestWarpPointer(x, y); } // Noop ___________________________________________________________ Yahoo! Answers - Got a question? Someone out there knows the answer. Try it now. http://uk.answers.yahoo.com/ ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Flightgear-devel mailing list Flightgear-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/flightgear-devel