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 **************************************************************************/
31 # include <Windows32/Base.h>
37 #include "../Aircraft/aircraft.h"
40 #define M_PI 3.14159265358979323846 /* pi */
43 extern double fogDensity;
44 extern double goal_view_offset;
46 /* Handle keyboard events */
47 void GLUTkey(unsigned char k, int x, int y) {
48 struct control_params *c;
50 c = ¤t_aircraft.controls;
52 printf("Key hit = %d\n", k);
54 if ( GLUT_ACTIVE_SHIFT && glutGetModifiers() ) {
56 case 49: /* numeric keypad 1 */
57 goal_view_offset = M_PI * 0.75;
59 case 50: /* numeric keypad 2 */
60 goal_view_offset = M_PI;
62 case 51: /* numeric keypad 3 */
63 goal_view_offset = M_PI * 1.25;
65 case 52: /* numeric keypad 4 */
66 goal_view_offset = M_PI * 0.50;
68 case 54: /* numeric keypad 6 */
69 goal_view_offset = M_PI * 1.50;
71 case 55: /* numeric keypad 7 */
72 goal_view_offset = M_PI * 0.25;
74 case 56: /* numeric keypad 8 */
75 goal_view_offset = 0.00;
77 case 57: /* numeric keypad 9 */
78 goal_view_offset = M_PI * 1.75;
83 case 50: /* numeric keypad 2 */
86 case 56: /* numeric keypad 8 */
89 case 49: /* numeric keypad 1 */
90 fgElevTrimMove(-0.001);
92 case 55: /* numeric keypad 7 */
93 fgElevTrimMove(0.001);
95 case 52: /* numeric keypad 4 */
98 case 54: /* numeric keypad 6 */
101 case 48: /* numeric keypad Ins */
104 case 13: /* numeric keypad Enter */
107 case 53: /* numeric keypad 5 */
112 case 57: /* numeric keypad 9 (Pg Up) */
113 fgThrottleMove(0, 0.01);
115 case 51: /* numeric keypad 3 (Pg Dn) */
116 fgThrottleMove(0, -0.01);
120 glFogf(GL_FOG_END, fogDensity);
121 printf("Fog density = %.4f\n", fogDensity);
125 glFogf(GL_FOG_END, fogDensity);
126 printf("Fog density = %.4f\n", fogDensity);
136 /* Handle "special" keyboard events */
137 void GLUTspecialkey(int k, int x, int y) {
138 struct control_params *c;
140 c = ¤t_aircraft.controls;
142 printf("Special key hit = %d\n", k);
152 fgAileronMove(-0.05);
163 /* Revision 1.14 1997/07/12 03:50:20 curt
164 /* Added an #include <Windows32/Base.h> to help compiling for Win32
166 * Revision 1.13 1997/06/25 15:39:46 curt
167 * Minor changes to compile with rsxnt/win32.
169 * Revision 1.12 1997/06/21 17:12:52 curt
170 * Capitalized subdirectory names.
172 * Revision 1.11 1997/06/18 04:10:31 curt
173 * A couple more runway tweaks ...
175 * Revision 1.10 1997/06/18 02:21:23 curt
178 * Revision 1.9 1997/06/02 03:40:06 curt
179 * A tiny bit more view tweaking.
181 * Revision 1.8 1997/06/02 03:01:38 curt
182 * Working on views (side, front, back, transitions, etc.)
184 * Revision 1.7 1997/05/31 19:16:25 curt
185 * Elevator trim added.
187 * Revision 1.6 1997/05/31 04:13:52 curt
190 * Continuing work on the LaRCsim flight model integration.
191 * Added some MSFS-like keyboard input handling.
193 * Revision 1.5 1997/05/30 23:26:19 curt
194 * Added elevator/aileron controls.
196 * Revision 1.4 1997/05/27 17:44:31 curt
197 * Renamed & rearranged variables and routines. Added some initial simple
198 * timer/alarm routines so the flight model can be updated on a regular interval.
200 * Revision 1.3 1997/05/23 15:40:25 curt
201 * Added GNU copyright headers.
204 * Revision 1.2 1997/05/23 00:35:12 curt
205 * Trying to get fog to work ...
207 * Revision 1.1 1997/05/21 15:57:50 curt
208 * Renamed due to added GLUT support.
210 * Revision 1.2 1997/05/19 18:22:41 curt
211 * Parameter tweaking ... starting to stub in fog support.
213 * Revision 1.1 1997/05/16 16:05:51 curt