1 // controls.cxx -- defines a standard interface to all flight sim controls
3 // Written by Curtis Olson, started May 1997.
5 // Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
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.
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.
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.
24 #include "controls.hxx"
26 #include <simgear/debug/logstream.hxx>
27 #include <Main/fg_props.hxx>
31 ////////////////////////////////////////////////////////////////////////
32 // Inline utility methods.
33 ////////////////////////////////////////////////////////////////////////
36 CLAMP(double *x, double min, double max )
38 if ( *x < min ) { *x = min; }
39 if ( *x > max ) { *x = max; }
43 CLAMP(int *i, int min, int max )
45 if ( *i < min ) { *i = min; }
46 if ( *i > max ) { *i = max; }
50 ////////////////////////////////////////////////////////////////////////
51 // Implementation of FGControls.
52 ////////////////////////////////////////////////////////////////////////
55 FGControls::FGControls() :
70 throttle_idle( true ),
77 tailwheel_lock( false ),
82 battery_switch( true ),
83 external_power( false ),
84 APU_generator( false ),
94 instruments_norm( 0.0 ),
99 vertical_adjust( 0.0 ),
100 fore_aft_adjust( 0.0 ),
103 APU_fire_switch( false ),
104 autothrottle_arm( false ),
105 autothrottle_engage( false ),
106 heading_select( 0.0 ),
107 altitude_select( 50000.0 ),
108 bank_angle_select( 30.0 ),
109 vertical_speed_select( 0.0 ),
118 void FGControls::reset_all()
121 set_aileron_trim( 0.0 );
123 set_elevator_trim( 0.0 );
125 set_rudder_trim( 0.0 );
128 set_speedbrake( 0.0 );
129 set_wing_sweep( 0.0 );
132 set_throttle( ALL_ENGINES, 0.0 );
133 set_starter( ALL_ENGINES, false );
134 set_magnetos( ALL_ENGINES, 0 );
135 set_fuel_pump( ALL_ENGINES, false );
136 set_fire_switch( ALL_ENGINES, false );
137 set_fire_bottle_discharge( ALL_ENGINES, false );
138 set_cutoff( ALL_ENGINES, true );
139 set_nitrous_injection( ALL_ENGINES, false );
140 set_cowl_flaps_norm( ALL_ENGINES, 1.0 );
141 set_feather( ALL_ENGINES, false );
142 set_ignition( ALL_ENGINES, false );
143 set_augmentation( ALL_ENGINES, false );
144 set_reverser( ALL_ENGINES, false );
145 set_water_injection( ALL_ENGINES, false );
146 set_condition( ALL_ENGINES, 0 );
147 throttle_idle = true;
148 set_fuel_selector( ALL_TANKS, true );
153 tailwheel_lock = false;
154 set_carb_heat( ALL_ENGINES, false );
155 set_inlet_heat( ALL_ENGINES, false );
160 set_engine_pump( ALL_HYD_SYSTEMS, true );
161 set_electric_pump( ALL_HYD_SYSTEMS, true );
162 landing_lights = false;
163 turn_off_lights = false;
166 APU_fire_switch = false;
167 autothrottle_arm = false;
168 autothrottle_engage = false;
169 set_autopilot_engage( ALL_AUTOPILOTS, false );
174 FGControls::~FGControls() {
181 throttle_idle = true;
182 for ( int engine = 0; engine < MAX_ENGINES; engine++ ) {
183 throttle[engine] = 0.0;
184 mixture[engine] = 1.0;
185 fuel_pump[engine] = false;
186 prop_advance[engine] = 1.0;
187 magnetos[engine] = 0;
188 starter[engine] = false;
189 ignition[engine] = false;
190 fire_switch[engine] = false;
191 cutoff[engine] = true;
192 augmentation[engine] = false;
193 reverser[engine] = false;
194 water_injection[engine] = false;
195 nitrous_injection[engine] = false;
196 condition[engine] = 0;
199 for ( int wheel = 0; wheel < MAX_WHEELS; wheel++ ) {
201 alternate_extension[wheel] = false;
204 auto_coordination = fgGetNode("/sim/auto-coordination", true);
214 fgTie("/controls/flight/aileron", this,
215 &FGControls::get_aileron, &FGControls::set_aileron);
216 fgSetArchivable("/controls/flight/aileron");
218 fgTie("/controls/flight/aileron-trim", this,
219 &FGControls::get_aileron_trim, &FGControls::set_aileron_trim);
220 fgSetArchivable("/controls/flight/aileron-trim");
222 fgTie("/controls/flight/elevator", this,
223 &FGControls::get_elevator, &FGControls::set_elevator);
224 fgSetArchivable("/controls/flight/elevator");
226 fgTie("/controls/flight/elevator-trim", this,
227 &FGControls::get_elevator_trim, &FGControls::set_elevator_trim);
228 fgSetArchivable("/controls/flight/elevator-trim");
230 fgTie("/controls/flight/rudder", this,
231 &FGControls::get_rudder, &FGControls::set_rudder);
232 fgSetArchivable("/controls/flight/rudder");
234 fgTie("/controls/flight/rudder-trim", this,
235 &FGControls::get_rudder_trim, &FGControls::set_rudder_trim);
236 fgSetArchivable("/controls/flight/rudder-trim");
238 fgTie("/controls/flight/flaps", this,
239 &FGControls::get_flaps, &FGControls::set_flaps);
240 fgSetArchivable("/controls/flight/flaps");
242 fgTie("/controls/flight/slats", this,
243 &FGControls::get_slats, &FGControls::set_slats);
244 fgSetArchivable("/controls/flight/slats");
246 fgTie("/controls/flight/BLC", this,
247 &FGControls::get_BLC, &FGControls::set_BLC);
248 fgSetArchivable("/controls/flight/BLC");
250 fgTie("/controls/flight/spoilers", this,
251 &FGControls::get_spoilers, &FGControls::set_spoilers);
252 fgSetArchivable("/controls/flight/spoilers");
254 fgTie("/controls/flight/speedbrake", this,
255 &FGControls::get_speedbrake, &FGControls::set_speedbrake);
256 fgSetArchivable("/controls/flight/speedbrake");
258 fgTie("/controls/flight/wing-sweep", this,
259 &FGControls::get_wing_sweep, &FGControls::set_wing_sweep);
260 fgSetArchivable("/controls/flight/wing-sweep");
262 fgTie("/controls/flight/wing-fold", this,
263 &FGControls::get_wing_fold, &FGControls::set_wing_fold);
264 fgSetArchivable("/controls/flight/wing-fold");
266 fgTie("/controls/flight/drag-chute", this,
267 &FGControls::get_drag_chute, &FGControls::set_drag_chute);
268 fgSetArchivable("/controls/flight/drag-chute");
271 fgTie("/controls/engines/throttle_idle", this,
272 &FGControls::get_throttle_idle, &FGControls::set_throttle_idle);
273 fgSetArchivable("/controls/engines/throttle_idle");
275 for (index = 0; index < MAX_ENGINES; index++) {
277 sprintf(name, "/controls/engines/engine[%d]/throttle", index);
278 fgTie(name, this, index,
279 &FGControls::get_throttle, &FGControls::set_throttle);
280 fgSetArchivable(name);
282 sprintf(name, "/controls/engines/engine[%d]/starter", index);
283 fgTie(name, this, index,
284 &FGControls::get_starter, &FGControls::set_starter);
285 fgSetArchivable(name);
287 sprintf(name, "/controls/engines/engine[%d]/fuel-pump", index);
288 fgTie(name, this, index,
289 &FGControls::get_fuel_pump, &FGControls::set_fuel_pump);
290 fgSetArchivable(name);
292 sprintf(name, "/controls/engines/engine[%d]/fire-switch", index);
293 fgTie(name, this, index,
294 &FGControls::get_fire_switch, &FGControls::set_fire_switch);
295 fgSetArchivable(name);
298 "/controls/engines/engine[%d]/fire-bottle-discharge", index);
299 fgTie(name, this, index,
300 &FGControls::get_fire_bottle_discharge,
301 &FGControls::set_fire_bottle_discharge);
302 fgSetArchivable(name);
304 sprintf(name, "/controls/engines/engine[%d]/cutoff", index);
305 fgTie(name, this, index,
306 &FGControls::get_cutoff, &FGControls::set_cutoff);
307 fgSetArchivable(name);
309 sprintf(name, "/controls/engines/engine[%d]/mixture", index);
310 fgTie(name, this, index,
311 &FGControls::get_mixture, &FGControls::set_mixture);
312 fgSetArchivable(name);
315 "/controls/engines/engine[%d]/propeller-pitch", index);
316 fgTie(name, this, index,
317 &FGControls::get_prop_advance,
318 &FGControls::set_prop_advance);
319 fgSetArchivable(name);
321 sprintf(name, "/controls/engines/engine[%d]/magnetos", index);
322 fgTie(name, this, index,
323 &FGControls::get_magnetos, &FGControls::set_magnetos);
324 fgSetArchivable(name);
326 sprintf(name, "/controls/engines/engine[%d]/WEP", index);
327 fgTie(name, this, index,
328 &FGControls::get_nitrous_injection,
329 &FGControls::set_nitrous_injection);
330 fgSetArchivable(name);
333 "/controls/engines/engine[%d]/cowl-flaps-norm", index);
334 fgTie(name, this, index,
335 &FGControls::get_cowl_flaps_norm,
336 &FGControls::set_cowl_flaps_norm);
337 fgSetArchivable(name);
339 sprintf(name, "/controls/engines/engine[%d]/feather", index);
340 fgTie(name, this, index,
341 &FGControls::get_feather, &FGControls::set_feather);
342 fgSetArchivable(name);
344 sprintf(name, "/controls/engines/engine[%d]/ignition", index);
345 fgTie(name, this, index,
346 &FGControls::get_ignition, &FGControls::set_ignition);
347 fgSetArchivable(name);
349 sprintf(name, "/controls/engines/engine[%d]/augmentation", index);
350 fgTie(name, this, index,
351 &FGControls::get_augmentation,
352 &FGControls::set_augmentation);
353 fgSetArchivable(name);
355 sprintf(name, "/controls/engines/engine[%d]/reverser", index);
356 fgTie(name, this, index,
357 &FGControls::get_reverser, &FGControls::set_reverser);
358 fgSetArchivable(name);
361 "/controls/engines/engine[%d]/water-injection", index);
362 fgTie(name, this, index,
363 &FGControls::get_water_injection,
364 &FGControls::set_water_injection);
365 fgSetArchivable(name);
367 sprintf(name, "/controls/engines/engine[%d]/condition", index);
368 fgTie(name, this, index,
369 &FGControls::get_condition, &FGControls::set_condition);
370 fgSetArchivable(name);
374 fgTie("/controls/fuel/dump-valve", this,
375 &FGControls::get_dump_valve, &FGControls::set_dump_valve);
376 fgSetArchivable("/controls/fuel/dump-valve");
378 for (index = 0; index < MAX_TANKS; index++) {
380 sprintf(name, "/controls/fuel/tank[%d]/fuel_selector", index);
381 fgTie(name, this, index,
382 &FGControls::get_fuel_selector,
383 &FGControls::set_fuel_selector);
384 fgSetArchivable(name);
386 sprintf(name, "/controls/fuel/tank[%d]/to_engine", index);
387 fgTie(name, this, index,
388 &FGControls::get_to_engine, &FGControls::set_to_engine);
389 fgSetArchivable(name);
391 sprintf(name, "/controls/fuel/tank[%d]/to_tank", index);
392 fgTie(name, this, index,
393 &FGControls::get_to_tank, &FGControls::set_to_tank);
394 fgSetArchivable(name);
396 for (i = 0; i < MAX_BOOSTPUMPS; i++) {
399 "/controls/fuel/tank[%d]/boost-pump[%d]", index, i);
400 fgTie(name, this, index * 2 + i,
401 &FGControls::get_boost_pump,
402 &FGControls::set_boost_pump);
403 fgSetArchivable(name);
408 fgTie("/controls/gear/parking-brake", this,
409 &FGControls::get_parking_brake,
410 &FGControls::set_parking_brake);
411 fgSetArchivable("/controls/gear/parking-brake");
413 fgTie("/controls/gear/steering", this,
414 &FGControls::get_steering, &FGControls::set_steering);
415 fgSetArchivable("/controls/gear/steering");
417 fgTie("/controls/gear/gear-down", this,
418 &FGControls::get_gear_down, &FGControls::set_gear_down);
419 fgSetArchivable("/controls/gear/gear-down");
421 fgTie("/controls/gear/antiskid", this,
422 &FGControls::get_antiskid, &FGControls::set_antiskid);
423 fgSetArchivable("/controls/gear/antiskid");
425 fgTie("/controls/gear/tailhook", this,
426 &FGControls::get_tailhook, &FGControls::set_tailhook);
427 fgSetArchivable("/controls/gear/tailhook");
429 fgTie("/controls/gear/tailwheel-lock", this,
430 &FGControls::get_tailwheel_lock,
431 &FGControls::set_tailwheel_lock);
432 fgSetArchivable("/controls/gear/tailwheel-lock");
434 for (index = 0; index < MAX_WHEELS; index++) {
436 sprintf(name, "/controls/gear/wheel[%d]/brake", index);
437 fgTie(name, this, index,
438 &FGControls::get_brake, &FGControls::set_brake);
439 fgSetArchivable(name);
441 sprintf(name, "/controls/gear/wheel[%d]/alternate-extension", index);
442 fgTie(name, this, index,
443 &FGControls::get_alternate_extension,
444 &FGControls::set_alternate_extension);
445 fgSetArchivable(name);
449 fgTie("/controls/anti-ice/wing-heat", this,
450 &FGControls::get_wing_heat, &FGControls::set_wing_heat);
451 fgSetArchivable("/controls/anti-ice/wing-heat");
453 fgTie("/controls/anti-ice/pitot-heat", this,
454 &FGControls::get_pitot_heat, &FGControls::set_pitot_heat);
455 fgSetArchivable("/controls/anti-ice/pitot-heat");
457 fgTie("/controls/anti-ice/wiper", this,
458 &FGControls::get_wiper, &FGControls::set_wiper);
459 fgSetArchivable("/controls/anti-ice/wiper");
461 fgTie("/controls/anti-ice/window-heat", this,
462 &FGControls::get_window_heat, &FGControls::set_window_heat);
463 fgSetArchivable("/controls/anti-ice/window-heat");
465 for (index = 0; index < MAX_ENGINES; index++) {
467 sprintf(name, "/controls/anti-ice/engine[%d]/carb-heat", index);
468 fgTie(name, this, index,
469 &FGControls::get_carb_heat, &FGControls::set_carb_heat);
470 fgSetArchivable(name);
472 sprintf(name, "/controls/anti-ice/engine[%d]/inlet-heat", index);
473 fgTie(name, this, index,
474 &FGControls::get_inlet_heat, &FGControls::set_inlet_heat);
475 fgSetArchivable(name);
479 for (index = 0; index < MAX_HYD_SYSTEMS; index++) {
482 "/controls/hydraulic/system[%d]/engine-pump", index);
483 fgTie(name, this, index,
484 &FGControls::get_engine_pump, &FGControls::set_engine_pump);
485 fgSetArchivable(name);
488 "/controls/hydraulic/system[%d]/electric-pump", index);
489 fgTie(name, this, index,
490 &FGControls::get_electric_pump,
491 &FGControls::set_electric_pump);
492 fgSetArchivable(name);
496 fgTie("/controls/electric/battery-switch", this,
497 &FGControls::get_battery_switch,
498 &FGControls::set_battery_switch);
499 fgSetArchivable("/controls/electric/battery-switch");
501 fgTie("/controls/electric/external-power", this,
502 &FGControls::get_external_power,
503 &FGControls::set_external_power);
504 fgSetArchivable("/controls/electric/external-power");
506 fgTie("/controls/electric/APU-generator", this,
507 &FGControls::get_APU_generator,
508 &FGControls::set_APU_generator);
509 fgSetArchivable("/controls/electric/APU-generator");
511 for (index = 0; index < MAX_ENGINES; index++) {
514 "/controls/electric/engine[%d]/generator", index);
515 fgTie(name, this, index,
516 &FGControls::get_generator_breaker,
517 &FGControls::set_generator_breaker);
518 fgSetArchivable(name);
520 sprintf(name, "/controls/electric/engine[%d]/bus-tie", index);
521 fgTie(name, this, index,
522 &FGControls::get_bus_tie,
523 &FGControls::set_bus_tie);
524 fgSetArchivable(name);
528 fgTie("/controls/pneumatic/APU-bleed", this,
529 &FGControls::get_APU_bleed,
530 &FGControls::set_APU_bleed);
531 fgSetArchivable("/controls/pneumatic/APU-bleed");
533 for (index = 0; index < MAX_ENGINES; index++) {
536 "/controls/pneumatic/engine[%d]/bleed", index);
537 fgTie(name, this, index,
538 &FGControls::get_engine_bleed,
539 &FGControls::set_engine_bleed);
540 fgSetArchivable(name);
544 fgTie("/controls/pressurization/mode", this,
545 &FGControls::get_mode, &FGControls::set_mode);
546 fgSetArchivable("/controls/pressurization/mode");
548 fgTie("/controls/pressurization/dump", this,
549 &FGControls::get_dump, &FGControls::set_dump);
550 fgSetArchivable("/controls/pressurization/dump");
552 fgTie("/controls/pressurization/outflow-valve", this,
553 &FGControls::get_outflow_valve,
554 &FGControls::set_outflow_valve);
555 fgSetArchivable("/controls/pressurization/outflow-valve");
557 for (index = 0; index < MAX_PACKS; index++) {
559 sprintf(name, "/controls/pressurization/pack[%d]/pack-on", index);
560 fgTie(name, this, index,
561 &FGControls::get_pack_on, &FGControls::set_pack_on);
562 fgSetArchivable(name);
566 fgTie("/controls/lighting/landing-lights", this,
567 &FGControls::get_landing_lights,
568 &FGControls::set_landing_lights);
569 fgSetArchivable("/controls/lighting/landing-lights");
571 fgTie("/controls/lighting/turn-off-lights", this,
572 &FGControls::get_turn_off_lights,
573 &FGControls::set_turn_off_lights);
574 fgSetArchivable("/controls/lighting/turn-off-lights");
576 fgTie("/controls/lighting/taxi-light", this,
577 &FGControls::get_taxi_light, &FGControls::set_taxi_light);
578 fgSetArchivable("/controls/lighting/taxi-light");
580 fgTie("/controls/lighting/logo-lights", this,
581 &FGControls::get_logo_lights, &FGControls::set_logo_lights);
582 fgSetArchivable("/controls/lighting/logo-lights");
584 fgTie("/controls/lighting/nav-lights", this,
585 &FGControls::get_nav_lights, &FGControls::set_nav_lights);
586 fgSetArchivable("/controls/lighting/nav-lights");
588 fgTie("/controls/lighting/beacon", this,
589 &FGControls::get_beacon, &FGControls::set_beacon);
590 fgSetArchivable("/controls/lighting/beacon");
592 fgTie("/controls/lighting/strobe", this,
593 &FGControls::get_strobe, &FGControls::set_strobe);
594 fgSetArchivable("/controls/lighting/strobe");
596 fgTie("/controls/lighting/panel-norm", this,
597 &FGControls::get_panel_norm, &FGControls::set_panel_norm);
598 fgSetArchivable("/controls/lighting/panel-norm");
600 fgTie("/controls/lighting/instruments-norm", this,
601 &FGControls::get_instruments_norm,
602 &FGControls::set_instruments_norm);
603 fgSetArchivable("/controls/lighting/instruments-norm");
605 fgTie("/controls/lighting/dome-norm", this,
606 &FGControls::get_dome_norm, &FGControls::set_dome_norm);
607 fgSetArchivable("/controls/lighting/dome-norm");
609 #ifdef FG_HAVE_ARMAMENT
611 fgTie("/controls/armament/master-arm", this,
612 &FGControls::get_master_arm, &FGControls::set_master_arm);
613 fgSetArchivable("/controls/armament/master-arm");
615 fgTie("/controls/armament/station-select", this,
616 &FGControls::get_station_select,
617 &FGControls::set_station_select);
618 fgSetArchivable("/controls/armament/station-select");
620 fgTie("/controls/armament/release-all", this,
621 &FGControls::get_release_ALL,
622 &FGControls::set_release_ALL);
623 fgSetArchivable("/controls/armament/release-all");
625 for (index = 0; index < MAX_STATIONS; index++) {
627 sprintf(name, "/controls/armament/station[%d]/stick-size", index);
628 fgTie(name, this, index,
629 &FGControls::get_stick_size, &FGControls::set_stick_size);
630 fgSetArchivable(name);
633 "/controls/armament/station[%d]/release-stick", index);
634 fgTie(name, this, index,
635 &FGControls::get_release_stick, &FGControls::set_release_stick);
636 fgSetArchivable(name);
638 sprintf(name, "/controls/armament/station[%d]/release-all", index);
639 fgTie(name, this, index,
640 &FGControls::get_release_all, &FGControls::set_release_all);
641 fgSetArchivable(name);
643 sprintf(name, "/controls/armament/station[%d]/jettison-all", index);
644 fgTie(name, this, index,
645 &FGControls::get_jettison_all, &FGControls::set_jettison_all);
646 fgSetArchivable(name);
652 fgTie("/controls/seat/vertical-adjust", this,
653 &FGControls::get_vertical_adjust,
654 &FGControls::set_vertical_adjust);
655 fgSetArchivable("/controls/seat/vertical-adjust");
657 fgTie("/controls/seat/fore-aft-adjust", this,
658 &FGControls::get_fore_aft_adjust,
659 &FGControls::set_fore_aft_adjust);
660 fgSetArchivable("/controls/seat/fore-aft-adjust");
662 fgTie("/controls/seat/eject", this,
663 &FGControls::get_eject, &FGControls::set_eject);
664 fgSetArchivable("/controls/seat/eject");
667 fgTie("/controls/APU/off-start-run", this,
668 &FGControls::get_off_start_run,
669 &FGControls::set_off_start_run);
670 fgSetArchivable("/controls/APU/off-start-run");
672 fgTie("/controls/APU/fire-switch", this,
673 &FGControls::get_APU_fire_switch,
674 &FGControls::set_APU_fire_switch);
675 fgSetArchivable("/controls/APU/fire-switch");
678 for (index = 0; index < MAX_AUTOPILOTS; index++) {
681 "/controls/autoflight/autopilot[%d]/engage", index);
682 fgTie(name, this, index,
683 &FGControls::get_autopilot_engage,
684 &FGControls::set_autopilot_engage);
685 fgSetArchivable(name);
688 fgTie("/controls/autoflight/autothrottle-arm", this,
689 &FGControls::get_autothrottle_arm,
690 &FGControls::set_autothrottle_arm);
691 fgSetArchivable("/controls/autoflight/autothrottle-arm");
693 fgTie("/controls/autoflight/autothrottle-engage", this,
694 &FGControls::get_autothrottle_engage,
695 &FGControls::set_autothrottle_engage);
696 fgSetArchivable("/controls/autoflight/autothrottle-engage");
698 fgTie("/controls/autoflight/heading-select", this,
699 &FGControls::get_heading_select,
700 &FGControls::set_heading_select);
701 fgSetArchivable("/controls/autoflight/heading-select");
703 fgTie("/controls/autoflight/altitude-select", this,
704 &FGControls::get_altitude_select,
705 &FGControls::set_altitude_select);
706 fgSetArchivable("/controls/autoflight/altitude-select");
708 fgTie("/controls/autoflight/bank-angle-select", this,
709 &FGControls::get_bank_angle_select,
710 &FGControls::set_bank_angle_select);
711 fgSetArchivable("/controls/autoflight/bank-angle-select");
713 fgTie("/controls/autoflight/vertical-speed-select", this,
714 &FGControls::get_vertical_speed_select,
715 &FGControls::set_vertical_speed_select);
716 fgSetArchivable("/controls/autoflight/vertical-speed-select");
718 fgTie("/controls/autoflight/speed-select", this,
719 &FGControls::get_speed_select,
720 &FGControls::set_speed_select);
721 fgSetArchivable("/controls/autoflight/speed-select");
723 fgTie("/controls/autoflight/mach-select", this,
724 &FGControls::get_mach_select,
725 &FGControls::set_mach_select);
726 fgSetArchivable("/controls/autoflight/mach-select");
728 fgTie("/controls/autoflight/vertical-mode", this,
729 &FGControls::get_vertical_mode,
730 &FGControls::set_vertical_mode);
731 fgSetArchivable("/controls/autoflight/vertical-mode");
733 fgTie("/controls/autoflight/lateral-mode", this,
734 &FGControls::get_lateral_mode,
735 &FGControls::set_lateral_mode);
736 fgSetArchivable("/controls/autoflight/lateral-mode");
740 void FGControls::unbind ()
743 //Tie control properties.
744 fgUntie("/controls/flight/aileron");
745 fgUntie("/controls/flight/aileron-trim");
746 fgUntie("/controls/flight/elevator");
747 fgUntie("/controls/flight/elevator-trim");
748 fgUntie("/controls/flight/rudder");
749 fgUntie("/controls/flight/rudder-trim");
750 fgUntie("/controls/flight/flaps");
751 fgUntie("/controls/flight/slats");
752 fgUntie("/controls/flight/BLC");
753 fgUntie("/controls/flight/spoilers");
754 fgUntie("/controls/flight/speedbrake");
755 fgUntie("/controls/flight/wing-sweep");
756 fgUntie("/controls/flight/wing-fold");
757 fgUntie("/controls/flight/drag-chute");
758 for (index = 0; index < MAX_ENGINES; index++) {
760 sprintf(name, "/controls/engines/engine[%d]/throttle", index);
762 sprintf(name, "/controls/engines/engine[%d]/starter", index);
764 sprintf(name, "/controls/engines/engine[%d]/fuel_pump", index);
766 sprintf(name, "/controls/engines/engine[%d]/fire-switch", index);
769 "/controls/engines/engine[%d]/fire-bottle-discharge", index);
771 sprintf(name, "/controls/engines/engine[%d]/throttle_idle", index);
773 sprintf(name, "/controls/engines/engine[%d]/cutoff", index);
775 sprintf(name, "/controls/engines/engine[%d]/mixture", index);
778 "/controls/engines/engine[%d]/propeller-pitch", index);
780 sprintf(name, "/controls/engines/engine[%d]/magnetos", index);
782 sprintf(name, "/controls/engines/engine[%d]/WEP", index);
784 sprintf(name, "/controls/engines/engine[%d]/cowl-flaps-norm", index);
786 sprintf(name, "/controls/engines/engine[%d]/feather", index);
788 sprintf(name, "/controls/engines/engine[%d]/ignition", index);
790 sprintf(name, "/controls/engines/engine[%d]/augmentation", index);
792 sprintf(name, "/controls/engines/engine[%d]/reverser", index);
794 sprintf(name, "/controls/engines/engine[%d]/water-injection", index);
796 sprintf(name, "/controls/engines/engine[%d]/condition", index);
799 fgUntie("/controls/fuel/dump-valve");
800 for (index = 0; index < MAX_TANKS; index++) {
802 sprintf(name, "/controls/fuel/tank[%d]/fuel_selector", index);
804 sprintf(name, "/controls/fuel/tank[%d]/to_engine", index);
806 sprintf(name, "/controls/fuel/tank[%d]/to_tank", index);
808 for (i = 0; index < MAX_BOOSTPUMPS; i++) {
809 sprintf(name, "/controls/fuel/tank[%d]/boost-pump[%d]", index, i);
813 fgUntie("/controls/gear/parking_brake");
814 fgUntie("/controls/gear/steering");
815 fgUntie("/controls/gear/gear_down");
816 fgUntie("/controls/gear/antiskid");
817 fgUntie("/controls/gear/tailhook");
818 fgUntie("/controls/gear/tailwheel-lock");
819 for (index = 0; index < MAX_WHEELS; index++) {
821 sprintf(name, "/controls/gear/wheel[%d]/brakes", index);
824 "/controls/gear/wheel[%d]/alternate-extension", index);
827 fgUntie("/controls/anti-ice/wing-heat");
828 fgUntie("/controls/anti-ice/pitot-heat");
829 fgUntie("/controls/anti-ice/wiper");
830 fgUntie("/controls/anti-ice/window-heat");
831 for (index = 0; index < MAX_ENGINES; index++) {
833 sprintf(name, "/controls/anti-ice/engine[%d]/carb-heat", index);
835 sprintf(name, "/controls/anti-ice/engine[%d]/inlet-heat", index);
838 for (index = 0; index < MAX_HYD_SYSTEMS; index++) {
841 "/controls/hydraulic/system[%d]/engine-pump", index);
844 "/controls/hydraulic/system[%d]/electric-pump", index);
847 fgUntie("/controls/electric/battery-switch");
848 fgUntie("/controls/electric/external-power");
849 fgUntie("/controls/electric/APU-generator");
850 for (index = 0; index < MAX_ENGINES; index++) {
853 "/controls/electric/engine[%d]/generator", index);
856 "/controls/electric/engine[%d]/bus-tie", index);
859 fgUntie("/controls/pneumatic/APU-bleed");
860 for (index = 0; index < MAX_ENGINES; index++) {
863 "/controls/pneumatic/engine[%d]/bleed", index);
866 fgUntie("/controls/pressurization/mode");
867 fgUntie("/controls/pressurization/dump");
868 for (index = 0; index < MAX_PACKS; index++) {
871 "/controls/pressurization/pack[%d]/pack-on", index);
874 fgUntie("/controls/lighting/landing-lights");
875 fgUntie("/controls/lighting/turn-off-lights");
876 fgUntie("/controls/lighting/taxi-light");
877 fgUntie("/controls/lighting/logo-lights");
878 fgUntie("/controls/lighting/nav-lights");
879 fgUntie("/controls/lighting/beacon");
880 fgUntie("/controls/lighting/strobe");
881 fgUntie("/controls/lighting/panel-norm");
882 fgUntie("/controls/lighting/instruments-norm");
883 fgUntie("/controls/lighting/dome-norm");
885 #ifdef FG_HAVE_ARMAMENT
886 fgUntie("/controls/armament/master-arm");
887 fgUntie("/controls/armament/station-select");
888 fgUntie("/controls/armament/release-all");
889 for (index = 0; index < MAX_STATIONS; index++) {
892 "/controls/armament/station[%d]/stick-size", index);
895 "/controls/armament/station[%d]/release-stick", index);
898 "/controls/armament/station[%d]/release-all", index);
901 "/controls/armament/station[%d]/jettison-all", index);
905 fgUntie("/controls/seat/vertical-adjust");
906 fgUntie("/controls/seat/fore-aft-adjust");
907 fgUntie("/controls/seat/eject");
908 fgUntie("/controls/APU/off-start-run");
909 fgUntie("/controls/APU/fire-switch");
910 for (index = 0; index < MAX_AUTOPILOTS; index++) {
913 "/controls/autoflight/autopilot[%d]/engage", index);
916 fgUntie("/controls/autoflight/autothrottle-arm");
917 fgUntie("/controls/autoflight/autothrottle-engage");
918 fgUntie("/controls/autoflight/heading-select");
919 fgUntie("/controls/autoflight/altitude-select");
920 fgUntie("/controls/autoflight/bank-angle-select");
921 fgUntie("/controls/autoflight/vertical-speed-select");
922 fgUntie("/controls/autoflight/speed-select");
923 fgUntie("/controls/autoflight/mach-select");
924 fgUntie("/controls/autoflight/vertical-mode");
925 fgUntie("/controls/autoflight/lateral-mode");
930 FGControls::update (double dt)
936 ////////////////////////////////////////////////////////////////////////
937 // Setters and adjusters.
938 ////////////////////////////////////////////////////////////////////////
941 FGControls::set_aileron (double pos)
944 CLAMP( &aileron, -1.0, 1.0 );
946 // check for autocoordination
947 if ( auto_coordination->getBoolValue() ) {
948 set_rudder( aileron / 2.0 );
953 FGControls::move_aileron (double amt)
956 CLAMP( &aileron, -1.0, 1.0 );
958 // check for autocoordination
959 if ( auto_coordination->getBoolValue() ) {
960 set_rudder( aileron / 2.0 );
965 FGControls::set_aileron_trim( double pos )
968 CLAMP( &aileron_trim, -1.0, 1.0 );
972 FGControls::move_aileron_trim( double amt )
975 CLAMP( &aileron_trim, -1.0, 1.0 );
979 FGControls::set_elevator( double pos )
982 CLAMP( &elevator, -1.0, 1.0 );
986 FGControls::move_elevator( double amt )
989 CLAMP( &elevator, -1.0, 1.0 );
993 FGControls::set_elevator_trim( double pos )
996 CLAMP( &elevator_trim, -1.0, 1.0 );
1000 FGControls::move_elevator_trim( double amt )
1002 elevator_trim += amt;
1003 CLAMP( &elevator_trim, -1.0, 1.0 );
1007 FGControls::set_rudder( double pos )
1010 CLAMP( &rudder, -1.0, 1.0 );
1014 FGControls::move_rudder( double amt )
1017 CLAMP( &rudder, -1.0, 1.0 );
1021 FGControls::set_rudder_trim( double pos )
1024 CLAMP( &rudder_trim, -1.0, 1.0 );
1028 FGControls::move_rudder_trim( double amt )
1031 CLAMP( &rudder_trim, -1.0, 1.0 );
1035 FGControls::set_flaps( double pos )
1038 CLAMP( &flaps, 0.0, 1.0 );
1042 FGControls::move_flaps( double amt )
1045 CLAMP( &flaps, 0.0, 1.0 );
1049 FGControls::set_slats( double pos )
1052 CLAMP( &slats, 0.0, 1.0 );
1056 FGControls::move_slats( double amt )
1059 CLAMP( &slats, 0.0, 1.0 );
1063 FGControls::set_BLC( bool val )
1069 FGControls::set_spoilers( double pos )
1072 CLAMP( &spoilers, 0.0, 1.0 );
1076 FGControls::move_spoilers( double amt )
1079 CLAMP( &spoilers, 0.0, 1.0 );
1083 FGControls::set_speedbrake( double pos )
1086 CLAMP( &speedbrake, 0.0, 1.0 );
1090 FGControls::move_speedbrake( double amt )
1093 CLAMP( &speedbrake, 0.0, 1.0 );
1097 FGControls::set_wing_sweep( double pos )
1100 CLAMP( &wing_sweep, 0.0, 1.0 );
1104 FGControls::move_wing_sweep( double amt )
1107 CLAMP( &wing_sweep, 0.0, 1.0 );
1111 FGControls::set_wing_fold( bool val )
1117 FGControls::set_drag_chute( bool val )
1123 FGControls::set_throttle_idle( bool val )
1125 throttle_idle = val;
1129 FGControls::set_throttle( int engine, double pos )
1131 if ( engine == ALL_ENGINES ) {
1132 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1134 CLAMP( &throttle[i], 0.0, 1.0 );
1137 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1138 throttle[engine] = pos;
1139 CLAMP( &throttle[engine], 0.0, 1.0 );
1145 FGControls::move_throttle( int engine, double amt )
1147 if ( engine == ALL_ENGINES ) {
1148 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1150 CLAMP( &throttle[i], 0.0, 1.0 );
1153 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1154 throttle[engine] += amt;
1155 CLAMP( &throttle[engine], 0.0, 1.0 );
1161 FGControls::set_starter( int engine, bool flag )
1163 if ( engine == ALL_ENGINES ) {
1164 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1168 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1169 starter[engine] = flag;
1175 FGControls::set_fuel_pump( int engine, bool val )
1177 if ( engine == ALL_ENGINES ) {
1178 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1182 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1183 fuel_pump[engine] = val;
1189 FGControls::set_fire_switch( int engine, bool val )
1191 if ( engine == ALL_ENGINES ) {
1192 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1193 fire_switch[i] = val;
1196 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1197 fire_switch[engine] = val;
1203 FGControls::set_fire_bottle_discharge( int engine, bool val )
1205 if ( engine == ALL_ENGINES ) {
1206 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1207 fire_bottle_discharge[i] = val;
1210 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1211 fire_bottle_discharge[engine] = val;
1217 FGControls::set_cutoff( int engine, bool val )
1219 if ( engine == ALL_ENGINES ) {
1220 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1224 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1225 cutoff[engine] = val;
1232 FGControls::set_mixture( int engine, double pos )
1234 if ( engine == ALL_ENGINES ) {
1235 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1237 CLAMP( &mixture[i], 0.0, 1.0 );
1240 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1241 mixture[engine] = pos;
1242 CLAMP( &mixture[engine], 0.0, 1.0 );
1248 FGControls::move_mixture( int engine, double amt )
1250 if ( engine == ALL_ENGINES ) {
1251 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1253 CLAMP( &mixture[i], 0.0, 1.0 );
1256 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1257 mixture[engine] += amt;
1258 CLAMP( &mixture[engine], 0.0, 1.0 );
1264 FGControls::set_prop_advance( int engine, double pos )
1266 if ( engine == ALL_ENGINES ) {
1267 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1268 prop_advance[i] = pos;
1269 CLAMP( &prop_advance[i], 0.0, 1.0 );
1272 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1273 prop_advance[engine] = pos;
1274 CLAMP( &prop_advance[engine], 0.0, 1.0 );
1280 FGControls::move_prop_advance( int engine, double amt )
1282 if ( engine == ALL_ENGINES ) {
1283 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1284 prop_advance[i] += amt;
1285 CLAMP( &prop_advance[i], 0.0, 1.0 );
1288 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1289 prop_advance[engine] += amt;
1290 CLAMP( &prop_advance[engine], 0.0, 1.0 );
1296 FGControls::set_magnetos( int engine, int pos )
1298 if ( engine == ALL_ENGINES ) {
1299 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1301 CLAMP( &magnetos[i], 0, 3 );
1304 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1305 magnetos[engine] = pos;
1306 CLAMP( &magnetos[engine], 0, 3 );
1312 FGControls::move_magnetos( int engine, int amt )
1314 if ( engine == ALL_ENGINES ) {
1315 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1317 CLAMP( &magnetos[i], 0, 3 );
1320 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1321 magnetos[engine] += amt;
1322 CLAMP( &magnetos[engine], 0, 3 );
1328 FGControls::set_nitrous_injection( int engine, bool val )
1330 if ( engine == ALL_ENGINES ) {
1331 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1332 nitrous_injection[i] = val;
1335 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1336 nitrous_injection[engine] = val;
1343 FGControls::set_cowl_flaps_norm( int engine, double pos )
1345 if ( engine == ALL_ENGINES ) {
1346 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1347 cowl_flaps_norm[i] = pos;
1348 CLAMP( &cowl_flaps_norm[i], 0.0, 1.0 );
1351 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1352 cowl_flaps_norm[engine] = pos;
1353 CLAMP( &cowl_flaps_norm[engine], 0.0, 1.0 );
1359 FGControls::move_cowl_flaps_norm( int engine, double amt )
1361 if ( engine == ALL_ENGINES ) {
1362 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1363 cowl_flaps_norm[i] += amt;
1364 CLAMP( &cowl_flaps_norm[i], 0.0, 1.0 );
1367 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1368 cowl_flaps_norm[engine] += amt;
1369 CLAMP( &cowl_flaps_norm[engine], 0.0, 1.0 );
1375 FGControls::set_feather( int engine, bool val )
1377 if ( engine == ALL_ENGINES ) {
1378 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1382 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1383 feather[engine] = val;
1389 FGControls::set_ignition( int engine, int pos )
1391 if ( engine == ALL_ENGINES ) {
1392 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1394 CLAMP( &ignition[i], 0, 3 );
1397 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1398 ignition[engine] = pos;
1399 CLAMP( &ignition[engine], 0, 3 );
1405 FGControls::set_augmentation( int engine, bool val )
1407 if ( engine == ALL_ENGINES ) {
1408 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1409 augmentation[i] = val;
1412 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1413 augmentation[engine] = val;
1419 FGControls::set_reverser( int engine, bool val )
1421 if ( engine == ALL_ENGINES ) {
1422 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1426 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1427 reverser[engine] = val;
1433 FGControls::set_water_injection( int engine, bool val )
1435 if ( engine == ALL_ENGINES ) {
1436 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1437 water_injection[i] = val;
1440 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1441 water_injection[engine] = val;
1447 FGControls::set_condition( int engine, int val )
1449 if ( engine == ALL_ENGINES ) {
1450 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1452 CLAMP( &condition[i], 0, 3 );
1455 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1456 condition[engine] = val;
1457 CLAMP( &condition[engine], 0, 3 );
1463 FGControls::set_dump_valve( bool val )
1470 FGControls::set_fuel_selector( int tank, bool pos )
1472 if ( tank == ALL_TANKS ) {
1473 for ( int i = 0; i < MAX_TANKS; i++ ) {
1474 fuel_selector[i] = pos;
1477 if ( (tank >= 0) && (tank < MAX_TANKS) ) {
1478 fuel_selector[tank] = pos;
1484 FGControls::set_to_engine( int tank, int engine )
1486 if ( tank == ALL_TANKS ) {
1487 for ( int i = 0; i < MAX_TANKS; i++ ) {
1488 to_engine[i] = engine;
1491 if ( (tank >= 0) && (tank < MAX_TANKS) ) {
1492 to_engine[tank] = engine;
1498 FGControls::set_to_tank( int tank, int dest_tank )
1500 if ( tank == ALL_TANKS ) {
1501 for ( int i = 0; i < MAX_TANKS; i++ ) {
1502 to_tank[i] = dest_tank;
1505 if ( (tank >= 0) && (tank < MAX_TANKS) ) {
1506 to_tank[tank] = dest_tank;
1512 FGControls::set_boost_pump( int index, bool val )
1514 if ( index == -1 ) {
1515 for ( int i = 0; i < (MAX_TANKS * MAX_BOOSTPUMPS); i++ ) {
1516 boost_pump[i] = val;
1519 if ( (index >= 0) && (index < (MAX_TANKS * MAX_BOOSTPUMPS)) ) {
1520 boost_pump[index] = val;
1527 FGControls::set_parking_brake( double pos )
1529 parking_brake = pos;
1530 CLAMP(&parking_brake, 0.0, 1.0);
1534 FGControls::set_steering( double angle )
1537 CLAMP(&steering, -80.0, 80.0);
1541 FGControls::move_steering( double angle )
1544 CLAMP(&steering, -80.0, 80.0);
1548 FGControls::set_gear_down( bool gear )
1554 FGControls::set_antiskid( bool state )
1560 FGControls::set_tailhook( bool state )
1566 FGControls::set_tailwheel_lock( bool state )
1568 tailwheel_lock = state;
1573 FGControls::set_brake( int wheel, double pos )
1575 if ( wheel == ALL_WHEELS ) {
1576 for ( int i = 0; i < MAX_WHEELS; i++ ) {
1578 CLAMP( &brake[i], 0.0, 1.0 );
1581 if ( (wheel >= 0) && (wheel < MAX_WHEELS) ) {
1583 CLAMP( &brake[wheel], 0.0, 1.0 );
1589 FGControls::move_brake( int wheel, double amt )
1591 if ( wheel == ALL_WHEELS ) {
1592 for ( int i = 0; i < MAX_WHEELS; i++ ) {
1594 CLAMP( &brake[i], 0.0, 1.0 );
1597 if ( (wheel >= 0) && (wheel < MAX_WHEELS) ) {
1598 brake[wheel] += amt;
1599 CLAMP( &brake[wheel], 0.0, 1.0 );
1605 FGControls::set_alternate_extension( int wheel, bool val )
1607 if ( wheel == ALL_WHEELS ) {
1608 for ( int i = 0; i < MAX_WHEELS; i++ ) {
1609 alternate_extension[i] = val;
1612 if ( (wheel >= 0) && (wheel < MAX_WHEELS) ) {
1613 alternate_extension[wheel] = val;
1619 FGControls::set_wing_heat( bool state )
1625 FGControls::set_pitot_heat( bool state )
1631 FGControls::set_wiper( int state )
1637 FGControls::set_window_heat( bool state )
1639 window_heat = state;
1643 FGControls::set_carb_heat( int engine, bool val )
1645 if ( engine == ALL_ENGINES ) {
1646 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1650 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1651 carb_heat[engine] = val;
1657 FGControls::set_inlet_heat( int engine, bool val )
1659 if ( engine == ALL_ENGINES ) {
1660 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1661 inlet_heat[i] = val;
1664 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1665 inlet_heat[engine] = val;
1671 FGControls::set_engine_pump( int system, bool val )
1673 if ( system == ALL_HYD_SYSTEMS ) {
1674 for ( int i = 0; i < MAX_HYD_SYSTEMS; i++ ) {
1675 engine_pump[i] = val;
1678 if ( (system >= 0) && (system < MAX_HYD_SYSTEMS) ) {
1679 engine_pump[system] = val;
1685 FGControls::set_electric_pump( int system, bool val )
1687 if ( system == ALL_HYD_SYSTEMS ) {
1688 for ( int i = 0; i < MAX_HYD_SYSTEMS; i++ ) {
1689 electric_pump[i] = val;
1692 if ( (system >= 0) && (system < MAX_HYD_SYSTEMS) ) {
1693 electric_pump[system] = val;
1699 FGControls::set_battery_switch( bool state )
1701 battery_switch = state;
1705 FGControls::set_external_power( bool state )
1707 external_power = state;
1711 FGControls::set_APU_generator( bool state )
1713 APU_generator = state;
1717 FGControls::set_generator_breaker( int engine, bool val )
1719 if ( engine == ALL_ENGINES ) {
1720 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1721 generator_breaker[i] = val;
1724 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1725 generator_breaker[engine] = val;
1731 FGControls::set_bus_tie( int engine, bool val )
1733 if ( engine == ALL_ENGINES ) {
1734 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1738 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1739 bus_tie[engine] = val;
1745 FGControls::set_APU_bleed( bool state )
1751 FGControls::set_engine_bleed( int engine, bool val )
1753 if ( engine == ALL_ENGINES ) {
1754 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1755 engine_bleed[i] = val;
1758 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1759 engine_bleed[engine] = val;
1765 FGControls::set_mode( int new_mode )
1771 FGControls::set_outflow_valve( double pos )
1773 outflow_valve = pos;
1774 CLAMP( &outflow_valve, 0.0, 1.0 );
1778 FGControls::move_outflow_valve( double amt )
1780 outflow_valve += amt;
1781 CLAMP( &outflow_valve, 0.0, 1.0 );
1785 FGControls::set_dump( bool state )
1791 FGControls::set_pack_on( int pack, bool val )
1793 if ( pack == ALL_PACKS ) {
1794 for ( int i = 0; i < MAX_PACKS; i++ ) {
1798 if ( (pack >= 0) && (pack < MAX_PACKS) ) {
1799 pack_on[pack] = val;
1805 FGControls::set_landing_lights( bool state )
1807 landing_lights = state;
1811 FGControls::set_turn_off_lights( bool state )
1813 turn_off_lights = state;
1817 FGControls::set_taxi_light( bool state )
1823 FGControls::set_logo_lights( bool state )
1825 logo_lights = state;
1829 FGControls::set_nav_lights( bool state )
1835 FGControls::set_beacon( bool state )
1841 FGControls::set_strobe( bool state )
1847 FGControls::set_panel_norm( double intensity )
1849 panel_norm = intensity;
1850 CLAMP( &panel_norm, 0.0, 1.0 );
1854 FGControls::move_panel_norm( double amt )
1857 CLAMP( &panel_norm, 0.0, 1.0 );
1861 FGControls::set_instruments_norm( double intensity )
1863 instruments_norm = intensity;
1864 CLAMP( &instruments_norm, 0.0, 1.0 );
1868 FGControls::move_instruments_norm( double amt )
1870 instruments_norm += amt;
1871 CLAMP( &instruments_norm, 0.0, 1.0 );
1875 FGControls::set_dome_norm( double intensity )
1877 dome_norm = intensity;
1878 CLAMP( &dome_norm, 0.0, 1.0 );
1882 FGControls::move_dome_norm( double amt )
1885 CLAMP( &dome_norm, 0.0, 1.0 );
1888 #ifdef FG_HAVE_ARMAMENT
1891 FGControls::set_master_arm( bool val )
1897 FGControls::set_station_select( int station )
1899 station_select = station;
1900 CLAMP( &station_select, 0, MAX_STATIONS );
1904 FGControls::set_release_ALL( bool val )
1910 FGControls::set_stick_size( int station, int size )
1912 if ( station == ALL_STATIONS ) {
1913 for ( int i = 0; i < MAX_STATIONS; i++ ) {
1914 stick_size[i] = size;
1915 CLAMP( &stick_size[i], 1, 20 );
1918 if ( (station >= 0) && (station < MAX_STATIONS) ) {
1919 stick_size[station] = size;
1920 CLAMP( &stick_size[station], 1, 20 );
1926 FGControls::set_release_stick( int station, bool val )
1928 if ( station == ALL_STATIONS ) {
1929 for ( int i = 0; i < MAX_STATIONS; i++ ) {
1930 release_stick[i] = val;
1933 if ( (station >= 0) && (station < MAX_STATIONS) ) {
1934 release_stick[station] = val;
1940 FGControls::set_release_all( int station, bool val )
1942 if ( station == ALL_STATIONS ) {
1943 for ( int i = 0; i < MAX_STATIONS; i++ ) {
1944 release_all[i] = val;
1947 if ( (station >= 0) && (station < MAX_STATIONS) ) {
1948 release_all[station] = val;
1954 FGControls::set_jettison_all( int station, bool val )
1956 if ( station == ALL_STATIONS ) {
1957 for ( int i = 0; i < MAX_STATIONS; i++ ) {
1958 jettison_all[i] = val;
1961 if ( (station >= 0) && (station < MAX_STATIONS) ) {
1962 jettison_all[station] = val;
1970 FGControls::set_vertical_adjust( double pos )
1972 vertical_adjust = pos;
1973 CLAMP( &vertical_adjust, -1.0, 1.0 );
1977 FGControls::move_vertical_adjust( double amt )
1979 vertical_adjust += amt;
1980 CLAMP( &vertical_adjust, -1.0, 1.0 );
1984 FGControls::set_fore_aft_adjust( double pos )
1986 fore_aft_adjust = pos;
1987 CLAMP( &fore_aft_adjust, -1.0, 1.0 );
1991 FGControls::move_fore_aft_adjust( double amt )
1993 fore_aft_adjust += amt;
1994 CLAMP( &fore_aft_adjust, -1.0, 1.0 );
1998 FGControls::set_eject( bool val )
2004 FGControls::set_off_start_run( int pos )
2006 off_start_run = pos;
2007 CLAMP( &off_start_run, 0, 3 );
2011 FGControls::set_APU_fire_switch( bool val )
2013 APU_fire_switch = val;
2017 FGControls::set_autothrottle_arm( bool val )
2019 autothrottle_arm = val;
2023 FGControls::set_autothrottle_engage( bool val )
2025 autothrottle_engage = val;
2029 FGControls::set_heading_select( double heading )
2031 heading_select = heading;
2032 CLAMP( &heading_select, 0.0, 360.0 );
2036 FGControls::move_heading_select( double amt )
2038 heading_select += amt;
2039 CLAMP( &heading_select, 0.0, 360.0 );
2043 FGControls::set_altitude_select( double altitude )
2045 altitude_select = altitude;
2046 CLAMP( &altitude_select, -1000.0, 100000.0 );
2050 FGControls::move_altitude_select( double amt )
2052 altitude_select += amt;
2053 CLAMP( &altitude_select, -1000.0, 100000.0 );
2057 FGControls::set_bank_angle_select( double angle )
2059 bank_angle_select = angle;
2060 CLAMP( &bank_angle_select, 10.0, 30.0 );
2064 FGControls::move_bank_angle_select( double amt )
2066 bank_angle_select += amt;
2067 CLAMP( &bank_angle_select, 10.0, 30.0 );
2071 FGControls::set_vertical_speed_select( double speed )
2073 vertical_speed_select = speed;
2074 CLAMP( &vertical_speed_select, -3000.0, 4000.0 );
2078 FGControls::move_vertical_speed_select( double amt )
2080 vertical_speed_select += amt;
2081 CLAMP( &vertical_speed_select, -3000.0, 4000.0 );
2085 FGControls::set_speed_select( double speed )
2087 speed_select = speed;
2088 CLAMP( &speed_select, 60.0, 400.0 );
2092 FGControls::move_speed_select( double amt )
2094 speed_select += amt;
2095 CLAMP( &speed_select, 60.0, 400.0 );
2099 FGControls::set_mach_select( double mach )
2102 CLAMP( &mach_select, 0.4, 4.0 );
2106 FGControls::move_mach_select( double amt )
2109 CLAMP( &mach_select, 0.4, 4.0 );
2113 FGControls::set_vertical_mode( int mode )
2115 vertical_mode = mode;
2116 CLAMP( &vertical_mode, 0, 4 );
2120 FGControls::set_lateral_mode( int mode )
2122 lateral_mode = mode;
2123 CLAMP( &lateral_mode, 0, 4 );
2127 FGControls::set_autopilot_engage( int ap, bool val )
2129 if ( ap == ALL_AUTOPILOTS ) {
2130 for ( int i = 0; i < MAX_AUTOPILOTS; i++ ) {
2131 autopilot_engage[i] = val;
2134 if ( (ap >= 0) && (ap < MAX_AUTOPILOTS) ) {
2135 autopilot_engage[ap] = val;