]> git.mxchange.org Git - flightgear.git/blob - Main/GLUTkey.c
WE CAN NOW FLY!!!
[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 <stdio.h>
28
29 #include <GL/glut.h>
30
31 #include "GLUTkey.h"
32 #include "../aircraft/aircraft.h"
33
34 extern double fogDensity;
35
36 /* Handle keyboard events */
37 void GLUTkey(unsigned char k, int x, int y) {
38     struct control_params *c;
39
40     c = &current_aircraft.controls;
41
42     printf("Key hit = %d\n", k);
43
44     switch (k) {
45     case 50: /* numeric keypad 2 */
46         c->elev += 0.01;
47         return;
48     case 56: /* numeric keypad 8 */
49         c->elev -= 0.01;
50         return;
51     case 52: /* numeric keypad 4 */
52         c->aileron += 0.01;
53         return;
54     case 54: /* numeric keypad 6 */
55         c->aileron -= 0.01;
56         return;
57     case 48: /* numeric keypad Ins */
58         c->rudder -= 0.01;
59         return;
60     case 13: /* numeric keypad Enter */
61         c->rudder += 0.01;
62         return;
63     case 53: /* numeric keypad 5 */
64         c->aileron = 0.0;
65         c->elev = 0.0;
66         c->rudder = 0.0;
67     case 57: /* numeric keypad 9 (Pg Up) */
68         c->throttle[0] += 0.05;
69         return;
70     case 51: /* numeric keypad 3 (Pg Dn) */
71         c->throttle[0] -= 0.05;
72         return;
73     case 122:
74         fogDensity *= 1.10;
75         glFogf(GL_FOG_END, fogDensity);
76         printf("Fog density = %.4f\n", fogDensity);
77         return;
78     case 90:
79         fogDensity /= 1.10;
80         glFogf(GL_FOG_END, fogDensity);
81         printf("Fog density = %.4f\n", fogDensity);
82         return;
83     case 27: /* ESC */
84         exit(0);
85     }
86
87 }
88
89
90 /* Handle "special" keyboard events */
91 void GLUTspecialkey(unsigned char k, int x, int y) {
92     struct control_params *c;
93
94     c = &current_aircraft.controls;
95
96     printf("Special key hit = %d\n", k);
97
98     switch (k) {
99     case GLUT_KEY_UP:
100         c->elev -= 0.01;
101         return;
102     case GLUT_KEY_DOWN:
103         c->elev += 0.01;
104         return;
105     case GLUT_KEY_LEFT:
106         c->aileron += 0.01;
107         return;
108     case GLUT_KEY_RIGHT:
109         c->aileron -= 0.01;
110         return;
111     }
112
113 }
114
115
116 /* $Log$
117 /* Revision 1.6  1997/05/31 04:13:52  curt
118 /* WE CAN NOW FLY!!!
119 /*
120 /* Continuing work on the LaRCsim flight model integration.
121 /* Added some MSFS-like keyboard input handling.
122 /*
123  * Revision 1.5  1997/05/30 23:26:19  curt
124  * Added elevator/aileron controls.
125  *
126  * Revision 1.4  1997/05/27 17:44:31  curt
127  * Renamed & rearranged variables and routines.   Added some initial simple
128  * timer/alarm routines so the flight model can be updated on a regular interval.
129  *
130  * Revision 1.3  1997/05/23 15:40:25  curt
131  * Added GNU copyright headers.
132  * Fog now works!
133  *
134  * Revision 1.2  1997/05/23 00:35:12  curt
135  * Trying to get fog to work ...
136  *
137  * Revision 1.1  1997/05/21 15:57:50  curt
138  * Renamed due to added GLUT support.
139  *
140  * Revision 1.2  1997/05/19 18:22:41  curt
141  * Parameter tweaking ... starting to stub in fog support.
142  *
143  * Revision 1.1  1997/05/16 16:05:51  curt
144  * Initial revision.
145  *
146  */