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