]> git.mxchange.org Git - flightgear.git/blobdiff - src/Input/FGJoystickInput.cxx
ITM radio calculations are only considered valid
[flightgear.git] / src / Input / FGJoystickInput.cxx
index 506de36bb3c61a40b0c5507d691e45df5176ba66..83e5f68a7294c91e37df5d14726a8dbf2e7b80b7 100644 (file)
 //
 // $Id$
 
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
 #include "FGJoystickInput.hxx"
+
+#include <simgear/props/props_io.hxx>
 #include "FGDeviceConfigurationMap.hxx"
 #include <Main/fg_props.hxx>
 #include <Scripting/NasalSys.hxx>
@@ -191,7 +197,7 @@ void FGJoystickInput::postinit()
     //
     // Initialize nasal groups.
     //
-    ostringstream str;
+    std::ostringstream str;
     str << "__js" << i;
     string module = str.str();
     nasalsys->createModule(module.c_str(), module.c_str(), "", 0);
@@ -215,10 +221,19 @@ void FGJoystickInput::postinit()
       if (num_node != 0) {
           n_axis = num_node->getIntValue(TGT_PLATFORM, -1);
 
+        #ifdef SG_MAC
+          // Mac falls back to Unix by default - avoids specifying many
+          // duplicate <mac> entries in joystick config files
+          if (n_axis < 0) {
+              n_axis = num_node->getIntValue("unix", -1);
+          }
+        #endif
+          
           // Silently ignore platforms that are not specified within the
           // <number></number> section
-          if (n_axis < 0)
-             continue;
+          if (n_axis < 0) {
+              continue;
+          }
       }
 
       if (n_axis >= naxes) {
@@ -305,7 +320,9 @@ void FGJoystickInput::update( double dt )
                                 // Do nothing if the axis position
                                 // is unchanged; only a change in
                                 // position fires the bindings.
-      if (fabs(axis_values[j] - a.last_value) > a.tolerance) {
+                                // But only if there are bindings
+      if (fabs(axis_values[j] - a.last_value) > a.tolerance
+         && a.bindings[KEYMOD_NONE].size() > 0 ) {
         a.last_value = axis_values[j];
         for (unsigned int k = 0; k < a.bindings[KEYMOD_NONE].size(); k++)
           a.bindings[KEYMOD_NONE][k]->fire(axis_values[j]);
@@ -329,7 +346,7 @@ void FGJoystickInput::update( double dt )
       FGButton &b = bindings[i].buttons[j];
       b.last_dt += dt;
       if(b.last_dt >= b.interval_sec) {
-        bindings[i].buttons[j].update( modifiers, (buttons & (1 << j)) > 0 );
+        bindings[i].buttons[j].update( modifiers, (buttons & (1u << j)) > 0 );
         b.last_dt -= b.interval_sec;
       }
     }