]> git.mxchange.org Git - flightgear.git/blob - src/Main/keyboard.cxx
Added a special default default fgroot for cygwin.
[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/sg_path.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 "fg_props.hxx"
74 #include "options.hxx"
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     FGViewer *v = globals->get_current_view();
87
88     SG_LOG( SG_INPUT, SG_DEBUG, "Key hit = " << k );
89     if ( puKeyboard(k, PU_DOWN) ) {
90         return;
91     }
92
93     if ( GLUT_ACTIVE_ALT && glutGetModifiers() ) {
94         SG_LOG( SG_INPUT, SG_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_TC_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( fgGetString("/sim/flight-model"), 
151                                     alt * SG_FEET_TO_METER );
152             }
153             return;
154         case 49: // numeric keypad 1
155             v->set_goal_view_offset( SGD_PI * 0.75 );
156             return;
157         case 50: // numeric keypad 2
158             v->set_goal_view_offset( SGD_PI );
159             return;
160         case 51: // numeric keypad 3
161             v->set_goal_view_offset( SGD_PI * 1.25 );
162             return;
163         case 52: // numeric keypad 4
164             v->set_goal_view_offset( SGD_PI * 0.50 );
165             return;
166         case 54: // numeric keypad 6
167             v->set_goal_view_offset( SGD_PI * 1.50 );
168             return;
169         case 55: // numeric keypad 7
170             v->set_goal_view_offset( SGD_PI * 0.25 );
171             return;
172         case 56: // numeric keypad 8
173             v->set_goal_view_offset( 0.00 );
174             return;
175         case 57: // numeric keypad 9
176             v->set_goal_view_offset( SGD_PI * 1.75 );
177             return;
178         case 65: // A key
179             speed = fgGetInt("/sim/speed-up");
180             speed--;
181             if ( speed < 1 ) {
182                 speed = 1;
183             }
184             fgSetInt("/sim/speed-up", speed);
185             return;
186         case 72: // H key
187             HUD_brightkey( true );
188             return;
189         case 73: // I key
190             // Minimal Hud
191             fgHUDInit2(&current_aircraft);
192             return;
193         case 77: // M key
194             globals->inc_warp( -60 );
195             fgUpdateSkyAndLightingParams();
196             return;
197         case 80: // P key
198             if (fgGetBool("/sim/panel/visibility"))
199               fgSetBool("/sim/panel/visibility", false);
200             else
201               fgSetBool("/sim/panel/visibility", true);
202             fgReshape(fgGetInt("/sim/startup/xsize"),
203                       fgGetInt("/sim/startup/ysize"));
204             break;
205         case 84: // T key
206             globals->inc_warp_delta( -30 );
207             fgUpdateSkyAndLightingParams();
208             return;
209         case 87: // W key
210 #if defined(FX) && !defined(WIN32)
211             global_fullscreen = ( !global_fullscreen );
212 #  if defined(XMESA_FX_FULLSCREEN) && defined(XMESA_FX_WINDOW)
213             XMesaSetFXmode( global_fullscreen ? 
214                             XMESA_FX_FULLSCREEN : XMESA_FX_WINDOW );
215 #  endif
216 #endif
217             return;
218         case 88: // X key
219             fov = globals->get_current_view()->get_fov();
220             fov *= 1.05;
221             if ( fov > FG_FOV_MAX ) {
222                 fov = FG_FOV_MAX;
223             }
224             globals->get_current_view()->set_fov(fov);
225             // v->force_update_fov_math();
226             return;
227         case 90: // Z key
228 #ifndef FG_OLD_WEATHER
229             tmp = WeatherDatabase->getWeatherVisibility();
230             tmp /= 1.10;
231             WeatherDatabase->setWeatherVisibility( tmp );
232 #else
233             tmp = current_weather.get_visibility();   // in meters
234             tmp /= 1.10;
235             current_weather.set_visibility( tmp );
236 #endif
237             return;
238         }
239     } else {
240         SG_LOG( SG_INPUT, SG_DEBUG, "" );
241         switch (k) {
242         case 50: // numeric keypad 2
243             if ( current_autopilot->get_AltitudeEnabled() ) {
244                 current_autopilot->AltitudeAdjust( 100 );
245             } else {
246                 controls.move_elevator(-0.05);
247             }
248             return;
249         case 56: // numeric keypad 8
250             if ( current_autopilot->get_AltitudeEnabled() ) {
251                 current_autopilot->AltitudeAdjust( -100 );
252             } else {
253                 controls.move_elevator(0.05);
254             }
255             return;
256         case 49: // numeric keypad 1
257             controls.move_elevator_trim(-0.001);
258             return;
259         case 55: // numeric keypad 7
260             controls.move_elevator_trim(0.001);
261             return;
262         case 52: // numeric keypad 4
263             controls.move_aileron(-0.05);
264             return;
265         case 54: // numeric keypad 6
266             controls.move_aileron(0.05);
267             return;
268         case 48: // numeric keypad Ins
269             if ( current_autopilot->get_HeadingEnabled() ) {
270                 current_autopilot->HeadingAdjust( -1 );
271             } else {
272                 controls.move_rudder(-0.05);
273             }
274             return;
275         case 13: // numeric keypad Enter
276             if ( current_autopilot->get_HeadingEnabled() ) {
277                 current_autopilot->HeadingAdjust( 1 );
278             } else {
279                 controls.move_rudder(0.05);
280             }
281             return;
282         case 53: // numeric keypad 5
283             controls.set_aileron(0.0);
284             controls.set_elevator(0.0);
285             controls.set_rudder(0.0);
286             return;
287         case 57: // numeric keypad 9 (Pg Up)
288             if ( current_autopilot->get_AutoThrottleEnabled() ) {
289                 current_autopilot->AutoThrottleAdjust( 5 );
290             } else {
291                 controls.move_throttle( FGControls::ALL_ENGINES, 0.01 );
292             }
293             return;
294         case 51: // numeric keypad 3 (Pg Dn)
295             if ( current_autopilot->get_AutoThrottleEnabled() ) {
296                 current_autopilot->AutoThrottleAdjust( -5 );
297             } else {
298                 controls.move_throttle( FGControls::ALL_ENGINES, -0.01 );
299             }
300             return;
301         case 91: // [ key
302             controls.move_flaps(-0.34);
303             SG_LOG( SG_INPUT, SG_INFO,
304                     "Set flaps to " << controls.get_flaps() );
305             return;
306         case 93: // ] key
307             controls.move_flaps(0.34);
308             SG_LOG( SG_INPUT, SG_INFO,
309                     "Set flaps to " << controls.get_flaps() );
310             return;
311         case 97: // a key
312             speed = fgGetInt("/sim/speed-up");
313             speed++;
314             fgSetInt("/sim/speed-up", speed);
315             return;
316         case 98: // b key
317             int b_ret;
318             double b_set;
319             b_ret = int( controls.get_brake( 0 ) );
320             b_set = double(!b_ret);
321             controls.set_brake( FGControls::ALL_WHEELS, b_set);
322             return;
323         case 44: // , key
324             if (controls.get_brake(0) > 0.0) {
325                 controls.set_brake(0, 0.0);
326             } else {
327                 controls.set_brake(0, 1.0);
328             }
329             return;
330         case 46: // . key
331             if (controls.get_brake(1) > 0.0) {
332                 controls.set_brake(1, 0.0);
333             } else {
334                 controls.set_brake(1, 1.0);
335             }
336             return;
337         case 104: // h key
338             HUD_masterswitch( true );
339             return;
340         case 105: // i key
341             fgHUDInit(&current_aircraft);  // normal HUD
342             return;
343         case 109: // m key
344             globals->inc_warp( 60 );
345             fgUpdateSkyAndLightingParams();
346             return;
347         case 112: // p key
348             globals->set_freeze( ! globals->get_freeze() );
349
350             {
351                 SGBucket p( f->get_Longitude() * SGD_RADIANS_TO_DEGREES,
352                             f->get_Latitude() * SGD_RADIANS_TO_DEGREES );
353                 SGPath tile_path( globals->get_fg_root() );
354                 tile_path.append( "Scenery" );
355                 tile_path.append( p.gen_base_path() );
356                 tile_path.append( p.gen_index_str() );
357
358                 // printf position and attitude information
359                 SG_LOG( SG_INPUT, SG_INFO,
360                         "Lon = " << f->get_Longitude() * SGD_RADIANS_TO_DEGREES
361                         << "  Lat = " << f->get_Latitude() * SGD_RADIANS_TO_DEGREES
362                         << "  Altitude = " << f->get_Altitude() * SG_FEET_TO_METER
363                         );
364                 SG_LOG( SG_INPUT, SG_INFO,
365                         "Heading = " << f->get_Psi() * SGD_RADIANS_TO_DEGREES 
366                         << "  Roll = " << f->get_Phi() * SGD_RADIANS_TO_DEGREES
367                         << "  Pitch = " << f->get_Theta() * SGD_RADIANS_TO_DEGREES );
368                 SG_LOG( SG_INPUT, SG_INFO, tile_path.c_str());
369             }
370             return;
371         case 116: // t key
372             globals->inc_warp_delta( 30 );
373             fgUpdateSkyAndLightingParams();
374             return;
375         case 118: // v key
376             // handles GUI state as well as Viewer LookAt Direction
377             CenterView();
378             globals->set_current_view( globals->get_viewmgr()->next_view() );
379             fgReshape( fgGetInt("/sim/startup/xsize"),
380                        fgGetInt("/sim/startup/ysize") );
381             return;
382         case 120: // x key
383             fov = globals->get_current_view()->get_fov();
384             fov /= 1.05;
385             if ( fov < FG_FOV_MIN ) {
386                 fov = FG_FOV_MIN;
387             }
388             globals->get_current_view()->set_fov(fov);
389             // v->force_update_fov_math();
390             return;
391         case 122: // z key
392 #ifndef FG_OLD_WEATHER
393             tmp = WeatherDatabase->getWeatherVisibility();
394             tmp *= 1.10;
395             WeatherDatabase->setWeatherVisibility( tmp );
396 #else
397             tmp = current_weather.get_visibility();   // in meters
398             tmp *= 1.10;
399             current_weather.set_visibility( tmp );
400 #endif
401             return;
402         case 27: // ESC
403             // if( fg_DebugOutput ) {
404             //   fclose( fg_DebugOutput );
405             // }
406             SG_LOG( SG_INPUT, SG_ALERT, 
407                     "Program exit requested." );
408             ConfirmExitDialog();
409             return;
410         }
411     }
412 }
413
414
415 // Handle "special" keyboard events
416 void GLUTspecialkey(int k, int x, int y) {
417     FGViewer *v = globals->get_current_view();
418
419     SG_LOG( SG_INPUT, SG_DEBUG, "Special key hit = " << k );
420
421     if ( puKeyboard(k + PU_KEY_GLUT_SPECIAL_OFFSET, PU_DOWN) ) {
422         return;
423     }
424
425     if ( GLUT_ACTIVE_SHIFT && glutGetModifiers() ) {
426         SG_LOG( SG_INPUT, SG_DEBUG, " SHIFTED" );
427         switch (k) {
428         case GLUT_KEY_F1: {
429             ifstream input("fgfs.sav");
430             if (input.good() && fgLoadFlight(input)) {
431                 input.close();
432                 SG_LOG(SG_INPUT, SG_INFO, "Restored flight from fgfs.sav");
433             } else {
434                 SG_LOG(SG_INPUT, SG_ALERT, "Cannot load flight from fgfs.sav");
435             }
436             return;
437         }
438         case GLUT_KEY_F2: {
439             SG_LOG(SG_INPUT, SG_INFO, "Saving flight");
440             cerr << "Opening output stream" << endl;
441             ofstream output("fgfs.sav");
442             cerr << "output stream opened" << endl;
443             if (output.good() && fgSaveFlight(output)) {
444                 output.close();
445                 SG_LOG(SG_INPUT, SG_INFO, "Saved flight to fgfs.sav");
446             } else {
447                 SG_LOG(SG_INPUT, SG_ALERT, "Cannot save flight to fgfs.sav");
448             }
449             return;
450         }
451         case GLUT_KEY_F3: {
452             string panel_path =
453                 fgGetString("/sim/panel/path", "Panels/Default/default.xml");
454             FGPanel * new_panel = fgReadPanel(panel_path);
455             if (new_panel == 0) {
456                 SG_LOG(SG_INPUT, SG_ALERT,
457                        "Error reading new panel from " << panel_path);
458                 return;
459             }
460             SG_LOG(SG_INPUT, SG_INFO, "Loaded new panel from " << panel_path);
461             current_panel->unbind();
462             delete current_panel;
463             current_panel = new_panel;
464             return;
465         }
466         case GLUT_KEY_F4: {
467             SGPath props_path(globals->get_fg_root());
468             props_path.append("preferences.xml");
469             SG_LOG(SG_INPUT, SG_INFO, "Rereading global preferences");
470             if (!readProperties(props_path.str(), globals->get_props())) {
471                 SG_LOG(SG_INPUT, SG_ALERT,
472                        "Failed to reread global preferences from "
473                        << props_path.str());
474             } else {
475                 SG_LOG(SG_INPUT, SG_INFO, "Finished Reading global preferences");
476             }
477             return;
478         }
479         case GLUT_KEY_F5: {
480             current_panel->setYOffset(current_panel->getYOffset() - 5);
481             fgReshape(fgGetInt("/sim/startup/xsize"),
482                       fgGetInt("/sim/startup/ysize"));
483             return;
484         }
485         case GLUT_KEY_F6: {
486             current_panel->setYOffset(current_panel->getYOffset() + 5);
487             fgReshape(fgGetInt("/sim/startup/xsize"),
488                       fgGetInt("/sim/startup/ysize"));
489             return;
490         }
491         case GLUT_KEY_F7: {
492             current_panel->setXOffset(current_panel->getXOffset() - 5);
493             return;
494         }
495         case GLUT_KEY_F8: {
496             current_panel->setXOffset(current_panel->getXOffset() + 5);
497             return;
498         }
499         // case GLUT_KEY_F9: {
500         //     return;
501         // }
502         case GLUT_KEY_F10: {
503             fgToggleFDMdataLogging();
504             return;
505         }
506         // case GLUT_KEY_F11: {
507         //     return;
508         // }
509         // case GLUT_KEY_F12: {
510         //     return;
511         // }
512         case GLUT_KEY_END: // numeric keypad 1
513             v->set_goal_view_offset( SGD_PI * 0.75 );
514             return;
515         case GLUT_KEY_DOWN: // numeric keypad 2
516             v->set_goal_view_offset( SGD_PI );
517             return;
518         case GLUT_KEY_PAGE_DOWN: // numeric keypad 3
519             v->set_goal_view_offset( SGD_PI * 1.25 );
520             return;
521         case GLUT_KEY_LEFT: // numeric keypad 4
522             v->set_goal_view_offset( SGD_PI * 0.50 );
523             return;
524         case GLUT_KEY_RIGHT: // numeric keypad 6
525             v->set_goal_view_offset( SGD_PI * 1.50 );
526             return;
527         case GLUT_KEY_HOME: // numeric keypad 7
528             v->set_goal_view_offset( SGD_PI * 0.25 );
529             return;
530         case GLUT_KEY_UP: // numeric keypad 8
531             v->set_goal_view_offset( 0.00 );
532             return;
533         case GLUT_KEY_PAGE_UP: // numeric keypad 9
534             v->set_goal_view_offset( SGD_PI * 1.75 );
535             return;
536         }
537     } else {
538         SG_LOG( SG_INPUT, SG_DEBUG, "" );
539         switch (k) {
540         case GLUT_KEY_F2: // F2 Reload Tile Cache...
541             {
542                 bool freeze = globals->get_freeze();
543                 SG_LOG(SG_INPUT, SG_INFO, "ReIniting TileCache");
544                 if ( !freeze ) 
545                     globals->set_freeze( true );
546                 BusyCursor(0);
547                 if ( global_tile_mgr.init() ) {
548                     // Load the local scenery data
549                     global_tile_mgr.update( 
550                         cur_fdm_state->get_Longitude() * SGD_RADIANS_TO_DEGREES,
551                         cur_fdm_state->get_Latitude() * SGD_RADIANS_TO_DEGREES );
552                 } else {
553                     SG_LOG( SG_GENERAL, SG_ALERT, 
554                             "Error in Tile Manager initialization!" );
555                     exit(-1);
556                 }
557                 BusyCursor(1);
558                 if ( !freeze )
559                    globals->set_freeze( false );
560                 return;
561             }
562         case GLUT_KEY_F3: // F3 Take a screen shot
563             fgDumpSnapShot();
564             return;
565         case GLUT_KEY_F4: // F4 Update lighting manually
566             fgUpdateSkyAndLightingParams();
567         case GLUT_KEY_F6: // F6 toggles Autopilot target location
568             if ( current_autopilot->get_HeadingMode() !=
569                  FGAutopilot::FG_HEADING_WAYPOINT ) {
570                 current_autopilot->set_HeadingMode(
571                     FGAutopilot::FG_HEADING_WAYPOINT );
572                 current_autopilot->set_HeadingEnabled( true );
573             } else {
574                 current_autopilot->set_HeadingMode(
575                     FGAutopilot::FG_TC_HEADING_LOCK );
576             }
577             return;
578         case GLUT_KEY_F8: {// F8 toggles fog ... off fastest nicest...
579             const string &fog = fgGetString("/sim/rendering/fog");
580             if (fog == "disabled") {
581               fgSetString("/sim/rendering/fog", "fastest");
582               SG_LOG(SG_INPUT, SG_INFO, "Fog enabled, hint=fastest");
583             } else if (fog == "fastest") {
584               fgSetString("/sim/rendering/fog", "nicest");
585               SG_LOG(SG_INPUT, SG_INFO, "Fog enabled, hint=nicest");
586             } else if (fog == "nicest") {
587               fgSetString("/sim/rendering/fog", "disabled");
588               SG_LOG(SG_INPUT, SG_INFO, "Fog disabled");
589             } else {
590               fgSetString("/sim/rendering/fog", "disabled");
591               SG_LOG(SG_INPUT, SG_ALERT, "Unrecognized fog type "
592                      << fog << ", changed to 'disabled'");
593             }
594             return;
595         }
596         case GLUT_KEY_F9: // F9 toggles textures on and off...
597             SG_LOG( SG_INPUT, SG_INFO, "Toggling texture" );
598             if ( fgGetBool("/sim/rendering/textures")) {
599                 fgSetBool("/sim/rendering/textures", false);
600                 material_lib.set_step( 1 );
601             } else {
602                 fgSetBool("/sim/rendering/textures", true);
603                 material_lib.set_step( 0 );
604             }
605             return;
606         case GLUT_KEY_F10: // F10 toggles menu on and off...
607             SG_LOG(SG_INPUT, SG_INFO, "Invoking call back function");
608             guiToggleMenu();
609             return;
610         case GLUT_KEY_F11: // F11 Altitude Dialog.
611             SG_LOG(SG_INPUT, SG_INFO, "Invoking Altitude call back function");
612             NewAltitude( NULL );
613             return;
614         case GLUT_KEY_F12: // F12 Heading Dialog...
615             SG_LOG(SG_INPUT, SG_INFO, "Invoking Heading call back function");
616             NewHeading( NULL );
617             return;
618         case GLUT_KEY_UP:
619             if ( current_autopilot->get_AltitudeEnabled() ) {
620                 current_autopilot->AltitudeAdjust( -100 );
621             } else {
622                 controls.move_elevator(0.05);
623             }
624             return;
625         case GLUT_KEY_DOWN:
626             if ( current_autopilot->get_AltitudeEnabled() ) {
627                 current_autopilot->AltitudeAdjust( 100 );
628             } else {
629                 controls.move_elevator(-0.05);
630             }
631             return;
632         case GLUT_KEY_LEFT:
633             controls.move_aileron(-0.05);
634             return;
635         case GLUT_KEY_RIGHT:
636             controls.move_aileron(0.05);
637             return;
638         case GLUT_KEY_HOME: // numeric keypad 1
639             controls.move_elevator_trim(0.001);
640             return;
641         case GLUT_KEY_END: // numeric keypad 7
642             controls.move_elevator_trim(-0.001);
643             return;
644         case GLUT_KEY_INSERT: // numeric keypad Ins
645             if ( current_autopilot->get_HeadingEnabled() ) {
646                 current_autopilot->HeadingAdjust( -1 );
647             } else {
648                 controls.move_rudder(-0.05);
649             }
650             return;
651         case 13: // numeric keypad Enter
652             if ( current_autopilot->get_HeadingEnabled() ) {
653                 current_autopilot->HeadingAdjust( 1 );
654             } else {
655                 controls.move_rudder(0.05);
656             }
657             return;
658         case 53: // numeric keypad 5
659             controls.set_aileron(0.0);
660             controls.set_elevator(0.0);
661             controls.set_rudder(0.0);
662             return;
663         case GLUT_KEY_PAGE_UP: // numeric keypad 9 (Pg Up)
664             if ( current_autopilot->get_AutoThrottleEnabled() ) {
665                 current_autopilot->AutoThrottleAdjust( 5 );
666             } else {
667                 controls.move_throttle( FGControls::ALL_ENGINES, 0.01 );
668             }
669             return;
670         case GLUT_KEY_PAGE_DOWN: // numeric keypad 3 (Pg Dn)
671             if ( current_autopilot->get_AutoThrottleEnabled() ) {
672                 current_autopilot->AutoThrottleAdjust( -5 );
673             } else {
674                 controls.move_throttle( FGControls::ALL_ENGINES, -0.01 );
675             }
676             return;
677         }
678     }
679 }
680
681