1 /**************************************************************************
2 * tkglkey.c -- handle tkgl keyboard events
4 * Written by Curtis Olson, started May 1997.
6 * Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of the
11 * License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 * (Log is kept at end of this file)
24 **************************************************************************/
33 #include "../aircraft/aircraft.h"
35 extern double fogDensity;
36 extern double goal_view_offset;
38 /* Handle keyboard events */
39 void GLUTkey(unsigned char k, int x, int y) {
40 struct control_params *c;
42 c = ¤t_aircraft.controls;
44 printf("Key hit = %d\n", k);
46 if ( GLUT_ACTIVE_SHIFT && glutGetModifiers() ) {
48 case 49: /* numeric keypad 1 */
49 goal_view_offset = M_PI * 0.75;
51 case 50: /* numeric keypad 2 */
52 goal_view_offset = M_PI;
54 case 51: /* numeric keypad 3 */
55 goal_view_offset = M_PI * 1.25;
57 case 52: /* numeric keypad 4 */
58 goal_view_offset = M_PI * 0.50;
60 case 54: /* numeric keypad 6 */
61 goal_view_offset = M_PI * 1.50;
63 case 55: /* numeric keypad 7 */
64 goal_view_offset = M_PI * 0.25;
66 case 56: /* numeric keypad 8 */
67 goal_view_offset = 0.00;
69 case 57: /* numeric keypad 9 */
70 goal_view_offset = M_PI * 1.75;
75 case 50: /* numeric keypad 2 */
78 case 56: /* numeric keypad 8 */
81 case 49: /* numeric keypad 1 */
82 fgElevTrimMove(-0.001);
84 case 55: /* numeric keypad 7 */
85 fgElevTrimMove(0.001);
87 case 52: /* numeric keypad 4 */
90 case 54: /* numeric keypad 6 */
93 case 48: /* numeric keypad Ins */
96 case 13: /* numeric keypad Enter */
99 case 53: /* numeric keypad 5 */
104 case 57: /* numeric keypad 9 (Pg Up) */
105 fgThrottleMove(0, 0.01);
107 case 51: /* numeric keypad 3 (Pg Dn) */
108 fgThrottleMove(0, -0.01);
112 glFogf(GL_FOG_END, fogDensity);
113 printf("Fog density = %.4f\n", fogDensity);
117 glFogf(GL_FOG_END, fogDensity);
118 printf("Fog density = %.4f\n", fogDensity);
128 /* Handle "special" keyboard events */
129 void GLUTspecialkey(int k, int x, int y) {
130 struct control_params *c;
132 c = ¤t_aircraft.controls;
134 printf("Special key hit = %d\n", k);
144 fgAileronMove(-0.05);
155 /* Revision 1.11 1997/06/18 04:10:31 curt
156 /* A couple more runway tweaks ...
158 * Revision 1.10 1997/06/18 02:21:23 curt
161 * Revision 1.9 1997/06/02 03:40:06 curt
162 * A tiny bit more view tweaking.
164 * Revision 1.8 1997/06/02 03:01:38 curt
165 * Working on views (side, front, back, transitions, etc.)
167 * Revision 1.7 1997/05/31 19:16:25 curt
168 * Elevator trim added.
170 * Revision 1.6 1997/05/31 04:13:52 curt
173 * Continuing work on the LaRCsim flight model integration.
174 * Added some MSFS-like keyboard input handling.
176 * Revision 1.5 1997/05/30 23:26:19 curt
177 * Added elevator/aileron controls.
179 * Revision 1.4 1997/05/27 17:44:31 curt
180 * Renamed & rearranged variables and routines. Added some initial simple
181 * timer/alarm routines so the flight model can be updated on a regular interval.
183 * Revision 1.3 1997/05/23 15:40:25 curt
184 * Added GNU copyright headers.
187 * Revision 1.2 1997/05/23 00:35:12 curt
188 * Trying to get fog to work ...
190 * Revision 1.1 1997/05/21 15:57:50 curt
191 * Renamed due to added GLUT support.
193 * Revision 1.2 1997/05/19 18:22:41 curt
194 * Parameter tweaking ... starting to stub in fog support.
196 * Revision 1.1 1997/05/16 16:05:51 curt