]> git.mxchange.org Git - flightgear.git/blobdiff - Main/GLUTkey.cxx
Converted fgFLIGHT to a class.
[flightgear.git] / Main / GLUTkey.cxx
index ebc72535e5ec2770e06f511cf70a70faeed8092e..edd0559e870cb8d08c0c8aae4a36b5c26cbb1453 100644 (file)
@@ -40,7 +40,7 @@
 #include <Astro/sky.hxx>
 #include <Autopilot/autopilot.hxx>
 #include <Cockpit/hud.hxx>
-#include <Debug/fg_debug.h>
+#include <Debug/logstream.hxx>
 #include <GUI/gui.h>
 #include <Include/fg_constants.h>
 #include <Objects/material.hxx>
@@ -69,24 +69,23 @@ static void local_update_sky_and_lighting_params( void ) {
 
 // Handle keyboard events
 void GLUTkey(unsigned char k, int x, int y) {
-    fgCONTROLS *c;
     fgFLIGHT *f;
     fgTIME *t;
     fgVIEW *v;
     struct fgWEATHER *w;
     float fov, tmp;
+    static bool winding_ccw = true;
 
-    c = current_aircraft.controls;
     f = current_aircraft.flight;
     t = &cur_time_params;
     v = &current_view;
     w = &current_weather;
 
-    fgPrintf( FG_INPUT, FG_DEBUG, "Key hit = %d", k);
+    FG_LOG( FG_INPUT, FG_DEBUG, "Key hit = " << k );
     puKeyboard(k, PU_DOWN );
 
     if ( GLUT_ACTIVE_ALT && glutGetModifiers() ) {
-       fgPrintf( FG_INPUT, FG_DEBUG, " SHIFTED\n");
+       FG_LOG( FG_INPUT, FG_DEBUG, " SHIFTED" );
        switch (k) {
        case 1: // Ctrl-A key
            fgAPToggleAltitude();
@@ -94,6 +93,15 @@ void GLUTkey(unsigned char k, int x, int y) {
        case 8: // Ctrl-H key
            fgAPToggleHeading();
            return;
+       case 18: // Ctrl-R key
+           // temporary
+           winding_ccw = !winding_ccw;
+           if ( winding_ccw ) {
+               glFrontFace ( GL_CCW );
+           } else {
+               glFrontFace ( GL_CW );
+           }
+           return;
        case 19: // Ctrl-S key
            fgAPToggleAutoThrottle();
            return;
@@ -165,49 +173,49 @@ void GLUTkey(unsigned char k, int x, int y) {
            return;
        }
     } else {
-       fgPrintf( FG_INPUT, FG_DEBUG, "\n");
+       FG_LOG( FG_INPUT, FG_DEBUG, "" );
        switch (k) {
        case 50: // numeric keypad 2
-           fgElevMove(-0.05);
+           controls.move_elevator(-0.05);
            return;
        case 56: // numeric keypad 8
-           fgElevMove(0.05);
+           controls.move_elevator(0.05);
            return;
        case 49: // numeric keypad 1
-           fgElevTrimMove(-0.001);
+           controls.move_elevator_trim(-0.001);
            return;
        case 55: // numeric keypad 7
-           fgElevTrimMove(0.001);
+           controls.move_elevator_trim(0.001);
            return;
        case 52: // numeric keypad 4
-           fgAileronMove(-0.05);
+           controls.move_aileron(-0.05);
            return;
        case 54: // numeric keypad 6
-           fgAileronMove(0.05);
+           controls.move_aileron(0.05);
            return;
        case 48: // numeric keypad Ins
-           fgRudderMove(-0.05);
+           controls.move_rudder(-0.05);
            return;
        case 13: // numeric keypad Enter
-           fgRudderMove(0.05);
+           controls.move_rudder(0.05);
            return;
        case 53: // numeric keypad 5
-           fgAileronSet(0.0);
-           fgElevSet(0.0);
-           fgRudderSet(0.0);
+           controls.set_aileron(0.0);
+           controls.set_elevator(0.0);
+           controls.set_rudder(0.0);
            return;
        case 57: // numeric keypad 9 (Pg Up)
-           fgThrottleMove(0, 0.01);
+           controls.move_throttle( fgCONTROLS::FG_ALL_ENGINES, 0.01 );
            return;
        case 51: // numeric keypad 3 (Pg Dn)
-           fgThrottleMove(0, -0.01);
+           controls.move_throttle( fgCONTROLS::FG_ALL_ENGINES, -0.01 );
            return;
        case 98: // b key
            int b_ret;
            double b_set;
-           b_ret = int( fgBrakeGet() );
+           b_ret = int( controls.get_brake( 0 ) );
            b_set = double(!b_ret);
-           fgBrakeSet(b_set);
+           controls.set_brake( fgCONTROLS::FG_ALL_WHEELS, b_set);
            return;
        case 104: // h key
            HUD_brightkey( false );
@@ -222,16 +230,14 @@ void GLUTkey(unsigned char k, int x, int y) {
        case 112: // p key
            t->pause = !t->pause;
            // printf position and attitude information
-           fgPrintf( FG_INPUT, FG_INFO,
-                     "Lon = %.4f  Lat = %.4f  Altitude = %.1f\n", 
-                     FG_Longitude * RAD_TO_DEG,
-                     FG_Latitude * RAD_TO_DEG,
-                     FG_Altitude * FEET_TO_METER);
-           fgPrintf( FG_INPUT, FG_INFO,
-                     "Heading = %.2f  Roll = %.2f  Pitch = %.2f\n", 
-                     FG_Psi * RAD_TO_DEG,
-                     FG_Phi * RAD_TO_DEG,
-                     FG_Theta * RAD_TO_DEG);
+           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 );
            return;
        case 116: // t key
            t->warp_delta += 30;
@@ -255,8 +261,9 @@ void GLUTkey(unsigned char k, int x, int y) {
            // if( fg_DebugOutput ) {
            //   fclose( fg_DebugOutput );
            // }
-           fgPrintf( FG_INPUT, FG_EXIT, 
-                     "Program exiting normally at user request.\n");
+           FG_LOG( FG_INPUT, FG_ALERT, 
+                   "Program exiting normally at user request." );
+           exit(-1);
        }
     }
 }
@@ -264,17 +271,15 @@ void GLUTkey(unsigned char k, int x, int y) {
 
 // Handle "special" keyboard events
 void GLUTspecialkey(int k, int x, int y) {
-    fgCONTROLS *c;
     fgVIEW *v;
 
-    c = current_aircraft.controls;
     v = &current_view;
 
-    fgPrintf( FG_INPUT, FG_DEBUG, "Special key hit = %d", k);
+    FG_LOG( FG_INPUT, FG_DEBUG, "Special key hit = " << k );
     puKeyboard(k + PU_KEY_GLUT_SPECIAL_OFFSET, PU_DOWN);
 
     if ( GLUT_ACTIVE_SHIFT && glutGetModifiers() ) {
-       fgPrintf( FG_INPUT, FG_DEBUG, " SHIFTED\n");
+       FG_LOG( FG_INPUT, FG_DEBUG, " SHIFTED" );
        switch (k) {
        case GLUT_KEY_END: // numeric keypad 1
            v->goal_view_offset = FG_PI * 0.75;
@@ -302,23 +307,23 @@ void GLUTspecialkey(int k, int x, int y) {
            return;
        }
     } else {
-        fgPrintf( FG_INPUT, FG_DEBUG, "\n");
+        FG_LOG( FG_INPUT, FG_DEBUG, "" );
        switch (k) {
        case GLUT_KEY_F8: // F8 toggles fog ... off fastest nicest...
            current_options.cycle_fog();
        
            if ( current_options.get_fog() == fgOPTIONS::FG_FOG_DISABLED ) {
-               fgPrintf( FG_INPUT, FG_INFO, "Fog disabled\n" );
+               FG_LOG( FG_INPUT, FG_INFO, "Fog disabled" );
            } else if ( current_options.get_fog() == 
                        fgOPTIONS::FG_FOG_FASTEST )
            {
-               fgPrintf( FG_INPUT, FG_INFO, 
-                         "Fog enabled, hint set to fastest\n" );
+               FG_LOG( FG_INPUT, FG_INFO, 
+                       "Fog enabled, hint set to fastest" );
            } else if ( current_options.get_fog() ==
                        fgOPTIONS::FG_FOG_NICEST )
            {
-               fgPrintf( FG_INPUT, FG_INFO,
-                         "Fog enabled, hint set to nicest\n" );
+               FG_LOG( FG_INPUT, FG_INFO,
+                       "Fog enabled, hint set to nicest" );
            }
 
            return;
@@ -327,53 +332,53 @@ void GLUTspecialkey(int k, int x, int y) {
                current_options.get_textures() ?
                    current_options.set_textures(false) :
                    current_options.set_textures(true);
-               fgPrintf( FG_INPUT, FG_INFO, "Toggling texture\n" );
+               FG_LOG( FG_INPUT, FG_INFO, "Toggling texture" );
            } else {
-               fgPrintf( FG_INPUT, FG_INFO, 
-                         "No textures loaded, cannot toggle\n" );
+               FG_LOG( FG_INPUT, FG_INFO, 
+                       "No textures loaded, cannot toggle" );
            }
            return;
        case GLUT_KEY_F10: // F10 toggles menu on and off...
-           fgPrintf(FG_INPUT, FG_INFO, "Invoking call back function");
+           FG_LOG(FG_INPUT, FG_INFO, "Invoking call back function");
            hideMenuButton -> 
                setValue ((int) !(hideMenuButton -> getValue() ) );
            hideMenuButton -> invokeCallback();
            //exit(1);
            return;
        case GLUT_KEY_UP:
-           fgElevMove(0.05);
+           controls.move_elevator(0.05);
            return;
        case GLUT_KEY_DOWN:
-           fgElevMove(-0.05);
+           controls.move_elevator(-0.05);
            return;
        case GLUT_KEY_LEFT:
-           fgAileronMove(-0.05);
+           controls.move_aileron(-0.05);
            return;
        case GLUT_KEY_RIGHT:
-           fgAileronMove(0.05);
+           controls.move_aileron(0.05);
            return;
        case GLUT_KEY_HOME: // numeric keypad 1
-           fgElevTrimMove(0.001);
+           controls.move_elevator_trim(0.001);
            return;
        case GLUT_KEY_END: // numeric keypad 7
-           fgElevTrimMove(-0.001);
+           controls.move_elevator_trim(-0.001);
            return;
        case GLUT_KEY_INSERT: // numeric keypad Ins
-           fgRudderMove(-0.05);
+           controls.move_rudder(-0.05);
            return;
        case 13: // numeric keypad Enter
-           fgRudderMove(0.05);
+           controls.move_rudder(0.05);
            return;
        case 53: // numeric keypad 5
-           fgAileronSet(0.0);
-           fgElevSet(0.0);
-           fgRudderSet(0.0);
+           controls.set_aileron(0.0);
+           controls.set_elevator(0.0);
+           controls.set_rudder(0.0);
            return;
        case GLUT_KEY_PAGE_UP: // numeric keypad 9 (Pg Up)
-           fgThrottleMove(0, 0.01);
+           controls.move_throttle( fgCONTROLS::FG_ALL_ENGINES, 0.01 );
            return;
        case GLUT_KEY_PAGE_DOWN: // numeric keypad 3 (Pg Dn)
-           fgThrottleMove(0, -0.01);
+           controls.move_throttle( fgCONTROLS::FG_ALL_ENGINES, -0.01 );
            return;
        }
     }
@@ -381,6 +386,25 @@ void GLUTspecialkey(int k, int x, int y) {
 
 
 // $Log$
+// Revision 1.33  1998/12/03 01:17:12  curt
+// Converted fgFLIGHT to a class.
+//
+// Revision 1.32  1998/11/06 21:18:06  curt
+// Converted to new logstream debugging facility.  This allows release
+// builds with no messages at all (and no performance impact) by using
+// the -DFG_NDEBUG flag.
+//
+// Revision 1.31  1998/11/02 18:25:37  curt
+// Check for __CYGWIN__ (b20) as well as __CYGWIN32__ (pre b20 compilers)
+// Other misc. tweaks.
+//
+// Revision 1.30  1998/10/25 14:08:46  curt
+// Turned "struct fgCONTROLS" into a class, with inlined accessor functions.
+//
+// Revision 1.29  1998/10/20 14:58:57  curt
+// Ctrl-R now reverses default polygon winding so I can see if a hole in the
+// terrain is a result of improper winding, or if it is just an empty hole.
+//
 // Revision 1.28  1998/10/17 01:34:20  curt
 // C++ ifying ...
 //