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