]> git.mxchange.org Git - flightgear.git/commitdiff
Updates by norman vine to controls.hxx.
authorcurt <curt>
Sat, 9 Oct 1999 13:09:16 +0000 (13:09 +0000)
committercurt <curt>
Sat, 9 Oct 1999 13:09:16 +0000 (13:09 +0000)
Joystick auto-coordination tweaks.
Additional debuging output when pausing and resuming the sim.
Window resizing tweaks by David Megginson (and Norman Vine).

src/Controls/controls.hxx
src/FDM/LaRCsim.cxx
src/FDM/flight.hxx
src/Joystick/joystick.cxx
src/Main/keyboard.cxx
src/Main/main.cxx

index 690e9b11c6be30a5a595e876c26ee6ab556dad86..3aff6ba2a3fe417d19b62ee8275fa4da51d6ae8a 100644 (file)
@@ -58,6 +58,11 @@ private:
     double throttle[MAX_ENGINES];
     double brake[MAX_WHEELS];
 
+    inline void CLAMP(double *x, double min, double max ) {
+       if ( *x < min ) { *x = min; }
+       if ( *x > max ) { *x = max; }
+    }
+               
 public:
 
     FGControls();
@@ -77,9 +82,8 @@ public:
     // Update functions
     inline void set_aileron( double pos ) {
        aileron = pos;
-       if ( aileron < -1.0 ) aileron = -1.0;
-       if ( aileron >  1.0 ) aileron =  1.0;
-
+       CLAMP( &aileron, -1.0, 1.0 );
+                       
        // check for autocoordination
        if ( current_options.get_auto_coordination() == 
             fgOPTIONS::FG_AUTO_COORD_ENABLED ) 
@@ -89,9 +93,8 @@ public:
     }
     inline void move_aileron( double amt ) {
        aileron += amt;
-       if ( aileron < -1.0 ) aileron = -1.0;
-       if ( aileron >  1.0 ) aileron =  1.0;
-
+       CLAMP( &aileron, -1.0, 1.0 );
+                       
        // check for autocoordination
        if ( current_options.get_auto_coordination() == 
             fgOPTIONS::FG_AUTO_COORD_ENABLED ) 
@@ -101,46 +104,38 @@ public:
     }
     inline void set_elevator( double pos ) {
        elevator = pos;
-       if ( elevator < -1.0 ) elevator = -1.0;
-       if ( elevator >  1.0 ) elevator =  1.0;
+       CLAMP( &elevator, -1.0, 1.0 );
     }
     inline void move_elevator( double amt ) {
        elevator += amt;
-       if ( elevator < -1.0 ) elevator = -1.0;
-       if ( elevator >  1.0 ) elevator =  1.0;
+       CLAMP( &elevator, -1.0, 1.0 );
     }
     inline void set_elevator_trim( double pos ) {
        elevator_trim = pos;
-       if ( elevator_trim < -1.0 ) elevator_trim = -1.0;
-       if ( elevator_trim >  1.0 ) elevator_trim =  1.0;
+       CLAMP( &elevator_trim, -1.0, 1.0 );
     }
     inline void move_elevator_trim( double amt ) {
        elevator_trim += amt;
-       if ( elevator_trim < -1.0 ) elevator_trim = -1.0;
-       if ( elevator_trim >  1.0 ) elevator_trim =  1.0;
+       CLAMP( &elevator_trim, -1.0, 1.0 );
     }
     inline void set_rudder( double pos ) {
        rudder = pos;
-       if ( rudder < -1.0 ) rudder = -1.0;
-       if ( rudder >  1.0 ) rudder =  1.0;
+       CLAMP( &rudder, -1.0, 1.0 );
     }
     inline void move_rudder( double amt ) {
        rudder += amt;
-       if ( rudder < -1.0 ) rudder = -1.0;
-       if ( rudder >  1.0 ) rudder =  1.0;
+       CLAMP( &rudder, -1.0, 1.0 );
     }
     inline void set_throttle( int engine, double pos ) {
        if ( engine == ALL_ENGINES ) {
            for ( int i = 0; i < MAX_ENGINES; i++ ) {
                throttle[i] = pos;
-               if ( throttle[i] < 0.0 ) throttle[i] = 0.0;
-               if ( throttle[i] >  1.0 ) throttle[i] =  1.0;
+               CLAMP( &throttle[i], 0.0, 1.0 );
            }
        } else {
            if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
                throttle[engine] = pos;
-               if ( throttle[engine] < 0.0 ) throttle[engine] = 0.0;
-               if ( throttle[engine] >  1.0 ) throttle[engine] =  1.0;
+               CLAMP( &throttle[engine], 0.0, 1.0 );
            }
        }
     }
@@ -148,14 +143,12 @@ public:
        if ( engine == ALL_ENGINES ) {
            for ( int i = 0; i < MAX_ENGINES; i++ ) {
                throttle[i] += amt;
-               if ( throttle[i] < 0.0 ) throttle[i] = 0.0;
-               if ( throttle[i] >  1.0 ) throttle[i] =  1.0;
+               CLAMP( &throttle[i], 0.0, 1.0 );
            }
        } else {
            if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
                throttle[engine] += amt;
-               if ( throttle[engine] < 0.0 ) throttle[engine] = 0.0;
-               if ( throttle[engine] >  1.0 ) throttle[engine] =  1.0;
+               CLAMP( &throttle[engine], 0.0, 1.0 );
            }
        }
     }
