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