]> git.mxchange.org Git - flightgear.git/blob - Main/GLUTkey.c
Minor changes to compile with rsxnt/win32.
[flightgear.git] / Main / GLUTkey.c
1 /**************************************************************************
2  * tkglkey.c -- handle tkgl keyboard events
3  *
4  * Written by Curtis Olson, started May 1997.
5  *
6  * Copyright (C) 1997  Curtis L. Olson  - curt@infoplane.com
7  *
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.
12  *
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.
17  *
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.
21  *
22  * $Id$
23  * (Log is kept at end of this file)
24  **************************************************************************/
25
26
27 #include <math.h>
28 #include <stdio.h>
29
30 #include <GL/glut.h>
31
32 #include "GLUTkey.h"
33 #include "../Aircraft/aircraft.h"
34
35 #ifndef M_PI
36 #define M_PI        3.14159265358979323846      /* pi */
37 #endif
38
39 extern double fogDensity;
40 extern double goal_view_offset;
41
42 /* Handle keyboard events */
43 void GLUTkey(unsigned char k, int x, int y) {
44     struct control_params *c;
45
46     c = &current_aircraft.controls;
47
48     printf("Key hit = %d\n", k);
49
50     if ( GLUT_ACTIVE_SHIFT && glutGetModifiers() ) {
51         switch (k) {
52         case 49: /* numeric keypad 1 */
53             goal_view_offset = M_PI * 0.75;
54             return;
55         case 50: /* numeric keypad 2 */
56             goal_view_offset = M_PI;
57             return;
58         case 51: /* numeric keypad 3 */
59             goal_view_offset = M_PI * 1.25;
60             return;
61         case 52: /* numeric keypad 4 */
62             goal_view_offset = M_PI * 0.50;
63             return;
64         case 54: /* numeric keypad 6 */
65             goal_view_offset = M_PI * 1.50;
66             return;
67         case 55: /* numeric keypad 7 */
68             goal_view_offset = M_PI * 0.25;
69             return;
70         case 56: /* numeric keypad 8 */
71             goal_view_offset = 0.00;
72             return;
73         case 57: /* numeric keypad 9 */
74             goal_view_offset = M_PI * 1.75;
75             return;
76         }
77     } else {
78         switch (k) {
79         case 50: /* numeric keypad 2 */
80             fgElevMove(-0.05);
81             return;
82         case 56: /* numeric keypad 8 */
83             fgElevMove(0.05);
84             return;
85         case 49: /* numeric keypad 1 */
86             fgElevTrimMove(-0.001);
87             return;
88         case 55: /* numeric keypad 7 */
89             fgElevTrimMove(0.001);
90             return;
91         case 52: /* numeric keypad 4 */
92             fgAileronMove(-0.05);
93             return;
94         case 54: /* numeric keypad 6 */
95             fgAileronMove(0.05);
96             return;
97         case 48: /* numeric keypad Ins */
98             fgRudderMove(-0.05);
99             return;
100         case 13: /* numeric keypad Enter */
101             fgRudderMove(0.05);
102             return;
103         case 53: /* numeric keypad 5 */
104             fgAileronSet(0.0);
105             fgElevSet(0.0);
106             fgRudderSet(0.0);
107             return;
108         case 57: /* numeric keypad 9 (Pg Up) */
109             fgThrottleMove(0, 0.01);
110             return;
111         case 51: /* numeric keypad 3 (Pg Dn) */
112             fgThrottleMove(0, -0.01);
113             return;
114         case 122:
115             fogDensity *= 1.10;
116             glFogf(GL_FOG_END, fogDensity);
117             printf("Fog density = %.4f\n", fogDensity);
118             return;
119         case 90:
120             fogDensity /= 1.10;
121             glFogf(GL_FOG_END, fogDensity);
122             printf("Fog density = %.4f\n", fogDensity);
123             return;
124         case 27: /* ESC */
125             exit(0);
126         }
127     }
128
129 }
130
131
132 /* Handle "special" keyboard events */
133 void GLUTspecialkey(int k, int x, int y) {
134     struct control_params *c;
135
136     c = &current_aircraft.controls;
137
138     printf("Special key hit = %d\n", k);
139
140     switch (k) {
141     case GLUT_KEY_UP:
142         fgElevMove(0.05);
143         return;
144     case GLUT_KEY_DOWN:
145         fgElevMove(-0.05);
146         return;
147     case GLUT_KEY_LEFT:
148         fgAileronMove(-0.05);
149         return;
150     case GLUT_KEY_RIGHT:
151         fgAileronMove(0.05);
152         return;
153     }
154
155 }
156
157
158 /* $Log$
159 /* Revision 1.13  1997/06/25 15:39:46  curt
160 /* Minor changes to compile with rsxnt/win32.
161 /*
162  * Revision 1.12  1997/06/21 17:12:52  curt
163  * Capitalized subdirectory names.
164  *
165  * Revision 1.11  1997/06/18 04:10:31  curt
166  * A couple more runway tweaks ...
167  *
168  * Revision 1.10  1997/06/18 02:21:23  curt
169  * Hacked in a runway
170  *
171  * Revision 1.9  1997/06/02 03:40:06  curt
172  * A tiny bit more view tweaking.
173  *
174  * Revision 1.8  1997/06/02 03:01:38  curt
175  * Working on views (side, front, back, transitions, etc.)
176  *
177  * Revision 1.7  1997/05/31 19:16:25  curt
178  * Elevator trim added.
179  *
180  * Revision 1.6  1997/05/31 04:13:52  curt
181  * WE CAN NOW FLY!!!
182  *
183  * Continuing work on the LaRCsim flight model integration.
184  * Added some MSFS-like keyboard input handling.
185  *
186  * Revision 1.5  1997/05/30 23:26:19  curt
187  * Added elevator/aileron controls.
188  *
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.
192  *
193  * Revision 1.3  1997/05/23 15:40:25  curt
194  * Added GNU copyright headers.
195  * Fog now works!
196  *
197  * Revision 1.2  1997/05/23 00:35:12  curt
198  * Trying to get fog to work ...
199  *
200  * Revision 1.1  1997/05/21 15:57:50  curt
201  * Renamed due to added GLUT support.
202  *
203  * Revision 1.2  1997/05/19 18:22:41  curt
204  * Parameter tweaking ... starting to stub in fog support.
205  *
206  * Revision 1.1  1997/05/16 16:05:51  curt
207  * Initial revision.
208  *
209  */