diff --git a/src/Input/input.cxx b/src/Input/input.cxx index 0c5ce80fb..dea8995c5 100644 --- a/src/Input/input.cxx +++ b/src/Input/input.cxx @@ -184,7 +184,7 @@ FGInput::update (double dt) { _update_keyboard(); _update_joystick(dt); - _update_mouse(); + _update_mouse(dt); } void @@ -303,15 +303,23 @@ FGInput::doMouseMotion (int x, int y) int xsize = fgGetInt("/sim/startup/xsize", 800); int ysize = fgGetInt("/sim/startup/ysize", 600); + mouse &m = _mouse_bindings[0]; - if (m.current_mode < 0 || m.current_mode >= m.nModes) - return; + + if (m.current_mode < 0 || m.current_mode >= m.nModes) { + m.x = x; + m.y = y; + return; + } mouse_mode &mode = m.modes[m.current_mode]; // Pass on to PUI if requested, and return // if PUI consumed the event. - if (mode.pass_through && puMouse(x, y)) - return; + if (mode.pass_through && puMouse(x, y)) { + m.x = x; + m.y = y; + return; + } // OK, PUI didn't want the event, // so we can play with it. @@ -709,12 +717,13 @@ FGInput::_update_joystick (double dt) } void -FGInput::_update_mouse () +FGInput::_update_mouse ( double dt ) { mouse &m = _mouse_bindings[0]; int mode = m.mode_node->getIntValue(); if (mode != m.current_mode) { m.current_mode = mode; + 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; @@ -725,6 +734,21 @@ FGInput::_update_mouse () fgSetMouseCursor(MOUSE_CURSOR_POINTER); } } + + if ( fgGetBool( "/sim/mouse/hide-cursor", true ) ) { + if ( m.x != m.save_x || m.y != m.save_y ) { + m.timeout = fgGetDouble( "/sim/mouse/cursor-timeout-sec", 10.0 ); + fgSetMouseCursor(m.modes[mode].cursor); + } else { + m.timeout -= dt; + if ( m.timeout <= 0.0 ) { + fgSetMouseCursor(MOUSE_CURSOR_NONE); + m.timeout = 0.0; + } + } + m.save_x = m.x; + m.save_y = m.y; + } } void diff --git a/src/Input/input.hxx b/src/Input/input.hxx index ac59a6627..755b6d66f 100644 --- a/src/Input/input.hxx +++ b/src/Input/input.hxx @@ -339,6 +339,9 @@ private: SGPropertyNode * mouse_button_nodes[MAX_MOUSE_BUTTONS]; int nModes; int current_mode; + double timeout; + int save_x; + int save_y; mouse_mode * modes; }; @@ -384,7 +387,7 @@ private: /** * Update the mouse. */ - void _update_mouse (); + void _update_mouse (double dt); /**