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