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 **************************************************************************/
37 #include "../constants.h"
39 #include "../Aircraft/aircraft.h"
40 #include "../Weather/weather.h"
43 extern int show_hud; /* HUD state */
46 /* Handle keyboard events */
47 void GLUTkey(unsigned char k, int x, int y) {
52 c = ¤t_aircraft.controls;
56 printf("Key hit = %d", k);
58 if ( GLUT_ACTIVE_ALT && glutGetModifiers() ) {
61 case 49: /* numeric keypad 1 */
62 v->goal_view_offset = FG_PI * 0.75;
64 case 50: /* numeric keypad 2 */
65 v->goal_view_offset = FG_PI;
67 case 51: /* numeric keypad 3 */
68 v->goal_view_offset = FG_PI * 1.25;
70 case 52: /* numeric keypad 4 */
71 v->goal_view_offset = FG_PI * 0.50;
73 case 54: /* numeric keypad 6 */
74 v->goal_view_offset = FG_PI * 1.50;
76 case 55: /* numeric keypad 7 */
77 v->goal_view_offset = FG_PI * 0.25;
79 case 56: /* numeric keypad 8 */
80 v->goal_view_offset = 0.00;
82 case 57: /* numeric keypad 9 */
83 v->goal_view_offset = FG_PI * 1.75;
89 w->visibility /= 1.10;
90 glFogf(GL_FOG_END, w->visibility);
91 printf("Fog density = %.4f\n", w->visibility);
97 case 50: /* numeric keypad 2 */
100 case 56: /* numeric keypad 8 */
103 case 49: /* numeric keypad 1 */
104 fgElevTrimMove(-0.001);
106 case 55: /* numeric keypad 7 */
107 fgElevTrimMove(0.001);
109 case 52: /* numeric keypad 4 */
110 fgAileronMove(-0.05);
112 case 54: /* numeric keypad 6 */
115 case 48: /* numeric keypad Ins */
118 case 13: /* numeric keypad Enter */
121 case 53: /* numeric keypad 5 */
126 case 57: /* numeric keypad 9 (Pg Up) */
127 fgThrottleMove(0, 0.01);
129 case 51: /* numeric keypad 3 (Pg Dn) */
130 fgThrottleMove(0, -0.01);
132 case 122: /* z key */
133 w->visibility *= 1.10;
134 glFogf(GL_FOG_END, w->visibility);
135 printf("Fog density = %.4f\n", w->visibility);
145 /* Handle "special" keyboard events */
146 void GLUTspecialkey(int k, int x, int y) {
147 struct fgCONTROLS *c;
150 c = ¤t_aircraft.controls;
153 printf("Special key hit = %d", k);
155 if ( GLUT_ACTIVE_SHIFT && glutGetModifiers() ) {
156 printf(" SHIFTED\n");
158 case GLUT_KEY_END: /* numeric keypad 1 */
159 v->goal_view_offset = FG_PI * 0.75;
161 case GLUT_KEY_DOWN: /* numeric keypad 2 */
162 v->goal_view_offset = FG_PI;
164 case GLUT_KEY_PAGE_DOWN: /* numeric keypad 3 */
165 v->goal_view_offset = FG_PI * 1.25;
167 case GLUT_KEY_LEFT: /* numeric keypad 4 */
168 v->goal_view_offset = FG_PI * 0.50;
170 case GLUT_KEY_RIGHT: /* numeric keypad 6 */
171 v->goal_view_offset = FG_PI * 1.50;
173 case GLUT_KEY_HOME: /* numeric keypad 7 */
174 v->goal_view_offset = FG_PI * 0.25;
176 case GLUT_KEY_UP: /* numeric keypad 8 */
177 v->goal_view_offset = 0.00;
179 case GLUT_KEY_PAGE_UP: /* numeric keypad 9 */
180 v->goal_view_offset = FG_PI * 1.75;
193 fgAileronMove(-0.05);
198 case GLUT_KEY_HOME: /* numeric keypad 1 */
199 fgElevTrimMove(-0.001);
201 case GLUT_KEY_END: /* numeric keypad 7 */
202 fgElevTrimMove(0.001);
204 case GLUT_KEY_INSERT: /* numeric keypad Ins */
207 case 13: /* numeric keypad Enter */
210 case 53: /* numeric keypad 5 */
215 case GLUT_KEY_PAGE_UP: /* numeric keypad 9 (Pg Up) */
216 fgThrottleMove(0, 0.01);
218 case GLUT_KEY_PAGE_DOWN: /* numeric keypad 3 (Pg Dn) */
219 fgThrottleMove(0, -0.01);
227 /* Revision 1.22 1997/12/10 22:37:45 curt
228 /* Prepended "fg" on the name of all global structures that didn't have it yet.
229 /* i.e. "struct WEATHER {}" became "struct fgWEATHER {}"
231 * Revision 1.21 1997/08/27 21:32:23 curt
232 * Restructured view calculation code. Added stars.
234 * Revision 1.20 1997/08/27 03:30:13 curt
235 * Changed naming scheme of basic shared structures.
237 * Revision 1.19 1997/08/25 20:27:21 curt
238 * Merged in initial HUD and Joystick code.
240 * Revision 1.18 1997/08/22 21:34:38 curt
241 * Doing a bit of reorganizing and house cleaning.
243 * Revision 1.17 1997/07/19 22:34:02 curt
244 * Moved PI definitions to ../constants.h
245 * Moved random() stuff to ../Utils/ and renamed fg_random()
247 * Revision 1.16 1997/07/18 23:41:24 curt
248 * Tweaks for building with Cygnus Win32 compiler.
250 * Revision 1.15 1997/07/16 20:04:47 curt
251 * Minor tweaks to aid Win32 port.
253 * Revision 1.14 1997/07/12 03:50:20 curt
254 * Added an #include <Windows32/Base.h> to help compiling for Win32
256 * Revision 1.13 1997/06/25 15:39:46 curt
257 * Minor changes to compile with rsxnt/win32.
259 * Revision 1.12 1997/06/21 17:12:52 curt
260 * Capitalized subdirectory names.
262 * Revision 1.11 1997/06/18 04:10:31 curt
263 * A couple more runway tweaks ...
265 * Revision 1.10 1997/06/18 02:21:23 curt
268 * Revision 1.9 1997/06/02 03:40:06 curt
269 * A tiny bit more view tweaking.
271 * Revision 1.8 1997/06/02 03:01:38 curt
272 * Working on views (side, front, back, transitions, etc.)
274 * Revision 1.7 1997/05/31 19:16:25 curt
275 * Elevator trim added.
277 * Revision 1.6 1997/05/31 04:13:52 curt
280 * Continuing work on the LaRCsim flight model integration.
281 * Added some MSFS-like keyboard input handling.
283 * Revision 1.5 1997/05/30 23:26:19 curt
284 * Added elevator/aileron controls.
286 * Revision 1.4 1997/05/27 17:44:31 curt
287 * Renamed & rearranged variables and routines. Added some initial simple
288 * timer/alarm routines so the flight model can be updated on a regular interval.
290 * Revision 1.3 1997/05/23 15:40:25 curt
291 * Added GNU copyright headers.
294 * Revision 1.2 1997/05/23 00:35:12 curt
295 * Trying to get fog to work ...
297 * Revision 1.1 1997/05/21 15:57:50 curt
298 * Renamed due to added GLUT support.
300 * Revision 1.2 1997/05/19 18:22:41 curt
301 * Parameter tweaking ... starting to stub in fog support.
303 * Revision 1.1 1997/05/16 16:05:51 curt