]> git.mxchange.org Git - flightgear.git/blob - src/Controls/controls.cxx
Moved some of the low level scene graph construction code over to simgear.
[flightgear.git] / src / Controls / controls.cxx
1 // controls.cxx -- defines a standard interface to all flight sim controls
2 //
3 // Written by Curtis Olson, started May 1997.
4 //
5 // Copyright (C) 1997  Curtis L. Olson  - curt@infoplane.com
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 //
21 // $Id$
22
23
24 #include <simgear/compiler.h>
25 #include <simgear/debug/logstream.hxx>
26 #include <Main/fg_props.hxx>
27
28 #include "controls.hxx"
29
30
31 static const int MAX_NAME_LEN = 128;
32
33 \f
34 ////////////////////////////////////////////////////////////////////////
35 // Inline utility methods.
36 ////////////////////////////////////////////////////////////////////////
37
38 static inline void
39 CLAMP(double *x, double min, double max )
40 {
41   if ( *x < min ) { *x = min; }
42   if ( *x > max ) { *x = max; }
43 }
44
45 static inline void
46 CLAMP(int *i, int min, int max )
47 {
48   if ( *i < min ) { *i = min; }
49   if ( *i > max ) { *i = max; }
50 }
51
52 \f
53 ////////////////////////////////////////////////////////////////////////
54 // Implementation of FGControls.
55 ////////////////////////////////////////////////////////////////////////
56
57 // Constructor
58 FGControls::FGControls() :
59     aileron( 0.0 ),
60     aileron_trim( 0.0 ),
61     elevator( 0.0 ),
62     elevator_trim( 0.0 ),
63     rudder( 0.0 ),
64     rudder_trim( 0.0 ),
65     flaps( 0.0 ),
66     slats( 0.0 ),
67     BLC( false ),
68     spoilers( 0.0 ),
69     speedbrake( 0.0 ),
70     wing_sweep( 0.0 ),
71     wing_fold( false ),
72     drag_chute( false ),
73     throttle_idle( true ),
74     dump_valve( false ),
75     parking_brake( 0.0 ),
76     steering( 0.0 ),
77     gear_down( true ),
78     antiskid( true ),
79     tailhook( false ),
80     tailwheel_lock( false ),
81     wing_heat( false ),
82     pitot_heat( true ),
83     wiper( 0 ),
84     window_heat( false ),
85     battery_switch( true ),
86     external_power( false ),
87     APU_generator( false ),
88     APU_bleed( false ),
89     mode( 0 ),
90     dump( false ),
91     outflow_valve( 0.0 ),
92     taxi_light( false ),
93     logo_lights( false ),
94     nav_lights( false ),
95     beacon( false ),
96     strobe( false ),
97     panel_norm( 0.0 ),
98     instruments_norm( 0.0 ),
99     dome_norm( 0.0 ),
100     master_arm( false ),
101     station_select( 1 ),
102     release_ALL( false ),
103     vertical_adjust( 0.0 ),
104     fore_aft_adjust( 0.0 ),
105     eject( false ),
106     off_start_run( 0 ),
107     APU_fire_switch( false ),
108     autothrottle_arm( false ),
109     autothrottle_engage( false ),
110     heading_select( 0.0 ),
111     altitude_select( 50000.0 ),
112     bank_angle_select( 30.0 ),
113     vertical_speed_select( 0.0 ),
114     speed_select( 0.0 ),
115     mach_select( 0.0 ),
116     vertical_mode( 0 ),
117     lateral_mode( 0 )
118 {
119 }
120
121
122 void FGControls::reset_all()
123 {
124     set_aileron( 0.0 );
125     set_aileron_trim( 0.0 );
126     set_elevator( 0.0 );
127     set_elevator_trim( 0.0 );
128     set_rudder( 0.0 );
129     set_rudder_trim( 0.0 );
130     BLC = false;
131     set_spoilers( 0.0 );
132     set_speedbrake( 0.0 );
133     set_wing_sweep( 0.0 );
134     wing_fold = false;
135     drag_chute = false;
136     set_throttle( ALL_ENGINES, 0.0 );
137     set_starter( ALL_ENGINES, false );
138     set_magnetos( ALL_ENGINES, 0 );
139     set_fuel_pump( ALL_ENGINES, false );
140     set_fire_switch( ALL_ENGINES, false );
141     set_fire_bottle_discharge( ALL_ENGINES, false );
142     set_cutoff( ALL_ENGINES, true );
143     set_nitrous_injection( ALL_ENGINES, false );
144     set_cowl_flaps_norm( ALL_ENGINES, 1.0 );
145     set_feather( ALL_ENGINES, false );
146     set_ignition( ALL_ENGINES, false );
147     set_augmentation( ALL_ENGINES, false );
148     set_reverser( ALL_ENGINES, false );
149     set_water_injection( ALL_ENGINES, false );
150     set_condition( ALL_ENGINES, 0 );
151     throttle_idle = true;
152     set_fuel_selector( ALL_TANKS, true );
153     dump_valve = false;
154     steering =  0.0;
155     gear_down = true;
156     tailhook = false;
157     tailwheel_lock = false;
158     set_carb_heat( ALL_ENGINES, false );
159     set_inlet_heat( ALL_ENGINES, false );
160     wing_heat = false;
161     pitot_heat = true;
162     wiper = 0;
163     window_heat = false;
164     set_engine_pump( ALL_HYD_SYSTEMS, true );
165     set_electric_pump( ALL_HYD_SYSTEMS, true );
166     landing_lights = false;
167     turn_off_lights = false;
168     master_arm = false;
169     eject = false;
170     APU_fire_switch = false;
171     autothrottle_arm = false;
172     autothrottle_engage = false;
173     set_autopilot_engage( ALL_AUTOPILOTS, false );
174 }
175
176
177 // Destructor
178 FGControls::~FGControls() {
179 }
180
181
182 void
183 FGControls::init ()
184 {
185     throttle_idle = true;
186     for ( int engine = 0; engine < MAX_ENGINES; engine++ ) {
187         throttle[engine] = 0.0;
188         mixture[engine] = 1.0;
189         fuel_pump[engine] = false;
190         prop_advance[engine] = 1.0;
191         magnetos[engine] = 0;
192         starter[engine] = false;
193         ignition[engine] = false;
194         fire_switch[engine] = false;
195         cutoff[engine] = true;
196         augmentation[engine] = false;
197         reverser[engine] = false;
198         water_injection[engine] = false;
199         nitrous_injection[engine] = false;
200         cowl_flaps_norm[engine] = 0.0;
201         condition[engine] = 0;
202     }
203
204     for ( int wheel = 0; wheel < MAX_WHEELS; wheel++ ) {
205         brake[wheel] = 0.0;
206         alternate_extension[wheel] = false;
207     }
208
209     auto_coordination = fgGetNode("/sim/auto-coordination", true);
210 }
211
212
213 void
214 FGControls::bind ()
215 {
216   int index, i;
217
218   // flight controls
219   fgTie("/controls/flight/aileron", this,
220         &FGControls::get_aileron, &FGControls::set_aileron);
221   fgSetArchivable("/controls/flight/aileron");
222
223   fgTie("/controls/flight/aileron-trim", this,
224        &FGControls::get_aileron_trim, &FGControls::set_aileron_trim);
225   fgSetArchivable("/controls/flight/aileron-trim");
226
227   fgTie("/controls/flight/elevator", this,
228        &FGControls::get_elevator, &FGControls::set_elevator);
229   fgSetArchivable("/controls/flight/elevator");
230
231   fgTie("/controls/flight/elevator-trim", this,
232        &FGControls::get_elevator_trim, &FGControls::set_elevator_trim);
233   fgSetArchivable("/controls/flight/elevator-trim");
234
235   fgTie("/controls/flight/rudder", this,
236        &FGControls::get_rudder, &FGControls::set_rudder);
237   fgSetArchivable("/controls/flight/rudder");
238
239   fgTie("/controls/flight/rudder-trim", this,
240        &FGControls::get_rudder_trim, &FGControls::set_rudder_trim);
241   fgSetArchivable("/controls/flight/rudder-trim");
242
243   fgTie("/controls/flight/flaps", this,
244        &FGControls::get_flaps, &FGControls::set_flaps);
245   fgSetArchivable("/controls/flight/flaps");
246
247   fgTie("/controls/flight/slats", this,
248        &FGControls::get_slats, &FGControls::set_slats);
249   fgSetArchivable("/controls/flight/slats");
250
251   fgTie("/controls/flight/BLC", this,
252        &FGControls::get_BLC, &FGControls::set_BLC);
253   fgSetArchivable("/controls/flight/BLC");
254
255   fgTie("/controls/flight/spoilers", this,
256        &FGControls::get_spoilers, &FGControls::set_spoilers);
257   fgSetArchivable("/controls/flight/spoilers");
258
259   fgTie("/controls/flight/speedbrake", this,
260        &FGControls::get_speedbrake, &FGControls::set_speedbrake);
261   fgSetArchivable("/controls/flight/speedbrake");
262
263   fgTie("/controls/flight/wing-sweep", this,
264        &FGControls::get_wing_sweep, &FGControls::set_wing_sweep);
265   fgSetArchivable("/controls/flight/wing-sweep");
266
267   fgTie("/controls/flight/wing-fold", this,
268        &FGControls::get_wing_fold, &FGControls::set_wing_fold);
269   fgSetArchivable("/controls/flight/wing-fold");
270
271   fgTie("/controls/flight/drag-chute", this,
272        &FGControls::get_drag_chute, &FGControls::set_drag_chute);
273   fgSetArchivable("/controls/flight/drag-chute");
274
275   // engines
276   fgTie("/controls/engines/throttle_idle", this,
277        &FGControls::get_throttle_idle, &FGControls::set_throttle_idle);
278   fgSetArchivable("/controls/engines/throttle_idle");
279
280   for (index = 0; index < MAX_ENGINES; index++) {
281     char name[MAX_NAME_LEN];
282     snprintf(name, MAX_NAME_LEN,
283              "/controls/engines/engine[%d]/throttle", index);
284     fgTie(name, this, index,
285           &FGControls::get_throttle, &FGControls::set_throttle);
286     fgSetArchivable(name);
287
288     snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/starter", index);
289     fgTie(name, this, index,
290          &FGControls::get_starter, &FGControls::set_starter);
291     fgSetArchivable(name);
292
293     snprintf(name, MAX_NAME_LEN,
294              "/controls/engines/engine[%d]/fuel-pump", index);
295     fgTie(name, this, index,
296          &FGControls::get_fuel_pump, &FGControls::set_fuel_pump);
297     fgSetArchivable(name);
298
299     snprintf(name, MAX_NAME_LEN,
300              "/controls/engines/engine[%d]/fire-switch", index);
301     fgTie(name, this, index,
302          &FGControls::get_fire_switch, &FGControls::set_fire_switch);
303     fgSetArchivable(name);
304
305     snprintf(name, MAX_NAME_LEN, 
306        "/controls/engines/engine[%d]/fire-bottle-discharge", index);
307     fgTie(name, this, index,
308          &FGControls::get_fire_bottle_discharge,
309          &FGControls::set_fire_bottle_discharge);
310     fgSetArchivable(name);
311
312     snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/cutoff", index);
313     fgTie(name, this, index,
314          &FGControls::get_cutoff, &FGControls::set_cutoff);
315     fgSetArchivable(name);
316
317     snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/mixture", index);
318     fgTie(name, this, index,
319          &FGControls::get_mixture, &FGControls::set_mixture);
320     fgSetArchivable(name);
321
322     snprintf(name, MAX_NAME_LEN, 
323        "/controls/engines/engine[%d]/propeller-pitch", index);
324     fgTie(name, this, index,
325          &FGControls::get_prop_advance, 
326          &FGControls::set_prop_advance);
327     fgSetArchivable(name);
328
329     snprintf(name, MAX_NAME_LEN,
330              "/controls/engines/engine[%d]/magnetos", index);
331     fgTie(name, this, index,
332          &FGControls::get_magnetos, &FGControls::set_magnetos);
333     fgSetArchivable(name);
334
335     snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/WEP", index);
336     fgTie(name, this, index,
337          &FGControls::get_nitrous_injection,
338          &FGControls::set_nitrous_injection);
339     fgSetArchivable(name);
340
341     snprintf(name, MAX_NAME_LEN, 
342        "/controls/engines/engine[%d]/cowl-flaps-norm", index);
343     fgTie(name, this, index,
344          &FGControls::get_cowl_flaps_norm, 
345          &FGControls::set_cowl_flaps_norm);
346     fgSetArchivable(name);
347
348     snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/feather", index);
349     fgTie(name, this, index,
350          &FGControls::get_feather, &FGControls::set_feather);
351     fgSetArchivable(name);
352
353     snprintf(name, MAX_NAME_LEN,
354              "/controls/engines/engine[%d]/ignition", index);
355     fgTie(name, this, index,
356          &FGControls::get_ignition, &FGControls::set_ignition);
357     fgSetArchivable(name);
358
359     snprintf(name, MAX_NAME_LEN,
360              "/controls/engines/engine[%d]/augmentation", index);
361     fgTie(name, this, index,
362          &FGControls::get_augmentation, 
363          &FGControls::set_augmentation);
364     fgSetArchivable(name);
365
366     snprintf(name, MAX_NAME_LEN,
367              "/controls/engines/engine[%d]/reverser", index);
368     fgTie(name, this, index,
369          &FGControls::get_reverser, &FGControls::set_reverser);
370     fgSetArchivable(name);
371
372     snprintf(name, MAX_NAME_LEN, 
373        "/controls/engines/engine[%d]/water-injection", index);
374     fgTie(name, this, index,
375          &FGControls::get_water_injection,
376          &FGControls::set_water_injection);
377     fgSetArchivable(name);
378
379     snprintf(name, MAX_NAME_LEN,
380              "/controls/engines/engine[%d]/condition", index);
381     fgTie(name, this, index,
382          &FGControls::get_condition, &FGControls::set_condition);
383     fgSetArchivable(name);
384   }
385
386   // fuel
387   fgTie("/controls/fuel/dump-valve", this,
388        &FGControls::get_dump_valve, &FGControls::set_dump_valve);
389   fgSetArchivable("/controls/fuel/dump-valve");
390
391   for (index = 0; index < MAX_TANKS; index++) {
392     char name[MAX_NAME_LEN];
393     snprintf(name, MAX_NAME_LEN,
394              "/controls/fuel/tank[%d]/fuel_selector", index);
395     fgTie(name, this, index,
396           &FGControls::get_fuel_selector, 
397           &FGControls::set_fuel_selector);
398     fgSetArchivable(name);  
399
400     snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_engine", index);
401     fgTie(name, this, index,
402           &FGControls::get_to_engine, &FGControls::set_to_engine);
403     fgSetArchivable(name);  
404
405     snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_tank", index);
406     fgTie(name, this, index,
407           &FGControls::get_to_tank, &FGControls::set_to_tank);
408     fgSetArchivable(name);  
409
410     for (i = 0; i < MAX_BOOSTPUMPS; i++) {
411       char name[MAX_NAME_LEN];
412       snprintf(name, MAX_NAME_LEN, 
413          "/controls/fuel/tank[%d]/boost-pump[%d]", index, i);
414       fgTie(name, this, index * 2 + i,
415             &FGControls::get_boost_pump, 
416             &FGControls::set_boost_pump);
417       fgSetArchivable(name);  
418     }
419   }
420
421   // gear
422   fgTie("/controls/gear/parking-brake", this,
423         &FGControls::get_parking_brake, 
424         &FGControls::set_parking_brake);
425   fgSetArchivable("/controls/gear/parking-brake");
426
427   fgTie("/controls/gear/steering", this,
428         &FGControls::get_steering, &FGControls::set_steering);
429   fgSetArchivable("/controls/gear/steering");
430
431   fgTie("/controls/gear/gear-down", this,
432         &FGControls::get_gear_down, &FGControls::set_gear_down);
433   fgSetArchivable("/controls/gear/gear-down");
434
435   fgTie("/controls/gear/antiskid", this,
436         &FGControls::get_antiskid, &FGControls::set_antiskid);
437   fgSetArchivable("/controls/gear/antiskid");
438
439   fgTie("/controls/gear/tailhook", this,
440         &FGControls::get_tailhook, &FGControls::set_tailhook);
441   fgSetArchivable("/controls/gear/tailhook");
442
443   fgTie("/controls/gear/tailwheel-lock", this,
444         &FGControls::get_tailwheel_lock, 
445         &FGControls::set_tailwheel_lock);
446   fgSetArchivable("/controls/gear/tailwheel-lock");
447
448   for (index = 0; index < MAX_WHEELS; index++) {
449       char name[MAX_NAME_LEN];
450       snprintf(name, MAX_NAME_LEN, "/controls/gear/wheel[%d]/brake", index);
451       fgTie(name, this, index,
452             &FGControls::get_brake, &FGControls::set_brake);
453       fgSetArchivable(name);
454
455       snprintf(name, MAX_NAME_LEN,
456                "/controls/gear/wheel[%d]/alternate-extension", index);
457       fgTie(name, this, index,
458             &FGControls::get_alternate_extension, 
459             &FGControls::set_alternate_extension);
460       fgSetArchivable(name);
461   }
462
463   // anti-ice
464   fgTie("/controls/anti-ice/wing-heat", this,
465         &FGControls::get_wing_heat, &FGControls::set_wing_heat);
466   fgSetArchivable("/controls/anti-ice/wing-heat");
467
468   fgTie("/controls/anti-ice/pitot-heat", this,
469         &FGControls::get_pitot_heat, &FGControls::set_pitot_heat);
470   fgSetArchivable("/controls/anti-ice/pitot-heat");
471
472   fgTie("/controls/anti-ice/wiper", this,
473         &FGControls::get_wiper, &FGControls::set_wiper);
474   fgSetArchivable("/controls/anti-ice/wiper");
475
476   fgTie("/controls/anti-ice/window-heat", this,
477         &FGControls::get_window_heat, &FGControls::set_window_heat);
478   fgSetArchivable("/controls/anti-ice/window-heat");
479
480   for (index = 0; index < MAX_ENGINES; index++) {
481       char name[MAX_NAME_LEN];
482       snprintf(name, MAX_NAME_LEN,
483                "/controls/anti-ice/engine[%d]/carb-heat", index);  
484       fgTie(name, this, index,
485         &FGControls::get_carb_heat, &FGControls::set_carb_heat);
486       fgSetArchivable(name);
487
488       snprintf(name, MAX_NAME_LEN,
489                "/controls/anti-ice/engine[%d]/inlet-heat", index);  
490       fgTie(name, this, index,
491         &FGControls::get_inlet_heat, &FGControls::set_inlet_heat);
492       fgSetArchivable(name);
493   }
494
495   // hydraulics
496   for (index = 0; index < MAX_HYD_SYSTEMS; index++) {
497       char name[MAX_NAME_LEN];
498       snprintf(name, MAX_NAME_LEN, 
499          "/controls/hydraulic/system[%d]/engine-pump", index);  
500       fgTie(name, this, index,
501         &FGControls::get_engine_pump, &FGControls::set_engine_pump);
502       fgSetArchivable(name);
503
504       snprintf(name, MAX_NAME_LEN, 
505          "/controls/hydraulic/system[%d]/electric-pump", index);  
506       fgTie(name, this, index,
507         &FGControls::get_electric_pump, 
508         &FGControls::set_electric_pump);
509       fgSetArchivable(name);
510   }  
511
512   // electric
513   fgTie("/controls/electric/battery-switch", this,
514         &FGControls::get_battery_switch, 
515         &FGControls::set_battery_switch);
516   fgSetArchivable("/controls/electric/battery-switch");
517   
518   fgTie("/controls/electric/external-power", this,
519         &FGControls::get_external_power, 
520         &FGControls::set_external_power);
521   fgSetArchivable("/controls/electric/external-power");
522
523   fgTie("/controls/electric/APU-generator", this,
524         &FGControls::get_APU_generator, 
525         &FGControls::set_APU_generator);
526   fgSetArchivable("/controls/electric/APU-generator");
527
528   for (index = 0; index < MAX_ENGINES; index++) {
529       char name[MAX_NAME_LEN];
530       snprintf(name, MAX_NAME_LEN, 
531          "/controls/electric/engine[%d]/generator", index);  
532       fgTie(name, this, index,
533         &FGControls::get_generator_breaker, 
534         &FGControls::set_generator_breaker);
535       fgSetArchivable(name);
536
537       snprintf(name, MAX_NAME_LEN,
538                "/controls/electric/engine[%d]/bus-tie", index);  
539       fgTie(name, this, index,
540         &FGControls::get_bus_tie, 
541         &FGControls::set_bus_tie);
542       fgSetArchivable(name);
543   }  
544
545   // pneumatic
546   fgTie("/controls/pneumatic/APU-bleed", this,
547         &FGControls::get_APU_bleed, 
548         &FGControls::set_APU_bleed);
549   fgSetArchivable("/controls/pneumatic/APU-bleed");
550
551   for (index = 0; index < MAX_ENGINES; index++) {
552       char name[MAX_NAME_LEN];
553       snprintf(name, MAX_NAME_LEN, 
554          "/controls/pneumatic/engine[%d]/bleed", index);  
555       fgTie(name, this, index,
556         &FGControls::get_engine_bleed, 
557         &FGControls::set_engine_bleed);
558       fgSetArchivable(name);
559   }
560
561   // pressurization
562   fgTie("/controls/pressurization/mode", this,
563         &FGControls::get_mode, &FGControls::set_mode);
564   fgSetArchivable("/controls/pressurization/mode");
565
566   fgTie("/controls/pressurization/dump", this,
567         &FGControls::get_dump, &FGControls::set_dump);
568   fgSetArchivable("/controls/pressurization/dump");
569
570   fgTie("/controls/pressurization/outflow-valve", this,
571         &FGControls::get_outflow_valve, 
572         &FGControls::set_outflow_valve);
573   fgSetArchivable("/controls/pressurization/outflow-valve");
574
575   for (index = 0; index < MAX_PACKS; index++) {
576       char name[MAX_NAME_LEN];
577       snprintf(name, MAX_NAME_LEN,
578                "/controls/pressurization/pack[%d]/pack-on", index);  
579       fgTie(name, this, index,
580         &FGControls::get_pack_on, &FGControls::set_pack_on);
581       fgSetArchivable(name);
582   }
583  
584   // lights
585   fgTie("/controls/lighting/landing-lights", this,
586         &FGControls::get_landing_lights, 
587         &FGControls::set_landing_lights);
588   fgSetArchivable("/controls/lighting/landing-lights");  
589
590   fgTie("/controls/lighting/turn-off-lights", this,
591         &FGControls::get_turn_off_lights,
592         &FGControls::set_turn_off_lights);
593   fgSetArchivable("/controls/lighting/turn-off-lights");
594   
595   fgTie("/controls/lighting/taxi-light", this,
596         &FGControls::get_taxi_light, &FGControls::set_taxi_light);
597   fgSetArchivable("/controls/lighting/taxi-light");
598   
599   fgTie("/controls/lighting/logo-lights", this,
600         &FGControls::get_logo_lights, &FGControls::set_logo_lights);
601   fgSetArchivable("/controls/lighting/logo-lights");
602   
603   fgTie("/controls/lighting/nav-lights", this,
604         &FGControls::get_nav_lights, &FGControls::set_nav_lights);
605   fgSetArchivable("/controls/lighting/nav-lights");  
606
607   fgTie("/controls/lighting/beacon", this,
608         &FGControls::get_beacon, &FGControls::set_beacon);
609   fgSetArchivable("/controls/lighting/beacon");
610   
611   fgTie("/controls/lighting/strobe", this,
612         &FGControls::get_strobe, &FGControls::set_strobe);
613   fgSetArchivable("/controls/lighting/strobe");  
614
615   fgTie("/controls/lighting/panel-norm", this,
616         &FGControls::get_panel_norm, &FGControls::set_panel_norm);
617   fgSetArchivable("/controls/lighting/panel-norm");
618   
619   fgTie("/controls/lighting/instruments-norm", this,
620         &FGControls::get_instruments_norm, 
621         &FGControls::set_instruments_norm);
622   fgSetArchivable("/controls/lighting/instruments-norm");  
623
624   fgTie("/controls/lighting/dome-norm", this,
625         &FGControls::get_dome_norm, &FGControls::set_dome_norm);
626   fgSetArchivable("/controls/lighting/dome-norm"); 
627  
628 #ifdef FG_HAVE_ARMAMENT
629   // armament
630   fgTie("/controls/armament/master-arm", this,
631         &FGControls::get_master_arm, &FGControls::set_master_arm);
632   fgSetArchivable("/controls/armament/master-arm");  
633
634   fgTie("/controls/armament/station-select", this,
635         &FGControls::get_station_select, 
636         &FGControls::set_station_select);
637   fgSetArchivable("/controls/armament/station-select");  
638
639   fgTie("/controls/armament/release-all", this,
640         &FGControls::get_release_ALL, 
641         &FGControls::set_release_ALL);
642   fgSetArchivable("/controls/armament/release-all");  
643
644   for (index = 0; index < MAX_STATIONS; index++) {
645       char name[MAX_NAME_LEN];
646       snprintf(name, MAX_NAME_LEN,
647                "/controls/armament/station[%d]/stick-size", index);  
648       fgTie(name, this, index,
649         &FGControls::get_stick_size, &FGControls::set_stick_size);
650       fgSetArchivable(name);
651
652       snprintf(name, MAX_NAME_LEN, 
653           "/controls/armament/station[%d]/release-stick", index);  
654       fgTie(name, this, index,
655         &FGControls::get_release_stick, &FGControls::set_release_stick);
656       fgSetArchivable(name);
657
658       snprintf(name, MAX_NAME_LEN,
659                "/controls/armament/station[%d]/release-all", index);  
660       fgTie(name, this, index,
661         &FGControls::get_release_all, &FGControls::set_release_all);
662       fgSetArchivable(name);
663
664       snprintf(name, MAX_NAME_LEN,
665                "/controls/armament/station[%d]/jettison-all", index);  
666       fgTie(name, this, index,
667         &FGControls::get_jettison_all, &FGControls::set_jettison_all);
668       fgSetArchivable(name);
669   }
670
671 #endif
672
673   // seat
674   fgTie("/controls/seat/vertical-adjust", this,
675         &FGControls::get_vertical_adjust, 
676         &FGControls::set_vertical_adjust);
677   fgSetArchivable("/controls/seat/vertical-adjust");
678
679   fgTie("/controls/seat/fore-aft-adjust", this,
680         &FGControls::get_fore_aft_adjust, 
681         &FGControls::set_fore_aft_adjust);
682   fgSetArchivable("/controls/seat/fore-aft-adjust");
683   
684   fgTie("/controls/seat/eject", this,
685         &FGControls::get_eject, &FGControls::set_eject);
686   fgSetArchivable("/controls/seat/eject");
687
688   // APU
689   fgTie("/controls/APU/off-start-run", this,
690         &FGControls::get_off_start_run, 
691         &FGControls::set_off_start_run);
692   fgSetArchivable("/controls/APU/off-start-run");
693
694   fgTie("/controls/APU/fire-switch", this,
695         &FGControls::get_APU_fire_switch, 
696         &FGControls::set_APU_fire_switch);
697   fgSetArchivable("/controls/APU/fire-switch");
698
699   // autoflight
700   for (index = 0; index < MAX_AUTOPILOTS; index++) {
701       char name[MAX_NAME_LEN];
702       snprintf(name, MAX_NAME_LEN, 
703          "/controls/autoflight/autopilot[%d]/engage", index);  
704       fgTie(name, this, index,
705         &FGControls::get_autopilot_engage, 
706         &FGControls::set_autopilot_engage);
707       fgSetArchivable(name);
708   }
709  
710   fgTie("/controls/autoflight/autothrottle-arm", this,
711         &FGControls::get_autothrottle_arm, 
712         &FGControls::set_autothrottle_arm);
713   fgSetArchivable("/controls/autoflight/autothrottle-arm");
714
715   fgTie("/controls/autoflight/autothrottle-engage", this,
716         &FGControls::get_autothrottle_engage, 
717         &FGControls::set_autothrottle_engage);
718   fgSetArchivable("/controls/autoflight/autothrottle-engage");
719
720   fgTie("/controls/autoflight/heading-select", this,
721         &FGControls::get_heading_select, 
722         &FGControls::set_heading_select);
723   fgSetArchivable("/controls/autoflight/heading-select");
724
725   fgTie("/controls/autoflight/altitude-select", this,
726         &FGControls::get_altitude_select, 
727         &FGControls::set_altitude_select);
728   fgSetArchivable("/controls/autoflight/altitude-select");
729
730   fgTie("/controls/autoflight/bank-angle-select", this,
731         &FGControls::get_bank_angle_select, 
732         &FGControls::set_bank_angle_select);
733   fgSetArchivable("/controls/autoflight/bank-angle-select");
734
735   fgTie("/controls/autoflight/vertical-speed-select", this,
736         &FGControls::get_vertical_speed_select, 
737         &FGControls::set_vertical_speed_select);
738   fgSetArchivable("/controls/autoflight/vertical-speed-select");
739
740   fgTie("/controls/autoflight/speed-select", this,
741         &FGControls::get_speed_select, 
742         &FGControls::set_speed_select);
743   fgSetArchivable("/controls/autoflight/speed-select");
744
745   fgTie("/controls/autoflight/mach-select", this,
746         &FGControls::get_mach_select, 
747         &FGControls::set_mach_select);
748   fgSetArchivable("/controls/autoflight/mach-select");
749
750   fgTie("/controls/autoflight/vertical-mode", this,
751         &FGControls::get_vertical_mode, 
752         &FGControls::set_vertical_mode);
753   fgSetArchivable("/controls/autoflight/vertical-mode");
754
755   fgTie("/controls/autoflight/lateral-mode", this,
756         &FGControls::get_lateral_mode, 
757         &FGControls::set_lateral_mode);
758   fgSetArchivable("/controls/autoflight/lateral-mode");
759
760 }
761
762 void FGControls::unbind ()
763 {
764   int index, i;
765   //Tie control properties.
766   fgUntie("/controls/flight/aileron");
767   fgUntie("/controls/flight/aileron-trim");
768   fgUntie("/controls/flight/elevator");
769   fgUntie("/controls/flight/elevator-trim");
770   fgUntie("/controls/flight/rudder");
771   fgUntie("/controls/flight/rudder-trim");
772   fgUntie("/controls/flight/flaps");
773   fgUntie("/controls/flight/slats");
774   fgUntie("/controls/flight/BLC");  
775   fgUntie("/controls/flight/spoilers");  
776   fgUntie("/controls/flight/speedbrake");  
777   fgUntie("/controls/flight/wing-sweep");  
778   fgUntie("/controls/flight/wing-fold");  
779   fgUntie("/controls/flight/drag-chute");
780   for (index = 0; index < MAX_ENGINES; index++) {
781     char name[MAX_NAME_LEN];
782     snprintf(name, MAX_NAME_LEN,
783              "/controls/engines/engine[%d]/throttle", index);
784     fgUntie(name);
785     snprintf(name, MAX_NAME_LEN,
786              "/controls/engines/engine[%d]/starter", index);
787     fgUntie(name);
788     snprintf(name, MAX_NAME_LEN,
789              "/controls/engines/engine[%d]/fuel_pump", index);
790     fgUntie(name);
791     snprintf(name, MAX_NAME_LEN,
792              "/controls/engines/engine[%d]/fire-switch", index);
793     fgUntie(name);
794     snprintf(name, MAX_NAME_LEN, 
795              "/controls/engines/engine[%d]/fire-bottle-discharge", index);
796     fgUntie(name);
797     snprintf(name, MAX_NAME_LEN,
798              "/controls/engines/engine[%d]/throttle_idle", index);
799     fgUntie(name);
800     snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/cutoff", index);
801     fgUntie(name);
802     snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/mixture", index);
803     fgUntie(name);
804     snprintf(name, MAX_NAME_LEN, 
805              "/controls/engines/engine[%d]/propeller-pitch", index);
806     fgUntie(name);
807     snprintf(name, MAX_NAME_LEN,
808              "/controls/engines/engine[%d]/magnetos", index);
809     fgUntie(name);
810     snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/WEP", index);
811     fgUntie(name);
812     snprintf(name, MAX_NAME_LEN,
813              "/controls/engines/engine[%d]/cowl-flaps-norm", index);
814     fgUntie(name);
815     snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/feather", index);
816     fgUntie(name);
817     snprintf(name, MAX_NAME_LEN,
818              "/controls/engines/engine[%d]/ignition", index);
819     fgUntie(name);
820     snprintf(name, MAX_NAME_LEN,
821              "/controls/engines/engine[%d]/augmentation", index);
822     fgUntie(name);
823     snprintf(name, MAX_NAME_LEN,
824              "/controls/engines/engine[%d]/reverser", index);
825     fgUntie(name);
826     snprintf(name, MAX_NAME_LEN,
827              "/controls/engines/engine[%d]/water-injection", index);
828     fgUntie(name);
829     snprintf(name, MAX_NAME_LEN,
830              "/controls/engines/engine[%d]/condition", index);
831     fgUntie(name);
832   }
833   fgUntie("/controls/fuel/dump-valve");
834   for (index = 0; index < MAX_TANKS; index++) {
835     char name[MAX_NAME_LEN];
836     snprintf(name, MAX_NAME_LEN,
837              "/controls/fuel/tank[%d]/fuel_selector", index);
838     fgUntie(name);
839     snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_engine", index);
840     fgUntie(name);
841     snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_tank", index);
842     fgUntie(name);
843     for (i = 0; index < MAX_BOOSTPUMPS; i++) {
844       snprintf(name, MAX_NAME_LEN,
845                "/controls/fuel/tank[%d]/boost-pump[%d]", index, i);
846       fgUntie(name);
847     }
848   }
849   fgUntie("/controls/gear/parking_brake");
850   fgUntie("/controls/gear/steering");
851   fgUntie("/controls/gear/gear_down");
852   fgUntie("/controls/gear/antiskid");
853   fgUntie("/controls/gear/tailhook");
854   fgUntie("/controls/gear/tailwheel-lock");
855   for (index = 0; index < MAX_WHEELS; index++) {
856     char name[MAX_NAME_LEN];
857     snprintf(name, MAX_NAME_LEN, "/controls/gear/wheel[%d]/brakes", index);
858     fgUntie(name);
859     snprintf(name, MAX_NAME_LEN, 
860        "/controls/gear/wheel[%d]/alternate-extension", index);
861     fgUntie(name);
862   }
863   fgUntie("/controls/anti-ice/wing-heat");
864   fgUntie("/controls/anti-ice/pitot-heat");
865   fgUntie("/controls/anti-ice/wiper");
866   fgUntie("/controls/anti-ice/window-heat");
867   for (index = 0; index < MAX_ENGINES; index++) {
868     char name[MAX_NAME_LEN];
869     snprintf(name, MAX_NAME_LEN,
870              "/controls/anti-ice/engine[%d]/carb-heat", index);
871     fgUntie(name);
872     snprintf(name, MAX_NAME_LEN,
873              "/controls/anti-ice/engine[%d]/inlet-heat", index);
874     fgUntie(name);
875   }
876   for (index = 0; index < MAX_HYD_SYSTEMS; index++) {
877     char name[MAX_NAME_LEN];
878     snprintf(name, MAX_NAME_LEN, 
879        "/controls/hydraulic/system[%d]/engine-pump", index);
880     fgUntie(name);
881     snprintf(name, MAX_NAME_LEN, 
882        "/controls/hydraulic/system[%d]/electric-pump", index);
883     fgUntie(name);
884   }
885   fgUntie("/controls/electric/battery-switch");
886   fgUntie("/controls/electric/external-power");
887   fgUntie("/controls/electric/APU-generator");    
888   for (index = 0; index < MAX_ENGINES; index++) {
889     char name[MAX_NAME_LEN];
890      snprintf(name, MAX_NAME_LEN, 
891        "/controls/electric/engine[%d]/generator", index);
892     fgUntie(name);
893     snprintf(name, MAX_NAME_LEN, 
894        "/controls/electric/engine[%d]/bus-tie", index);
895     fgUntie(name);
896   }
897   fgUntie("/controls/pneumatic/APU-bleed");
898   for (index = 0; index < MAX_ENGINES; index++) {
899     char name[MAX_NAME_LEN];
900      snprintf(name, MAX_NAME_LEN, 
901        "/controls/pneumatic/engine[%d]/bleed", index);
902     fgUntie(name);
903   }
904   fgUntie("/controls/pressurization/mode");
905   fgUntie("/controls/pressurization/dump");
906   for (index = 0; index < MAX_PACKS; index++) {
907     char name[MAX_NAME_LEN];
908     snprintf(name, MAX_NAME_LEN, 
909        "/controls/pressurization/pack[%d]/pack-on", index);
910     fgUntie(name);
911   }
912   fgUntie("/controls/lighting/landing-lights");  
913   fgUntie("/controls/lighting/turn-off-lights");  
914   fgUntie("/controls/lighting/taxi-light");  
915   fgUntie("/controls/lighting/logo-lights");  
916   fgUntie("/controls/lighting/nav-lights");  
917   fgUntie("/controls/lighting/beacon");  
918   fgUntie("/controls/lighting/strobe");  
919   fgUntie("/controls/lighting/panel-norm");  
920   fgUntie("/controls/lighting/instruments-norm");  
921   fgUntie("/controls/lighting/dome-norm");
922
923 #ifdef FG_HAVE_ARMAMENT
924   fgUntie("/controls/armament/master-arm");  
925   fgUntie("/controls/armament/station-select");  
926   fgUntie("/controls/armament/release-all");  
927   for (index = 0; index < MAX_STATIONS; index++) {
928     char name[MAX_NAME_LEN];
929     snprintf(name, MAX_NAME_LEN, 
930        "/controls/armament/station[%d]/stick-size", index);
931     fgUntie(name);
932     snprintf(name, MAX_NAME_LEN, 
933        "/controls/armament/station[%d]/release-stick", index);
934     fgUntie(name);
935     snprintf(name, MAX_NAME_LEN, 
936        "/controls/armament/station[%d]/release-all", index);
937     fgUntie(name);
938     snprintf(name, MAX_NAME_LEN, 
939        "/controls/armament/station[%d]/jettison-all", index);
940     fgUntie(name);
941   }
942 #endif
943   fgUntie("/controls/seat/vertical-adjust");  
944   fgUntie("/controls/seat/fore-aft-adjust");  
945   fgUntie("/controls/seat/eject");  
946   fgUntie("/controls/APU/off-start-run");  
947   fgUntie("/controls/APU/fire-switch");  
948   for (index = 0; index < MAX_AUTOPILOTS; index++) {
949     char name[MAX_NAME_LEN];
950     snprintf(name, MAX_NAME_LEN,
951        "/controls/autoflight/autopilot[%d]/engage", index);
952     fgUntie(name);
953   }
954   fgUntie("/controls/autoflight/autothrottle-arm");  
955   fgUntie("/controls/autoflight/autothrottle-engage");  
956   fgUntie("/controls/autoflight/heading-select");  
957   fgUntie("/controls/autoflight/altitude-select");  
958   fgUntie("/controls/autoflight/bank-angle-select");  
959   fgUntie("/controls/autoflight/vertical-speed-select");  
960   fgUntie("/controls/autoflight/speed-select");  
961   fgUntie("/controls/autoflight/mach-select");  
962   fgUntie("/controls/autoflight/vertical-mode");  
963   fgUntie("/controls/autoflight/lateral-mode");  
964 }
965
966
967 void
968 FGControls::update (double dt)
969 {
970 }
971
972
973 \f
974 ////////////////////////////////////////////////////////////////////////
975 // Setters and adjusters.
976 ////////////////////////////////////////////////////////////////////////
977
978 void
979 FGControls::set_aileron (double pos)
980 {
981   aileron = pos;
982   CLAMP( &aileron, -1.0, 1.0 );
983                         
984   // check for autocoordination
985   if ( auto_coordination->getBoolValue() ) {
986     set_rudder( aileron / 2.0 );
987   }
988 }
989
990 void
991 FGControls::move_aileron (double amt)
992 {
993   aileron += amt;
994   CLAMP( &aileron, -1.0, 1.0 );
995                         
996   // check for autocoordination
997   if ( auto_coordination->getBoolValue() ) {
998     set_rudder( aileron / 2.0 );
999   }
1000 }
1001
1002 void
1003 FGControls::set_aileron_trim( double pos )
1004 {
1005     aileron_trim = pos;
1006     CLAMP( &aileron_trim, -1.0, 1.0 );
1007 }
1008
1009 void
1010 FGControls::move_aileron_trim( double amt )
1011 {
1012     aileron_trim += amt;
1013     CLAMP( &aileron_trim, -1.0, 1.0 );
1014 }
1015
1016 void
1017 FGControls::set_elevator( double pos )
1018 {
1019     elevator = pos;
1020     CLAMP( &elevator, -1.0, 1.0 );
1021 }
1022
1023 void
1024 FGControls::move_elevator( double amt )
1025 {
1026     elevator += amt;
1027     CLAMP( &elevator, -1.0, 1.0 );
1028 }
1029
1030 void
1031 FGControls::set_elevator_trim( double pos )
1032 {
1033     elevator_trim = pos;
1034     CLAMP( &elevator_trim, -1.0, 1.0 );
1035 }
1036
1037 void
1038 FGControls::move_elevator_trim( double amt )
1039 {
1040     elevator_trim += amt;
1041     CLAMP( &elevator_trim, -1.0, 1.0 );
1042 }
1043
1044 void
1045 FGControls::set_rudder( double pos )
1046 {
1047     rudder = pos;
1048     CLAMP( &rudder, -1.0, 1.0 );
1049 }
1050
1051 void
1052 FGControls::move_rudder( double amt )
1053 {
1054     rudder += amt;
1055     CLAMP( &rudder, -1.0, 1.0 );
1056 }
1057
1058 void
1059 FGControls::set_rudder_trim( double pos )
1060 {
1061     rudder_trim = pos;
1062     CLAMP( &rudder_trim, -1.0, 1.0 );
1063 }
1064
1065 void
1066 FGControls::move_rudder_trim( double amt )
1067 {
1068     rudder_trim += amt;
1069     CLAMP( &rudder_trim, -1.0, 1.0 );
1070 }
1071
1072 void
1073 FGControls::set_flaps( double pos )
1074 {
1075     flaps = pos;
1076     CLAMP( &flaps, 0.0, 1.0 );
1077 }
1078
1079 void
1080 FGControls::move_flaps( double amt )
1081 {
1082     flaps += amt;
1083     CLAMP( &flaps, 0.0, 1.0 );
1084 }
1085
1086 void
1087 FGControls::set_slats( double pos )
1088 {
1089     slats = pos;
1090     CLAMP( &slats, 0.0, 1.0 );
1091 }
1092
1093 void
1094 FGControls::move_slats( double amt )
1095 {
1096     slats += amt;
1097     CLAMP( &slats, 0.0, 1.0 );
1098 }
1099
1100 void
1101 FGControls::set_BLC( bool val )
1102 {
1103   BLC = val;
1104 }
1105
1106 void
1107 FGControls::set_spoilers( double pos )
1108 {
1109     spoilers = pos;
1110     CLAMP( &spoilers, 0.0, 1.0 );
1111 }
1112
1113 void
1114 FGControls::move_spoilers( double amt )
1115 {
1116     spoilers += amt;
1117     CLAMP( &spoilers, 0.0, 1.0 );
1118 }
1119
1120 void
1121 FGControls::set_speedbrake( double pos )
1122 {
1123     speedbrake = pos;
1124     CLAMP( &speedbrake, 0.0, 1.0 );
1125 }
1126
1127 void
1128 FGControls::move_speedbrake( double amt )
1129 {
1130     speedbrake += amt;
1131     CLAMP( &speedbrake, 0.0, 1.0 );
1132 }
1133
1134 void
1135 FGControls::set_wing_sweep( double pos )
1136 {
1137     wing_sweep = pos;
1138     CLAMP( &wing_sweep, 0.0, 1.0 );
1139 }
1140
1141 void
1142 FGControls::move_wing_sweep( double amt )
1143 {
1144     wing_sweep += amt;
1145     CLAMP( &wing_sweep, 0.0, 1.0 );
1146 }
1147
1148 void
1149 FGControls::set_wing_fold( bool val )
1150 {
1151   wing_fold = val;
1152 }
1153
1154 void
1155 FGControls::set_drag_chute( bool val )
1156 {
1157   drag_chute = val;
1158 }
1159
1160 void
1161 FGControls::set_throttle_idle( bool val )
1162 {
1163   throttle_idle = val;
1164 }
1165
1166 void
1167 FGControls::set_throttle( int engine, double pos )
1168 {
1169   if ( engine == ALL_ENGINES ) {
1170     for ( int i = 0; i < MAX_ENGINES; i++ ) {
1171       throttle[i] = pos;
1172       CLAMP( &throttle[i], 0.0, 1.0 );
1173     }
1174   } else {
1175     if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1176       throttle[engine] = pos;
1177       CLAMP( &throttle[engine], 0.0, 1.0 );
1178     }
1179   }
1180 }
1181
1182 void
1183 FGControls::move_throttle( int engine, double amt )
1184 {
1185     if ( engine == ALL_ENGINES ) {
1186         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1187             throttle[i] += amt;
1188             CLAMP( &throttle[i], 0.0, 1.0 );
1189         }
1190     } else {
1191         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1192             throttle[engine] += amt;
1193             CLAMP( &throttle[engine], 0.0, 1.0 );
1194         }
1195     }
1196 }
1197
1198 void
1199 FGControls::set_starter( int engine, bool flag )
1200 {
1201     if ( engine == ALL_ENGINES ) {
1202         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1203             starter[i] = flag;
1204         }
1205     } else {
1206         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1207             starter[engine] = flag;
1208         }
1209     }
1210 }
1211
1212 void
1213 FGControls::set_fuel_pump( int engine, bool val )
1214 {
1215     if ( engine == ALL_ENGINES ) {
1216         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1217             fuel_pump[i] = val;
1218         }
1219     } else {
1220         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1221             fuel_pump[engine] = val;
1222         }
1223     }
1224 }
1225
1226 void
1227 FGControls::set_fire_switch( int engine, bool val )
1228 {
1229     if ( engine == ALL_ENGINES ) {
1230         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1231             fire_switch[i] = val;
1232         }
1233     } else {
1234         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1235             fire_switch[engine] = val;
1236         }
1237     }
1238 }
1239
1240 void
1241 FGControls::set_fire_bottle_discharge( int engine, bool val )
1242 {
1243     if ( engine == ALL_ENGINES ) {
1244         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1245             fire_bottle_discharge[i] = val;
1246         }
1247     } else {
1248         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1249             fire_bottle_discharge[engine] = val;
1250         }
1251     }
1252 }
1253
1254 void
1255 FGControls::set_cutoff( int engine, bool val )
1256 {
1257     if ( engine == ALL_ENGINES ) {
1258         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1259             cutoff[i] = val;
1260         }
1261     } else {
1262         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1263             cutoff[engine] = val;
1264         }
1265     }
1266 }
1267
1268
1269 void
1270 FGControls::set_mixture( int engine, double pos )
1271 {
1272     if ( engine == ALL_ENGINES ) {
1273         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1274             mixture[i] = pos;
1275             CLAMP( &mixture[i], 0.0, 1.0 );
1276         }
1277     } else {
1278         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1279             mixture[engine] = pos;
1280             CLAMP( &mixture[engine], 0.0, 1.0 );
1281         }
1282     }
1283 }
1284
1285 void
1286 FGControls::move_mixture( int engine, double amt )
1287 {
1288     if ( engine == ALL_ENGINES ) {
1289         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1290             mixture[i] += amt;
1291             CLAMP( &mixture[i], 0.0, 1.0 );
1292         }
1293     } else {
1294         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1295             mixture[engine] += amt;
1296             CLAMP( &mixture[engine], 0.0, 1.0 );
1297         }
1298     }
1299 }
1300
1301 void
1302 FGControls::set_prop_advance( int engine, double pos )
1303 {
1304     if ( engine == ALL_ENGINES ) {
1305         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1306             prop_advance[i] = pos;
1307             CLAMP( &prop_advance[i], 0.0, 1.0 );
1308         }
1309     } else {
1310         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1311             prop_advance[engine] = pos;
1312             CLAMP( &prop_advance[engine], 0.0, 1.0 );
1313         }
1314     }
1315 }
1316
1317 void
1318 FGControls::move_prop_advance( int engine, double amt )
1319 {
1320     if ( engine == ALL_ENGINES ) {
1321         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1322             prop_advance[i] += amt;
1323             CLAMP( &prop_advance[i], 0.0, 1.0 );
1324         }
1325     } else {
1326         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1327             prop_advance[engine] += amt;
1328             CLAMP( &prop_advance[engine], 0.0, 1.0 );
1329         }
1330     }
1331 }
1332
1333 void
1334 FGControls::set_magnetos( int engine, int pos )
1335 {
1336     if ( engine == ALL_ENGINES ) {
1337         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1338             magnetos[i] = pos;
1339             CLAMP( &magnetos[i], 0, 3 );
1340         }
1341     } else {
1342         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1343             magnetos[engine] = pos;
1344             CLAMP( &magnetos[engine], 0, 3 );
1345         }
1346     }
1347 }
1348
1349 void
1350 FGControls::move_magnetos( int engine, int amt )
1351 {
1352     if ( engine == ALL_ENGINES ) {
1353         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1354             magnetos[i] += amt;
1355             CLAMP( &magnetos[i], 0, 3 );
1356         }
1357     } else {
1358         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1359             magnetos[engine] += amt;
1360             CLAMP( &magnetos[engine], 0, 3 );
1361         }
1362     }
1363 }
1364
1365 void
1366 FGControls::set_nitrous_injection( int engine, bool val )
1367 {
1368     if ( engine == ALL_ENGINES ) {
1369         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1370             nitrous_injection[i] = val;
1371         }
1372     } else {
1373         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1374             nitrous_injection[engine] = val;
1375         }
1376     }
1377 }
1378
1379
1380 void
1381 FGControls::set_cowl_flaps_norm( int engine, double pos )
1382 {
1383     if ( engine == ALL_ENGINES ) {
1384         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1385             cowl_flaps_norm[i] = pos;
1386             CLAMP( &cowl_flaps_norm[i], 0.0, 1.0 );
1387         }
1388     } else {
1389         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1390             cowl_flaps_norm[engine] = pos;
1391             CLAMP( &cowl_flaps_norm[engine], 0.0, 1.0 );
1392         }
1393     }
1394 }
1395
1396 void
1397 FGControls::move_cowl_flaps_norm( int engine, double amt )
1398 {
1399     if ( engine == ALL_ENGINES ) {
1400         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1401             cowl_flaps_norm[i] += amt;
1402             CLAMP( &cowl_flaps_norm[i], 0.0, 1.0 );
1403         }
1404     } else {
1405         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1406             cowl_flaps_norm[engine] += amt;
1407             CLAMP( &cowl_flaps_norm[engine], 0.0, 1.0 );
1408         }
1409     }
1410 }
1411
1412 void
1413 FGControls::set_feather( int engine, bool val )
1414 {
1415     if ( engine == ALL_ENGINES ) {
1416         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1417             feather[i] = val;
1418         }
1419     } else {
1420         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1421             feather[engine] = val;
1422         }
1423     }
1424 }
1425
1426 void
1427 FGControls::set_ignition( int engine, int pos )
1428 {
1429     if ( engine == ALL_ENGINES ) {
1430         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1431             ignition[i] = pos;
1432             CLAMP( &ignition[i], 0, 3 );
1433         }
1434     } else {
1435         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1436             ignition[engine] = pos;
1437             CLAMP( &ignition[engine], 0, 3 );
1438         }
1439     }
1440 }
1441
1442 void
1443 FGControls::set_augmentation( int engine, bool val )
1444 {
1445     if ( engine == ALL_ENGINES ) {
1446         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1447             augmentation[i] = val;
1448         }
1449     } else {
1450         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1451             augmentation[engine] = val;
1452         }
1453     }
1454 }
1455
1456 void
1457 FGControls::set_reverser( int engine, bool val )
1458 {
1459     if ( engine == ALL_ENGINES ) {
1460         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1461             reverser[i] = val;
1462         }
1463     } else {
1464         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1465             reverser[engine] = val;
1466         }
1467     }
1468 }
1469
1470 void
1471 FGControls::set_water_injection( int engine, bool val )
1472 {
1473     if ( engine == ALL_ENGINES ) {
1474         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1475             water_injection[i] = val;
1476         }
1477     } else {
1478         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1479             water_injection[engine] = val;
1480         }
1481     }
1482 }
1483
1484 void
1485 FGControls::set_condition( int engine, int val )
1486 {
1487     if ( engine == ALL_ENGINES ) {
1488         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1489             condition[i] = val;
1490             CLAMP( &condition[i], 0, 3 );
1491         }
1492     } else {
1493         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1494             condition[engine] = val;
1495             CLAMP( &condition[engine], 0, 3 );
1496         }
1497     }
1498 }
1499
1500 void
1501 FGControls::set_dump_valve( bool val )
1502 {
1503     dump_valve = val;
1504 }
1505
1506
1507 void
1508 FGControls::set_fuel_selector( int tank, bool pos )
1509 {
1510     if ( tank == ALL_TANKS ) {
1511         for ( int i = 0; i < MAX_TANKS; i++ ) {
1512             fuel_selector[i] = pos;
1513         }
1514     } else {
1515         if ( (tank >= 0) && (tank < MAX_TANKS) ) {
1516             fuel_selector[tank] = pos;
1517         }
1518     }
1519 }
1520
1521 void
1522 FGControls::set_to_engine( int tank, int engine )
1523 {
1524     if ( tank == ALL_TANKS ) {
1525         for ( int i = 0; i < MAX_TANKS; i++ ) {
1526             to_engine[i] = engine;
1527         }
1528     } else {
1529         if ( (tank >= 0) && (tank < MAX_TANKS) ) {
1530             to_engine[tank] = engine;
1531         }
1532     }
1533 }
1534
1535 void
1536 FGControls::set_to_tank( int tank, int dest_tank )
1537 {
1538     if ( tank == ALL_TANKS ) {
1539         for ( int i = 0; i < MAX_TANKS; i++ ) {
1540             to_tank[i] = dest_tank;
1541         }
1542     } else {
1543         if ( (tank >= 0) && (tank < MAX_TANKS) ) {
1544             to_tank[tank] = dest_tank;
1545         }
1546     }
1547 }
1548
1549 void
1550 FGControls::set_boost_pump( int index, bool val ) 
1551 {
1552     if ( index == -1 ) {
1553         for ( int i = 0; i < (MAX_TANKS * MAX_BOOSTPUMPS); i++ ) {
1554             boost_pump[i] = val;
1555         }
1556     } else {
1557         if ( (index >= 0) && (index < (MAX_TANKS * MAX_BOOSTPUMPS)) ) {
1558             boost_pump[index] = val;
1559         }
1560     }
1561 }
1562
1563
1564 void
1565 FGControls::set_parking_brake( double pos )
1566 {
1567     parking_brake = pos;
1568     CLAMP(&parking_brake, 0.0, 1.0);
1569 }
1570
1571 void
1572 FGControls::set_steering( double angle )
1573 {
1574     steering = angle;
1575     CLAMP(&steering, -80.0, 80.0);
1576 }
1577
1578 void
1579 FGControls::move_steering( double angle )
1580 {
1581     steering += angle;
1582     CLAMP(&steering, -80.0, 80.0);
1583 }
1584
1585 void
1586 FGControls::set_gear_down( bool gear )
1587 {
1588   gear_down = gear;
1589 }
1590
1591 void
1592 FGControls::set_antiskid( bool state )
1593 {
1594   antiskid = state;
1595 }
1596
1597 void
1598 FGControls::set_tailhook( bool state )
1599 {
1600   tailhook = state;
1601 }
1602
1603 void
1604 FGControls::set_tailwheel_lock( bool state )
1605 {
1606   tailwheel_lock = state;
1607 }
1608
1609
1610 void
1611 FGControls::set_brake( int wheel, double pos )
1612 {
1613     if ( wheel == ALL_WHEELS ) {
1614         for ( int i = 0; i < MAX_WHEELS; i++ ) {
1615             brake[i] = pos;
1616             CLAMP( &brake[i], 0.0, 1.0 );
1617         }
1618     } else {
1619         if ( (wheel >= 0) && (wheel < MAX_WHEELS) ) {
1620             brake[wheel] = pos;
1621             CLAMP( &brake[wheel], 0.0, 1.0 );
1622         }
1623     }
1624 }
1625
1626 void
1627 FGControls::move_brake( int wheel, double amt )
1628 {
1629     if ( wheel == ALL_WHEELS ) {
1630         for ( int i = 0; i < MAX_WHEELS; i++ ) {
1631             brake[i] += amt;
1632             CLAMP( &brake[i], 0.0, 1.0 );
1633         }
1634     } else {
1635         if ( (wheel >= 0) && (wheel < MAX_WHEELS) ) {
1636             brake[wheel] += amt;
1637             CLAMP( &brake[wheel], 0.0, 1.0 );
1638         }
1639     }
1640 }
1641
1642 void
1643 FGControls::set_alternate_extension( int wheel, bool val )
1644 {
1645     if ( wheel == ALL_WHEELS ) {
1646         for ( int i = 0; i < MAX_WHEELS; i++ ) {
1647             alternate_extension[i] = val;
1648         }
1649     } else {
1650         if ( (wheel >= 0) && (wheel < MAX_WHEELS) ) {
1651             alternate_extension[wheel] = val;
1652         }
1653     }
1654 }
1655
1656 void
1657 FGControls::set_wing_heat( bool state )
1658 {
1659   wing_heat = state;
1660 }
1661
1662 void
1663 FGControls::set_pitot_heat( bool state )
1664 {
1665   pitot_heat = state;
1666 }
1667
1668 void
1669 FGControls::set_wiper( int state )
1670 {
1671   wiper = state;
1672 }
1673
1674 void
1675 FGControls::set_window_heat( bool state )
1676 {
1677   window_heat = state;
1678 }
1679
1680 void
1681 FGControls::set_carb_heat( int engine, bool val )
1682 {
1683     if ( engine == ALL_ENGINES ) {
1684         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1685             carb_heat[i] = val;
1686         }
1687     } else {
1688         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1689             carb_heat[engine] = val;
1690         }
1691     }
1692 }
1693
1694 void
1695 FGControls::set_inlet_heat( int engine, bool val )
1696 {
1697     if ( engine == ALL_ENGINES ) {
1698         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1699             inlet_heat[i] = val;
1700         }
1701     } else {
1702         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1703             inlet_heat[engine] = val;
1704         }
1705     }
1706 }
1707
1708 void
1709 FGControls::set_engine_pump( int system, bool val )
1710 {
1711     if ( system == ALL_HYD_SYSTEMS ) {
1712         for ( int i = 0; i < MAX_HYD_SYSTEMS; i++ ) {
1713             engine_pump[i] = val;
1714         }
1715     } else {
1716         if ( (system >= 0) && (system < MAX_HYD_SYSTEMS) ) {
1717             engine_pump[system] = val;
1718         }
1719     }
1720 }
1721
1722 void
1723 FGControls::set_electric_pump( int system, bool val )
1724 {
1725     if ( system == ALL_HYD_SYSTEMS ) {
1726         for ( int i = 0; i < MAX_HYD_SYSTEMS; i++ ) {
1727             electric_pump[i] = val;
1728         }
1729     } else {
1730         if ( (system >= 0) && (system < MAX_HYD_SYSTEMS) ) {
1731             electric_pump[system] = val;
1732         }
1733     }
1734 }
1735
1736 void
1737 FGControls::set_battery_switch( bool state )
1738 {
1739   battery_switch = state;
1740 }
1741
1742 void
1743 FGControls::set_external_power( bool state )
1744 {
1745   external_power = state;
1746 }
1747
1748 void
1749 FGControls::set_APU_generator( bool state )
1750 {
1751   APU_generator = state;
1752 }
1753
1754 void
1755 FGControls::set_generator_breaker( int engine, bool val )
1756 {
1757     if ( engine == ALL_ENGINES ) {
1758         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1759             generator_breaker[i] = val;
1760         }
1761     } else {
1762         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1763             generator_breaker[engine] = val;
1764         }
1765     }
1766 }
1767
1768 void
1769 FGControls::set_bus_tie( int engine, bool val )
1770 {
1771     if ( engine == ALL_ENGINES ) {
1772         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1773             bus_tie[i] = val;
1774         }
1775     } else {
1776         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1777             bus_tie[engine] = val;
1778         }
1779     }
1780 }
1781
1782 void
1783 FGControls::set_APU_bleed( bool state )
1784 {
1785   APU_bleed = state;
1786 }
1787
1788 void
1789 FGControls::set_engine_bleed( int engine, bool val )
1790 {
1791     if ( engine == ALL_ENGINES ) {
1792         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1793             engine_bleed[i] = val;
1794         }
1795     } else {
1796         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1797             engine_bleed[engine] = val;
1798         }
1799     }
1800 }
1801
1802 void
1803 FGControls::set_mode( int new_mode )
1804 {
1805   mode = new_mode;
1806 }
1807
1808 void
1809 FGControls::set_outflow_valve( double pos )
1810 {
1811   outflow_valve = pos;
1812   CLAMP( &outflow_valve, 0.0, 1.0 );
1813 }
1814
1815 void
1816 FGControls::move_outflow_valve( double amt )
1817 {
1818   outflow_valve += amt;
1819   CLAMP( &outflow_valve, 0.0, 1.0 );
1820 }
1821
1822 void
1823 FGControls::set_dump( bool state )
1824 {
1825   dump = state;
1826 }
1827
1828 void
1829 FGControls::set_pack_on( int pack, bool val )
1830 {
1831     if ( pack == ALL_PACKS ) {
1832         for ( int i = 0; i < MAX_PACKS; i++ ) {
1833             pack_on[i] = val;
1834         }
1835     } else {
1836         if ( (pack >= 0) && (pack < MAX_PACKS) ) {
1837             pack_on[pack] = val;
1838         }
1839     }
1840 }
1841
1842 void
1843 FGControls::set_landing_lights( bool state )
1844 {
1845   landing_lights = state;
1846 }
1847
1848 void
1849 FGControls::set_turn_off_lights( bool state )
1850 {
1851   turn_off_lights = state;
1852 }
1853
1854 void
1855 FGControls::set_taxi_light( bool state )
1856 {
1857   taxi_light = state;
1858 }
1859
1860 void
1861 FGControls::set_logo_lights( bool state )
1862 {
1863   logo_lights = state;
1864 }
1865
1866 void
1867 FGControls::set_nav_lights( bool state )
1868 {
1869   nav_lights = state;
1870 }
1871
1872 void
1873 FGControls::set_beacon( bool state )
1874 {
1875   beacon = state;
1876 }
1877
1878 void
1879 FGControls::set_strobe( bool state )
1880 {
1881   strobe = state;
1882 }
1883
1884 void
1885 FGControls::set_panel_norm( double intensity )
1886 {
1887   panel_norm = intensity;
1888   CLAMP( &panel_norm, 0.0, 1.0 );
1889 }
1890
1891 void
1892 FGControls::move_panel_norm( double amt )
1893 {
1894   panel_norm += amt;
1895   CLAMP( &panel_norm, 0.0, 1.0 );
1896 }
1897
1898 void
1899 FGControls::set_instruments_norm( double intensity )
1900 {
1901   instruments_norm = intensity;
1902   CLAMP( &instruments_norm, 0.0, 1.0 );
1903 }
1904
1905 void
1906 FGControls::move_instruments_norm( double amt )
1907 {
1908   instruments_norm += amt;
1909   CLAMP( &instruments_norm, 0.0, 1.0 );
1910 }
1911
1912 void
1913 FGControls::set_dome_norm( double intensity )
1914 {
1915   dome_norm = intensity;
1916   CLAMP( &dome_norm, 0.0, 1.0 );
1917 }
1918
1919 void
1920 FGControls::move_dome_norm( double amt )
1921 {
1922   dome_norm += amt;
1923   CLAMP( &dome_norm, 0.0, 1.0 );
1924 }
1925
1926 #ifdef FG_HAVE_ARMAMENT
1927
1928 void
1929 FGControls::set_master_arm( bool val )
1930 {
1931   master_arm = val;
1932 }
1933
1934 void
1935 FGControls::set_station_select( int station )
1936 {
1937   station_select = station;
1938   CLAMP( &station_select, 0, MAX_STATIONS );
1939 }
1940
1941 void
1942 FGControls::set_release_ALL( bool val )
1943 {
1944   release_ALL = val;
1945 }
1946
1947 void
1948 FGControls::set_stick_size( int station, int size )
1949 {
1950     if ( station == ALL_STATIONS ) {
1951         for ( int i = 0; i < MAX_STATIONS; i++ ) {
1952             stick_size[i] = size;
1953             CLAMP( &stick_size[i], 1, 20 );
1954         }
1955     } else {
1956         if ( (station >= 0) && (station < MAX_STATIONS) ) {
1957             stick_size[station] = size;
1958             CLAMP( &stick_size[station], 1, 20 );
1959         }
1960     }
1961 }
1962
1963 void
1964 FGControls::set_release_stick( int station, bool val )
1965 {
1966     if ( station == ALL_STATIONS ) {
1967         for ( int i = 0; i < MAX_STATIONS; i++ ) {
1968             release_stick[i] = val;
1969         }
1970     } else {
1971         if ( (station >= 0) && (station < MAX_STATIONS) ) {
1972             release_stick[station] = val;
1973         }
1974     }
1975 }
1976
1977 void
1978 FGControls::set_release_all( int station, bool val )
1979 {
1980     if ( station == ALL_STATIONS ) {
1981         for ( int i = 0; i < MAX_STATIONS; i++ ) {
1982             release_all[i] = val;
1983         }
1984     } else {
1985         if ( (station >= 0) && (station < MAX_STATIONS) ) {
1986             release_all[station] = val;
1987         }
1988     }
1989 }
1990
1991 void
1992 FGControls::set_jettison_all( int station, bool val )
1993 {
1994     if ( station == ALL_STATIONS ) {
1995         for ( int i = 0; i < MAX_STATIONS; i++ ) {
1996             jettison_all[i] = val;
1997         }
1998     } else {
1999         if ( (station >= 0) && (station < MAX_STATIONS) ) {
2000             jettison_all[station] = val;
2001         }
2002     }
2003 }
2004
2005 #endif
2006
2007 void
2008 FGControls::set_vertical_adjust( double pos )
2009 {
2010   vertical_adjust = pos;
2011   CLAMP( &vertical_adjust, -1.0, 1.0 );
2012 }
2013
2014 void
2015 FGControls::move_vertical_adjust( double amt )
2016 {
2017   vertical_adjust += amt;
2018   CLAMP( &vertical_adjust, -1.0, 1.0 );
2019 }
2020
2021 void
2022 FGControls::set_fore_aft_adjust( double pos )
2023 {
2024   fore_aft_adjust = pos;
2025   CLAMP( &fore_aft_adjust, -1.0, 1.0 );
2026 }
2027
2028 void
2029 FGControls::move_fore_aft_adjust( double amt )
2030 {
2031   fore_aft_adjust += amt;
2032   CLAMP( &fore_aft_adjust, -1.0, 1.0 );
2033 }
2034
2035 void
2036 FGControls::set_eject( bool val )
2037 {
2038   eject = val;
2039 }
2040
2041 void
2042 FGControls::set_off_start_run( int pos )
2043 {
2044   off_start_run = pos;
2045   CLAMP( &off_start_run, 0, 3 );
2046 }
2047
2048 void
2049 FGControls::set_APU_fire_switch( bool val )
2050 {
2051   APU_fire_switch = val;
2052 }
2053
2054 void
2055 FGControls::set_autothrottle_arm( bool val )
2056 {
2057   autothrottle_arm = val;
2058 }
2059
2060 void
2061 FGControls::set_autothrottle_engage( bool val )
2062 {
2063   autothrottle_engage = val;
2064 }
2065
2066 void
2067 FGControls::set_heading_select( double heading )
2068 {
2069   heading_select = heading;
2070   CLAMP( &heading_select, 0.0, 360.0 );
2071 }
2072
2073 void
2074 FGControls::move_heading_select( double amt )
2075 {
2076   heading_select += amt;
2077   CLAMP( &heading_select, 0.0, 360.0 );
2078 }
2079
2080 void
2081 FGControls::set_altitude_select( double altitude )
2082 {
2083   altitude_select = altitude;
2084   CLAMP( &altitude_select, -1000.0, 100000.0 );
2085 }
2086
2087 void
2088 FGControls::move_altitude_select( double amt )
2089 {
2090   altitude_select += amt;
2091   CLAMP( &altitude_select, -1000.0, 100000.0 );
2092 }
2093
2094 void
2095 FGControls::set_bank_angle_select( double angle )
2096 {
2097   bank_angle_select = angle;
2098   CLAMP( &bank_angle_select, 10.0, 30.0 );
2099 }
2100
2101 void
2102 FGControls::move_bank_angle_select( double amt )
2103 {
2104   bank_angle_select += amt;
2105   CLAMP( &bank_angle_select, 10.0, 30.0 );
2106 }
2107
2108 void
2109 FGControls::set_vertical_speed_select( double speed )
2110 {
2111   vertical_speed_select = speed;
2112   CLAMP( &vertical_speed_select, -3000.0, 4000.0 );
2113 }
2114
2115 void
2116 FGControls::move_vertical_speed_select( double amt )
2117 {
2118   vertical_speed_select += amt;
2119   CLAMP( &vertical_speed_select, -3000.0, 4000.0 );
2120 }
2121
2122 void
2123 FGControls::set_speed_select( double speed )
2124 {
2125   speed_select = speed;
2126   CLAMP( &speed_select, 60.0, 400.0 );
2127 }
2128
2129 void
2130 FGControls::move_speed_select( double amt )
2131 {
2132   speed_select += amt;
2133   CLAMP( &speed_select, 60.0, 400.0 );
2134 }
2135
2136 void
2137 FGControls::set_mach_select( double mach )
2138 {
2139   mach_select = mach;
2140   CLAMP( &mach_select, 0.4, 4.0 );
2141 }
2142
2143 void
2144 FGControls::move_mach_select( double amt )
2145 {
2146   mach_select += amt;
2147   CLAMP( &mach_select, 0.4, 4.0 );
2148 }
2149
2150 void
2151 FGControls::set_vertical_mode( int mode )
2152 {
2153   vertical_mode = mode;
2154   CLAMP( &vertical_mode, 0, 4 );
2155 }
2156
2157 void
2158 FGControls::set_lateral_mode( int mode )
2159 {
2160   lateral_mode = mode;
2161   CLAMP( &lateral_mode, 0, 4 );
2162 }
2163
2164 void
2165 FGControls::set_autopilot_engage( int ap, bool val )
2166 {
2167     if ( ap == ALL_AUTOPILOTS ) {
2168         for ( int i = 0; i < MAX_AUTOPILOTS; i++ ) {
2169             autopilot_engage[i] = val;
2170         }
2171     } else {
2172         if ( (ap >= 0) && (ap < MAX_AUTOPILOTS) ) {
2173             autopilot_engage[ap] = val;
2174         }
2175     }
2176 }