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 **************************************************************************/
36 #include "../Aircraft/aircraft.h"
37 #include "../constants.h"
39 extern double fogDensity;
40 extern double goal_view_offset;
42 /* Handle keyboard events */
43 void GLUTkey(unsigned char k, int x, int y) {
44 struct control_params *c;
46 c = ¤t_aircraft.controls;
48 printf("Key hit = %d", k);
50 if ( GLUT_ACTIVE_ALT && glutGetModifiers() ) {
53 case 49: /* numeric keypad 1 */
54 goal_view_offset = FG_PI * 0.75;
56 case 50: /* numeric keypad 2 */
57 goal_view_offset = FG_PI;
59 case 51: /* numeric keypad 3 */
60 goal_view_offset = FG_PI * 1.25;
62 case 52: /* numeric keypad 4 */
63 goal_view_offset = FG_PI * 0.50;
65 case 54: /* numeric keypad 6 */
66 goal_view_offset = FG_PI * 1.50;
68 case 55: /* numeric keypad 7 */
69 goal_view_offset = FG_PI * 0.25;
71 case 56: /* numeric keypad 8 */
72 goal_view_offset = 0.00;
74 case 57: /* numeric keypad 9 */
75 goal_view_offset = FG_PI * 1.75;
81 case 50: /* numeric keypad 2 */
84 case 56: /* numeric keypad 8 */
87 case 49: /* numeric keypad 1 */
88 fgElevTrimMove(-0.001);
90 case 55: /* numeric keypad 7 */
91 fgElevTrimMove(0.001);
93 case 52: /* numeric keypad 4 */
96 case 54: /* numeric keypad 6 */
99 case 48: /* numeric keypad Ins */
102 case 13: /* numeric keypad Enter */
105 case 53: /* numeric keypad 5 */
110 case 57: /* numeric keypad 9 (Pg Up) */
111 fgThrottleMove(0, 0.01);
113 case 51: /* numeric keypad 3 (Pg Dn) */
114 fgThrottleMove(0, -0.01);
118 glFogf(GL_FOG_END, fogDensity);
119 printf("Fog density = %.4f\n", fogDensity);
123 glFogf(GL_FOG_END, fogDensity);
124 printf("Fog density = %.4f\n", fogDensity);
134 /* Handle "special" keyboard events */
135 void GLUTspecialkey(int k, int x, int y) {
136 struct control_params *c;
138 c = ¤t_aircraft.controls;
140 printf("Special key hit = %d", k);
142 if ( GLUT_ACTIVE_SHIFT && glutGetModifiers() ) {
143 printf(" SHIFTED\n");
145 case GLUT_KEY_END: /* numeric keypad 1 */
146 goal_view_offset = FG_PI * 0.75;
148 case GLUT_KEY_DOWN: /* numeric keypad 2 */
149 goal_view_offset = FG_PI;
151 case GLUT_KEY_PAGE_DOWN: /* numeric keypad 3 */
152 goal_view_offset = FG_PI * 1.25;
154 case GLUT_KEY_LEFT: /* numeric keypad 4 */
155 goal_view_offset = FG_PI * 0.50;
157 case GLUT_KEY_RIGHT: /* numeric keypad 6 */
158 goal_view_offset = FG_PI * 1.50;
160 case GLUT_KEY_HOME: /* numeric keypad 7 */
161 goal_view_offset = FG_PI * 0.25;
163 case GLUT_KEY_UP: /* numeric keypad 8 */
164 goal_view_offset = 0.00;
166 case GLUT_KEY_PAGE_UP: /* numeric keypad 9 */
167 goal_view_offset = FG_PI * 1.75;
180 fgAileronMove(-0.05);
185 case GLUT_KEY_HOME: /* numeric keypad 1 */
186 fgElevTrimMove(-0.001);
188 case GLUT_KEY_END: /* numeric keypad 7 */
189 fgElevTrimMove(0.001);
191 case GLUT_KEY_INSERT: /* numeric keypad Ins */
194 case 13: /* numeric keypad Enter */
197 case 53: /* numeric keypad 5 */
202 case GLUT_KEY_PAGE_UP: /* numeric keypad 9 (Pg Up) */
203 fgThrottleMove(0, 0.01);
205 case GLUT_KEY_PAGE_DOWN: /* numeric keypad 3 (Pg Dn) */
206 fgThrottleMove(0, -0.01);
214 /* Revision 1.17 1997/07/19 22:34:02 curt
215 /* Moved PI definitions to ../constants.h
216 /* Moved random() stuff to ../Utils/ and renamed fg_random()
218 * Revision 1.16 1997/07/18 23:41:24 curt
219 * Tweaks for building with Cygnus Win32 compiler.
221 * Revision 1.15 1997/07/16 20:04:47 curt
222 * Minor tweaks to aid Win32 port.
224 * Revision 1.14 1997/07/12 03:50:20 curt
225 * Added an #include <Windows32/Base.h> to help compiling for Win32
227 * Revision 1.13 1997/06/25 15:39:46 curt
228 * Minor changes to compile with rsxnt/win32.
230 * Revision 1.12 1997/06/21 17:12:52 curt
231 * Capitalized subdirectory names.
233 * Revision 1.11 1997/06/18 04:10:31 curt
234 * A couple more runway tweaks ...
236 * Revision 1.10 1997/06/18 02:21:23 curt
239 * Revision 1.9 1997/06/02 03:40:06 curt
240 * A tiny bit more view tweaking.
242 * Revision 1.8 1997/06/02 03:01:38 curt
243 * Working on views (side, front, back, transitions, etc.)
245 * Revision 1.7 1997/05/31 19:16:25 curt
246 * Elevator trim added.
248 * Revision 1.6 1997/05/31 04:13:52 curt
251 * Continuing work on the LaRCsim flight model integration.
252 * Added some MSFS-like keyboard input handling.
254 * Revision 1.5 1997/05/30 23:26:19 curt
255 * Added elevator/aileron controls.
257 * Revision 1.4 1997/05/27 17:44:31 curt
258 * Renamed & rearranged variables and routines. Added some initial simple
259 * timer/alarm routines so the flight model can be updated on a regular interval.
261 * Revision 1.3 1997/05/23 15:40:25 curt
262 * Added GNU copyright headers.
265 * Revision 1.2 1997/05/23 00:35:12 curt
266 * Trying to get fog to work ...
268 * Revision 1.1 1997/05/21 15:57:50 curt
269 * Renamed due to added GLUT support.
271 * Revision 1.2 1997/05/19 18:22:41 curt
272 * Parameter tweaking ... starting to stub in fog support.
274 * Revision 1.1 1997/05/16 16:05:51 curt