]> git.mxchange.org Git - flightgear.git/blobdiff - src/Input/FGMouseInput.cxx
Allow using the system version of flite and the HTS engine
[flightgear.git] / src / Input / FGMouseInput.cxx
index 6ac4c0e9827a4966a532307ad5295d6719787a58..6d052c8817f544e76db793991f40e92ef09e2e71 100644 (file)
@@ -154,6 +154,7 @@ class FGMouseInput::FGMouseInputPrivate : public SGPropertyChangeListener
 {
 public:
     FGMouseInputPrivate() :
+        initialized(false),
         haveWarped(false),
         xSizeNode(fgGetNode("/sim/startup/xsize", false ) ),
         ySizeNode(fgGetNode("/sim/startup/ysize", false ) ),
@@ -164,12 +165,14 @@ public:
     {
         tooltipTimeoutDone = false;
         hoverPickScheduled = false;
-      
+        tooltipsEnabled = false;
+        
         fgGetNode("/sim/mouse/hide-cursor", true )->addChangeListener(this, true);
         fgGetNode("/sim/mouse/cursor-timeout-sec", true )->addChangeListener(this, true);
         fgGetNode("/sim/mouse/right-button-mode-cycle-enabled", true)->addChangeListener(this, true);
         fgGetNode("/sim/mouse/tooltip-delay-msec", true)->addChangeListener(this, true);
         fgGetNode("/sim/mouse/click-shows-tooltip", true)->addChangeListener(this, true);
+        fgGetNode("/sim/mouse/tooltips-enabled", true)->addChangeListener(this, true);
         fgGetNode("/sim/mouse/drag-sensitivity", true)->addChangeListener(this, true);
         fgGetNode("/sim/mouse/invert-mouse-wheel", true)->addChangeListener(this, true);
     }
@@ -313,7 +316,8 @@ public:
             rightClickModeCycle = node->getBoolValue();
         } else if (node->getNameString() == "click-shows-tooltip") {
             clickTriggersTooltip = node->getBoolValue();
-
+        } else if (node->getNameString() == "tooltips-enabled") {
+            tooltipsEnabled = node->getBoolValue();
         }
     }
     
@@ -322,11 +326,13 @@ public:
 
     mouse mice[MAX_MICE];
     
+    bool initialized;
     bool hideCursor, haveWarped;
     bool tooltipTimeoutDone;
     bool clickTriggersTooltip;
     int tooltipDelayMsec, cursorTimeoutMsec;
     bool rightClickModeCycle;
+    bool tooltipsEnabled;
     
     SGPropertyNode_ptr xSizeNode;
     SGPropertyNode_ptr ySizeNode;
@@ -372,8 +378,16 @@ FGMouseInput::~FGMouseInput()
 
 void FGMouseInput::init()
 {
+    if (d->initialized) {
+        SG_LOG(SG_INPUT, SG_WARN, "Duplicate init of FGMouseInput");
+
+        return;
+    }
+    
+    d->initialized = true;
+    
   SG_LOG(SG_INPUT, SG_DEBUG, "Initializing mouse bindings");
-  string module = "";
+  std::string module = "";
 
   SGPropertyNode * mouse_nodes = fgGetNode("/input/mice");
   if (mouse_nodes == 0) {
@@ -457,6 +471,10 @@ void FGMouseInput::init()
 
 void FGMouseInput::update ( double dt )
 {
+    if (!d->initialized) {
+        SG_LOG(SG_INPUT, SG_WARN, "update of mouse before init");
+    }
+    
   mouse &m = d->mice[0];
   int mode =  m.mode_node->getIntValue();
   if (mode != m.current_mode) {
@@ -478,9 +496,8 @@ void FGMouseInput::update ( double dt )
     d->hoverPickScheduled = false;
   }
   
-  // if delay is <= 0, disable tooltips
   if ( !d->tooltipTimeoutDone &&
-      (d->tooltipDelayMsec > 0) &&
+      d->tooltipsEnabled &&
       (m.timeSinceLastMove.elapsedMSec() > d->tooltipDelayMsec))
   {
       d->tooltipTimeoutDone = true;
@@ -537,6 +554,11 @@ mouse_mode::~mouse_mode ()
 
 void FGMouseInput::doMouseClick (int b, int updown, int x, int y, bool mainWindow, const osgGA::GUIEventAdapter* ea)
 {
+    if (!d->initialized) {
+        // can occur during reset
+        return;
+    }
+    
   int modifiers = fgGetKeyModifiers();
 
   mouse &m = d->mice[0];
@@ -678,6 +700,11 @@ void FGMouseInput::processMotion(int x, int y, const osgGA::GUIEventAdapter* ea)
 
 void FGMouseInput::doMouseMotion (int x, int y, const osgGA::GUIEventAdapter* ea)
 {
+    if (!d->initialized) {
+        // can occur during reset
+        return;
+    }
+    
   mouse &m = d->mice[0];
 
   if (m.current_mode < 0 || m.current_mode >= m.nModes) {