# 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
// these will hold the values of the axes
static float *js_ax0, *js_ax1;
+static bool sync_throttle=false;
+
+static float throttle_tmp=0;
+
+#define SYNC_TOLERANCE 0.02
+
#elif defined( ENABLE_GLUT_JOYSTICK )
// Do we want these user settable ??
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);
+ }
+
+ if(current_options.get_trim_mode() > 0) {
+ FG_LOG(FG_INPUT, FG_INFO,
+ " Waiting for user to synchronize throttle lever...");
+ sync_throttle=true;
+ }
+
+
#elif defined( ENABLE_GLUT_JOYSTICK )
glutJoystickFunc(joystick, 100);
js0->read( &b, js_ax0 ) ;
controls.set_aileron( js_ax0[0] );
controls.set_elevator( -js_ax0[1] );
+
+ // Added by William Riley -- riley@technologist.com
+ if ( js0->getNumAxes() >= 3 ) {
+ throttle_tmp=(-js_ax0[3] + 1) / 2;
+
+ if(sync_throttle == true) {
+ if (fabs(controls.get_throttle(0)-throttle_tmp)
+ < SYNC_TOLERANCE)
+ {
+ FG_LOG(FG_INPUT, FG_INFO, " Throttle lever synchronized.");
+ controls.set_throttle(FGControls::ALL_ENGINES,throttle_tmp);
+ sync_throttle=false;
+ }
+ } else {
+ controls.set_throttle( FGControls::ALL_ENGINES,throttle_tmp );
+ }
+ }
+ if ( js0->getNumAxes() > 3 ) {
+ if ( current_options.get_auto_coordination() !=
+ fgOPTIONS::FG_AUTO_COORD_ENABLED )
+ {
+ controls.set_rudder( js_ax0[2] );
+ }
+ }
+ // End of William's code
+
}
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 );
}