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