]> 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 545c9890eecb69c0a64b2f5cd89a2e16a4dd73a1..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 ) ),
@@ -325,6 +326,7 @@ public:
 
     mouse mice[MAX_MICE];
     
+    bool initialized;
     bool hideCursor, haveWarped;
     bool tooltipTimeoutDone;
     bool clickTriggersTooltip;
@@ -376,6 +378,14 @@ 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");
   std::string module = "";
 
@@ -461,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) {
@@ -540,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];
@@ -681,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) {