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