1
0
Fork 0

Updates by norman vine to controls.hxx.

Joystick auto-coordination tweaks.
Additional debuging output when pausing and resuming the sim.
Window resizing tweaks by David Megginson (and Norman Vine).
This commit is contained in:
curt 1999-10-09 13:09:16 +00:00
parent 65ea4e8bfc
commit 5f5905f6e8
6 changed files with 64 additions and 51 deletions

View file

@ -58,6 +58,11 @@ private:
double throttle[MAX_ENGINES]; double throttle[MAX_ENGINES];
double brake[MAX_WHEELS]; double brake[MAX_WHEELS];
inline void CLAMP(double *x, double min, double max ) {
if ( *x < min ) { *x = min; }
if ( *x > max ) { *x = max; }
}
public: public:
FGControls(); FGControls();
@ -77,9 +82,8 @@ public:
// Update functions // Update functions
inline void set_aileron( double pos ) { inline void set_aileron( double pos ) {
aileron = pos; aileron = pos;
if ( aileron < -1.0 ) aileron = -1.0; CLAMP( &aileron, -1.0, 1.0 );
if ( aileron > 1.0 ) aileron = 1.0;
// check for autocoordination // check for autocoordination
if ( current_options.get_auto_coordination() == if ( current_options.get_auto_coordination() ==
fgOPTIONS::FG_AUTO_COORD_ENABLED ) fgOPTIONS::FG_AUTO_COORD_ENABLED )
@ -89,9 +93,8 @@ public:
} }
inline void move_aileron( double amt ) { inline void move_aileron( double amt ) {
aileron += amt; aileron += amt;
if ( aileron < -1.0 ) aileron = -1.0; CLAMP( &aileron, -1.0, 1.0 );
if ( aileron > 1.0 ) aileron = 1.0;
// check for autocoordination // check for autocoordination
if ( current_options.get_auto_coordination() == if ( current_options.get_auto_coordination() ==
fgOPTIONS::FG_AUTO_COORD_ENABLED ) fgOPTIONS::FG_AUTO_COORD_ENABLED )
@ -101,46 +104,38 @@ public:
} }
inline void set_elevator( double pos ) { inline void set_elevator( double pos ) {
elevator = pos; elevator = pos;
if ( elevator < -1.0 ) elevator = -1.0; CLAMP( &elevator, -1.0, 1.0 );
if ( elevator > 1.0 ) elevator = 1.0;
} }
inline void move_elevator( double amt ) { inline void move_elevator( double amt ) {
elevator += amt; elevator += amt;
if ( elevator < -1.0 ) elevator = -1.0; CLAMP( &elevator, -1.0, 1.0 );
if ( elevator > 1.0 ) elevator = 1.0;
} }
inline void set_elevator_trim( double pos ) { inline void set_elevator_trim( double pos ) {
elevator_trim = pos; elevator_trim = pos;
if ( elevator_trim < -1.0 ) elevator_trim = -1.0; CLAMP( &elevator_trim, -1.0, 1.0 );
if ( elevator_trim > 1.0 ) elevator_trim = 1.0;
} }
inline void move_elevator_trim( double amt ) { inline void move_elevator_trim( double amt ) {
elevator_trim += amt; elevator_trim += amt;
if ( elevator_trim < -1.0 ) elevator_trim = -1.0; CLAMP( &elevator_trim, -1.0, 1.0 );
if ( elevator_trim > 1.0 ) elevator_trim = 1.0;
} }
inline void set_rudder( double pos ) { inline void set_rudder( double pos ) {
rudder = pos; rudder = pos;
if ( rudder < -1.0 ) rudder = -1.0; CLAMP( &rudder, -1.0, 1.0 );
if ( rudder > 1.0 ) rudder = 1.0;
} }
inline void move_rudder( double amt ) { inline void move_rudder( double amt ) {
rudder += amt; rudder += amt;
if ( rudder < -1.0 ) rudder = -1.0; CLAMP( &rudder, -1.0, 1.0 );
if ( rudder > 1.0 ) rudder = 1.0;
} }
inline void set_throttle( int engine, double pos ) { inline void set_throttle( int engine, double pos ) {
if ( engine == ALL_ENGINES ) { if ( engine == ALL_ENGINES ) {
for ( int i = 0; i < MAX_ENGINES; i++ ) { for ( int i = 0; i < MAX_ENGINES; i++ ) {
throttle[i] = pos; throttle[i] = pos;
if ( throttle[i] < 0.0 ) throttle[i] = 0.0; CLAMP( &throttle[i], 0.0, 1.0 );
if ( throttle[i] > 1.0 ) throttle[i] = 1.0;
} }
} else { } else {
if ( (engine >= 0) && (engine < MAX_ENGINES) ) { if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
throttle[engine] = pos; throttle[engine] = pos;
if ( throttle[engine] < 0.0 ) throttle[engine] = 0.0; CLAMP( &throttle[engine], 0.0, 1.0 );
if ( throttle[engine] > 1.0 ) throttle[engine] = 1.0;
} }
} }
} }
@ -148,14 +143,12 @@ public:
if ( engine == ALL_ENGINES ) { if ( engine == ALL_ENGINES ) {
for ( int i = 0; i < MAX_ENGINES; i++ ) { for ( int i = 0; i < MAX_ENGINES; i++ ) {
throttle[i] += amt; throttle[i] += amt;
if ( throttle[i] < 0.0 ) throttle[i] = 0.0; CLAMP( &throttle[i], 0.0, 1.0 );
if ( throttle[i] > 1.0 ) throttle[i] = 1.0;
} }
} else { } else {
if ( (engine >= 0) && (engine < MAX_ENGINES) ) { if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
throttle[engine] += amt; throttle[engine] += amt;
if ( throttle[engine] < 0.0 ) throttle[engine] = 0.0; CLAMP( &throttle[engine], 0.0, 1.0 );
if ( throttle[engine] > 1.0 ) throttle[engine] = 1.0;
} }
} }
} }
@ -163,14 +156,12 @@ public:
if ( wheel == ALL_WHEELS ) { if ( wheel == ALL_WHEELS ) {
for ( int i = 0; i < MAX_WHEELS; i++ ) { for ( int i = 0; i < MAX_WHEELS; i++ ) {
brake[i] = pos; brake[i] = pos;
if ( brake[i] < 0.0 ) brake[i] = 0.0; CLAMP( &brake[i], 0.0, 1.0 );
if ( brake[i] > 1.0 ) brake[i] = 1.0;
} }
} else { } else {
if ( (wheel >= 0) && (wheel < MAX_WHEELS) ) { if ( (wheel >= 0) && (wheel < MAX_WHEELS) ) {
brake[wheel] = pos; brake[wheel] = pos;
if ( brake[wheel] < 0.0 ) brake[wheel] = 0.0; CLAMP( &brake[wheel], 0.0, 1.0 );
if ( brake[wheel] > 1.0 ) brake[wheel] = 1.0;
} }
} }
} }
@ -178,14 +169,12 @@ public:
if ( wheel == ALL_WHEELS ) { if ( wheel == ALL_WHEELS ) {
for ( int i = 0; i < MAX_WHEELS; i++ ) { for ( int i = 0; i < MAX_WHEELS; i++ ) {
brake[i] += amt; brake[i] += amt;
if ( brake[i] < 0.0 ) brake[i] = 0.0; CLAMP( &brake[i], 0.0, 1.0 );
if ( brake[i] > 1.0 ) brake[i] = 1.0;
} }
} else { } else {
if ( (wheel >= 0) && (wheel < MAX_WHEELS) ) { if ( (wheel >= 0) && (wheel < MAX_WHEELS) ) {
brake[wheel] += amt; brake[wheel] += amt;
if ( brake[wheel] < 0.0 ) brake[wheel] = 0.0; CLAMP( &brake[wheel], 0.0, 1.0 );
if ( brake[wheel] > 1.0 ) brake[wheel] = 1.0;
} }
} }
} }

