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 <simgear/compiler.h>
25 #include <simgear/debug/logstream.hxx>
26 #include <Main/fg_props.hxx>
28 #include "controls.hxx"
31 static const int MAX_NAME_LEN = 128;
34 ////////////////////////////////////////////////////////////////////////
35 // Inline utility methods.
36 ////////////////////////////////////////////////////////////////////////
39 CLAMP(double *x, double min, double max )
41 if ( *x < min ) { *x = min; }
42 if ( *x > max ) { *x = max; }
46 CLAMP(int *i, int min, int max )
48 if ( *i < min ) { *i = min; }
49 if ( *i > max ) { *i = max; }
53 ////////////////////////////////////////////////////////////////////////
54 // Implementation of FGControls.
55 ////////////////////////////////////////////////////////////////////////
58 FGControls::FGControls() :
73 throttle_idle( true ),
80 tailwheel_lock( false ),
85 battery_switch( true ),
86 external_power( false ),
87 APU_generator( false ),
98 instruments_norm( 0.0 ),
102 release_ALL( false ),
103 vertical_adjust( 0.0 ),
104 fore_aft_adjust( 0.0 ),
107 APU_fire_switch( false ),
108 autothrottle_arm( false ),
109 autothrottle_engage( false ),
110 heading_select( 0.0 ),
111 altitude_select( 50000.0 ),
112 bank_angle_select( 30.0 ),
113 vertical_speed_select( 0.0 ),
122 void FGControls::reset_all()
125 set_aileron_trim( 0.0 );
127 set_elevator_trim( 0.0 );
129 set_rudder_trim( 0.0 );
132 set_speedbrake( 0.0 );
133 set_wing_sweep( 0.0 );
136 set_throttle( ALL_ENGINES, 0.0 );
137 set_starter( ALL_ENGINES, false );
138 set_magnetos( ALL_ENGINES, 0 );
139 set_fuel_pump( ALL_ENGINES, false );
140 set_fire_switch( ALL_ENGINES, false );
141 set_fire_bottle_discharge( ALL_ENGINES, false );
142 set_cutoff( ALL_ENGINES, true );
143 set_nitrous_injection( ALL_ENGINES, false );
144 set_cowl_flaps_norm( ALL_ENGINES, 1.0 );
145 set_feather( ALL_ENGINES, false );
146 set_ignition( ALL_ENGINES, false );
147 set_augmentation( ALL_ENGINES, false );
148 set_reverser( ALL_ENGINES, false );
149 set_water_injection( ALL_ENGINES, false );
150 set_condition( ALL_ENGINES, 0 );
151 throttle_idle = true;
152 set_fuel_selector( ALL_TANKS, true );
157 tailwheel_lock = false;
158 set_carb_heat( ALL_ENGINES, false );
159 set_inlet_heat( ALL_ENGINES, false );
164 set_engine_pump( ALL_HYD_SYSTEMS, true );
165 set_electric_pump( ALL_HYD_SYSTEMS, true );
166 landing_lights = false;
167 turn_off_lights = false;
170 APU_fire_switch = false;
171 autothrottle_arm = false;
172 autothrottle_engage = false;
173 set_autopilot_engage( ALL_AUTOPILOTS, false );
178 FGControls::~FGControls() {
185 throttle_idle = true;
186 for ( int engine = 0; engine < MAX_ENGINES; engine++ ) {
187 throttle[engine] = 0.0;
188 mixture[engine] = 1.0;
189 fuel_pump[engine] = false;
190 prop_advance[engine] = 1.0;
191 magnetos[engine] = 0;
192 starter[engine] = false;
193 ignition[engine] = false;
194 fire_switch[engine] = false;
195 cutoff[engine] = true;
196 augmentation[engine] = false;
197 reverser[engine] = false;
198 water_injection[engine] = false;
199 nitrous_injection[engine] = false;
200 cowl_flaps_norm[engine] = 0.0;
201 condition[engine] = 0;
204 for ( int wheel = 0; wheel < MAX_WHEELS; wheel++ ) {
206 alternate_extension[wheel] = false;
209 auto_coordination = fgGetNode("/sim/auto-coordination", true);
219 fgTie("/controls/flight/aileron", this,
220 &FGControls::get_aileron, &FGControls::set_aileron);
221 fgSetArchivable("/controls/flight/aileron");
223 fgTie("/controls/flight/aileron-trim", this,
224 &FGControls::get_aileron_trim, &FGControls::set_aileron_trim);
225 fgSetArchivable("/controls/flight/aileron-trim");
227 fgTie("/controls/flight/elevator", this,
228 &FGControls::get_elevator, &FGControls::set_elevator);
229 fgSetArchivable("/controls/flight/elevator");
231 fgTie("/controls/flight/elevator-trim", this,
232 &FGControls::get_elevator_trim, &FGControls::set_elevator_trim);
233 fgSetArchivable("/controls/flight/elevator-trim");
235 fgTie("/controls/flight/rudder", this,
236 &FGControls::get_rudder, &FGControls::set_rudder);
237 fgSetArchivable("/controls/flight/rudder");
239 fgTie("/controls/flight/rudder-trim", this,
240 &FGControls::get_rudder_trim, &FGControls::set_rudder_trim);
241 fgSetArchivable("/controls/flight/rudder-trim");
243 fgTie("/controls/flight/flaps", this,
244 &FGControls::get_flaps, &FGControls::set_flaps);
245 fgSetArchivable("/controls/flight/flaps");
247 fgTie("/controls/flight/slats", this,
248 &FGControls::get_slats, &FGControls::set_slats);
249 fgSetArchivable("/controls/flight/slats");
251 fgTie("/controls/flight/BLC", this,
252 &FGControls::get_BLC, &FGControls::set_BLC);
253 fgSetArchivable("/controls/flight/BLC");
255 fgTie("/controls/flight/spoilers", this,
256 &FGControls::get_spoilers, &FGControls::set_spoilers);
257 fgSetArchivable("/controls/flight/spoilers");
259 fgTie("/controls/flight/speedbrake", this,
260 &FGControls::get_speedbrake, &FGControls::set_speedbrake);
261 fgSetArchivable("/controls/flight/speedbrake");
263 fgTie("/controls/flight/wing-sweep", this,
264 &FGControls::get_wing_sweep, &FGControls::set_wing_sweep);
265 fgSetArchivable("/controls/flight/wing-sweep");
267 fgTie("/controls/flight/wing-fold", this,
268 &FGControls::get_wing_fold, &FGControls::set_wing_fold);
269 fgSetArchivable("/controls/flight/wing-fold");
271 fgTie("/controls/flight/drag-chute", this,
272 &FGControls::get_drag_chute, &FGControls::set_drag_chute);
273 fgSetArchivable("/controls/flight/drag-chute");
276 fgTie("/controls/engines/throttle_idle", this,
277 &FGControls::get_throttle_idle, &FGControls::set_throttle_idle);
278 fgSetArchivable("/controls/engines/throttle_idle");
280 for (index = 0; index < MAX_ENGINES; index++) {
281 char name[MAX_NAME_LEN];
282 snprintf(name, MAX_NAME_LEN,
283 "/controls/engines/engine[%d]/throttle", index);
284 fgTie(name, this, index,
285 &FGControls::get_throttle, &FGControls::set_throttle);
286 fgSetArchivable(name);
288 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/starter", index);
289 fgTie(name, this, index,
290 &FGControls::get_starter, &FGControls::set_starter);
291 fgSetArchivable(name);
293 snprintf(name, MAX_NAME_LEN,
294 "/controls/engines/engine[%d]/fuel-pump", index);
295 fgTie(name, this, index,
296 &FGControls::get_fuel_pump, &FGControls::set_fuel_pump);
297 fgSetArchivable(name);
299 snprintf(name, MAX_NAME_LEN,
300 "/controls/engines/engine[%d]/fire-switch", index);
301 fgTie(name, this, index,
302 &FGControls::get_fire_switch, &FGControls::set_fire_switch);
303 fgSetArchivable(name);
305 snprintf(name, MAX_NAME_LEN,
306 "/controls/engines/engine[%d]/fire-bottle-discharge", index);
307 fgTie(name, this, index,
308 &FGControls::get_fire_bottle_discharge,
309 &FGControls::set_fire_bottle_discharge);
310 fgSetArchivable(name);
312 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/cutoff", index);
313 fgTie(name, this, index,
314 &FGControls::get_cutoff, &FGControls::set_cutoff);
315 fgSetArchivable(name);
317 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/mixture", index);
318 fgTie(name, this, index,
319 &FGControls::get_mixture, &FGControls::set_mixture);
320 fgSetArchivable(name);
322 snprintf(name, MAX_NAME_LEN,
323 "/controls/engines/engine[%d]/propeller-pitch", index);
324 fgTie(name, this, index,
325 &FGControls::get_prop_advance,
326 &FGControls::set_prop_advance);
327 fgSetArchivable(name);
329 snprintf(name, MAX_NAME_LEN,
330 "/controls/engines/engine[%d]/magnetos", index);
331 fgTie(name, this, index,
332 &FGControls::get_magnetos, &FGControls::set_magnetos);
333 fgSetArchivable(name);
335 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/WEP", index);
336 fgTie(name, this, index,
337 &FGControls::get_nitrous_injection,
338 &FGControls::set_nitrous_injection);
339 fgSetArchivable(name);
341 snprintf(name, MAX_NAME_LEN,
342 "/controls/engines/engine[%d]/cowl-flaps-norm", index);
343 fgTie(name, this, index,
344 &FGControls::get_cowl_flaps_norm,
345 &FGControls::set_cowl_flaps_norm);
346 fgSetArchivable(name);
348 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/feather", index);
349 fgTie(name, this, index,
350 &FGControls::get_feather, &FGControls::set_feather);
351 fgSetArchivable(name);
353 snprintf(name, MAX_NAME_LEN,
354 "/controls/engines/engine[%d]/ignition", index);
355 fgTie(name, this, index,
356 &FGControls::get_ignition, &FGControls::set_ignition);
357 fgSetArchivable(name);
359 snprintf(name, MAX_NAME_LEN,
360 "/controls/engines/engine[%d]/augmentation", index);
361 fgTie(name, this, index,
362 &FGControls::get_augmentation,
363 &FGControls::set_augmentation);
364 fgSetArchivable(name);
366 snprintf(name, MAX_NAME_LEN,
367 "/controls/engines/engine[%d]/reverser", index);
368 fgTie(name, this, index,
369 &FGControls::get_reverser, &FGControls::set_reverser);
370 fgSetArchivable(name);
372 snprintf(name, MAX_NAME_LEN,
373 "/controls/engines/engine[%d]/water-injection", index);
374 fgTie(name, this, index,
375 &FGControls::get_water_injection,
376 &FGControls::set_water_injection);
377 fgSetArchivable(name);
379 snprintf(name, MAX_NAME_LEN,
380 "/controls/engines/engine[%d]/condition", index);
381 fgTie(name, this, index,
382 &FGControls::get_condition, &FGControls::set_condition);
383 fgSetArchivable(name);
387 fgTie("/controls/fuel/dump-valve", this,
388 &FGControls::get_dump_valve, &FGControls::set_dump_valve);
389 fgSetArchivable("/controls/fuel/dump-valve");
391 for (index = 0; index < MAX_TANKS; index++) {
392 char name[MAX_NAME_LEN];
393 snprintf(name, MAX_NAME_LEN,
394 "/controls/fuel/tank[%d]/fuel_selector", index);
395 fgTie(name, this, index,
396 &FGControls::get_fuel_selector,
397 &FGControls::set_fuel_selector);
398 fgSetArchivable(name);
400 snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_engine", index);
401 fgTie(name, this, index,
402 &FGControls::get_to_engine, &FGControls::set_to_engine);
403 fgSetArchivable(name);
405 snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_tank", index);
406 fgTie(name, this, index,
407 &FGControls::get_to_tank, &FGControls::set_to_tank);
408 fgSetArchivable(name);
410 for (i = 0; i < MAX_BOOSTPUMPS; i++) {
411 char name[MAX_NAME_LEN];
412 snprintf(name, MAX_NAME_LEN,
413 "/controls/fuel/tank[%d]/boost-pump[%d]", index, i);
414 fgTie(name, this, index * 2 + i,
415 &FGControls::get_boost_pump,
416 &FGControls::set_boost_pump);
417 fgSetArchivable(name);
422 fgTie("/controls/gear/parking-brake", this,
423 &FGControls::get_parking_brake,
424 &FGControls::set_parking_brake);
425 fgSetArchivable("/controls/gear/parking-brake");
427 fgTie("/controls/gear/steering", this,
428 &FGControls::get_steering, &FGControls::set_steering);
429 fgSetArchivable("/controls/gear/steering");
431 fgTie("/controls/gear/gear-down", this,
432 &FGControls::get_gear_down, &FGControls::set_gear_down);
433 fgSetArchivable("/controls/gear/gear-down");
435 fgTie("/controls/gear/antiskid", this,
436 &FGControls::get_antiskid, &FGControls::set_antiskid);
437 fgSetArchivable("/controls/gear/antiskid");
439 fgTie("/controls/gear/tailhook", this,
440 &FGControls::get_tailhook, &FGControls::set_tailhook);
441 fgSetArchivable("/controls/gear/tailhook");
443 fgTie("/controls/gear/tailwheel-lock", this,
444 &FGControls::get_tailwheel_lock,
445 &FGControls::set_tailwheel_lock);
446 fgSetArchivable("/controls/gear/tailwheel-lock");
448 for (index = 0; index < MAX_WHEELS; index++) {
449 char name[MAX_NAME_LEN];
450 snprintf(name, MAX_NAME_LEN, "/controls/gear/wheel[%d]/brake", index);
451 fgTie(name, this, index,
452 &FGControls::get_brake, &FGControls::set_brake);
453 fgSetArchivable(name);
455 snprintf(name, MAX_NAME_LEN,
456 "/controls/gear/wheel[%d]/alternate-extension", index);
457 fgTie(name, this, index,
458 &FGControls::get_alternate_extension,
459 &FGControls::set_alternate_extension);
460 fgSetArchivable(name);
464 fgTie("/controls/anti-ice/wing-heat", this,
465 &FGControls::get_wing_heat, &FGControls::set_wing_heat);
466 fgSetArchivable("/controls/anti-ice/wing-heat");
468 fgTie("/controls/anti-ice/pitot-heat", this,
469 &FGControls::get_pitot_heat, &FGControls::set_pitot_heat);
470 fgSetArchivable("/controls/anti-ice/pitot-heat");
472 fgTie("/controls/anti-ice/wiper", this,
473 &FGControls::get_wiper, &FGControls::set_wiper);
474 fgSetArchivable("/controls/anti-ice/wiper");
476 fgTie("/controls/anti-ice/window-heat", this,
477 &FGControls::get_window_heat, &FGControls::set_window_heat);
478 fgSetArchivable("/controls/anti-ice/window-heat");
480 for (index = 0; index < MAX_ENGINES; index++) {
481 char name[MAX_NAME_LEN];
482 snprintf(name, MAX_NAME_LEN,
483 "/controls/anti-ice/engine[%d]/carb-heat", index);
484 fgTie(name, this, index,
485 &FGControls::get_carb_heat, &FGControls::set_carb_heat);
486 fgSetArchivable(name);
488 snprintf(name, MAX_NAME_LEN,
489 "/controls/anti-ice/engine[%d]/inlet-heat", index);
490 fgTie(name, this, index,
491 &FGControls::get_inlet_heat, &FGControls::set_inlet_heat);
492 fgSetArchivable(name);
496 for (index = 0; index < MAX_HYD_SYSTEMS; index++) {
497 char name[MAX_NAME_LEN];
498 snprintf(name, MAX_NAME_LEN,
499 "/controls/hydraulic/system[%d]/engine-pump", index);
500 fgTie(name, this, index,
501 &FGControls::get_engine_pump, &FGControls::set_engine_pump);
502 fgSetArchivable(name);
504 snprintf(name, MAX_NAME_LEN,
505 "/controls/hydraulic/system[%d]/electric-pump", index);
506 fgTie(name, this, index,
507 &FGControls::get_electric_pump,
508 &FGControls::set_electric_pump);
509 fgSetArchivable(name);
513 fgTie("/controls/electric/battery-switch", this,
514 &FGControls::get_battery_switch,
515 &FGControls::set_battery_switch);
516 fgSetArchivable("/controls/electric/battery-switch");
518 fgTie("/controls/electric/external-power", this,
519 &FGControls::get_external_power,
520 &FGControls::set_external_power);
521 fgSetArchivable("/controls/electric/external-power");
523 fgTie("/controls/electric/APU-generator", this,
524 &FGControls::get_APU_generator,
525 &FGControls::set_APU_generator);
526 fgSetArchivable("/controls/electric/APU-generator");
528 for (index = 0; index < MAX_ENGINES; index++) {
529 char name[MAX_NAME_LEN];
530 snprintf(name, MAX_NAME_LEN,
531 "/controls/electric/engine[%d]/generator", index);
532 fgTie(name, this, index,
533 &FGControls::get_generator_breaker,
534 &FGControls::set_generator_breaker);
535 fgSetArchivable(name);
537 snprintf(name, MAX_NAME_LEN,
538 "/controls/electric/engine[%d]/bus-tie", index);
539 fgTie(name, this, index,
540 &FGControls::get_bus_tie,
541 &FGControls::set_bus_tie);
542 fgSetArchivable(name);
546 fgTie("/controls/pneumatic/APU-bleed", this,
547 &FGControls::get_APU_bleed,
548 &FGControls::set_APU_bleed);
549 fgSetArchivable("/controls/pneumatic/APU-bleed");
551 for (index = 0; index < MAX_ENGINES; index++) {
552 char name[MAX_NAME_LEN];
553 snprintf(name, MAX_NAME_LEN,
554 "/controls/pneumatic/engine[%d]/bleed", index);
555 fgTie(name, this, index,
556 &FGControls::get_engine_bleed,
557 &FGControls::set_engine_bleed);
558 fgSetArchivable(name);
562 fgTie("/controls/pressurization/mode", this,
563 &FGControls::get_mode, &FGControls::set_mode);
564 fgSetArchivable("/controls/pressurization/mode");
566 fgTie("/controls/pressurization/dump", this,
567 &FGControls::get_dump, &FGControls::set_dump);
568 fgSetArchivable("/controls/pressurization/dump");
570 fgTie("/controls/pressurization/outflow-valve", this,
571 &FGControls::get_outflow_valve,
572 &FGControls::set_outflow_valve);
573 fgSetArchivable("/controls/pressurization/outflow-valve");
575 for (index = 0; index < MAX_PACKS; index++) {
576 char name[MAX_NAME_LEN];
577 snprintf(name, MAX_NAME_LEN,
578 "/controls/pressurization/pack[%d]/pack-on", index);
579 fgTie(name, this, index,
580 &FGControls::get_pack_on, &FGControls::set_pack_on);
581 fgSetArchivable(name);
585 fgTie("/controls/lighting/landing-lights", this,
586 &FGControls::get_landing_lights,
587 &FGControls::set_landing_lights);
588 fgSetArchivable("/controls/lighting/landing-lights");
590 fgTie("/controls/lighting/turn-off-lights", this,
591 &FGControls::get_turn_off_lights,
592 &FGControls::set_turn_off_lights);
593 fgSetArchivable("/controls/lighting/turn-off-lights");
595 fgTie("/controls/lighting/taxi-light", this,
596 &FGControls::get_taxi_light, &FGControls::set_taxi_light);
597 fgSetArchivable("/controls/lighting/taxi-light");
599 fgTie("/controls/lighting/logo-lights", this,
600 &FGControls::get_logo_lights, &FGControls::set_logo_lights);
601 fgSetArchivable("/controls/lighting/logo-lights");
603 fgTie("/controls/lighting/nav-lights", this,
604 &FGControls::get_nav_lights, &FGControls::set_nav_lights);
605 fgSetArchivable("/controls/lighting/nav-lights");
607 fgTie("/controls/lighting/beacon", this,
608 &FGControls::get_beacon, &FGControls::set_beacon);
609 fgSetArchivable("/controls/lighting/beacon");
611 fgTie("/controls/lighting/strobe", this,
612 &FGControls::get_strobe, &FGControls::set_strobe);
613 fgSetArchivable("/controls/lighting/strobe");
615 fgTie("/controls/lighting/panel-norm", this,
616 &FGControls::get_panel_norm, &FGControls::set_panel_norm);
617 fgSetArchivable("/controls/lighting/panel-norm");
619 fgTie("/controls/lighting/instruments-norm", this,
620 &FGControls::get_instruments_norm,
621 &FGControls::set_instruments_norm);
622 fgSetArchivable("/controls/lighting/instruments-norm");
624 fgTie("/controls/lighting/dome-norm", this,
625 &FGControls::get_dome_norm, &FGControls::set_dome_norm);
626 fgSetArchivable("/controls/lighting/dome-norm");
628 #ifdef FG_HAVE_ARMAMENT
630 fgTie("/controls/armament/master-arm", this,
631 &FGControls::get_master_arm, &FGControls::set_master_arm);
632 fgSetArchivable("/controls/armament/master-arm");
634 fgTie("/controls/armament/station-select", this,
635 &FGControls::get_station_select,
636 &FGControls::set_station_select);
637 fgSetArchivable("/controls/armament/station-select");
639 fgTie("/controls/armament/release-all", this,
640 &FGControls::get_release_ALL,
641 &FGControls::set_release_ALL);
642 fgSetArchivable("/controls/armament/release-all");
644 for (index = 0; index < MAX_STATIONS; index++) {
645 char name[MAX_NAME_LEN];
646 snprintf(name, MAX_NAME_LEN,
647 "/controls/armament/station[%d]/stick-size", index);
648 fgTie(name, this, index,
649 &FGControls::get_stick_size, &FGControls::set_stick_size);
650 fgSetArchivable(name);
652 snprintf(name, MAX_NAME_LEN,
653 "/controls/armament/station[%d]/release-stick", index);
654 fgTie(name, this, index,
655 &FGControls::get_release_stick, &FGControls::set_release_stick);
656 fgSetArchivable(name);
658 snprintf(name, MAX_NAME_LEN,
659 "/controls/armament/station[%d]/release-all", index);
660 fgTie(name, this, index,
661 &FGControls::get_release_all, &FGControls::set_release_all);
662 fgSetArchivable(name);
664 snprintf(name, MAX_NAME_LEN,
665 "/controls/armament/station[%d]/jettison-all", index);
666 fgTie(name, this, index,
667 &FGControls::get_jettison_all, &FGControls::set_jettison_all);
668 fgSetArchivable(name);
674 fgTie("/controls/seat/vertical-adjust", this,
675 &FGControls::get_vertical_adjust,
676 &FGControls::set_vertical_adjust);
677 fgSetArchivable("/controls/seat/vertical-adjust");
679 fgTie("/controls/seat/fore-aft-adjust", this,
680 &FGControls::get_fore_aft_adjust,
681 &FGControls::set_fore_aft_adjust);
682 fgSetArchivable("/controls/seat/fore-aft-adjust");
684 fgTie("/controls/seat/eject", this,
685 &FGControls::get_eject, &FGControls::set_eject);
686 fgSetArchivable("/controls/seat/eject");
689 fgTie("/controls/APU/off-start-run", this,
690 &FGControls::get_off_start_run,
691 &FGControls::set_off_start_run);
692 fgSetArchivable("/controls/APU/off-start-run");
694 fgTie("/controls/APU/fire-switch", this,
695 &FGControls::get_APU_fire_switch,
696 &FGControls::set_APU_fire_switch);
697 fgSetArchivable("/controls/APU/fire-switch");
700 for (index = 0; index < MAX_AUTOPILOTS; index++) {
701 char name[MAX_NAME_LEN];
702 snprintf(name, MAX_NAME_LEN,
703 "/controls/autoflight/autopilot[%d]/engage", index);
704 fgTie(name, this, index,
705 &FGControls::get_autopilot_engage,
706 &FGControls::set_autopilot_engage);
707 fgSetArchivable(name);
710 fgTie("/controls/autoflight/autothrottle-arm", this,
711 &FGControls::get_autothrottle_arm,
712 &FGControls::set_autothrottle_arm);
713 fgSetArchivable("/controls/autoflight/autothrottle-arm");
715 fgTie("/controls/autoflight/autothrottle-engage", this,
716 &FGControls::get_autothrottle_engage,
717 &FGControls::set_autothrottle_engage);
718 fgSetArchivable("/controls/autoflight/autothrottle-engage");
720 fgTie("/controls/autoflight/heading-select", this,
721 &FGControls::get_heading_select,
722 &FGControls::set_heading_select);
723 fgSetArchivable("/controls/autoflight/heading-select");
725 fgTie("/controls/autoflight/altitude-select", this,
726 &FGControls::get_altitude_select,
727 &FGControls::set_altitude_select);
728 fgSetArchivable("/controls/autoflight/altitude-select");
730 fgTie("/controls/autoflight/bank-angle-select", this,
731 &FGControls::get_bank_angle_select,
732 &FGControls::set_bank_angle_select);
733 fgSetArchivable("/controls/autoflight/bank-angle-select");
735 fgTie("/controls/autoflight/vertical-speed-select", this,
736 &FGControls::get_vertical_speed_select,
737 &FGControls::set_vertical_speed_select);
738 fgSetArchivable("/controls/autoflight/vertical-speed-select");
740 fgTie("/controls/autoflight/speed-select", this,
741 &FGControls::get_speed_select,
742 &FGControls::set_speed_select);
743 fgSetArchivable("/controls/autoflight/speed-select");
745 fgTie("/controls/autoflight/mach-select", this,
746 &FGControls::get_mach_select,
747 &FGControls::set_mach_select);
748 fgSetArchivable("/controls/autoflight/mach-select");
750 fgTie("/controls/autoflight/vertical-mode", this,
751 &FGControls::get_vertical_mode,
752 &FGControls::set_vertical_mode);
753 fgSetArchivable("/controls/autoflight/vertical-mode");
755 fgTie("/controls/autoflight/lateral-mode", this,
756 &FGControls::get_lateral_mode,
757 &FGControls::set_lateral_mode);
758 fgSetArchivable("/controls/autoflight/lateral-mode");
762 void FGControls::unbind ()
765 //Tie control properties.
766 fgUntie("/controls/flight/aileron");
767 fgUntie("/controls/flight/aileron-trim");
768 fgUntie("/controls/flight/elevator");
769 fgUntie("/controls/flight/elevator-trim");
770 fgUntie("/controls/flight/rudder");
771 fgUntie("/controls/flight/rudder-trim");
772 fgUntie("/controls/flight/flaps");
773 fgUntie("/controls/flight/slats");
774 fgUntie("/controls/flight/BLC");
775 fgUntie("/controls/flight/spoilers");
776 fgUntie("/controls/flight/speedbrake");
777 fgUntie("/controls/flight/wing-sweep");
778 fgUntie("/controls/flight/wing-fold");
779 fgUntie("/controls/flight/drag-chute");
780 for (index = 0; index < MAX_ENGINES; index++) {
781 char name[MAX_NAME_LEN];
782 snprintf(name, MAX_NAME_LEN,
783 "/controls/engines/engine[%d]/throttle", index);
785 snprintf(name, MAX_NAME_LEN,
786 "/controls/engines/engine[%d]/starter", index);
788 snprintf(name, MAX_NAME_LEN,
789 "/controls/engines/engine[%d]/fuel_pump", index);
791 snprintf(name, MAX_NAME_LEN,
792 "/controls/engines/engine[%d]/fire-switch", index);
794 snprintf(name, MAX_NAME_LEN,
795 "/controls/engines/engine[%d]/fire-bottle-discharge", index);
797 snprintf(name, MAX_NAME_LEN,
798 "/controls/engines/engine[%d]/throttle_idle", index);
800 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/cutoff", index);
802 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/mixture", index);
804 snprintf(name, MAX_NAME_LEN,
805 "/controls/engines/engine[%d]/propeller-pitch", index);
807 snprintf(name, MAX_NAME_LEN,
808 "/controls/engines/engine[%d]/magnetos", index);
810 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/WEP", index);
812 snprintf(name, MAX_NAME_LEN,
813 "/controls/engines/engine[%d]/cowl-flaps-norm", index);
815 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/feather", index);
817 snprintf(name, MAX_NAME_LEN,
818 "/controls/engines/engine[%d]/ignition", index);
820 snprintf(name, MAX_NAME_LEN,
821 "/controls/engines/engine[%d]/augmentation", index);
823 snprintf(name, MAX_NAME_LEN,
824 "/controls/engines/engine[%d]/reverser", index);
826 snprintf(name, MAX_NAME_LEN,
827 "/controls/engines/engine[%d]/water-injection", index);
829 snprintf(name, MAX_NAME_LEN,
830 "/controls/engines/engine[%d]/condition", index);
833 fgUntie("/controls/fuel/dump-valve");
834 for (index = 0; index < MAX_TANKS; index++) {
835 char name[MAX_NAME_LEN];
836 snprintf(name, MAX_NAME_LEN,
837 "/controls/fuel/tank[%d]/fuel_selector", index);
839 snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_engine", index);
841 snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_tank", index);
843 for (i = 0; index < MAX_BOOSTPUMPS; i++) {
844 snprintf(name, MAX_NAME_LEN,
845 "/controls/fuel/tank[%d]/boost-pump[%d]", index, i);
849 fgUntie("/controls/gear/parking_brake");
850 fgUntie("/controls/gear/steering");
851 fgUntie("/controls/gear/gear_down");
852 fgUntie("/controls/gear/antiskid");
853 fgUntie("/controls/gear/tailhook");
854 fgUntie("/controls/gear/tailwheel-lock");
855 for (index = 0; index < MAX_WHEELS; index++) {
856 char name[MAX_NAME_LEN];
857 snprintf(name, MAX_NAME_LEN, "/controls/gear/wheel[%d]/brakes", index);
859 snprintf(name, MAX_NAME_LEN,
860 "/controls/gear/wheel[%d]/alternate-extension", index);
863 fgUntie("/controls/anti-ice/wing-heat");
864 fgUntie("/controls/anti-ice/pitot-heat");
865 fgUntie("/controls/anti-ice/wiper");
866 fgUntie("/controls/anti-ice/window-heat");
867 for (index = 0; index < MAX_ENGINES; index++) {
868 char name[MAX_NAME_LEN];
869 snprintf(name, MAX_NAME_LEN,
870 "/controls/anti-ice/engine[%d]/carb-heat", index);
872 snprintf(name, MAX_NAME_LEN,
873 "/controls/anti-ice/engine[%d]/inlet-heat", index);
876 for (index = 0; index < MAX_HYD_SYSTEMS; index++) {
877 char name[MAX_NAME_LEN];
878 snprintf(name, MAX_NAME_LEN,
879 "/controls/hydraulic/system[%d]/engine-pump", index);
881 snprintf(name, MAX_NAME_LEN,
882 "/controls/hydraulic/system[%d]/electric-pump", index);
885 fgUntie("/controls/electric/battery-switch");
886 fgUntie("/controls/electric/external-power");
887 fgUntie("/controls/electric/APU-generator");
888 for (index = 0; index < MAX_ENGINES; index++) {
889 char name[MAX_NAME_LEN];
890 snprintf(name, MAX_NAME_LEN,
891 "/controls/electric/engine[%d]/generator", index);
893 snprintf(name, MAX_NAME_LEN,
894 "/controls/electric/engine[%d]/bus-tie", index);
897 fgUntie("/controls/pneumatic/APU-bleed");
898 for (index = 0; index < MAX_ENGINES; index++) {
899 char name[MAX_NAME_LEN];
900 snprintf(name, MAX_NAME_LEN,
901 "/controls/pneumatic/engine[%d]/bleed", index);
904 fgUntie("/controls/pressurization/mode");
905 fgUntie("/controls/pressurization/dump");
906 for (index = 0; index < MAX_PACKS; index++) {
907 char name[MAX_NAME_LEN];
908 snprintf(name, MAX_NAME_LEN,
909 "/controls/pressurization/pack[%d]/pack-on", index);
912 fgUntie("/controls/lighting/landing-lights");
913 fgUntie("/controls/lighting/turn-off-lights");
914 fgUntie("/controls/lighting/taxi-light");
915 fgUntie("/controls/lighting/logo-lights");
916 fgUntie("/controls/lighting/nav-lights");
917 fgUntie("/controls/lighting/beacon");
918 fgUntie("/controls/lighting/strobe");
919 fgUntie("/controls/lighting/panel-norm");
920 fgUntie("/controls/lighting/instruments-norm");
921 fgUntie("/controls/lighting/dome-norm");
923 #ifdef FG_HAVE_ARMAMENT
924 fgUntie("/controls/armament/master-arm");
925 fgUntie("/controls/armament/station-select");
926 fgUntie("/controls/armament/release-all");
927 for (index = 0; index < MAX_STATIONS; index++) {
928 char name[MAX_NAME_LEN];
929 snprintf(name, MAX_NAME_LEN,
930 "/controls/armament/station[%d]/stick-size", index);
932 snprintf(name, MAX_NAME_LEN,
933 "/controls/armament/station[%d]/release-stick", index);
935 snprintf(name, MAX_NAME_LEN,
936 "/controls/armament/station[%d]/release-all", index);
938 snprintf(name, MAX_NAME_LEN,
939 "/controls/armament/station[%d]/jettison-all", index);
943 fgUntie("/controls/seat/vertical-adjust");
944 fgUntie("/controls/seat/fore-aft-adjust");
945 fgUntie("/controls/seat/eject");
946 fgUntie("/controls/APU/off-start-run");
947 fgUntie("/controls/APU/fire-switch");
948 for (index = 0; index < MAX_AUTOPILOTS; index++) {
949 char name[MAX_NAME_LEN];
950 snprintf(name, MAX_NAME_LEN,
951 "/controls/autoflight/autopilot[%d]/engage", index);
954 fgUntie("/controls/autoflight/autothrottle-arm");
955 fgUntie("/controls/autoflight/autothrottle-engage");
956 fgUntie("/controls/autoflight/heading-select");
957 fgUntie("/controls/autoflight/altitude-select");
958 fgUntie("/controls/autoflight/bank-angle-select");
959 fgUntie("/controls/autoflight/vertical-speed-select");
960 fgUntie("/controls/autoflight/speed-select");
961 fgUntie("/controls/autoflight/mach-select");
962 fgUntie("/controls/autoflight/vertical-mode");
963 fgUntie("/controls/autoflight/lateral-mode");
968 FGControls::update (double dt)
974 ////////////////////////////////////////////////////////////////////////
975 // Setters and adjusters.
976 ////////////////////////////////////////////////////////////////////////
979 FGControls::set_aileron (double pos)
982 CLAMP( &aileron, -1.0, 1.0 );
984 // check for autocoordination
985 if ( auto_coordination->getBoolValue() ) {
986 set_rudder( aileron / 2.0 );
991 FGControls::move_aileron (double amt)
994 CLAMP( &aileron, -1.0, 1.0 );
996 // check for autocoordination
997 if ( auto_coordination->getBoolValue() ) {
998 set_rudder( aileron / 2.0 );
1003 FGControls::set_aileron_trim( double pos )
1006 CLAMP( &aileron_trim, -1.0, 1.0 );
1010 FGControls::move_aileron_trim( double amt )
1012 aileron_trim += amt;
1013 CLAMP( &aileron_trim, -1.0, 1.0 );
1017 FGControls::set_elevator( double pos )
1020 CLAMP( &elevator, -1.0, 1.0 );
1024 FGControls::move_elevator( double amt )
1027 CLAMP( &elevator, -1.0, 1.0 );
1031 FGControls::set_elevator_trim( double pos )
1033 elevator_trim = pos;
1034 CLAMP( &elevator_trim, -1.0, 1.0 );
1038 FGControls::move_elevator_trim( double amt )
1040 elevator_trim += amt;
1041 CLAMP( &elevator_trim, -1.0, 1.0 );
1045 FGControls::set_rudder( double pos )
1048 CLAMP( &rudder, -1.0, 1.0 );
1052 FGControls::move_rudder( double amt )
1055 CLAMP( &rudder, -1.0, 1.0 );
1059 FGControls::set_rudder_trim( double pos )
1062 CLAMP( &rudder_trim, -1.0, 1.0 );
1066 FGControls::move_rudder_trim( double amt )
1069 CLAMP( &rudder_trim, -1.0, 1.0 );
1073 FGControls::set_flaps( double pos )
1076 CLAMP( &flaps, 0.0, 1.0 );
1080 FGControls::move_flaps( double amt )
1083 CLAMP( &flaps, 0.0, 1.0 );
1087 FGControls::set_slats( double pos )
1090 CLAMP( &slats, 0.0, 1.0 );
1094 FGControls::move_slats( double amt )
1097 CLAMP( &slats, 0.0, 1.0 );
1101 FGControls::set_BLC( bool val )
1107 FGControls::set_spoilers( double pos )
1110 CLAMP( &spoilers, 0.0, 1.0 );
1114 FGControls::move_spoilers( double amt )
1117 CLAMP( &spoilers, 0.0, 1.0 );
1121 FGControls::set_speedbrake( double pos )
1124 CLAMP( &speedbrake, 0.0, 1.0 );
1128 FGControls::move_speedbrake( double amt )
1131 CLAMP( &speedbrake, 0.0, 1.0 );
1135 FGControls::set_wing_sweep( double pos )
1138 CLAMP( &wing_sweep, 0.0, 1.0 );
1142 FGControls::move_wing_sweep( double amt )
1145 CLAMP( &wing_sweep, 0.0, 1.0 );
1149 FGControls::set_wing_fold( bool val )
1155 FGControls::set_drag_chute( bool val )
1161 FGControls::set_throttle_idle( bool val )
1163 throttle_idle = val;
1167 FGControls::set_throttle( int engine, double pos )
1169 if ( engine == ALL_ENGINES ) {
1170 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1172 CLAMP( &throttle[i], 0.0, 1.0 );
1175 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1176 throttle[engine] = pos;
1177 CLAMP( &throttle[engine], 0.0, 1.0 );
1183 FGControls::move_throttle( int engine, double amt )
1185 if ( engine == ALL_ENGINES ) {
1186 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1188 CLAMP( &throttle[i], 0.0, 1.0 );
1191 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1192 throttle[engine] += amt;
1193 CLAMP( &throttle[engine], 0.0, 1.0 );
1199 FGControls::set_starter( int engine, bool flag )
1201 if ( engine == ALL_ENGINES ) {
1202 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1206 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1207 starter[engine] = flag;
1213 FGControls::set_fuel_pump( int engine, bool val )
1215 if ( engine == ALL_ENGINES ) {
1216 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1220 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1221 fuel_pump[engine] = val;
1227 FGControls::set_fire_switch( int engine, bool val )
1229 if ( engine == ALL_ENGINES ) {
1230 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1231 fire_switch[i] = val;
1234 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1235 fire_switch[engine] = val;
1241 FGControls::set_fire_bottle_discharge( int engine, bool val )
1243 if ( engine == ALL_ENGINES ) {
1244 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1245 fire_bottle_discharge[i] = val;
1248 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1249 fire_bottle_discharge[engine] = val;
1255 FGControls::set_cutoff( int engine, bool val )
1257 if ( engine == ALL_ENGINES ) {
1258 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1262 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1263 cutoff[engine] = val;
1270 FGControls::set_mixture( int engine, double pos )
1272 if ( engine == ALL_ENGINES ) {
1273 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1275 CLAMP( &mixture[i], 0.0, 1.0 );
1278 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1279 mixture[engine] = pos;
1280 CLAMP( &mixture[engine], 0.0, 1.0 );
1286 FGControls::move_mixture( int engine, double amt )
1288 if ( engine == ALL_ENGINES ) {
1289 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1291 CLAMP( &mixture[i], 0.0, 1.0 );
1294 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1295 mixture[engine] += amt;
1296 CLAMP( &mixture[engine], 0.0, 1.0 );
1302 FGControls::set_prop_advance( int engine, double pos )
1304 if ( engine == ALL_ENGINES ) {
1305 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1306 prop_advance[i] = pos;
1307 CLAMP( &prop_advance[i], 0.0, 1.0 );
1310 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1311 prop_advance[engine] = pos;
1312 CLAMP( &prop_advance[engine], 0.0, 1.0 );
1318 FGControls::move_prop_advance( int engine, double amt )
1320 if ( engine == ALL_ENGINES ) {
1321 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1322 prop_advance[i] += amt;
1323 CLAMP( &prop_advance[i], 0.0, 1.0 );
1326 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1327 prop_advance[engine] += amt;
1328 CLAMP( &prop_advance[engine], 0.0, 1.0 );
1334 FGControls::set_magnetos( int engine, int pos )
1336 if ( engine == ALL_ENGINES ) {
1337 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1339 CLAMP( &magnetos[i], 0, 3 );
1342 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1343 magnetos[engine] = pos;
1344 CLAMP( &magnetos[engine], 0, 3 );
1350 FGControls::move_magnetos( int engine, int amt )
1352 if ( engine == ALL_ENGINES ) {
1353 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1355 CLAMP( &magnetos[i], 0, 3 );
1358 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1359 magnetos[engine] += amt;
1360 CLAMP( &magnetos[engine], 0, 3 );
1366 FGControls::set_nitrous_injection( int engine, bool val )
1368 if ( engine == ALL_ENGINES ) {
1369 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1370 nitrous_injection[i] = val;
1373 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1374 nitrous_injection[engine] = val;
1381 FGControls::set_cowl_flaps_norm( int engine, double pos )
1383 if ( engine == ALL_ENGINES ) {
1384 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1385 cowl_flaps_norm[i] = pos;
1386 CLAMP( &cowl_flaps_norm[i], 0.0, 1.0 );
1389 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1390 cowl_flaps_norm[engine] = pos;
1391 CLAMP( &cowl_flaps_norm[engine], 0.0, 1.0 );
1397 FGControls::move_cowl_flaps_norm( int engine, double amt )
1399 if ( engine == ALL_ENGINES ) {
1400 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1401 cowl_flaps_norm[i] += amt;
1402 CLAMP( &cowl_flaps_norm[i], 0.0, 1.0 );
1405 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1406 cowl_flaps_norm[engine] += amt;
1407 CLAMP( &cowl_flaps_norm[engine], 0.0, 1.0 );
1413 FGControls::set_feather( int engine, bool val )
1415 if ( engine == ALL_ENGINES ) {
1416 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1420 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1421 feather[engine] = val;
1427 FGControls::set_ignition( int engine, int pos )
1429 if ( engine == ALL_ENGINES ) {
1430 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1432 CLAMP( &ignition[i], 0, 3 );
1435 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1436 ignition[engine] = pos;
1437 CLAMP( &ignition[engine], 0, 3 );
1443 FGControls::set_augmentation( int engine, bool val )
1445 if ( engine == ALL_ENGINES ) {
1446 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1447 augmentation[i] = val;
1450 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1451 augmentation[engine] = val;
1457 FGControls::set_reverser( int engine, bool val )
1459 if ( engine == ALL_ENGINES ) {
1460 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1464 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1465 reverser[engine] = val;
1471 FGControls::set_water_injection( int engine, bool val )
1473 if ( engine == ALL_ENGINES ) {
1474 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1475 water_injection[i] = val;
1478 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1479 water_injection[engine] = val;
1485 FGControls::set_condition( int engine, int val )
1487 if ( engine == ALL_ENGINES ) {
1488 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1490 CLAMP( &condition[i], 0, 3 );
1493 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1494 condition[engine] = val;
1495 CLAMP( &condition[engine], 0, 3 );
1501 FGControls::set_dump_valve( bool val )
1508 FGControls::set_fuel_selector( int tank, bool pos )
1510 if ( tank == ALL_TANKS ) {
1511 for ( int i = 0; i < MAX_TANKS; i++ ) {
1512 fuel_selector[i] = pos;
1515 if ( (tank >= 0) && (tank < MAX_TANKS) ) {
1516 fuel_selector[tank] = pos;
1522 FGControls::set_to_engine( int tank, int engine )
1524 if ( tank == ALL_TANKS ) {
1525 for ( int i = 0; i < MAX_TANKS; i++ ) {
1526 to_engine[i] = engine;
1529 if ( (tank >= 0) && (tank < MAX_TANKS) ) {
1530 to_engine[tank] = engine;
1536 FGControls::set_to_tank( int tank, int dest_tank )
1538 if ( tank == ALL_TANKS ) {
1539 for ( int i = 0; i < MAX_TANKS; i++ ) {
1540 to_tank[i] = dest_tank;
1543 if ( (tank >= 0) && (tank < MAX_TANKS) ) {
1544 to_tank[tank] = dest_tank;
1550 FGControls::set_boost_pump( int index, bool val )
1552 if ( index == -1 ) {
1553 for ( int i = 0; i < (MAX_TANKS * MAX_BOOSTPUMPS); i++ ) {
1554 boost_pump[i] = val;
1557 if ( (index >= 0) && (index < (MAX_TANKS * MAX_BOOSTPUMPS)) ) {
1558 boost_pump[index] = val;
1565 FGControls::set_parking_brake( double pos )
1567 parking_brake = pos;
1568 CLAMP(&parking_brake, 0.0, 1.0);
1572 FGControls::set_steering( double angle )
1575 CLAMP(&steering, -80.0, 80.0);
1579 FGControls::move_steering( double angle )
1582 CLAMP(&steering, -80.0, 80.0);
1586 FGControls::set_gear_down( bool gear )
1592 FGControls::set_antiskid( bool state )
1598 FGControls::set_tailhook( bool state )
1604 FGControls::set_tailwheel_lock( bool state )
1606 tailwheel_lock = state;
1611 FGControls::set_brake( int wheel, double pos )
1613 if ( wheel == ALL_WHEELS ) {
1614 for ( int i = 0; i < MAX_WHEELS; i++ ) {
1616 CLAMP( &brake[i], 0.0, 1.0 );
1619 if ( (wheel >= 0) && (wheel < MAX_WHEELS) ) {
1621 CLAMP( &brake[wheel], 0.0, 1.0 );
1627 FGControls::move_brake( int wheel, double amt )
1629 if ( wheel == ALL_WHEELS ) {
1630 for ( int i = 0; i < MAX_WHEELS; i++ ) {
1632 CLAMP( &brake[i], 0.0, 1.0 );
1635 if ( (wheel >= 0) && (wheel < MAX_WHEELS) ) {
1636 brake[wheel] += amt;
1637 CLAMP( &brake[wheel], 0.0, 1.0 );
1643 FGControls::set_alternate_extension( int wheel, bool val )
1645 if ( wheel == ALL_WHEELS ) {
1646 for ( int i = 0; i < MAX_WHEELS; i++ ) {
1647 alternate_extension[i] = val;
1650 if ( (wheel >= 0) && (wheel < MAX_WHEELS) ) {
1651 alternate_extension[wheel] = val;
1657 FGControls::set_wing_heat( bool state )
1663 FGControls::set_pitot_heat( bool state )
1669 FGControls::set_wiper( int state )
1675 FGControls::set_window_heat( bool state )
1677 window_heat = state;
1681 FGControls::set_carb_heat( int engine, bool val )
1683 if ( engine == ALL_ENGINES ) {
1684 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1688 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1689 carb_heat[engine] = val;
1695 FGControls::set_inlet_heat( int engine, bool val )
1697 if ( engine == ALL_ENGINES ) {
1698 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1699 inlet_heat[i] = val;
1702 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1703 inlet_heat[engine] = val;
1709 FGControls::set_engine_pump( int system, bool val )
1711 if ( system == ALL_HYD_SYSTEMS ) {
1712 for ( int i = 0; i < MAX_HYD_SYSTEMS; i++ ) {
1713 engine_pump[i] = val;
1716 if ( (system >= 0) && (system < MAX_HYD_SYSTEMS) ) {
1717 engine_pump[system] = val;
1723 FGControls::set_electric_pump( int system, bool val )
1725 if ( system == ALL_HYD_SYSTEMS ) {
1726 for ( int i = 0; i < MAX_HYD_SYSTEMS; i++ ) {
1727 electric_pump[i] = val;
1730 if ( (system >= 0) && (system < MAX_HYD_SYSTEMS) ) {
1731 electric_pump[system] = val;
1737 FGControls::set_battery_switch( bool state )
1739 battery_switch = state;
1743 FGControls::set_external_power( bool state )
1745 external_power = state;
1749 FGControls::set_APU_generator( bool state )
1751 APU_generator = state;
1755 FGControls::set_generator_breaker( int engine, bool val )
1757 if ( engine == ALL_ENGINES ) {
1758 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1759 generator_breaker[i] = val;
1762 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1763 generator_breaker[engine] = val;
1769 FGControls::set_bus_tie( int engine, bool val )
1771 if ( engine == ALL_ENGINES ) {
1772 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1776 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1777 bus_tie[engine] = val;
1783 FGControls::set_APU_bleed( bool state )
1789 FGControls::set_engine_bleed( int engine, bool val )
1791 if ( engine == ALL_ENGINES ) {
1792 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1793 engine_bleed[i] = val;
1796 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1797 engine_bleed[engine] = val;
1803 FGControls::set_mode( int new_mode )
1809 FGControls::set_outflow_valve( double pos )
1811 outflow_valve = pos;
1812 CLAMP( &outflow_valve, 0.0, 1.0 );
1816 FGControls::move_outflow_valve( double amt )
1818 outflow_valve += amt;
1819 CLAMP( &outflow_valve, 0.0, 1.0 );
1823 FGControls::set_dump( bool state )
1829 FGControls::set_pack_on( int pack, bool val )
1831 if ( pack == ALL_PACKS ) {
1832 for ( int i = 0; i < MAX_PACKS; i++ ) {
1836 if ( (pack >= 0) && (pack < MAX_PACKS) ) {
1837 pack_on[pack] = val;
1843 FGControls::set_landing_lights( bool state )
1845 landing_lights = state;
1849 FGControls::set_turn_off_lights( bool state )
1851 turn_off_lights = state;
1855 FGControls::set_taxi_light( bool state )
1861 FGControls::set_logo_lights( bool state )
1863 logo_lights = state;
1867 FGControls::set_nav_lights( bool state )
1873 FGControls::set_beacon( bool state )
1879 FGControls::set_strobe( bool state )
1885 FGControls::set_panel_norm( double intensity )
1887 panel_norm = intensity;
1888 CLAMP( &panel_norm, 0.0, 1.0 );
1892 FGControls::move_panel_norm( double amt )
1895 CLAMP( &panel_norm, 0.0, 1.0 );
1899 FGControls::set_instruments_norm( double intensity )
1901 instruments_norm = intensity;
1902 CLAMP( &instruments_norm, 0.0, 1.0 );
1906 FGControls::move_instruments_norm( double amt )
1908 instruments_norm += amt;
1909 CLAMP( &instruments_norm, 0.0, 1.0 );
1913 FGControls::set_dome_norm( double intensity )
1915 dome_norm = intensity;
1916 CLAMP( &dome_norm, 0.0, 1.0 );
1920 FGControls::move_dome_norm( double amt )
1923 CLAMP( &dome_norm, 0.0, 1.0 );
1926 #ifdef FG_HAVE_ARMAMENT
1929 FGControls::set_master_arm( bool val )
1935 FGControls::set_station_select( int station )
1937 station_select = station;
1938 CLAMP( &station_select, 0, MAX_STATIONS );
1942 FGControls::set_release_ALL( bool val )
1948 FGControls::set_stick_size( int station, int size )
1950 if ( station == ALL_STATIONS ) {
1951 for ( int i = 0; i < MAX_STATIONS; i++ ) {
1952 stick_size[i] = size;
1953 CLAMP( &stick_size[i], 1, 20 );
1956 if ( (station >= 0) && (station < MAX_STATIONS) ) {
1957 stick_size[station] = size;
1958 CLAMP( &stick_size[station], 1, 20 );
1964 FGControls::set_release_stick( int station, bool val )
1966 if ( station == ALL_STATIONS ) {
1967 for ( int i = 0; i < MAX_STATIONS; i++ ) {
1968 release_stick[i] = val;
1971 if ( (station >= 0) && (station < MAX_STATIONS) ) {
1972 release_stick[station] = val;
1978 FGControls::set_release_all( int station, bool val )
1980 if ( station == ALL_STATIONS ) {
1981 for ( int i = 0; i < MAX_STATIONS; i++ ) {
1982 release_all[i] = val;
1985 if ( (station >= 0) && (station < MAX_STATIONS) ) {
1986 release_all[station] = val;
1992 FGControls::set_jettison_all( int station, bool val )
1994 if ( station == ALL_STATIONS ) {
1995 for ( int i = 0; i < MAX_STATIONS; i++ ) {
1996 jettison_all[i] = val;
1999 if ( (station >= 0) && (station < MAX_STATIONS) ) {
2000 jettison_all[station] = val;
2008 FGControls::set_vertical_adjust( double pos )
2010 vertical_adjust = pos;
2011 CLAMP( &vertical_adjust, -1.0, 1.0 );
2015 FGControls::move_vertical_adjust( double amt )
2017 vertical_adjust += amt;
2018 CLAMP( &vertical_adjust, -1.0, 1.0 );
2022 FGControls::set_fore_aft_adjust( double pos )
2024 fore_aft_adjust = pos;
2025 CLAMP( &fore_aft_adjust, -1.0, 1.0 );
2029 FGControls::move_fore_aft_adjust( double amt )
2031 fore_aft_adjust += amt;
2032 CLAMP( &fore_aft_adjust, -1.0, 1.0 );
2036 FGControls::set_eject( bool val )
2042 FGControls::set_off_start_run( int pos )
2044 off_start_run = pos;
2045 CLAMP( &off_start_run, 0, 3 );
2049 FGControls::set_APU_fire_switch( bool val )
2051 APU_fire_switch = val;
2055 FGControls::set_autothrottle_arm( bool val )
2057 autothrottle_arm = val;
2061 FGControls::set_autothrottle_engage( bool val )
2063 autothrottle_engage = val;
2067 FGControls::set_heading_select( double heading )
2069 heading_select = heading;
2070 CLAMP( &heading_select, 0.0, 360.0 );
2074 FGControls::move_heading_select( double amt )
2076 heading_select += amt;
2077 CLAMP( &heading_select, 0.0, 360.0 );
2081 FGControls::set_altitude_select( double altitude )
2083 altitude_select = altitude;
2084 CLAMP( &altitude_select, -1000.0, 100000.0 );
2088 FGControls::move_altitude_select( double amt )
2090 altitude_select += amt;
2091 CLAMP( &altitude_select, -1000.0, 100000.0 );
2095 FGControls::set_bank_angle_select( double angle )
2097 bank_angle_select = angle;
2098 CLAMP( &bank_angle_select, 10.0, 30.0 );
2102 FGControls::move_bank_angle_select( double amt )
2104 bank_angle_select += amt;
2105 CLAMP( &bank_angle_select, 10.0, 30.0 );
2109 FGControls::set_vertical_speed_select( double speed )
2111 vertical_speed_select = speed;
2112 CLAMP( &vertical_speed_select, -3000.0, 4000.0 );
2116 FGControls::move_vertical_speed_select( double amt )
2118 vertical_speed_select += amt;
2119 CLAMP( &vertical_speed_select, -3000.0, 4000.0 );
2123 FGControls::set_speed_select( double speed )
2125 speed_select = speed;
2126 CLAMP( &speed_select, 60.0, 400.0 );
2130 FGControls::move_speed_select( double amt )
2132 speed_select += amt;
2133 CLAMP( &speed_select, 60.0, 400.0 );
2137 FGControls::set_mach_select( double mach )
2140 CLAMP( &mach_select, 0.4, 4.0 );
2144 FGControls::move_mach_select( double amt )
2147 CLAMP( &mach_select, 0.4, 4.0 );
2151 FGControls::set_vertical_mode( int mode )
2153 vertical_mode = mode;
2154 CLAMP( &vertical_mode, 0, 4 );
2158 FGControls::set_lateral_mode( int mode )
2160 lateral_mode = mode;
2161 CLAMP( &lateral_mode, 0, 4 );
2165 FGControls::set_autopilot_engage( int ap, bool val )
2167 if ( ap == ALL_AUTOPILOTS ) {
2168 for ( int i = 0; i < MAX_AUTOPILOTS; i++ ) {
2169 autopilot_engage[i] = val;
2172 if ( (ap >= 0) && (ap < MAX_AUTOPILOTS) ) {
2173 autopilot_engage[ap] = val;