@@ -163,14 +156,12 @@ public:
        if ( wheel == ALL_WHEELS ) {
            for ( int i = 0; i < MAX_WHEELS; i++ ) {
                brake[i] = pos;
-               if ( brake[i] < 0.0 ) brake[i] = 0.0;
-               if ( brake[i] >  1.0 ) brake[i] =  1.0;
+               CLAMP( &brake[i], 0.0, 1.0 );
            }
        } else {
            if ( (wheel >= 0) && (wheel < MAX_WHEELS) ) {
                brake[wheel] = pos;
-               if ( brake[wheel] < 0.0 ) brake[wheel] = 0.0;
-               if ( brake[wheel] >  1.0 ) brake[wheel] =  1.0;
+               CLAMP( &brake[wheel], 0.0, 1.0 );
            }
        }
     }
@@ -178,14 +169,12 @@ public:
        if ( wheel == ALL_WHEELS ) {
            for ( int i = 0; i < MAX_WHEELS; i++ ) {
                brake[i] += amt;
-               if ( brake[i] < 0.0 ) brake[i] = 0.0;
-               if ( brake[i] >  1.0 ) brake[i] =  1.0;
+               CLAMP( &brake[i], 0.0, 1.0 );
            }
        } else {
            if ( (wheel >= 0) && (wheel < MAX_WHEELS) ) {
                brake[wheel] += amt;
-               if ( brake[wheel] < 0.0 ) brake[wheel] = 0.0;
-               if ( brake[wheel] >  1.0 ) brake[wheel] =  1.0;
+               CLAMP( &brake[wheel], 0.0, 1.0 );
            }
        }
     }
index 66b8a9cbb9a8db1c4f936e9f5c30962d4dbc8d6e..7602bb5d879f55ab171e7219d861c597ad51844d 100644 (file)
@@ -360,9 +360,9 @@ int fgLaRCsim_2_FGInterface (FGInterface& f) {
     // f.set_Cos_beta( Cos_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_Cos_theta( Cos_theta );
+    f.set_Cos_theta( Cos_theta );
     // f.set_Sin_theta( Sin_theta );
     // f.set_Cos_psi( Cos_psi );
     // f.set_Sin_psi( Sin_psi );
index 2e3d793942f0aeb93465bd96399ca6418a43628c..529a320ca8f237ee52dcd0fedb8e73d61c6d905d 100644 (file)
@@ -665,12 +665,12 @@ public:
     // inline void set_Sin_beta( double sb ) { sin_beta = sb; }
 
     double    cos_phi, sin_phi, cos_theta, sin_theta, cos_psi, sin_psi;
-    // inline double get_Cos_phi() const { return cos_phi; }
-    // inline void set_Cos_phi( double cp ) { cos_phi = cp; }
+    inline double get_Cos_phi() const { return cos_phi; }
+    inline void set_Cos_phi( double cp ) { cos_phi = cp; }
     // inline double get_Sin_phi() const { return sin_phi; }
     // inline void set_Sin_phi( double sp ) { sin_phi = sp; }
-    // inline double get_Cos_theta() const { return cos_theta; }
-    // inline void set_Cos_theta( double ct ) { cos_theta = ct; }
+    inline double get_Cos_theta() const { return cos_theta; }
+    inline void set_Cos_theta( double ct ) { cos_theta = ct; }
     // inline double get_Sin_theta() const { return sin_theta; }
     // inline void set_Sin_theta( double st ) { sin_theta = st; }
     // inline double get_Cos_psi() const { return cos_psi; }
index 1f766e363dbea08bcf78ad89b2dedb967f270809..35cd5951e33520ba11022d4da16594eb4c07189b 100644 (file)
@@ -208,7 +208,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
 
@@ -216,7 +220,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 );
     }
 
index 5063874d0ff9d90267e9ea000e254d63f72f6294..67296cab57d35b9144f235b0d5fa5f40413007d1 100644 (file)
@@ -49,6 +49,7 @@
 #include <Cockpit/hud.hxx>
 #include <GUI/gui.h>
 #include <Include/fg_constants.h>
+#include <Misc/fgpath.hxx>
 #include <Scenery/tilemgr.hxx>
 #include <Objects/materialmgr.hxx>
 #include <Time/fg_time.hxx>
@@ -286,15 +287,27 @@ void GLUTkey(unsigned char k, int x, int y) {
            return;
        case 112: // p key
            t->togglePauseMode();
-           // 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 );
+
+           {
+               FGBucket p( f->get_Longitude() * RAD_TO_DEG,
+                           f->get_Latitude() * RAD_TO_DEG );
+               FGPath tile_path( current_options.get_fg_root() );
+               tile_path.append( "Scenery" );
+               tile_path.append( p.gen_base_path() );
+               tile_path.append( p.gen_index_str() );
+
+               // 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;
        case 116: // t key
            t->adjust_warp_delta (+30);
index 60f26a42422da4ce4e7b40d1f2cfacbf7b27c428..00623bbf6d5637f41e20378c4127d7bd529aface 100644 (file)
@@ -944,11 +944,14 @@ void fgReshape( int width, int height ) {
     ssgSetFOV( x_fov, y_fov );
 
     glViewport ( 0, 0, width, height );
+    float fov = current_options.get_fov();
+    ssgSetFOV(fov * current_view.get_win_ratio(), fov);
 
     if ( idle_state == 1000 ) {
        // yes we've finished all our initializations and are running
        // the main loop, so this will now work without seg faulting
        // the system.
+       solarSystemRebuild();
        current_view.UpdateViewParams(cur_fdm_state);
        if ( current_options.get_panel_status() ) {
            FGPanel::OurPanel->ReInit(0, 0, 1024, 768);