X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FJoystick%2Fjoystick.cxx;h=8b2256cca60dc2a4cf0e2544969772d2048bca08;hb=9a3b25e4fa4b9acb7b444e6e33bcba1c8310b888;hp=856e0a7fe86579ed291a2566cb2ae0e49eb6ebf2;hpb=c90db01dc8d5462a3da22771ffa7c96f5ea31217;p=flightgear.git diff --git a/src/Joystick/joystick.cxx b/src/Joystick/joystick.cxx index 856e0a7fe..8b2256cca 100644 --- a/src/Joystick/joystick.cxx +++ b/src/Joystick/joystick.cxx @@ -2,7 +2,7 @@ // // Written by Curtis Olson, started October 1998. // -// Copyright (C) 1998 Curtis L. Olson - curt@me.umn.edu +// Copyright (C) 1998 - 1999 Curtis L. Olson - curt@flightgear.org // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as @@ -29,14 +29,16 @@ # include #endif +#include + #include -#include +#include
#if defined( ENABLE_PLIB_JOYSTICK ) -# include +# include // plib include #elif defined( ENABLE_GLUT_JOYSTICK ) # include -# include +# include #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); @@ -185,11 +202,30 @@ int fgJoystickRead( void ) { 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 ) { + controls.set_throttle( FGControls::ALL_ENGINES, + ((-js_ax0[2] + 1) / 2) ); + } + if ( js0->getNumAxes() > 3 ) { + if ( current_options.get_auto_coordination() != + fgOPTIONS::FG_AUTO_COORD_ENABLED ) + { + controls.set_rudder( js_ax0[3] ); + } + } + // 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 ); }