]> git.mxchange.org Git - flightgear.git/blob - src/Main/keyboard.cxx
Some changes contributed by David Megginson to allow for more interesting
[flightgear.git] / src / Main / keyboard.cxx
1 // keyboard.cxx -- handle GLUT keyboard events
2 //
3 // Written by Curtis Olson, started May 1997.
4 //
5 // Copyright (C) 1997 - 1999  Curtis L. Olson  - curt@flightgear.org
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 //
21 // $Id$
22
23
24 #ifdef HAVE_CONFIG_H
25 #  include <config.h>
26 #endif
27
28 #ifdef HAVE_WINDOWS_H
29 #  include <windows.h>                     
30 #endif
31
32 #include <simgear/compiler.h>
33
34 #include <GL/glut.h>
35 #include <simgear/xgl/xgl.h>
36
37 #if defined(FX) && defined(XMESA)
38 #include <GL/xmesa.h>
39 #endif
40
41 #include <stdio.h>
42 #include <stdlib.h>
43
44 #include STL_FSTREAM
45
46 #include <plib/pu.h>            // plib include
47
48 #include <simgear/constants.h>
49 #include <simgear/debug/logstream.hxx>
50 #include <simgear/misc/fgpath.hxx>
51
52 #include <Aircraft/aircraft.hxx>
53 #include <Autopilot/auto_gui.hxx>
54 #include <Autopilot/newauto.hxx>
55 #include <Cockpit/hud.hxx>
56 #include <Cockpit/panel.hxx>
57 #include <Cockpit/panel_io.hxx>
58 #include <GUI/gui.h>
59 #include <Scenery/tilemgr.hxx>
60 #include <Objects/matlib.hxx>
61 #include <Time/light.hxx>
62 #include <Time/tmp.hxx>
63
64 #ifndef FG_OLD_WEATHER
65 #  include <WeatherCM/FGLocalWeatherDatabase.h>
66 #else
67 #  include <Weather/weather.hxx>
68 #endif
69
70 #include "bfi.hxx"
71 #include "globals.hxx"
72 #include "keyboard.hxx"
73 #include "options.hxx"
74 #include "save.hxx"
75 #include "views.hxx"
76
77                                 // From main.cxx
78 extern void fgReshape( int width, int height );
79
80
81 // Handle keyboard events
82 void GLUTkey(unsigned char k, int x, int y) {
83     FGInterface *f;
84     SGTime *t;
85     FGView *v;
86     float fov, tmp;
87     static bool winding_ccw = true;
88     int speed;
89
90     f = current_aircraft.fdm_state;
91     v = &current_view;
92
93     FG_LOG( FG_INPUT, FG_DEBUG, "Key hit = " << k );
94     if ( puKeyboard(k, PU_DOWN) ) {
95         return;
96     }
97
98     if ( GLUT_ACTIVE_ALT && glutGetModifiers() ) {
99         FG_LOG( FG_INPUT, FG_DEBUG, " SHIFTED" );
100         switch (k) {
101         case 1: // Ctrl-A key
102             current_autopilot->set_AltitudeMode( 
103                   FGAutopilot::FG_ALTITUDE_LOCK );
104             current_autopilot->set_AltitudeEnabled(
105                   ! current_autopilot->get_AltitudeEnabled()
106                 );
107             return;
108         case 7: // Ctrl-G key
109             current_autopilot->set_AltitudeMode( 
110                   FGAutopilot::FG_ALTITUDE_GS1 );
111             current_autopilot->set_AltitudeEnabled(
112                   ! current_autopilot->get_AltitudeEnabled()
113                 );
114             return;
115         case 8: // Ctrl-H key
116             current_autopilot->set_HeadingMode( 
117                   FGAutopilot::FG_HEADING_LOCK );
118             current_autopilot->set_HeadingEnabled(
119                   ! current_autopilot->get_HeadingEnabled()
120                 );
121             return;
122         case 14: // Ctrl-N key
123             current_autopilot->set_HeadingMode( 
124                   FGAutopilot::FG_HEADING_NAV1 );
125             current_autopilot->set_HeadingEnabled(
126                   ! current_autopilot->get_HeadingEnabled()
127                 );
128             return;
129         case 18: // Ctrl-R key
130             // temporary
131             winding_ccw = !winding_ccw;
132             if ( winding_ccw ) {
133                 glFrontFace ( GL_CCW );
134             } else {
135                 glFrontFace ( GL_CW );
136             }
137             return;
138         case 19: // Ctrl-S key
139             current_autopilot->set_AutoThrottleEnabled(
140                   ! current_autopilot->get_AutoThrottleEnabled()
141                 );
142             return;
143         case 20: // Ctrl-T key
144             current_autopilot->set_AltitudeMode( 
145                   FGAutopilot::FG_ALTITUDE_TERRAIN );
146             current_autopilot->set_AltitudeEnabled(
147                   ! current_autopilot->get_AltitudeEnabled()
148                 );
149             return;
150         case 21: // Ctrl-U key
151             // add 1000' of emergency altitude.  Possibly good for 
152             // unflipping yourself :-)
153             {
154                 double alt = cur_fdm_state->get_Altitude() + 1000;
155                 fgFDMForceAltitude( current_options.get_flight_model(), 
156                                     alt * FEET_TO_METER );
157             }
158             return;
159         case 49: // numeric keypad 1
160             v->set_goal_view_offset( FG_PI * 0.75 );
161             if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
162               pilot_view.set_pilot_offset(-25.0, 25.0, 1.0);
163               v->set_view_offset( FG_PI * 0.75 );
164             }
165             return;
166         case 50: // numeric keypad 2
167             v->set_goal_view_offset( FG_PI );
168             if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
169               pilot_view.set_pilot_offset(-25.0, 0.0, 1.0);
170               v->set_view_offset( FG_PI );
171             }
172             return;
173         case 51: // numeric keypad 3
174             v->set_goal_view_offset( FG_PI * 1.25 );
175             if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
176               pilot_view.set_pilot_offset(-25.0, -25.0, 1.0);
177               v->set_view_offset( FG_PI * 1.25 );
178             }
179             return;
180         case 52: // numeric keypad 4
181             v->set_goal_view_offset( FG_PI * 0.50 );
182             if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
183               pilot_view.set_pilot_offset(0.0, 25.0, 1.0);
184               v->set_view_offset( FG_PI * 0.50 );
185             }
186             return;
187         case 54: // numeric keypad 6
188             v->set_goal_view_offset( FG_PI * 1.50 );
189             if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
190               pilot_view.set_pilot_offset(0.0, -25.0, 1.0);
191               v->set_view_offset( FG_PI * 1.50 );
192             }
193             return;
194         case 55: // numeric keypad 7
195             v->set_goal_view_offset( FG_PI * 0.25 );
196             if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
197               pilot_view.set_pilot_offset(25.0, 25.0, 1.0);
198               v->set_view_offset( FG_PI * 0.25 );
199             }
200             return;
201         case 56: // numeric keypad 8
202             v->set_goal_view_offset( 0.00 );
203             if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
204               pilot_view.set_pilot_offset(25.0, 0.0, 1.0);
205               v->set_view_offset( 0.00 );
206             }
207             return;
208         case 57: // numeric keypad 9
209             v->set_goal_view_offset( FG_PI * 1.75 );
210             if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
211               pilot_view.set_pilot_offset(25.0, -25.0, 1.0);
212               v->set_view_offset( FG_PI * 1.75 );
213             }
214             return;
215         case 65: // A key
216             speed = current_options.get_speed_up();
217             speed--;
218             if ( speed < 1 ) {
219                 speed = 1;
220             }
221             current_options.set_speed_up( speed );
222             return;
223         case 72: // H key
224             // status = current_options.get_hud_status();
225             // current_options.set_hud_status(!status);
226             HUD_brightkey( true );
227             return;
228         case 73: // I key
229             // Minimal Hud
230             fgHUDInit2(&current_aircraft);
231             return;
232         case 77: // M key
233             globals->inc_warp( -60 );
234             fgUpdateSkyAndLightingParams();
235             return;
236         case 80: // P key
237             current_options.toggle_panel();
238             break;
239         case 84: // T key
240             globals->inc_warp_delta( -30 );
241             fgUpdateSkyAndLightingParams();
242             return;
243         case 87: // W key
244 #if defined(FX) && !defined(WIN32)
245             global_fullscreen = ( !global_fullscreen );
246 #  if defined(XMESA_FX_FULLSCREEN) && defined(XMESA_FX_WINDOW)
247             XMesaSetFXmode( global_fullscreen ? 
248                             XMESA_FX_FULLSCREEN : XMESA_FX_WINDOW );
249 #  endif
250 #endif
251             return;
252         case 88: // X key
253             fov = current_options.get_fov();
254             fov *= 1.05;
255             if ( fov > FG_FOV_MAX ) {
256                 fov = FG_FOV_MAX;
257             }
258             current_options.set_fov(fov);
259             v->force_update_fov_math();
260             return;
261         case 90: // Z key
262 #ifndef FG_OLD_WEATHER
263             tmp = WeatherDatabase->getWeatherVisibility();
264             tmp /= 1.10;
265             WeatherDatabase->setWeatherVisibility( tmp );
266 #else
267             tmp = current_weather.get_visibility();   // in meters
268             tmp /= 1.10;
269             current_weather.set_visibility( tmp );
270 #endif
271             return;
272         }
273     } else {
274         FG_LOG( FG_INPUT, FG_DEBUG, "" );
275         switch (k) {
276         case 50: // numeric keypad 2
277             if ( current_autopilot->get_AltitudeEnabled() ) {
278                 current_autopilot->AltitudeAdjust( 100 );
279             } else {
280                 controls.move_elevator(-0.05);
281             }
282             return;
283         case 56: // numeric keypad 8
284             if ( current_autopilot->get_AltitudeEnabled() ) {
285                 current_autopilot->AltitudeAdjust( -100 );
286             } else {
287                 controls.move_elevator(0.05);
288             }
289             return;
290         case 49: // numeric keypad 1
291             controls.move_elevator_trim(-0.001);
292             return;
293         case 55: // numeric keypad 7
294             controls.move_elevator_trim(0.001);
295             return;
296         case 52: // numeric keypad 4
297             controls.move_aileron(-0.05);
298             return;
299         case 54: // numeric keypad 6
300             controls.move_aileron(0.05);
301             return;
302         case 48: // numeric keypad Ins
303             if ( current_autopilot->get_HeadingEnabled() ) {
304                 current_autopilot->HeadingAdjust( -1 );
305             } else {
306                 controls.move_rudder(-0.05);
307             }
308             return;
309         case 13: // numeric keypad Enter
310             if ( current_autopilot->get_HeadingEnabled() ) {
311                 current_autopilot->HeadingAdjust( 1 );
312             } else {
313                 controls.move_rudder(0.05);
314             }
315             return;
316         case 53: // numeric keypad 5
317             controls.set_aileron(0.0);
318             controls.set_elevator(0.0);
319             controls.set_rudder(0.0);
320             return;
321         case 57: // numeric keypad 9 (Pg Up)
322             if ( current_autopilot->get_AutoThrottleEnabled() ) {
323                 current_autopilot->AutoThrottleAdjust( 5 );
324             } else {
325                 controls.move_throttle( FGControls::ALL_ENGINES, 0.01 );
326             }
327             return;
328         case 51: // numeric keypad 3 (Pg Dn)
329             if ( current_autopilot->get_AutoThrottleEnabled() ) {
330                 current_autopilot->AutoThrottleAdjust( -5 );
331             } else {
332                 controls.move_throttle( FGControls::ALL_ENGINES, -0.01 );
333             }
334             return;
335         case 91: // [ key
336             controls.move_flaps(-0.34);
337             FG_LOG( FG_INPUT, FG_INFO,
338                     "Set flaps to " << controls.get_flaps() );
339             return;
340         case 93: // ] key
341             controls.move_flaps(0.34);
342             FG_LOG( FG_INPUT, FG_INFO,
343                     "Set flaps to " << controls.get_flaps() );
344             return;
345         case 97: // a key
346             speed = current_options.get_speed_up();
347             speed++;
348             current_options.set_speed_up( speed );
349             return;
350         case 98: // b key
351             int b_ret;
352             double b_set;
353             b_ret = int( controls.get_brake( 0 ) );
354             b_set = double(!b_ret);
355             controls.set_brake( FGControls::ALL_WHEELS, b_set);
356             return;
357         case 44: // , key
358             if (controls.get_brake(0) > 0.0) {
359                 controls.set_brake(0, 0.0);
360             } else {
361                 controls.set_brake(0, 1.0);
362             }
363             return;
364         case 46: // . key
365             if (controls.get_brake(1) > 0.0) {
366                 controls.set_brake(1, 0.0);
367             } else {
368                 controls.set_brake(1, 1.0);
369             }
370             return;
371         case 104: // h key
372             HUD_masterswitch( true );
373             return;
374         case 105: // i key
375             fgHUDInit(&current_aircraft);  // normal HUD
376             return;
377         case 109: // m key
378             globals->inc_warp( 60 );
379             fgUpdateSkyAndLightingParams();
380             return;
381         case 112: // p key
382             globals->set_freeze( ! globals->get_freeze() );
383
384             {
385                 FGBucket p( f->get_Longitude() * RAD_TO_DEG,
386                             f->get_Latitude() * RAD_TO_DEG );
387                 FGPath tile_path( current_options.get_fg_root() );
388                 tile_path.append( "Scenery" );
389                 tile_path.append( p.gen_base_path() );
390                 tile_path.append( p.gen_index_str() );
391
392                 // printf position and attitude information
393                 FG_LOG( FG_INPUT, FG_INFO,
394                         "Lon = " << f->get_Longitude() * RAD_TO_DEG
395                         << "  Lat = " << f->get_Latitude() * RAD_TO_DEG
396                         << "  Altitude = " << f->get_Altitude() * FEET_TO_METER
397                         );
398                 FG_LOG( FG_INPUT, FG_INFO,
399                         "Heading = " << f->get_Psi() * RAD_TO_DEG 
400                         << "  Roll = " << f->get_Phi() * RAD_TO_DEG
401                         << "  Pitch = " << f->get_Theta() * RAD_TO_DEG );
402                 FG_LOG( FG_INPUT, FG_INFO, tile_path.c_str());
403             }
404             return;
405         case 116: // t key
406             globals->inc_warp_delta( 30 );
407             fgUpdateSkyAndLightingParams();
408             return;
409         case 118: // v key
410 //          current_options.cycle_view_mode();
411             if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
412               current_options.set_view_mode(fgOPTIONS::FG_VIEW_PILOT);
413               v->set_goal_view_offset( 0.0 );
414               v->set_view_offset( 0.0 );
415             } else if (current_options.get_view_mode() ==
416                        fgOPTIONS::FG_VIEW_PILOT) {
417               current_options.set_view_mode(fgOPTIONS::FG_VIEW_FOLLOW);
418               v->set_goal_view_offset( FG_PI * 1.75 );
419               v->set_view_offset( FG_PI * 1.75 );
420               pilot_view.set_pilot_offset(25.0, -25.0, 1.0);
421             }
422             fgReshape( current_view.get_winWidth(),
423                        current_view.get_winHeight() );
424             return;
425         case 120: // x key
426             fov = current_options.get_fov();
427             fov /= 1.05;
428             if ( fov < FG_FOV_MIN ) {
429                 fov = FG_FOV_MIN;
430             }
431             current_options.set_fov(fov);
432             v->force_update_fov_math();
433             return;
434         case 122: // z key
435 #ifndef FG_OLD_WEATHER
436             tmp = WeatherDatabase->getWeatherVisibility();
437             tmp *= 1.10;
438             WeatherDatabase->setWeatherVisibility( tmp );
439 #else
440             tmp = current_weather.get_visibility();   // in meters
441             tmp *= 1.10;
442             current_weather.set_visibility( tmp );
443 #endif
444             return;
445         case 27: // ESC
446             // if( fg_DebugOutput ) {
447             //   fclose( fg_DebugOutput );
448             // }
449             FG_LOG( FG_INPUT, FG_ALERT, 
450                     "Program exit requested." );
451             ConfirmExitDialog();
452             return;
453         }
454     }
455 }
456
457
458 // Handle "special" keyboard events
459 void GLUTspecialkey(int k, int x, int y) {
460     FGView *v;
461
462     v = &current_view;
463
464     FG_LOG( FG_INPUT, FG_DEBUG, "Special key hit = " << k );
465
466     if ( puKeyboard(k + PU_KEY_GLUT_SPECIAL_OFFSET, PU_DOWN) ) {
467         return;
468     }
469
470     if ( GLUT_ACTIVE_SHIFT && glutGetModifiers() ) {
471         FG_LOG( FG_INPUT, FG_DEBUG, " SHIFTED" );
472         switch (k) {
473         case GLUT_KEY_F1: {
474             ifstream input("fgfs.sav");
475             if (input.good() && fgLoadFlight(input)) {
476                 input.close();
477                 FG_LOG(FG_INPUT, FG_INFO, "Restored flight from fgfs.sav");
478             } else {
479                 FG_LOG(FG_INPUT, FG_ALERT, "Cannot load flight from fgfs.sav");
480             }
481             return;
482         }
483         case GLUT_KEY_F2: {
484             FG_LOG(FG_INPUT, FG_INFO, "Saving flight");
485             ofstream output("fgfs.sav");
486             if (output.good() && fgSaveFlight(output)) {
487                 output.close();
488                 FG_LOG(FG_INPUT, FG_INFO, "Saved flight to fgfs.sav");
489             } else {
490                 FG_LOG(FG_INPUT, FG_ALERT, "Cannot save flight to fgfs.sav");
491             }
492             return;
493         }
494         case GLUT_KEY_F3: {
495           string panel_path =
496             current_properties.getStringValue("/sim/panel/path",
497                                               "Panels/Default/default.xml");
498           FGPanel * new_panel = fgReadPanel(panel_path);
499           if (new_panel == 0) {
500             FG_LOG(FG_INPUT, FG_ALERT,
501                    "Error reading new panel from " << panel_path);
502             return;
503           }
504           FG_LOG(FG_INPUT, FG_INFO, "Loaded new panel from " << panel_path);
505           delete current_panel;
506           current_panel = new_panel;
507           return;
508         }
509         case GLUT_KEY_F4: {
510           FGPath props_path(current_options.get_fg_root());
511           props_path.append("preferences.xml");
512           FG_LOG(FG_INPUT, FG_INFO, "Rereading global preferences");
513           if (!readPropertyList(props_path.str(), &current_properties)) {
514             FG_LOG(FG_INPUT, FG_ALERT,
515                    "Failed to reread global preferences from "
516                    << props_path.str());
517           } else {
518             FG_LOG(FG_INPUT, FG_INFO, "Finished Reading global preferences");
519           }
520           return;
521         }
522         case GLUT_KEY_F5: {
523           current_panel->setYOffset(current_panel->getYOffset() - 5);
524           fgReshape(current_view.get_winWidth(),
525                     current_view.get_winHeight());
526           return;
527         }
528         case GLUT_KEY_F6: {
529           current_panel->setYOffset(current_panel->getYOffset() + 5);
530           fgReshape(current_view.get_winWidth(),
531                     current_view.get_winHeight());
532           return;
533         }
534         case GLUT_KEY_F7: {
535           current_panel->setXOffset(current_panel->getXOffset() - 5);
536           return;
537         }
538         case GLUT_KEY_F8: {
539           current_panel->setXOffset(current_panel->getXOffset() + 5);
540           return;
541         }
542         case GLUT_KEY_END: // numeric keypad 1
543             v->set_goal_view_offset( FG_PI * 0.75 );
544             if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
545               pilot_view.set_pilot_offset(-25.0, 25.0, 1.0);
546               v->set_view_offset( FG_PI * 0.75 );
547             }
548             return;
549         case GLUT_KEY_DOWN: // numeric keypad 2
550             v->set_goal_view_offset( FG_PI );
551             if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
552               pilot_view.set_pilot_offset(-25.0, 0.0, 1.0);
553               v->set_view_offset( FG_PI );
554             }
555             return;
556         case GLUT_KEY_PAGE_DOWN: // numeric keypad 3
557             v->set_goal_view_offset( FG_PI * 1.25 );
558             if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
559               pilot_view.set_pilot_offset(-25.0, -25.0, 1.0);
560               v->set_view_offset( FG_PI * 1.25 );
561             }
562             return;
563         case GLUT_KEY_LEFT: // numeric keypad 4
564             v->set_goal_view_offset( FG_PI * 0.50 );
565             if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
566               pilot_view.set_pilot_offset(0.0, 25.0, 1.0);
567               v->set_view_offset( FG_PI * 0.50 );
568             }
569             return;
570         case GLUT_KEY_RIGHT: // numeric keypad 6
571             v->set_goal_view_offset( FG_PI * 1.50 );
572             if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
573               pilot_view.set_pilot_offset(0.0, -25.0, 1.0);
574               v->set_view_offset( FG_PI * 1.50 );
575             }
576             return;
577         case GLUT_KEY_HOME: // numeric keypad 7
578             v->set_goal_view_offset( FG_PI * 0.25 );
579             if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
580               pilot_view.set_pilot_offset(25.0, 25.0, 1.0);
581               v->set_view_offset( FG_PI * 0.25 );
582             }
583             return;
584         case GLUT_KEY_UP: // numeric keypad 8
585             v->set_goal_view_offset( 0.00 );
586             if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
587               pilot_view.set_pilot_offset(25.0, 0.0, 1.0);
588               v->set_view_offset( 0.00 );
589             }
590             return;
591         case GLUT_KEY_PAGE_UP: // numeric keypad 9
592             v->set_goal_view_offset( FG_PI * 1.75 );
593             if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
594               pilot_view.set_pilot_offset(25.0, -25.0, 1.0);
595               v->set_view_offset( FG_PI * 1.75 );
596             }
597             return;
598         }
599     } else {
600         FG_LOG( FG_INPUT, FG_DEBUG, "" );
601         switch (k) {
602         case GLUT_KEY_F2: // F2 Reload Tile Cache...
603             {
604                 bool freeze;
605                 FG_LOG(FG_INPUT, FG_INFO, "ReIniting TileCache");
606                 if ( !freeze ) 
607                     globals->set_freeze( true );
608                 BusyCursor(0);
609                 if ( global_tile_mgr.init() ) {
610                     // Load the local scenery data
611                     global_tile_mgr.update( 
612                         cur_fdm_state->get_Longitude() * RAD_TO_DEG,
613                         cur_fdm_state->get_Latitude() * RAD_TO_DEG );
614                 } else {
615                     FG_LOG( FG_GENERAL, FG_ALERT, 
616                             "Error in Tile Manager initialization!" );
617                     exit(-1);
618                 }
619                 BusyCursor(1);
620                 if ( !freeze )
621                    globals->set_freeze( false );
622                 return;
623             }
624         case GLUT_KEY_F3: // F3 Take a screen shot
625             fgDumpSnapShot();
626             return;
627         case GLUT_KEY_F6: // F6 toggles Autopilot target location
628             if ( current_autopilot->get_HeadingMode() !=
629                  FGAutopilot::FG_HEADING_WAYPOINT ) {
630                 current_autopilot->set_HeadingMode(
631                     FGAutopilot::FG_HEADING_WAYPOINT );
632                 current_autopilot->set_HeadingEnabled( true );
633             } else {
634                 current_autopilot->set_HeadingMode(
635                     FGAutopilot::FG_HEADING_LOCK );
636             }
637             return;
638         case GLUT_KEY_F8: // F8 toggles fog ... off fastest nicest...
639             current_options.cycle_fog();
640         
641             if ( current_options.get_fog() == fgOPTIONS::FG_FOG_DISABLED ) {
642                 FG_LOG( FG_INPUT, FG_INFO, "Fog disabled" );
643             } else if ( current_options.get_fog() == 
644                         fgOPTIONS::FG_FOG_FASTEST )
645             {
646                 FG_LOG( FG_INPUT, FG_INFO, 
647                         "Fog enabled, hint set to fastest" );
648             } else if ( current_options.get_fog() ==
649                         fgOPTIONS::FG_FOG_NICEST )
650             {
651                 FG_LOG( FG_INPUT, FG_INFO,
652                         "Fog enabled, hint set to nicest" );
653             }
654
655             return;
656         case GLUT_KEY_F9: // F9 toggles textures on and off...
657             FG_LOG( FG_INPUT, FG_INFO, "Toggling texture" );
658             if ( current_options.get_textures() ) {
659                 current_options.set_textures( false );
660                 material_lib.set_step( 1 );
661             } else {
662                 current_options.set_textures( true );
663                 material_lib.set_step( 0 );
664             }
665             return;
666         case GLUT_KEY_F10: // F10 toggles menu on and off...
667             FG_LOG(FG_INPUT, FG_INFO, "Invoking call back function");
668             guiToggleMenu();
669             return;
670         case GLUT_KEY_F11: // F11 Altitude Dialog.
671             FG_LOG(FG_INPUT, FG_INFO, "Invoking Altitude call back function");
672             NewAltitude( NULL );
673             return;
674         case GLUT_KEY_F12: // F12 Heading Dialog...
675             FG_LOG(FG_INPUT, FG_INFO, "Invoking Heading call back function");
676             NewHeading( NULL );
677             return;
678         case GLUT_KEY_UP:
679             if ( current_autopilot->get_AltitudeEnabled() ) {
680                 current_autopilot->AltitudeAdjust( -100 );
681             } else {
682                 controls.move_elevator(0.05);
683             }
684             return;
685         case GLUT_KEY_DOWN:
686             if ( current_autopilot->get_AltitudeEnabled() ) {
687                 current_autopilot->AltitudeAdjust( 100 );
688             } else {
689                 controls.move_elevator(-0.05);
690             }
691             return;
692         case GLUT_KEY_LEFT:
693             controls.move_aileron(-0.05);
694             return;
695         case GLUT_KEY_RIGHT:
696             controls.move_aileron(0.05);
697             return;
698         case GLUT_KEY_HOME: // numeric keypad 1
699             controls.move_elevator_trim(0.001);
700             return;
701         case GLUT_KEY_END: // numeric keypad 7
702             controls.move_elevator_trim(-0.001);
703             return;
704         case GLUT_KEY_INSERT: // numeric keypad Ins
705             if ( current_autopilot->get_HeadingEnabled() ) {
706                 current_autopilot->HeadingAdjust( -1 );
707             } else {
708                 controls.move_rudder(-0.05);
709             }
710             return;
711         case 13: // numeric keypad Enter
712             if ( current_autopilot->get_HeadingEnabled() ) {
713                 current_autopilot->HeadingAdjust( 1 );
714             } else {
715                 controls.move_rudder(0.05);
716             }
717             return;
718         case 53: // numeric keypad 5
719             controls.set_aileron(0.0);
720             controls.set_elevator(0.0);
721             controls.set_rudder(0.0);
722             return;
723         case GLUT_KEY_PAGE_UP: // numeric keypad 9 (Pg Up)
724             if ( current_autopilot->get_AutoThrottleEnabled() ) {
725                 current_autopilot->AutoThrottleAdjust( 5 );
726             } else {
727                 controls.move_throttle( FGControls::ALL_ENGINES, 0.01 );
728             }
729             return;
730         case GLUT_KEY_PAGE_DOWN: // numeric keypad 3 (Pg Dn)
731             if ( current_autopilot->get_AutoThrottleEnabled() ) {
732                 current_autopilot->AutoThrottleAdjust( -5 );
733             } else {
734                 controls.move_throttle( FGControls::ALL_ENGINES, -0.01 );
735             }
736             return;
737         }
738     }
739 }
740
741