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"
42 extern double goal_view_offset;
44 /* Handle keyboard events */
45 void GLUTkey(unsigned char k, int x, int y) {
46 struct control_params *c;
47 struct weather_params *w;
49 c = ¤t_aircraft.controls;
52 printf("Key hit = %d", k);
54 if ( GLUT_ACTIVE_ALT && glutGetModifiers() ) {
57 case 49: /* numeric keypad 1 */
58 goal_view_offset = FG_PI * 0.75;
60 case 50: /* numeric keypad 2 */
61 goal_view_offset = FG_PI;
63 case 51: /* numeric keypad 3 */
64 goal_view_offset = FG_PI * 1.25;
66 case 52: /* numeric keypad 4 */
67 goal_view_offset = FG_PI * 0.50;
69 case 54: /* numeric keypad 6 */
70 goal_view_offset = FG_PI * 1.50;
72 case 55: /* numeric keypad 7 */
73 goal_view_offset = FG_PI * 0.25;
75 case 56: /* numeric keypad 8 */
76 goal_view_offset = 0.00;
78 case 57: /* numeric keypad 9 */
79 goal_view_offset = FG_PI * 1.75;
82 w->visibility /= 1.10;
83 glFogf(GL_FOG_END, w->visibility);
84 printf("Fog density = %.4f\n", w->visibility);
90 case 50: /* numeric keypad 2 */
93 case 56: /* numeric keypad 8 */
96 case 49: /* numeric keypad 1 */
97 fgElevTrimMove(-0.001);
99 case 55: /* numeric keypad 7 */
100 fgElevTrimMove(0.001);
102 case 52: /* numeric keypad 4 */
103 fgAileronMove(-0.05);
105 case 54: /* numeric keypad 6 */
108 case 48: /* numeric keypad Ins */
111 case 13: /* numeric keypad Enter */
114 case 53: /* numeric keypad 5 */
119 case 57: /* numeric keypad 9 (Pg Up) */
120 fgThrottleMove(0, 0.01);
122 case 51: /* numeric keypad 3 (Pg Dn) */
123 fgThrottleMove(0, -0.01);
126 w->visibility *= 1.10;
127 glFogf(GL_FOG_END, w->visibility);
128 printf("Fog density = %.4f\n", w->visibility);
138 /* Handle "special" keyboard events */
139 void GLUTspecialkey(int k, int x, int y) {
140 struct control_params *c;
142 c = ¤t_aircraft.controls;
144 printf("Special key hit = %d", k);
146 if ( GLUT_ACTIVE_SHIFT && glutGetModifiers() ) {
147 printf(" SHIFTED\n");
149 case GLUT_KEY_END: /* numeric keypad 1 */
150 goal_view_offset = FG_PI * 0.75;
152 case GLUT_KEY_DOWN: /* numeric keypad 2 */
153 goal_view_offset = FG_PI;
155 case GLUT_KEY_PAGE_DOWN: /* numeric keypad 3 */
156 goal_view_offset = FG_PI * 1.25;
158 case GLUT_KEY_LEFT: /* numeric keypad 4 */
159 goal_view_offset = FG_PI * 0.50;
161 case GLUT_KEY_RIGHT: /* numeric keypad 6 */
162 goal_view_offset = FG_PI * 1.50;
164 case GLUT_KEY_HOME: /* numeric keypad 7 */
165 goal_view_offset = FG_PI * 0.25;
167 case GLUT_KEY_UP: /* numeric keypad 8 */
168 goal_view_offset = 0.00;
170 case GLUT_KEY_PAGE_UP: /* numeric keypad 9 */
171 goal_view_offset = FG_PI * 1.75;
184 fgAileronMove(-0.05);
189 case GLUT_KEY_HOME: /* numeric keypad 1 */
190 fgElevTrimMove(-0.001);
192 case GLUT_KEY_END: /* numeric keypad 7 */
193 fgElevTrimMove(0.001);
195 case GLUT_KEY_INSERT: /* numeric keypad Ins */
198 case 13: /* numeric keypad Enter */
201 case 53: /* numeric keypad 5 */
206 case GLUT_KEY_PAGE_UP: /* numeric keypad 9 (Pg Up) */
207 fgThrottleMove(0, 0.01);
209 case GLUT_KEY_PAGE_DOWN: /* numeric keypad 3 (Pg Dn) */
210 fgThrottleMove(0, -0.01);
218 /* Revision 1.18 1997/08/22 21:34:38 curt
219 /* Doing a bit of reorganizing and house cleaning.
221 * Revision 1.17 1997/07/19 22:34:02 curt
222 * Moved PI definitions to ../constants.h
223 * Moved random() stuff to ../Utils/ and renamed fg_random()
225 * Revision 1.16 1997/07/18 23:41:24 curt
226 * Tweaks for building with Cygnus Win32 compiler.
228 * Revision 1.15 1997/07/16 20:04:47 curt
229 * Minor tweaks to aid Win32 port.
231 * Revision 1.14 1997/07/12 03:50:20 curt
232 * Added an #include <Windows32/Base.h> to help compiling for Win32
234 * Revision 1.13 1997/06/25 15:39:46 curt
235 * Minor changes to compile with rsxnt/win32.
237 * Revision 1.12 1997/06/21 17:12:52 curt
238 * Capitalized subdirectory names.
240 * Revision 1.11 1997/06/18 04:10:31 curt
241 * A couple more runway tweaks ...
243 * Revision 1.10 1997/06/18 02:21:23 curt
246 * Revision 1.9 1997/06/02 03:40:06 curt
247 * A tiny bit more view tweaking.
249 * Revision 1.8 1997/06/02 03:01:38 curt
250 * Working on views (side, front, back, transitions, etc.)
252 * Revision 1.7 1997/05/31 19:16:25 curt
253 * Elevator trim added.
255 * Revision 1.6 1997/05/31 04:13:52 curt
258 * Continuing work on the LaRCsim flight model integration.
259 * Added some MSFS-like keyboard input handling.
261 * Revision 1.5 1997/05/30 23:26:19 curt
262 * Added elevator/aileron controls.
264 * Revision 1.4 1997/05/27 17:44:31 curt
265 * Renamed & rearranged variables and routines. Added some initial simple
266 * timer/alarm routines so the flight model can be updated on a regular interval.
268 * Revision 1.3 1997/05/23 15:40:25 curt
269 * Added GNU copyright headers.
272 * Revision 1.2 1997/05/23 00:35:12 curt
273 * Trying to get fog to work ...
275 * Revision 1.1 1997/05/21 15:57:50 curt
276 * Renamed due to added GLUT support.
278 * Revision 1.2 1997/05/19 18:22:41 curt
279 * Parameter tweaking ... starting to stub in fog support.
281 * Revision 1.1 1997/05/16 16:05:51 curt