View file

@ -360,9 +360,9 @@ int fgLaRCsim_2_FGInterface (FGInterface& f) {
// f.set_Cos_beta( Cos_beta ); // f.set_Cos_beta( Cos_beta );
// f.set_Sin_beta( Sin_beta ); // f.set_Sin_beta( Sin_beta );
// f.set_Cos_phi( Cos_phi ); f.set_Cos_phi( Cos_phi );
// f.set_Sin_phi( Sin_phi ); // f.set_Sin_phi( Sin_phi );
// f.set_Cos_theta( Cos_theta ); f.set_Cos_theta( Cos_theta );
// f.set_Sin_theta( Sin_theta ); // f.set_Sin_theta( Sin_theta );
// f.set_Cos_psi( Cos_psi ); // f.set_Cos_psi( Cos_psi );
// f.set_Sin_psi( Sin_psi ); // f.set_Sin_psi( Sin_psi );

View file

@ -665,12 +665,12 @@ public:
// inline void set_Sin_beta( double sb ) { sin_beta = sb; } // inline void set_Sin_beta( double sb ) { sin_beta = sb; }
double cos_phi, sin_phi, cos_theta, sin_theta, cos_psi, sin_psi; double cos_phi, sin_phi, cos_theta, sin_theta, cos_psi, sin_psi;
// inline double get_Cos_phi() const { return cos_phi; } inline double get_Cos_phi() const { return cos_phi; }
// inline void set_Cos_phi( double cp ) { cos_phi = cp; } inline void set_Cos_phi( double cp ) { cos_phi = cp; }
// inline double get_Sin_phi() const { return sin_phi; } // inline double get_Sin_phi() const { return sin_phi; }
// inline void set_Sin_phi( double sp ) { sin_phi = sp; } // inline void set_Sin_phi( double sp ) { sin_phi = sp; }
// inline double get_Cos_theta() const { return cos_theta; } inline double get_Cos_theta() const { return cos_theta; }
// inline void set_Cos_theta( double ct ) { cos_theta = ct; } inline void set_Cos_theta( double ct ) { cos_theta = ct; }
// inline double get_Sin_theta() const { return sin_theta; } // inline double get_Sin_theta() const { return sin_theta; }
// inline void set_Sin_theta( double st ) { sin_theta = st; } // inline void set_Sin_theta( double st ) { sin_theta = st; }
// inline double get_Cos_psi() const { return cos_psi; } // inline double get_Cos_psi() const { return cos_psi; }

View file

@ -208,7 +208,11 @@ int fgJoystickRead( void ) {
((-js_ax0[2] + 1) / 2) ); ((-js_ax0[2] + 1) / 2) );
} }
if ( js0->getNumAxes() > 3 ) { 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 // End of William's code
@ -216,7 +220,11 @@ int fgJoystickRead( void ) {
if ( ! js1->notWorking() ) { if ( ! js1->notWorking() ) {
js1->read( &b, js_ax1 ) ; 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 ); controls.set_throttle( FGControls::ALL_ENGINES, -js_ax1[1] * 1.05 );
} }

View file

@ -49,6 +49,7 @@
#include <Cockpit/hud.hxx> #include <Cockpit/hud.hxx>
#include <GUI/gui.h> #include <GUI/gui.h>
#include <Include/fg_constants.h> #include <Include/fg_constants.h>
#include <Misc/fgpath.hxx>
#include <Scenery/tilemgr.hxx> #include <Scenery/tilemgr.hxx>
#include <Objects/materialmgr.hxx> #include <Objects/materialmgr.hxx>
#include <Time/fg_time.hxx> #include <Time/fg_time.hxx>
@ -286,15 +287,27 @@ void GLUTkey(unsigned char k, int x, int y) {
return; return;
case 112: // p key case 112: // p key
t->togglePauseMode(); t->togglePauseMode();
// printf position and attitude information
FG_LOG( FG_INPUT, FG_INFO, {
"Lon = " << f->get_Longitude() * RAD_TO_DEG FGBucket p( f->get_Longitude() * RAD_TO_DEG,
<< " Lat = " << f->get_Latitude() * RAD_TO_DEG f->get_Latitude() * RAD_TO_DEG );
<< " Altitude = " << f->get_Altitude() * FEET_TO_METER ); FGPath tile_path( current_options.get_fg_root() );
FG_LOG( FG_INPUT, FG_INFO, tile_path.append( "Scenery" );
"Heading = " << f->get_Psi() * RAD_TO_DEG tile_path.append( p.gen_base_path() );
<< " Roll = " << f->get_Phi() * RAD_TO_DEG tile_path.append( p.gen_index_str() );
<< " Pitch = " << f->get_Theta() * RAD_TO_DEG );
// printf position and attitude information
FG_LOG( FG_INPUT, FG_INFO,
"Lon = " << f->get_Longitude() * RAD_TO_DEG
<< " Lat = " << f->get_Latitude() * RAD_TO_DEG
<< " Altitude = " << f->get_Altitude() * FEET_TO_METER
);
FG_LOG( FG_INPUT, FG_INFO,
"Heading = " << f->get_Psi() * RAD_TO_DEG
<< " Roll = " << f->get_Phi() * RAD_TO_DEG
<< " Pitch = " << f->get_Theta() * RAD_TO_DEG );
FG_LOG( FG_INPUT, FG_INFO, tile_path.c_str());
}
return; return;
case 116: // t key case 116: // t key
t->adjust_warp_delta (+30); t->adjust_warp_delta (+30);

View file

@ -944,11 +944,14 @@ void fgReshape( int width, int height ) {
ssgSetFOV( x_fov, y_fov ); ssgSetFOV( x_fov, y_fov );
glViewport ( 0, 0, width, height ); glViewport ( 0, 0, width, height );
float fov = current_options.get_fov();
ssgSetFOV(fov * current_view.get_win_ratio(), fov);
if ( idle_state == 1000 ) { if ( idle_state == 1000 ) {
// yes we've finished all our initializations and are running // yes we've finished all our initializations and are running
// the main loop, so this will now work without seg faulting // the main loop, so this will now work without seg faulting
// the system. // the system.
solarSystemRebuild();
current_view.UpdateViewParams(cur_fdm_state); current_view.UpdateViewParams(cur_fdm_state);
if ( current_options.get_panel_status() ) { if ( current_options.get_panel_status() ) {
FGPanel::OurPanel->ReInit(0, 0, 1024, 768); FGPanel::OurPanel->ReInit(0, 0, 1024, 768);