]> git.mxchange.org Git - flightgear.git/blobdiff - src/Joystick/joystick.cxx
cygwin32 fixes by norman vine.
[flightgear.git] / src / Joystick / joystick.cxx
index ac38aaea27033c41fbbf583b8dec459e3273fca4..8b2256cca60dc2a4cf0e2544969772d2048bca08 100644 (file)
 #  include <windows.h>                     
 #endif
 
+#include <simgear/debug/logstream.hxx>
+
 #include <Aircraft/aircraft.hxx>
-#include <Debug/logstream.hxx>
+#include <Main/options.hxx>
 
 #if defined( ENABLE_PLIB_JOYSTICK )
-#  include <js.h>              // plib include
+#  include <plib/js.h>         // plib include
 #elif defined( ENABLE_GLUT_JOYSTICK )
 #  include <GL/glut.h>
-#  include <XGL/xgl.h>
+#  include <simgear/xgl.h>
 #endif
 
 
@@ -161,6 +163,21 @@ int fgJoystickInit( void ) {
        return 0;
     }
 
+    // I hate doing this sort of thing, but it's overridable from the
+    // command line/config file.  If the user hasn't specified an
+    // autocoordination preference, and if they have a single 2 axis
+    // joystick, then automatical enable auto_coordination.
+
+    if ( (current_options.get_auto_coordination() == 
+         fgOPTIONS::FG_AUTO_COORD_NOT_SPECIFIED) &&
+        (!js0->notWorking() && js1->notWorking() && (js0->getNumAxes() < 3)
+         )
+        )
+    {
+       current_options.set_auto_coordination(fgOPTIONS::FG_AUTO_COORD_ENABLED);
+    }
+
+
 #elif defined( ENABLE_GLUT_JOYSTICK )
 
     glutJoystickFunc(joystick, 100);
@@ -192,7 +209,11 @@ int fgJoystickRead( void ) {
                                   ((-js_ax0[2] + 1) / 2) );
        } 
        if ( js0->getNumAxes() > 3 ) {
-           controls.set_rudder( js_ax0[3] );
+           if ( current_options.get_auto_coordination() !=
+                 fgOPTIONS::FG_AUTO_COORD_ENABLED ) 
+           {
+               controls.set_rudder( js_ax0[3] );
+           }
        }
        //  End of William's code
 
@@ -200,7 +221,11 @@ int fgJoystickRead( void ) {
 
     if ( ! js1->notWorking() ) {
        js1->read( &b, js_ax1 ) ;
-       controls.set_rudder( js_ax1[0] );
+       if ( current_options.get_auto_coordination() !=
+            fgOPTIONS::FG_AUTO_COORD_ENABLED ) 
+       {
+           controls.set_rudder( js_ax1[0] );
+       }
        controls.set_throttle( FGControls::ALL_ENGINES, -js_ax1[1] * 1.05 );
     }