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