1998-09-26 13:16:44 +00:00
|
|
|
// GLUTkey.cxx -- handle GLUT keyboard events
|
|
|
|
//
|
|
|
|
// Written by Curtis Olson, started May 1997.
|
|
|
|
//
|
|
|
|
// Copyright (C) 1997 Curtis L. Olson - curt@me.umn.edu
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License as
|
|
|
|
// published by the Free Software Foundation; either version 2 of the
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful, but
|
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
//
|
|
|
|
// $Id$
|
1997-05-21 15:57:49 +00:00
|
|
|
|
|
|
|
|
1998-04-24 00:49:17 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
1998-04-03 22:09:02 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_WINDOWS_H
|
1997-07-16 20:04:42 +00:00
|
|
|
# include <windows.h>
|
1997-07-12 03:50:20 +00:00
|
|
|
#endif
|
|
|
|
|
1997-05-21 15:57:49 +00:00
|
|
|
#include <GL/glut.h>
|
1998-01-19 19:26:51 +00:00
|
|
|
#include <XGL/xgl.h>
|
1999-03-11 23:09:26 +00:00
|
|
|
|
|
|
|
#if defined(FX) && defined(XMESA)
|
|
|
|
#include <GL/xmesa.h>
|
|
|
|
#endif
|
|
|
|
|
1997-08-27 21:32:23 +00:00
|
|
|
#include <stdio.h>
|
1998-02-03 23:20:08 +00:00
|
|
|
#include <stdlib.h>
|
1997-05-21 15:57:49 +00:00
|
|
|
|
1999-02-26 22:08:34 +00:00
|
|
|
#include <Debug/logstream.hxx>
|
1998-10-17 01:33:52 +00:00
|
|
|
#include <Aircraft/aircraft.hxx>
|
1998-09-15 04:27:27 +00:00
|
|
|
#include <Astro/solarsystem.hxx>
|
1998-08-05 00:19:33 +00:00
|
|
|
#include <Astro/sky.hxx>
|
1998-09-29 02:03:36 +00:00
|
|
|
#include <Autopilot/autopilot.hxx>
|
1998-07-16 17:33:34 +00:00
|
|
|
#include <Cockpit/hud.hxx>
|
1998-06-12 14:27:25 +00:00
|
|
|
#include <GUI/gui.h>
|
1998-04-22 13:25:39 +00:00
|
|
|
#include <Include/fg_constants.h>
|
1999-06-01 21:17:10 +00:00
|
|
|
#include <Scenery/tilemgr.hxx>
|
1999-05-12 04:24:55 +00:00
|
|
|
#include <Objects/materialmgr.hxx>
|
1999-04-12 02:03:32 +00:00
|
|
|
#include <plib/pu.h>
|
1999-06-01 21:17:10 +00:00
|
|
|
#include <Time/fg_time.hxx>
|
1998-08-05 00:19:33 +00:00
|
|
|
#include <Time/light.hxx>
|
1998-10-17 01:33:52 +00:00
|
|
|
#include <Weather/weather.hxx>
|
1997-08-22 21:34:32 +00:00
|
|
|
|
1998-04-22 13:25:39 +00:00
|
|
|
#include "GLUTkey.hxx"
|
1998-04-24 00:49:17 +00:00
|
|
|
#include "options.hxx"
|
1998-04-22 13:25:39 +00:00
|
|
|
#include "views.hxx"
|
|
|
|
|
1999-06-01 21:17:10 +00:00
|
|
|
extern void NewAltitude( puObject *cb );
|
|
|
|
extern void NewHeading( puObject *cb );
|
1998-08-05 00:19:33 +00:00
|
|
|
|
|
|
|
// Force an update of the sky and lighting parameters
|
|
|
|
static void local_update_sky_and_lighting_params( void ) {
|
1998-09-15 04:27:27 +00:00
|
|
|
// fgSunInit();
|
|
|
|
SolarSystem::theSolarSystem->rebuild();
|
1998-08-29 13:09:25 +00:00
|
|
|
cur_light_params.Update();
|
1998-08-05 00:19:33 +00:00
|
|
|
fgSkyColorsInit();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-09-26 13:16:44 +00:00
|
|
|
// Handle keyboard events
|
1997-05-21 15:57:49 +00:00
|
|
|
void GLUTkey(unsigned char k, int x, int y) {
|
1999-02-05 21:28:09 +00:00
|
|
|
FGInterface *f;
|
1999-04-08 19:53:46 +00:00
|
|
|
FGTime *t;
|
1998-12-09 18:50:12 +00:00
|
|
|
FGView *v;
|
1998-12-06 13:51:20 +00:00
|
|
|
FGWeather *w;
|
1998-07-13 21:00:09 +00:00
|
|
|
float fov, tmp;
|
1998-10-20 14:58:57 +00:00
|
|
|
static bool winding_ccw = true;
|
1997-05-21 15:57:49 +00:00
|
|
|
|
1998-12-05 15:53:59 +00:00
|
|
|
f = current_aircraft.fdm_state;
|
1999-04-08 19:53:46 +00:00
|
|
|
t = FGTime::cur_time_params;
|
1997-08-27 21:32:23 +00:00
|
|
|
v = ¤t_view;
|
1997-08-22 21:34:32 +00:00
|
|
|
w = ¤t_weather;
|
1997-05-21 15:57:49 +00:00
|
|
|
|
1998-11-06 21:17:31 +00:00
|
|
|
FG_LOG( FG_INPUT, FG_DEBUG, "Key hit = " << k );
|
1999-05-29 13:03:26 +00:00
|
|
|
if ( puKeyboard(k, PU_DOWN) ) {
|
|
|
|
return;
|
|
|
|
}
|
1997-05-21 15:57:49 +00:00
|
|
|
|
1997-07-19 22:34:02 +00:00
|
|
|
if ( GLUT_ACTIVE_ALT && glutGetModifiers() ) {
|
1998-11-06 21:17:31 +00:00
|
|
|
FG_LOG( FG_INPUT, FG_DEBUG, " SHIFTED" );
|
1997-06-02 03:01:38 +00:00
|
|
|
switch (k) {
|
1998-09-29 02:03:36 +00:00
|
|
|
case 1: // Ctrl-A key
|
|
|
|
fgAPToggleAltitude();
|
|
|
|
return;
|
|
|
|
case 8: // Ctrl-H key
|
|
|
|
fgAPToggleHeading();
|
|
|
|
return;
|
1998-10-20 14:58:57 +00:00
|
|
|
case 18: // Ctrl-R key
|
|
|
|
// temporary
|
|
|
|
winding_ccw = !winding_ccw;
|
|
|
|
if ( winding_ccw ) {
|
|
|
|
glFrontFace ( GL_CCW );
|
|
|
|
} else {
|
|
|
|
glFrontFace ( GL_CW );
|
|
|
|
}
|
|
|
|
return;
|
1998-10-02 12:46:43 +00:00
|
|
|
case 19: // Ctrl-S key
|
|
|
|
fgAPToggleAutoThrottle();
|
|
|
|
return;
|
1998-10-01 00:37:57 +00:00
|
|
|
case 20: // Ctrl-T key
|
|
|
|
fgAPToggleTerrainFollow();
|
|
|
|
return;
|
1998-09-26 13:16:44 +00:00
|
|
|
case 49: // numeric keypad 1
|
1998-12-09 18:50:12 +00:00
|
|
|
v->set_goal_view_offset( FG_PI * 0.75 );
|
1997-06-02 03:01:38 +00:00
|
|
|
return;
|
1998-09-26 13:16:44 +00:00
|
|
|
case 50: // numeric keypad 2
|
1998-12-09 18:50:12 +00:00
|
|
|
v->set_goal_view_offset( FG_PI );
|
1997-06-02 03:01:38 +00:00
|
|
|
return;
|
1998-09-26 13:16:44 +00:00
|
|
|
case 51: // numeric keypad 3
|
1998-12-09 18:50:12 +00:00
|
|
|
v->set_goal_view_offset( FG_PI * 1.25 );
|
1997-06-02 03:01:38 +00:00
|
|
|
return;
|
1998-09-26 13:16:44 +00:00
|
|
|
case 52: // numeric keypad 4
|
1998-12-09 18:50:12 +00:00
|
|
|
v->set_goal_view_offset( FG_PI * 0.50 );
|
1997-06-02 03:01:38 +00:00
|
|
|
return;
|
1998-09-26 13:16:44 +00:00
|
|
|
case 54: // numeric keypad 6
|
1998-12-09 18:50:12 +00:00
|
|
|
v->set_goal_view_offset( FG_PI * 1.50 );
|
1997-06-02 03:01:38 +00:00
|
|
|
return;
|
1998-09-26 13:16:44 +00:00
|
|
|
case 55: // numeric keypad 7
|
1998-12-09 18:50:12 +00:00
|
|
|
v->set_goal_view_offset( FG_PI * 0.25 );
|
1997-06-02 03:01:38 +00:00
|
|
|
return;
|
1998-09-26 13:16:44 +00:00
|
|
|
case 56: // numeric keypad 8
|
1998-12-09 18:50:12 +00:00
|
|
|
v->set_goal_view_offset( 0.00 );
|
1997-06-02 03:01:38 +00:00
|
|
|
return;
|
1998-09-26 13:16:44 +00:00
|
|
|
case 57: // numeric keypad 9
|
1998-12-09 18:50:12 +00:00
|
|
|
v->set_goal_view_offset( FG_PI * 1.75 );
|
1997-06-02 03:01:38 +00:00
|
|
|
return;
|
1998-09-26 13:16:44 +00:00
|
|
|
case 72: // H key
|
1998-07-16 17:33:34 +00:00
|
|
|
// status = current_options.get_hud_status();
|
|
|
|
// current_options.set_hud_status(!status);
|
|
|
|
HUD_brightkey( true );
|
1997-08-25 20:27:21 +00:00
|
|
|
return;
|
1999-05-12 01:11:17 +00:00
|
|
|
case 73: // I key
|
1998-08-24 20:11:12 +00:00
|
|
|
// Minimal Hud
|
|
|
|
fgHUDInit2(¤t_aircraft);
|
|
|
|
return;
|
1998-09-26 13:16:44 +00:00
|
|
|
case 77: // M key
|
1999-04-08 19:53:46 +00:00
|
|
|
t->adjust_warp(-60);
|
1998-08-05 00:19:33 +00:00
|
|
|
local_update_sky_and_lighting_params();
|
1998-01-05 18:44:33 +00:00
|
|
|
return;
|
1999-05-06 22:16:12 +00:00
|
|
|
case 80: // P key
|
1999-05-12 01:11:17 +00:00
|
|
|
current_options.toggle_panel();
|
|
|
|
break;
|
1998-09-26 13:16:44 +00:00
|
|
|
case 84: // T key
|
1999-04-08 19:53:46 +00:00
|
|
|
t->adjust_warp_delta(-30);
|
1998-08-05 00:19:33 +00:00
|
|
|
local_update_sky_and_lighting_params();
|
1998-01-05 18:44:33 +00:00
|
|
|
return;
|
1998-09-26 13:16:44 +00:00
|
|
|
case 87: // W key
|
1998-07-06 02:42:02 +00:00
|
|
|
#if defined(FX) && !defined(WIN32)
|
1999-03-11 23:09:26 +00:00
|
|
|
global_fullscreen = ( !global_fullscreen );
|
|
|
|
# if defined(XMESA_FX_FULLSCREEN) && defined(XMESA_FX_WINDOW)
|
|
|
|
XMesaSetFXmode( global_fullscreen ?
|
|
|
|
XMESA_FX_FULLSCREEN : XMESA_FX_WINDOW );
|
|
|
|
# endif
|
1998-07-06 02:42:02 +00:00
|
|
|
#endif
|
1997-12-30 16:36:40 +00:00
|
|
|
return;
|
1998-09-26 13:16:44 +00:00
|
|
|
case 88: // X key
|
1998-07-13 21:00:09 +00:00
|
|
|
fov = current_options.get_fov();
|
|
|
|
fov *= 1.05;
|
|
|
|
if ( fov > FG_FOV_MAX ) {
|
|
|
|
fov = FG_FOV_MAX;
|
1998-05-16 13:05:21 +00:00
|
|
|
}
|
1998-07-13 21:00:09 +00:00
|
|
|
current_options.set_fov(fov);
|
1998-12-11 20:26:25 +00:00
|
|
|
v->force_update_fov_math();
|
1998-05-13 18:29:56 +00:00
|
|
|
return;
|
1998-09-26 13:16:44 +00:00
|
|
|
case 90: // Z key
|
1998-12-06 13:51:20 +00:00
|
|
|
tmp = w->get_visibility(); // in meters
|
1998-06-12 00:57:38 +00:00
|
|
|
tmp /= 1.10;
|
1998-12-06 13:51:20 +00:00
|
|
|
w->set_visibility( tmp );
|
1998-04-14 02:21:01 +00:00
|
|
|
return;
|
1997-06-02 03:01:38 +00:00
|
|
|
}
|
|
|
|
} else {
|
1998-11-06 21:17:31 +00:00
|
|
|
FG_LOG( FG_INPUT, FG_DEBUG, "" );
|
1997-06-02 03:01:38 +00:00
|
|
|
switch (k) {
|
1998-09-26 13:16:44 +00:00
|
|
|
case 50: // numeric keypad 2
|
1999-04-27 15:52:32 +00:00
|
|
|
if( fgAPAltitudeEnabled() || fgAPTerrainFollowEnabled() ) {
|
1999-02-12 22:17:59 +00:00
|
|
|
fgAPAltitudeAdjust( 100 );
|
|
|
|
} else {
|
|
|
|
controls.move_elevator(-0.05);
|
|
|
|
}
|
1997-06-02 03:01:38 +00:00
|
|
|
return;
|
1998-09-26 13:16:44 +00:00
|
|
|
case 56: // numeric keypad 8
|
1999-04-27 15:52:32 +00:00
|
|
|
if( fgAPAltitudeEnabled() || fgAPTerrainFollowEnabled() ) {
|
1999-02-12 22:17:59 +00:00
|
|
|
fgAPAltitudeAdjust( -100 );
|
|
|
|
} else {
|
|
|
|
controls.move_elevator(0.05);
|
|
|
|
}
|
1997-06-02 03:01:38 +00:00
|
|
|
return;
|
1998-09-26 13:16:44 +00:00
|
|
|
case 49: // numeric keypad 1
|
1998-10-25 14:08:37 +00:00
|
|
|
controls.move_elevator_trim(-0.001);
|
1997-06-02 03:01:38 +00:00
|
|
|
return;
|
1998-09-26 13:16:44 +00:00
|
|
|
case 55: // numeric keypad 7
|
1998-10-25 14:08:37 +00:00
|
|
|
controls.move_elevator_trim(0.001);
|
1997-06-02 03:01:38 +00:00
|
|
|
return;
|
1998-09-26 13:16:44 +00:00
|
|
|
case 52: // numeric keypad 4
|
1998-10-25 14:08:37 +00:00
|
|
|
controls.move_aileron(-0.05);
|
1997-06-02 03:01:38 +00:00
|
|
|
return;
|
1998-09-26 13:16:44 +00:00
|
|
|
case 54: // numeric keypad 6
|
1998-10-25 14:08:37 +00:00
|
|
|
controls.move_aileron(0.05);
|
1997-06-02 03:01:38 +00:00
|
|
|
return;
|
1998-09-26 13:16:44 +00:00
|
|
|
case 48: // numeric keypad Ins
|
1999-02-12 22:17:59 +00:00
|
|
|
if( fgAPHeadingEnabled() ) {
|
|
|
|
fgAPHeadingAdjust( -1 );
|
|
|
|
} else {
|
|
|
|
controls.move_rudder(-0.05);
|
|
|
|
}
|
1997-06-02 03:01:38 +00:00
|
|
|
return;
|
1998-09-26 13:16:44 +00:00
|
|
|
case 13: // numeric keypad Enter
|
1999-02-12 22:17:59 +00:00
|
|
|
if( fgAPHeadingEnabled() ) {
|
|
|
|
fgAPHeadingAdjust( 1 );
|
|
|
|
} else {
|
|
|
|
controls.move_rudder(0.05);
|
|
|
|
}
|
1997-06-02 03:01:38 +00:00
|
|
|
return;
|
1998-09-26 13:16:44 +00:00
|
|
|
case 53: // numeric keypad 5
|
1998-10-25 14:08:37 +00:00
|
|
|
controls.set_aileron(0.0);
|
|
|
|
controls.set_elevator(0.0);
|
|
|
|
controls.set_rudder(0.0);
|
1997-06-02 03:01:38 +00:00
|
|
|
return;
|
1998-09-26 13:16:44 +00:00
|
|
|
case 57: // numeric keypad 9 (Pg Up)
|
1999-02-12 23:22:35 +00:00
|
|
|
if( fgAPAutoThrottleEnabled() ) {
|
|
|
|
fgAPAutoThrottleAdjust( 5 );
|
|
|
|
} else {
|
|
|
|
controls.move_throttle( FGControls::ALL_ENGINES, 0.01 );
|
|
|
|
}
|
1997-06-02 03:01:38 +00:00
|
|
|
return;
|
1998-09-26 13:16:44 +00:00
|
|
|
case 51: // numeric keypad 3 (Pg Dn)
|
1999-02-12 23:22:35 +00:00
|
|
|
if( fgAPAutoThrottleEnabled() ) {
|
|
|
|
fgAPAutoThrottleAdjust( -5 );
|
|
|
|
} else {
|
|
|
|
controls.move_throttle( FGControls::ALL_ENGINES, -0.01 );
|
|
|
|
}
|
1997-06-02 03:01:38 +00:00
|
|
|
return;
|
1998-09-29 02:03:36 +00:00
|
|
|
case 98: // b key
|
|
|
|
int b_ret;
|
|
|
|
double b_set;
|
1998-10-25 14:08:37 +00:00
|
|
|
b_ret = int( controls.get_brake( 0 ) );
|
1998-09-29 02:03:36 +00:00
|
|
|
b_set = double(!b_ret);
|
1998-12-05 16:13:10 +00:00
|
|
|
controls.set_brake( FGControls::ALL_WHEELS, b_set);
|
1998-09-29 02:03:36 +00:00
|
|
|
return;
|
1998-09-26 13:16:44 +00:00
|
|
|
case 104: // h key
|
1998-07-16 17:33:34 +00:00
|
|
|
HUD_brightkey( false );
|
|
|
|
return;
|
1998-09-26 13:16:44 +00:00
|
|
|
case 105: // i key
|
1998-08-24 20:11:12 +00:00
|
|
|
fgHUDInit(¤t_aircraft); // normal HUD
|
|
|
|
return;
|
1998-09-26 13:16:44 +00:00
|
|
|
case 109: // m key
|
1999-04-08 19:53:46 +00:00
|
|
|
t->adjust_warp (+60);
|
1998-08-05 00:19:33 +00:00
|
|
|
local_update_sky_and_lighting_params();
|
1998-01-05 18:44:33 +00:00
|
|
|
return;
|
1998-09-26 13:16:44 +00:00
|
|
|
case 112: // p key
|
1999-04-08 19:53:46 +00:00
|
|
|
t->togglePauseMode();
|
1998-07-30 23:48:24 +00:00
|
|
|
// printf position and attitude information
|
1998-11-06 21:17:31 +00:00
|
|
|
FG_LOG( FG_INPUT, FG_INFO,
|
1998-12-03 01:14:58 +00:00
|
|
|
"Lon = " << f->get_Longitude() * RAD_TO_DEG
|
|
|
|
<< " Lat = " << f->get_Latitude() * RAD_TO_DEG
|
|
|
|
<< " Altitude = " << f->get_Altitude() * FEET_TO_METER );
|
1998-11-06 21:17:31 +00:00
|
|
|
FG_LOG( FG_INPUT, FG_INFO,
|
1998-12-03 01:14:58 +00:00
|
|
|
"Heading = " << f->get_Psi() * RAD_TO_DEG
|
|
|
|
<< " Roll = " << f->get_Phi() * RAD_TO_DEG
|
|
|
|
<< " Pitch = " << f->get_Theta() * RAD_TO_DEG );
|
1998-07-27 18:41:23 +00:00
|
|
|
return;
|
1998-09-26 13:16:44 +00:00
|
|
|
case 116: // t key
|
1999-04-08 19:53:46 +00:00
|
|
|
t->adjust_warp_delta (+30);
|
1998-08-05 00:19:33 +00:00
|
|
|
local_update_sky_and_lighting_params();
|
1998-01-05 18:44:33 +00:00
|
|
|
return;
|
1998-09-26 13:16:44 +00:00
|
|
|
case 120: // X key
|
1998-07-13 21:00:09 +00:00
|
|
|
fov = current_options.get_fov();
|
|
|
|
fov /= 1.05;
|
|
|
|
if ( fov < FG_FOV_MIN ) {
|
|
|
|
fov = FG_FOV_MIN;
|
1998-05-16 13:05:21 +00:00
|
|
|
}
|
1998-07-13 21:00:09 +00:00
|
|
|
current_options.set_fov(fov);
|
1998-12-11 20:26:25 +00:00
|
|
|
v->force_update_fov_math();
|
1998-05-13 18:29:56 +00:00
|
|
|
return;
|
1998-09-26 13:16:44 +00:00
|
|
|
case 122: // z key
|
1998-12-06 13:51:20 +00:00
|
|
|
tmp = w->get_visibility(); // in meters
|
1998-06-12 00:57:38 +00:00
|
|
|
tmp *= 1.10;
|
1998-12-06 13:51:20 +00:00
|
|
|
w->set_visibility( tmp );
|
1997-06-02 03:01:38 +00:00
|
|
|
return;
|
1998-09-26 13:16:44 +00:00
|
|
|
case 27: // ESC
|
1998-04-25 20:24:00 +00:00
|
|
|
// if( fg_DebugOutput ) {
|
|
|
|
// fclose( fg_DebugOutput );
|
|
|
|
// }
|
1998-11-06 21:17:31 +00:00
|
|
|
FG_LOG( FG_INPUT, FG_ALERT,
|
|
|
|
"Program exiting normally at user request." );
|
1999-05-12 01:11:17 +00:00
|
|
|
ConfirmExitDialog();
|
|
|
|
return;
|
1997-06-02 03:01:38 +00:00
|
|
|
}
|
1997-05-21 15:57:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-09-26 13:16:44 +00:00
|
|
|
// Handle "special" keyboard events
|
1997-06-02 03:40:06 +00:00
|
|
|
void GLUTspecialkey(int k, int x, int y) {
|
1998-12-09 18:50:12 +00:00
|
|
|
FGView *v;
|
1997-05-31 04:13:51 +00:00
|
|
|
|
1997-08-27 21:32:23 +00:00
|
|
|
v = ¤t_view;
|
1997-05-31 04:13:51 +00:00
|
|
|
|
1998-11-06 21:17:31 +00:00
|
|
|
FG_LOG( FG_INPUT, FG_DEBUG, "Special key hit = " << k );
|
1999-05-29 13:03:26 +00:00
|
|
|
|
|
|
|
if ( puKeyboard(k + PU_KEY_GLUT_SPECIAL_OFFSET, PU_DOWN) ) {
|
|
|
|
return;
|
|
|
|
}
|
1997-05-31 04:13:51 +00:00
|
|
|
|
1997-07-18 23:41:20 +00:00
|
|
|
if ( GLUT_ACTIVE_SHIFT && glutGetModifiers() ) {
|
1998-11-06 21:17:31 +00:00
|
|
|
FG_LOG( FG_INPUT, FG_DEBUG, " SHIFTED" );
|
1997-07-18 23:41:20 +00:00
|
|
|
switch (k) {
|
1998-09-26 13:16:44 +00:00
|
|
|
case GLUT_KEY_END: // numeric keypad 1
|
1998-12-09 18:50:12 +00:00
|
|
|
v->set_goal_view_offset( FG_PI * 0.75 );
|
1997-07-18 23:41:20 +00:00
|
|
|
return;
|
1998-09-26 13:16:44 +00:00
|
|
|
case GLUT_KEY_DOWN: // numeric keypad 2
|
1998-12-09 18:50:12 +00:00
|
|
|
v->set_goal_view_offset( FG_PI );
|
1997-07-18 23:41:20 +00:00
|
|
|
return;
|
1998-09-26 13:16:44 +00:00
|
|
|
case GLUT_KEY_PAGE_DOWN: // numeric keypad 3
|
1998-12-09 18:50:12 +00:00
|
|
|
v->set_goal_view_offset( FG_PI * 1.25 );
|
1997-07-18 23:41:20 +00:00
|
|
|
return;
|
1998-09-26 13:16:44 +00:00
|
|
|
case GLUT_KEY_LEFT: // numeric keypad 4
|
1998-12-09 18:50:12 +00:00
|
|
|
v->set_goal_view_offset( FG_PI * 0.50 );
|
1997-07-18 23:41:20 +00:00
|
|
|
return;
|
1998-09-26 13:16:44 +00:00
|
|
|
case GLUT_KEY_RIGHT: // numeric keypad 6
|
1998-12-09 18:50:12 +00:00
|
|
|
v->set_goal_view_offset( FG_PI * 1.50 );
|
1997-07-18 23:41:20 +00:00
|
|
|
return;
|
1998-09-26 13:16:44 +00:00
|
|
|
case GLUT_KEY_HOME: // numeric keypad 7
|
1998-12-09 18:50:12 +00:00
|
|
|
v->set_goal_view_offset( FG_PI * 0.25 );
|
1997-07-18 23:41:20 +00:00
|
|
|
return;
|
1998-09-26 13:16:44 +00:00
|
|
|
case GLUT_KEY_UP: // numeric keypad 8
|
1998-12-09 18:50:12 +00:00
|
|
|
v->set_goal_view_offset( 0.00 );
|
1997-07-18 23:41:20 +00:00
|
|
|
return;
|
1998-09-26 13:16:44 +00:00
|
|
|
case GLUT_KEY_PAGE_UP: // numeric keypad 9
|
1998-12-09 18:50:12 +00:00
|
|
|
v->set_goal_view_offset( FG_PI * 1.75 );
|
1997-07-18 23:41:20 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
1998-11-06 21:17:31 +00:00
|
|
|
FG_LOG( FG_INPUT, FG_DEBUG, "" );
|
1997-07-18 23:41:20 +00:00
|
|
|
switch (k) {
|
1999-06-01 21:17:10 +00:00
|
|
|
case GLUT_KEY_F2: // F2 Reload Tile Cache...
|
|
|
|
{
|
|
|
|
int toggle_pause;
|
|
|
|
FG_LOG(FG_INPUT, FG_INFO, "ReIniting TileCache");
|
|
|
|
FGTime *t = FGTime::cur_time_params;
|
|
|
|
if( (toggle_pause = !t->getPause()) )
|
|
|
|
t->togglePauseMode();
|
|
|
|
BusyCursor(0);
|
1999-06-13 05:58:02 +00:00
|
|
|
if( global_tile_mgr.init() ) {
|
|
|
|
// Load the local scenery data
|
|
|
|
global_tile_mgr.update();
|
|
|
|
} else {
|
|
|
|
FG_LOG( FG_GENERAL, FG_ALERT,
|
|
|
|
"Error in Tile Manager initialization!" );
|
|
|
|
exit(-1);
|
|
|
|
}
|
1999-06-01 21:17:10 +00:00
|
|
|
BusyCursor(1);
|
|
|
|
if(toggle_pause)
|
|
|
|
t->togglePauseMode();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
case GLUT_KEY_F8: // F8 toggles fog ... off fastest nicest...
|
1998-09-17 18:35:30 +00:00
|
|
|
current_options.cycle_fog();
|
|
|
|
|
|
|
|
if ( current_options.get_fog() == fgOPTIONS::FG_FOG_DISABLED ) {
|
1998-11-06 21:17:31 +00:00
|
|
|
FG_LOG( FG_INPUT, FG_INFO, "Fog disabled" );
|
1998-09-17 18:35:30 +00:00
|
|
|
} else if ( current_options.get_fog() ==
|
|
|
|
fgOPTIONS::FG_FOG_FASTEST )
|
|
|
|
{
|
1998-11-06 21:17:31 +00:00
|
|
|
FG_LOG( FG_INPUT, FG_INFO,
|
|
|
|
"Fog enabled, hint set to fastest" );
|
1998-09-17 18:35:30 +00:00
|
|
|
} else if ( current_options.get_fog() ==
|
|
|
|
fgOPTIONS::FG_FOG_NICEST )
|
|
|
|
{
|
1998-11-06 21:17:31 +00:00
|
|
|
FG_LOG( FG_INPUT, FG_INFO,
|
|
|
|
"Fog enabled, hint set to nicest" );
|
1998-09-17 18:35:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
1998-09-26 13:16:44 +00:00
|
|
|
case GLUT_KEY_F9: // F9 toggles textures on and off...
|
1999-04-27 15:52:32 +00:00
|
|
|
if ( material_mgr.loaded() ) {
|
1998-09-17 18:35:30 +00:00
|
|
|
current_options.get_textures() ?
|
|
|
|
current_options.set_textures(false) :
|
|
|
|
current_options.set_textures(true);
|
1998-11-06 21:17:31 +00:00
|
|
|
FG_LOG( FG_INPUT, FG_INFO, "Toggling texture" );
|
1998-09-17 18:35:30 +00:00
|
|
|
} else {
|
1998-11-06 21:17:31 +00:00
|
|
|
FG_LOG( FG_INPUT, FG_INFO,
|
|
|
|
"No textures loaded, cannot toggle" );
|
1998-09-17 18:35:30 +00:00
|
|
|
}
|
|
|
|
return;
|
1998-09-26 13:16:44 +00:00
|
|
|
case GLUT_KEY_F10: // F10 toggles menu on and off...
|
1998-11-06 21:17:31 +00:00
|
|
|
FG_LOG(FG_INPUT, FG_INFO, "Invoking call back function");
|
1999-05-06 21:14:06 +00:00
|
|
|
guiToggleMenu();
|
1999-05-12 01:11:17 +00:00
|
|
|
return;
|
|
|
|
case GLUT_KEY_F11: // F11 Altitude Dialog.
|
|
|
|
FG_LOG(FG_INPUT, FG_INFO, "Invoking Altitude call back function");
|
1999-06-01 21:17:10 +00:00
|
|
|
NewAltitude( NULL );
|
1998-06-12 00:57:38 +00:00
|
|
|
return;
|
1999-05-12 01:11:17 +00:00
|
|
|
case GLUT_KEY_F12: // F12 Heading Dialog...
|
|
|
|
FG_LOG(FG_INPUT, FG_INFO, "Invoking Heading call back function");
|
1999-06-01 21:17:10 +00:00
|
|
|
NewHeading( NULL );
|
1999-05-12 01:11:17 +00:00
|
|
|
return;
|
1997-07-18 23:41:20 +00:00
|
|
|
case GLUT_KEY_UP:
|
1999-04-27 15:52:32 +00:00
|
|
|
if( fgAPAltitudeEnabled() || fgAPTerrainFollowEnabled() ) {
|
1999-02-12 22:17:59 +00:00
|
|
|
fgAPAltitudeAdjust( -100 );
|
|
|
|
} else {
|
|
|
|
controls.move_elevator(0.05);
|
|
|
|
}
|
1997-07-18 23:41:20 +00:00
|
|
|
return;
|
|
|
|
case GLUT_KEY_DOWN:
|
1999-04-27 15:52:32 +00:00
|
|
|
if( fgAPAltitudeEnabled() || fgAPTerrainFollowEnabled() ) {
|
1999-02-12 22:17:59 +00:00
|
|
|
fgAPAltitudeAdjust( 100 );
|
|
|
|
} else {
|
|
|
|
controls.move_elevator(-0.05);
|
|
|
|
}
|
1997-07-18 23:41:20 +00:00
|
|
|
return;
|
|
|
|
case GLUT_KEY_LEFT:
|
1998-10-25 14:08:37 +00:00
|
|
|
controls.move_aileron(-0.05);
|
1997-07-18 23:41:20 +00:00
|
|
|
return;
|
|
|
|
case GLUT_KEY_RIGHT:
|
1998-10-25 14:08:37 +00:00
|
|
|
controls.move_aileron(0.05);
|
1997-07-18 23:41:20 +00:00
|
|
|
return;
|
1998-09-26 13:16:44 +00:00
|
|
|
case GLUT_KEY_HOME: // numeric keypad 1
|
1998-10-25 14:08:37 +00:00
|
|
|
controls.move_elevator_trim(0.001);
|
1997-07-18 23:41:20 +00:00
|
|
|
return;
|
1998-09-26 13:16:44 +00:00
|
|
|
case GLUT_KEY_END: // numeric keypad 7
|
1998-10-25 14:08:37 +00:00
|
|
|
controls.move_elevator_trim(-0.001);
|
1997-07-18 23:41:20 +00:00
|
|
|
return;
|
1998-09-26 13:16:44 +00:00
|
|
|
case GLUT_KEY_INSERT: // numeric keypad Ins
|
1999-02-12 22:17:59 +00:00
|
|
|
if( fgAPHeadingEnabled() ) {
|
|
|
|
fgAPHeadingAdjust( -1 );
|
|
|
|
} else {
|
|
|
|
controls.move_rudder(-0.05);
|
|
|
|
}
|
1997-07-18 23:41:20 +00:00
|
|
|
return;
|
1998-09-26 13:16:44 +00:00
|
|
|
case 13: // numeric keypad Enter
|
1999-02-12 22:17:59 +00:00
|
|
|
if( fgAPHeadingEnabled() ) {
|
|
|
|
fgAPHeadingAdjust( 1 );
|
|
|
|
} else {
|
|
|
|
controls.move_rudder(0.05);
|
|
|
|
}
|
1997-07-18 23:41:20 +00:00
|
|
|
return;
|
1998-09-26 13:16:44 +00:00
|
|
|
case 53: // numeric keypad 5
|
1998-10-25 14:08:37 +00:00
|
|
|
controls.set_aileron(0.0);
|
|
|
|
controls.set_elevator(0.0);
|
|
|
|
controls.set_rudder(0.0);
|
1997-07-18 23:41:20 +00:00
|
|
|
return;
|
1998-09-26 13:16:44 +00:00
|
|
|
case GLUT_KEY_PAGE_UP: // numeric keypad 9 (Pg Up)
|
1999-02-12 23:22:35 +00:00
|
|
|
if( fgAPAutoThrottleEnabled() ) {
|
|
|
|
fgAPAutoThrottleAdjust( 5 );
|
|
|
|
} else {
|
|
|
|
controls.move_throttle( FGControls::ALL_ENGINES, 0.01 );
|
|
|
|
}
|
1997-07-18 23:41:20 +00:00
|
|
|
return;
|
1998-09-26 13:16:44 +00:00
|
|
|
case GLUT_KEY_PAGE_DOWN: // numeric keypad 3 (Pg Dn)
|
1999-02-12 23:22:35 +00:00
|
|
|
if( fgAPAutoThrottleEnabled() ) {
|
|
|
|
fgAPAutoThrottleAdjust( -5 );
|
|
|
|
} else {
|
|
|
|
controls.move_throttle( FGControls::ALL_ENGINES, -0.01 );
|
|
|
|
}
|
1997-07-18 23:41:20 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
1997-05-31 04:13:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|