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"
36 #define M_PI 3.14159265358979323846 /* pi */
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\n", k);
50 if ( GLUT_ACTIVE_SHIFT && glutGetModifiers() ) {
52 case 49: /* numeric keypad 1 */
53 goal_view_offset = M_PI * 0.75;
55 case 50: /* numeric keypad 2 */
56 goal_view_offset = M_PI;
58 case 51: /* numeric keypad 3 */
59 goal_view_offset = M_PI * 1.25;
61 case 52: /* numeric keypad 4 */
62 goal_view_offset = M_PI * 0.50;
64 case 54: /* numeric keypad 6 */
65 goal_view_offset = M_PI * 1.50;
67 case 55: /* numeric keypad 7 */
68 goal_view_offset = M_PI * 0.25;
70 case 56: /* numeric keypad 8 */
71 goal_view_offset = 0.00;
73 case 57: /* numeric keypad 9 */
74 goal_view_offset = M_PI * 1.75;
79 case 50: /* numeric keypad 2 */
82 case 56: /* numeric keypad 8 */
85 case 49: /* numeric keypad 1 */
86 fgElevTrimMove(-0.001);
88 case 55: /* numeric keypad 7 */
89 fgElevTrimMove(0.001);
91 case 52: /* numeric keypad 4 */
94 case 54: /* numeric keypad 6 */
97 case 48: /* numeric keypad Ins */
100 case 13: /* numeric keypad Enter */
103 case 53: /* numeric keypad 5 */
108 case 57: /* numeric keypad 9 (Pg Up) */
109 fgThrottleMove(0, 0.01);
111 case 51: /* numeric keypad 3 (Pg Dn) */
112 fgThrottleMove(0, -0.01);
116 glFogf(GL_FOG_END, fogDensity);
117 printf("Fog density = %.4f\n", fogDensity);
121 glFogf(GL_FOG_END, fogDensity);
122 printf("Fog density = %.4f\n", fogDensity);
132 /* Handle "special" keyboard events */
133 void GLUTspecialkey(int k, int x, int y) {
134 struct control_params *c;
136 c = ¤t_aircraft.controls;
138 printf("Special key hit = %d\n", k);
148 fgAileronMove(-0.05);
159 /* Revision 1.13 1997/06/25 15:39:46 curt
160 /* Minor changes to compile with rsxnt/win32.
162 * Revision 1.12 1997/06/21 17:12:52 curt
163 * Capitalized subdirectory names.
165 * Revision 1.11 1997/06/18 04:10:31 curt
166 * A couple more runway tweaks ...
168 * Revision 1.10 1997/06/18 02:21:23 curt
171 * Revision 1.9 1997/06/02 03:40:06 curt
172 * A tiny bit more view tweaking.
174 * Revision 1.8 1997/06/02 03:01:38 curt
175 * Working on views (side, front, back, transitions, etc.)
177 * Revision 1.7 1997/05/31 19:16:25 curt
178 * Elevator trim added.
180 * Revision 1.6 1997/05/31 04:13:52 curt
183 * Continuing work on the LaRCsim flight model integration.
184 * Added some MSFS-like keyboard input handling.
186 * Revision 1.5 1997/05/30 23:26:19 curt
187 * Added elevator/aileron controls.
189 * Revision 1.4 1997/05/27 17:44:31 curt
190 * Renamed & rearranged variables and routines. Added some initial simple
191 * timer/alarm routines so the flight model can be updated on a regular interval.
193 * Revision 1.3 1997/05/23 15:40:25 curt
194 * Added GNU copyright headers.
197 * Revision 1.2 1997/05/23 00:35:12 curt
198 * Trying to get fog to work ...
200 * Revision 1.1 1997/05/21 15:57:50 curt
201 * Renamed due to added GLUT support.
203 * Revision 1.2 1997/05/19 18:22:41 curt
204 * Parameter tweaking ... starting to stub in fog support.
206 * Revision 1.1 1997/05/16 16:05:51 curt