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 - http://www.flightgear.org/~curt
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27 #include <simgear/compiler.h>
28 #include <simgear/debug/logstream.hxx>
29 #include <Main/fg_props.hxx>
31 #include "controls.hxx"
34 static const int MAX_NAME_LEN = 128;
37 ////////////////////////////////////////////////////////////////////////
38 // Inline utility methods.
39 ////////////////////////////////////////////////////////////////////////
42 CLAMP(double *x, double min, double max )
44 if ( *x < min ) { *x = min; }
45 if ( *x > max ) { *x = max; }
49 CLAMP(int *i, int min, int max )
51 if ( *i < min ) { *i = min; }
52 if ( *i > max ) { *i = max; }
56 ////////////////////////////////////////////////////////////////////////
57 // Implementation of FGControls.
58 ////////////////////////////////////////////////////////////////////////
61 FGControls::FGControls() :
76 throttle_idle( true ),
80 copilot_brake_left( 0.0 ),
81 copilot_brake_right( 0.0 ),
84 nose_wheel_steering( true ),
89 catapult_launch_cmd( false ),
90 tailwheel_lock( true ),
95 battery_switch( true ),
96 external_power( false ),
97 APU_generator( false ),
101 outflow_valve( 0.0 ),
103 logo_lights( false ),
108 instruments_norm( 0.0 ),
112 release_ALL( false ),
113 vertical_adjust( 0.0 ),
114 fore_aft_adjust( 0.0 ),
116 APU_fire_switch( false ),
117 autothrottle_arm( false ),
118 autothrottle_engage( false ),
119 heading_select( 0.0 ),
120 altitude_select( 50000.0 ),
121 bank_angle_select( 30.0 ),
122 vertical_speed_select( 0.0 ),
131 void FGControls::reset_all()
134 set_aileron_trim( 0.0 );
136 set_elevator_trim( 0.0 );
138 set_rudder_trim( 0.0 );
141 set_speedbrake( 0.0 );
142 set_wing_sweep( 0.0 );
145 set_throttle( ALL_ENGINES, 0.0 );
146 set_starter( ALL_ENGINES, false );
147 set_magnetos( ALL_ENGINES, 0 );
148 set_fuel_pump( ALL_ENGINES, false );
149 set_fire_switch( ALL_ENGINES, false );
150 set_fire_bottle_discharge( ALL_ENGINES, false );
151 set_cutoff( ALL_ENGINES, true );
152 set_nitrous_injection( ALL_ENGINES, false );
153 set_cowl_flaps_norm( ALL_ENGINES, 1.0 );
154 set_feather( ALL_ENGINES, false );
155 set_ignition( ALL_ENGINES, false );
156 set_augmentation( ALL_ENGINES, false );
157 set_reverser( ALL_ENGINES, false );
158 set_water_injection( ALL_ENGINES, false );
159 set_condition( ALL_ENGINES, 1.0 );
160 throttle_idle = true;
161 set_fuel_selector( ALL_TANKS, true );
164 nose_wheel_steering = true;
168 catapult_launch_cmd = false;
169 tailwheel_lock = true;
170 set_carb_heat( ALL_ENGINES, false );
171 set_inlet_heat( ALL_ENGINES, false );
176 set_engine_pump( ALL_HYD_SYSTEMS, true );
177 set_electric_pump( ALL_HYD_SYSTEMS, true );
178 landing_lights = false;
179 turn_off_lights = false;
181 set_ejection_seat( ALL_EJECTION_SEATS, false );
182 set_eseat_status( ALL_EJECTION_SEATS, SEAT_SAFED );
183 set_cmd_selector_valve( CMD_SEL_NORM );
184 APU_fire_switch = false;
185 autothrottle_arm = false;
186 autothrottle_engage = false;
187 set_autopilot_engage( ALL_AUTOPILOTS, false );
192 FGControls::~FGControls() {
199 throttle_idle = true;
200 for ( int engine = 0; engine < MAX_ENGINES; engine++ ) {
201 throttle[engine] = 0.0;
202 mixture[engine] = 1.0;
203 fuel_pump[engine] = false;
204 prop_advance[engine] = 1.0;
205 magnetos[engine] = 0;
206 feed_tank[engine] = -1; // set to -1 to turn off all tanks 0 feeds all engines from center body tank
207 starter[engine] = false;
208 feather[engine] = false;
209 ignition[engine] = false;
210 fire_switch[engine] = false;
211 fire_bottle_discharge[engine] = false;
212 cutoff[engine] = true;
213 augmentation[engine] = false;
214 reverser[engine] = false;
215 water_injection[engine] = false;
216 nitrous_injection[engine] = false;
217 cowl_flaps_norm[engine] = 0.0;
218 condition[engine] = 1.0;
219 carb_heat[engine] = false;
220 inlet_heat[engine] = false;
221 generator_breaker[engine] = false;
222 bus_tie[engine] = false;
223 engine_bleed[engine] = false;
226 for ( int tank = 0; tank < MAX_TANKS; tank++ ) {
227 fuel_selector[tank] = false;
232 // controls/fuel/tank[n]/pump[p]/
233 bool boost_pump[MAX_TANKS * MAX_BOOSTPUMPS];
235 brake_left = brake_right
236 = copilot_brake_left = copilot_brake_right
237 = brake_parking = 0.0;
238 for ( int wheel = 0; wheel < MAX_WHEELS; wheel++ ) {
239 alternate_extension[wheel] = false;
242 auto_coordination = fgGetNode("/sim/auto-coordination", true);
252 fgTie("/controls/flight/aileron", this,
253 &FGControls::get_aileron, &FGControls::set_aileron);
254 fgSetArchivable("/controls/flight/aileron");
256 fgTie("/controls/flight/aileron-trim", this,
257 &FGControls::get_aileron_trim, &FGControls::set_aileron_trim);
258 fgSetArchivable("/controls/flight/aileron-trim");
260 fgTie("/controls/flight/elevator", this,
261 &FGControls::get_elevator, &FGControls::set_elevator);
262 fgSetArchivable("/controls/flight/elevator");
264 fgTie("/controls/flight/elevator-trim", this,
265 &FGControls::get_elevator_trim, &FGControls::set_elevator_trim);
266 fgSetArchivable("/controls/flight/elevator-trim");
268 fgTie("/controls/flight/rudder", this,
269 &FGControls::get_rudder, &FGControls::set_rudder);
270 fgSetArchivable("/controls/flight/rudder");
272 fgTie("/controls/flight/rudder-trim", this,
273 &FGControls::get_rudder_trim, &FGControls::set_rudder_trim);
274 fgSetArchivable("/controls/flight/rudder-trim");
276 fgTie("/controls/flight/flaps", this,
277 &FGControls::get_flaps, &FGControls::set_flaps);
278 fgSetArchivable("/controls/flight/flaps");
280 fgTie("/controls/flight/slats", this,
281 &FGControls::get_slats, &FGControls::set_slats);
282 fgSetArchivable("/controls/flight/slats");
284 fgTie("/controls/flight/BLC", this,
285 &FGControls::get_BLC, &FGControls::set_BLC);
286 fgSetArchivable("/controls/flight/BLC");
288 fgTie("/controls/flight/spoilers", this,
289 &FGControls::get_spoilers, &FGControls::set_spoilers);
290 fgSetArchivable("/controls/flight/spoilers");
292 fgTie("/controls/flight/speedbrake", this,
293 &FGControls::get_speedbrake, &FGControls::set_speedbrake);
294 fgSetArchivable("/controls/flight/speedbrake");
296 fgTie("/controls/flight/wing-sweep", this,
297 &FGControls::get_wing_sweep, &FGControls::set_wing_sweep);
298 fgSetArchivable("/controls/flight/wing-sweep");
300 fgTie("/controls/flight/wing-fold", this,
301 &FGControls::get_wing_fold, &FGControls::set_wing_fold);
302 fgSetArchivable("/controls/flight/wing-fold");
304 fgTie("/controls/flight/drag-chute", this,
305 &FGControls::get_drag_chute, &FGControls::set_drag_chute);
306 fgSetArchivable("/controls/flight/drag-chute");
309 fgTie("/controls/engines/throttle_idle", this,
310 &FGControls::get_throttle_idle, &FGControls::set_throttle_idle);
311 fgSetArchivable("/controls/engines/throttle_idle");
313 for (index = 0; index < MAX_ENGINES; index++) {
314 char name[MAX_NAME_LEN];
315 snprintf(name, MAX_NAME_LEN,
316 "/controls/engines/engine[%d]/throttle", index);
317 fgTie(name, this, index,
318 &FGControls::get_throttle, &FGControls::set_throttle);
319 fgSetArchivable(name);
321 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/starter", index);
322 fgTie(name, this, index,
323 &FGControls::get_starter, &FGControls::set_starter);
324 fgSetArchivable(name);
326 snprintf(name, MAX_NAME_LEN,
327 "/controls/engines/engine[%d]/fuel-pump", index);
328 fgTie(name, this, index,
329 &FGControls::get_fuel_pump, &FGControls::set_fuel_pump);
330 fgSetArchivable(name);
332 snprintf(name, MAX_NAME_LEN,
333 "/controls/engines/engine[%d]/fire-switch", index);
334 fgTie(name, this, index,
335 &FGControls::get_fire_switch, &FGControls::set_fire_switch);
336 fgSetArchivable(name);
338 snprintf(name, MAX_NAME_LEN,
339 "/controls/engines/engine[%d]/fire-bottle-discharge", index);
340 fgTie(name, this, index,
341 &FGControls::get_fire_bottle_discharge,
342 &FGControls::set_fire_bottle_discharge);
343 fgSetArchivable(name);
345 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/cutoff", index);
346 fgTie(name, this, index,
347 &FGControls::get_cutoff, &FGControls::set_cutoff);
348 fgSetArchivable(name);
350 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/mixture", index);
351 fgTie(name, this, index,
352 &FGControls::get_mixture, &FGControls::set_mixture);
353 fgSetArchivable(name);
355 snprintf(name, MAX_NAME_LEN,
356 "/controls/engines/engine[%d]/propeller-pitch", index);
357 fgTie(name, this, index,
358 &FGControls::get_prop_advance,
359 &FGControls::set_prop_advance);
360 fgSetArchivable(name);
362 snprintf(name, MAX_NAME_LEN,
363 "/controls/engines/engine[%d]/magnetos", index);
364 fgTie(name, this, index,
365 &FGControls::get_magnetos, &FGControls::set_magnetos);
366 fgSetArchivable(name);
368 snprintf(name, MAX_NAME_LEN,
369 "/controls/engines/engine[%d]/feed_tank", index);
370 fgTie(name, this, index,
371 &FGControls::get_feed_tank, &FGControls::set_feed_tank);
372 fgSetArchivable(name);
375 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/WEP", index);
376 fgTie(name, this, index,
377 &FGControls::get_nitrous_injection,
378 &FGControls::set_nitrous_injection);
379 fgSetArchivable(name);
381 snprintf(name, MAX_NAME_LEN,
382 "/controls/engines/engine[%d]/cowl-flaps-norm", index);
383 fgTie(name, this, index,
384 &FGControls::get_cowl_flaps_norm,
385 &FGControls::set_cowl_flaps_norm);
386 fgSetArchivable(name);
388 snprintf(name, MAX_NAME_LEN,
389 "/controls/engines/engine[%d]/propeller-feather", index);
390 fgTie(name, this, index,
391 &FGControls::get_feather, &FGControls::set_feather);
392 fgSetArchivable(name);
394 snprintf(name, MAX_NAME_LEN,
395 "/controls/engines/engine[%d]/ignition", index);
396 fgTie(name, this, index,
397 &FGControls::get_ignition, &FGControls::set_ignition);
398 fgSetArchivable(name);
400 snprintf(name, MAX_NAME_LEN,
401 "/controls/engines/engine[%d]/augmentation", index);
402 fgTie(name, this, index,
403 &FGControls::get_augmentation,
404 &FGControls::set_augmentation);
405 fgSetArchivable(name);
407 snprintf(name, MAX_NAME_LEN,
408 "/controls/engines/engine[%d]/reverser", index);
409 fgTie(name, this, index,
410 &FGControls::get_reverser, &FGControls::set_reverser);
411 fgSetArchivable(name);
413 snprintf(name, MAX_NAME_LEN,
414 "/controls/engines/engine[%d]/water-injection", index);
415 fgTie(name, this, index,
416 &FGControls::get_water_injection,
417 &FGControls::set_water_injection);
418 fgSetArchivable(name);
420 snprintf(name, MAX_NAME_LEN,
421 "/controls/engines/engine[%d]/condition", index);
422 fgTie(name, this, index,
423 &FGControls::get_condition, &FGControls::set_condition);
424 fgSetArchivable(name);
428 fgTie("/controls/fuel/dump-valve", this,
429 &FGControls::get_dump_valve, &FGControls::set_dump_valve);
430 fgSetArchivable("/controls/fuel/dump-valve");
432 for (index = 0; index < MAX_TANKS; index++) {
433 char name[MAX_NAME_LEN];
434 snprintf(name, MAX_NAME_LEN,
435 "/controls/fuel/tank[%d]/fuel_selector", index);
436 fgTie(name, this, index,
437 &FGControls::get_fuel_selector,
438 &FGControls::set_fuel_selector);
439 fgSetArchivable(name);
441 snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_engine", index);
442 fgTie(name, this, index,
443 &FGControls::get_to_engine, &FGControls::set_to_engine);
444 fgSetArchivable(name);
446 snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_tank", index);
447 fgTie(name, this, index,
448 &FGControls::get_to_tank, &FGControls::set_to_tank);
449 fgSetArchivable(name);
451 for (i = 0; i < MAX_BOOSTPUMPS; i++) {
452 char name[MAX_NAME_LEN];
453 snprintf(name, MAX_NAME_LEN,
454 "/controls/fuel/tank[%d]/boost-pump[%d]", index, i);
455 fgTie(name, this, index * 2 + i,
456 &FGControls::get_boost_pump,
457 &FGControls::set_boost_pump);
458 fgSetArchivable(name);
463 fgTie("/controls/gear/brake-left", this,
464 &FGControls::get_brake_left,
465 &FGControls::set_brake_left);
466 fgSetArchivable("/controls/gear/brake-left");
468 fgTie("/controls/gear/brake-right", this,
469 &FGControls::get_brake_right,
470 &FGControls::set_brake_right);
471 fgSetArchivable("/controls/gear/brake-right");
473 fgTie("/controls/gear/copilot-brake-left", this,
474 &FGControls::get_copilot_brake_left,
475 &FGControls::set_copilot_brake_left);
476 fgSetArchivable("/controls/gear/copilot-brake-left");
478 fgTie("/controls/gear/copilot-brake-right", this,
479 &FGControls::get_copilot_brake_right,
480 &FGControls::set_copilot_brake_right);
481 fgSetArchivable("/controls/gear/copilot-brake-right");
483 fgTie("/controls/gear/brake-parking", this,
484 &FGControls::get_brake_parking,
485 &FGControls::set_brake_parking);
486 fgSetArchivable("/controls/gear/brake-parking");
488 fgTie("/controls/gear/steering", this,
489 &FGControls::get_steering, &FGControls::set_steering);
490 fgSetArchivable("/controls/gear/steering");
492 fgTie("/controls/gear/nose-wheel-steering", this,
493 &FGControls::get_nose_wheel_steering,
494 &FGControls::set_nose_wheel_steering);
495 fgSetArchivable("/controls/gear/nose-wheel-steering");
497 fgTie("/controls/gear/gear-down", this,
498 &FGControls::get_gear_down, &FGControls::set_gear_down);
499 fgSetArchivable("/controls/gear/gear-down");
501 fgTie("/controls/gear/antiskid", this,
502 &FGControls::get_antiskid, &FGControls::set_antiskid);
503 fgSetArchivable("/controls/gear/antiskid");
505 fgTie("/controls/gear/tailhook", this,
506 &FGControls::get_tailhook, &FGControls::set_tailhook);
507 fgSetArchivable("/controls/gear/tailhook");
509 fgTie("/controls/gear/launchbar", this,
510 &FGControls::get_launchbar, &FGControls::set_launchbar);
511 fgSetArchivable("/controls/gear/launchbar");
513 fgTie("/controls/gear/catapult-launch-cmd", this,
514 &FGControls::get_catapult_launch_cmd, &FGControls::set_catapult_launch_cmd);
515 fgSetArchivable("/controls/gear/catapult-launch-cmd");
517 fgTie("/controls/gear/tailwheel-lock", this,
518 &FGControls::get_tailwheel_lock,
519 &FGControls::set_tailwheel_lock);
520 fgSetArchivable("/controls/gear/tailwheel-lock");
522 for (index = 0; index < MAX_WHEELS; index++) {
523 char name[MAX_NAME_LEN];
524 snprintf(name, MAX_NAME_LEN,
525 "/controls/gear/wheel[%d]/alternate-extension", index);
526 fgTie(name, this, index,
527 &FGControls::get_alternate_extension,
528 &FGControls::set_alternate_extension);
529 fgSetArchivable(name);
533 fgTie("/controls/anti-ice/wing-heat", this,
534 &FGControls::get_wing_heat, &FGControls::set_wing_heat);
535 fgSetArchivable("/controls/anti-ice/wing-heat");
537 fgTie("/controls/anti-ice/pitot-heat", this,
538 &FGControls::get_pitot_heat, &FGControls::set_pitot_heat);
539 fgSetArchivable("/controls/anti-ice/pitot-heat");
541 fgTie("/controls/anti-ice/wiper", this,
542 &FGControls::get_wiper, &FGControls::set_wiper);
543 fgSetArchivable("/controls/anti-ice/wiper");
545 fgTie("/controls/anti-ice/window-heat", this,
546 &FGControls::get_window_heat, &FGControls::set_window_heat);
547 fgSetArchivable("/controls/anti-ice/window-heat");
549 for (index = 0; index < MAX_ENGINES; index++) {
550 char name[MAX_NAME_LEN];
551 snprintf(name, MAX_NAME_LEN,
552 "/controls/anti-ice/engine[%d]/carb-heat", index);
553 fgTie(name, this, index,
554 &FGControls::get_carb_heat, &FGControls::set_carb_heat);
555 fgSetArchivable(name);
557 snprintf(name, MAX_NAME_LEN,
558 "/controls/anti-ice/engine[%d]/inlet-heat", index);
559 fgTie(name, this, index,
560 &FGControls::get_inlet_heat, &FGControls::set_inlet_heat);
561 fgSetArchivable(name);
565 for (index = 0; index < MAX_HYD_SYSTEMS; index++) {
566 char name[MAX_NAME_LEN];
567 snprintf(name, MAX_NAME_LEN,
568 "/controls/hydraulic/system[%d]/engine-pump", index);
569 fgTie(name, this, index,
570 &FGControls::get_engine_pump, &FGControls::set_engine_pump);
571 fgSetArchivable(name);
573 snprintf(name, MAX_NAME_LEN,
574 "/controls/hydraulic/system[%d]/electric-pump", index);
575 fgTie(name, this, index,
576 &FGControls::get_electric_pump,
577 &FGControls::set_electric_pump);
578 fgSetArchivable(name);
582 fgTie("/controls/electric/battery-switch", this,
583 &FGControls::get_battery_switch,
584 &FGControls::set_battery_switch);
585 fgSetArchivable("/controls/electric/battery-switch");
587 fgTie("/controls/electric/external-power", this,
588 &FGControls::get_external_power,
589 &FGControls::set_external_power);
590 fgSetArchivable("/controls/electric/external-power");
592 fgTie("/controls/electric/APU-generator", this,
593 &FGControls::get_APU_generator,
594 &FGControls::set_APU_generator);
595 fgSetArchivable("/controls/electric/APU-generator");
597 for (index = 0; index < MAX_ENGINES; index++) {
598 char name[MAX_NAME_LEN];
599 snprintf(name, MAX_NAME_LEN,
600 "/controls/electric/engine[%d]/generator", index);
601 fgTie(name, this, index,
602 &FGControls::get_generator_breaker,
603 &FGControls::set_generator_breaker);
604 fgSetArchivable(name);
606 snprintf(name, MAX_NAME_LEN,
607 "/controls/electric/engine[%d]/bus-tie", index);
608 fgTie(name, this, index,
609 &FGControls::get_bus_tie,
610 &FGControls::set_bus_tie);
611 fgSetArchivable(name);
615 fgTie("/controls/pneumatic/APU-bleed", this,
616 &FGControls::get_APU_bleed,
617 &FGControls::set_APU_bleed);
618 fgSetArchivable("/controls/pneumatic/APU-bleed");
620 for (index = 0; index < MAX_ENGINES; index++) {
621 char name[MAX_NAME_LEN];
622 snprintf(name, MAX_NAME_LEN,
623 "/controls/pneumatic/engine[%d]/bleed", index);
624 fgTie(name, this, index,
625 &FGControls::get_engine_bleed,
626 &FGControls::set_engine_bleed);
627 fgSetArchivable(name);
631 fgTie("/controls/pressurization/mode", this,
632 &FGControls::get_mode, &FGControls::set_mode);
633 fgSetArchivable("/controls/pressurization/mode");
635 fgTie("/controls/pressurization/dump", this,
636 &FGControls::get_dump, &FGControls::set_dump);
637 fgSetArchivable("/controls/pressurization/dump");
639 fgTie("/controls/pressurization/outflow-valve", this,
640 &FGControls::get_outflow_valve,
641 &FGControls::set_outflow_valve);
642 fgSetArchivable("/controls/pressurization/outflow-valve");
644 for (index = 0; index < MAX_PACKS; index++) {
645 char name[MAX_NAME_LEN];
646 snprintf(name, MAX_NAME_LEN,
647 "/controls/pressurization/pack[%d]/pack-on", index);
648 fgTie(name, this, index,
649 &FGControls::get_pack_on, &FGControls::set_pack_on);
650 fgSetArchivable(name);
654 fgTie("/controls/lighting/landing-lights", this,
655 &FGControls::get_landing_lights,
656 &FGControls::set_landing_lights);
657 fgSetArchivable("/controls/lighting/landing-lights");
659 fgTie("/controls/lighting/turn-off-lights", this,
660 &FGControls::get_turn_off_lights,
661 &FGControls::set_turn_off_lights);
662 fgSetArchivable("/controls/lighting/turn-off-lights");
664 fgTie("/controls/lighting/taxi-light", this,
665 &FGControls::get_taxi_light, &FGControls::set_taxi_light);
666 fgSetArchivable("/controls/lighting/taxi-light");
668 fgTie("/controls/lighting/logo-lights", this,
669 &FGControls::get_logo_lights, &FGControls::set_logo_lights);
670 fgSetArchivable("/controls/lighting/logo-lights");
672 fgTie("/controls/lighting/nav-lights", this,
673 &FGControls::get_nav_lights, &FGControls::set_nav_lights);
674 fgSetArchivable("/controls/lighting/nav-lights");
676 fgTie("/controls/lighting/beacon", this,
677 &FGControls::get_beacon, &FGControls::set_beacon);
678 fgSetArchivable("/controls/lighting/beacon");
680 fgTie("/controls/lighting/strobe", this,
681 &FGControls::get_strobe, &FGControls::set_strobe);
682 fgSetArchivable("/controls/lighting/strobe");
684 fgTie("/controls/lighting/panel-norm", this,
685 &FGControls::get_panel_norm, &FGControls::set_panel_norm);
686 fgSetArchivable("/controls/lighting/panel-norm");
688 fgTie("/controls/lighting/instruments-norm", this,
689 &FGControls::get_instruments_norm,
690 &FGControls::set_instruments_norm);
691 fgSetArchivable("/controls/lighting/instruments-norm");
693 fgTie("/controls/lighting/dome-norm", this,
694 &FGControls::get_dome_norm, &FGControls::set_dome_norm);
695 fgSetArchivable("/controls/lighting/dome-norm");
698 fgTie("/controls/armament/master-arm", this,
699 &FGControls::get_master_arm, &FGControls::set_master_arm);
700 fgSetArchivable("/controls/armament/master-arm");
702 fgTie("/controls/armament/station-select", this,
703 &FGControls::get_station_select,
704 &FGControls::set_station_select);
705 fgSetArchivable("/controls/armament/station-select");
707 fgTie("/controls/armament/release-all", this,
708 &FGControls::get_release_ALL,
709 &FGControls::set_release_ALL);
710 fgSetArchivable("/controls/armament/release-all");
712 for (index = 0; index < MAX_STATIONS; index++) {
713 char name[MAX_NAME_LEN];
714 snprintf(name, MAX_NAME_LEN,
715 "/controls/armament/station[%d]/stick-size", index);
716 fgTie(name, this, index,
717 &FGControls::get_stick_size, &FGControls::set_stick_size);
718 fgSetArchivable(name);
720 snprintf(name, MAX_NAME_LEN,
721 "/controls/armament/station[%d]/release-stick", index);
722 fgTie(name, this, index,
723 &FGControls::get_release_stick, &FGControls::set_release_stick);
724 fgSetArchivable(name);
726 snprintf(name, MAX_NAME_LEN,
727 "/controls/armament/station[%d]/release-all", index);
728 fgTie(name, this, index,
729 &FGControls::get_release_all, &FGControls::set_release_all);
730 fgSetArchivable(name);
732 snprintf(name, MAX_NAME_LEN,
733 "/controls/armament/station[%d]/jettison-all", index);
734 fgTie(name, this, index,
735 &FGControls::get_jettison_all, &FGControls::set_jettison_all);
736 fgSetArchivable(name);
740 fgTie("/controls/seat/vertical-adjust", this,
741 &FGControls::get_vertical_adjust,
742 &FGControls::set_vertical_adjust);
743 fgSetArchivable("/controls/seat/vertical-adjust");
745 fgTie("/controls/seat/fore-aft-adjust", this,
746 &FGControls::get_fore_aft_adjust,
747 &FGControls::set_fore_aft_adjust);
748 fgSetArchivable("/controls/seat/fore-aft-adjust");
750 for (index = 0; index < MAX_EJECTION_SEATS; index++) {
751 char name[MAX_NAME_LEN];
752 snprintf(name, MAX_NAME_LEN,
753 "/controls/seat/eject[%d]/initiate", index);
754 fgTie(name, this, index,
755 &FGControls::get_ejection_seat,
756 &FGControls::set_ejection_seat);
757 fgSetArchivable(name);
759 snprintf(name, MAX_NAME_LEN,
760 "/controls/seat/eject[%d]/status", index);
762 fgTie(name, this, index,
763 &FGControls::get_eseat_status,
764 &FGControls::set_eseat_status);
766 fgSetArchivable(name);
769 fgTie("/controls/seat/cmd_selector_valve", this,
770 &FGControls::get_cmd_selector_valve,
771 &FGControls::set_cmd_selector_valve);
772 fgSetArchivable("/controls/seat/eject/cmd_selector_valve");
776 fgTie("/controls/APU/off-start-run", this,
777 &FGControls::get_off_start_run,
778 &FGControls::set_off_start_run);
779 fgSetArchivable("/controls/APU/off-start-run");
781 fgTie("/controls/APU/fire-switch", this,
782 &FGControls::get_APU_fire_switch,
783 &FGControls::set_APU_fire_switch);
784 fgSetArchivable("/controls/APU/fire-switch");
787 for (index = 0; index < MAX_AUTOPILOTS; index++) {
788 char name[MAX_NAME_LEN];
789 snprintf(name, MAX_NAME_LEN,
790 "/controls/autoflight/autopilot[%d]/engage", index);
791 fgTie(name, this, index,
792 &FGControls::get_autopilot_engage,
793 &FGControls::set_autopilot_engage);
794 fgSetArchivable(name);
797 fgTie("/controls/autoflight/autothrottle-arm", this,
798 &FGControls::get_autothrottle_arm,
799 &FGControls::set_autothrottle_arm);
800 fgSetArchivable("/controls/autoflight/autothrottle-arm");
802 fgTie("/controls/autoflight/autothrottle-engage", this,
803 &FGControls::get_autothrottle_engage,
804 &FGControls::set_autothrottle_engage);
805 fgSetArchivable("/controls/autoflight/autothrottle-engage");
807 fgTie("/controls/autoflight/heading-select", this,
808 &FGControls::get_heading_select,
809 &FGControls::set_heading_select);
810 fgSetArchivable("/controls/autoflight/heading-select");
812 fgTie("/controls/autoflight/altitude-select", this,
813 &FGControls::get_altitude_select,
814 &FGControls::set_altitude_select);
815 fgSetArchivable("/controls/autoflight/altitude-select");
817 fgTie("/controls/autoflight/bank-angle-select", this,
818 &FGControls::get_bank_angle_select,
819 &FGControls::set_bank_angle_select);
820 fgSetArchivable("/controls/autoflight/bank-angle-select");
822 fgTie("/controls/autoflight/vertical-speed-select", this,
823 &FGControls::get_vertical_speed_select,
824 &FGControls::set_vertical_speed_select);
825 fgSetArchivable("/controls/autoflight/vertical-speed-select");
827 fgTie("/controls/autoflight/speed-select", this,
828 &FGControls::get_speed_select,
829 &FGControls::set_speed_select);
830 fgSetArchivable("/controls/autoflight/speed-select");
832 fgTie("/controls/autoflight/mach-select", this,
833 &FGControls::get_mach_select,
834 &FGControls::set_mach_select);
835 fgSetArchivable("/controls/autoflight/mach-select");
837 fgTie("/controls/autoflight/vertical-mode", this,
838 &FGControls::get_vertical_mode,
839 &FGControls::set_vertical_mode);
840 fgSetArchivable("/controls/autoflight/vertical-mode");
842 fgTie("/controls/autoflight/lateral-mode", this,
843 &FGControls::get_lateral_mode,
844 &FGControls::set_lateral_mode);
845 fgSetArchivable("/controls/autoflight/lateral-mode");
849 void FGControls::unbind ()
852 //Tie control properties.
853 fgUntie("/controls/flight/aileron");
854 fgUntie("/controls/flight/aileron-trim");
855 fgUntie("/controls/flight/elevator");
856 fgUntie("/controls/flight/elevator-trim");
857 fgUntie("/controls/flight/rudder");
858 fgUntie("/controls/flight/rudder-trim");
859 fgUntie("/controls/flight/flaps");
860 fgUntie("/controls/flight/slats");
861 fgUntie("/controls/flight/BLC");
862 fgUntie("/controls/flight/spoilers");
863 fgUntie("/controls/flight/speedbrake");
864 fgUntie("/controls/flight/wing-sweep");
865 fgUntie("/controls/flight/wing-fold");
866 fgUntie("/controls/flight/drag-chute");
867 for (index = 0; index < MAX_ENGINES; index++) {
868 char name[MAX_NAME_LEN];
869 snprintf(name, MAX_NAME_LEN,
870 "/controls/engines/engine[%d]/throttle", index);
872 snprintf(name, MAX_NAME_LEN,
873 "/controls/engines/engine[%d]/feed_tank", index);
875 snprintf(name, MAX_NAME_LEN,
876 "/controls/engines/engine[%d]/starter", index);
878 snprintf(name, MAX_NAME_LEN,
879 "/controls/engines/engine[%d]/fuel_pump", index);
881 snprintf(name, MAX_NAME_LEN,
882 "/controls/engines/engine[%d]/fire-switch", index);
884 snprintf(name, MAX_NAME_LEN,
885 "/controls/engines/engine[%d]/fire-bottle-discharge", index);
887 snprintf(name, MAX_NAME_LEN,
888 "/controls/engines/engine[%d]/throttle_idle", index);
890 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/cutoff", index);
892 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/mixture", index);
894 snprintf(name, MAX_NAME_LEN,
895 "/controls/engines/engine[%d]/propeller-pitch", index);
897 snprintf(name, MAX_NAME_LEN,
898 "/controls/engines/engine[%d]/magnetos", index);
900 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/WEP", index);
902 snprintf(name, MAX_NAME_LEN,
903 "/controls/engines/engine[%d]/cowl-flaps-norm", index);
905 snprintf(name, MAX_NAME_LEN,
906 "/controls/engines/engine[%d]/propeller-feather", index);
908 snprintf(name, MAX_NAME_LEN,
909 "/controls/engines/engine[%d]/ignition", index);
911 snprintf(name, MAX_NAME_LEN,
912 "/controls/engines/engine[%d]/augmentation", index);
914 snprintf(name, MAX_NAME_LEN,
915 "/controls/engines/engine[%d]/reverser", index);
917 snprintf(name, MAX_NAME_LEN,
918 "/controls/engines/engine[%d]/water-injection", index);
920 snprintf(name, MAX_NAME_LEN,
921 "/controls/engines/engine[%d]/condition", index);
924 fgUntie("/controls/fuel/dump-valve");
925 for (index = 0; index < MAX_TANKS; index++) {
926 char name[MAX_NAME_LEN];
927 snprintf(name, MAX_NAME_LEN,
928 "/controls/fuel/tank[%d]/fuel_selector", index);
930 snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_engine", index);
932 snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_tank", index);
934 for (i = 0; index < MAX_BOOSTPUMPS; i++) {
935 snprintf(name, MAX_NAME_LEN,
936 "/controls/fuel/tank[%d]/boost-pump[%d]", index, i);
940 fgUntie("/controls/gear/brake-left");
941 fgUntie("/controls/gear/brake-right");
942 fgUntie("/controls/gear/brake-parking");
943 fgUntie("/controls/gear/steering");
944 fgUntie("/controls/gear/nose-wheel-steering");
945 fgUntie("/controls/gear/gear-down");
946 fgUntie("/controls/gear/antiskid");
947 fgUntie("/controls/gear/tailhook");
948 fgUntie("/controls/gear/launchbar");
949 fgUntie("/controls/gear/catapult-launch-cmd");
950 fgUntie("/controls/gear/tailwheel-lock");
951 for (index = 0; index < MAX_WHEELS; index++) {
952 char name[MAX_NAME_LEN];
953 snprintf(name, MAX_NAME_LEN,
954 "/controls/gear/wheel[%d]/alternate-extension", index);
957 fgUntie("/controls/anti-ice/wing-heat");
958 fgUntie("/controls/anti-ice/pitot-heat");
959 fgUntie("/controls/anti-ice/wiper");
960 fgUntie("/controls/anti-ice/window-heat");
961 for (index = 0; index < MAX_ENGINES; index++) {
962 char name[MAX_NAME_LEN];
963 snprintf(name, MAX_NAME_LEN,
964 "/controls/anti-ice/engine[%d]/carb-heat", index);
966 snprintf(name, MAX_NAME_LEN,
967 "/controls/anti-ice/engine[%d]/inlet-heat", index);
970 for (index = 0; index < MAX_HYD_SYSTEMS; index++) {
971 char name[MAX_NAME_LEN];
972 snprintf(name, MAX_NAME_LEN,
973 "/controls/hydraulic/system[%d]/engine-pump", index);
975 snprintf(name, MAX_NAME_LEN,
976 "/controls/hydraulic/system[%d]/electric-pump", index);
979 fgUntie("/controls/electric/battery-switch");
980 fgUntie("/controls/electric/external-power");
981 fgUntie("/controls/electric/APU-generator");
982 for (index = 0; index < MAX_ENGINES; index++) {
983 char name[MAX_NAME_LEN];
984 snprintf(name, MAX_NAME_LEN,
985 "/controls/electric/engine[%d]/generator", index);
987 snprintf(name, MAX_NAME_LEN,
988 "/controls/electric/engine[%d]/bus-tie", index);
991 fgUntie("/controls/pneumatic/APU-bleed");
992 for (index = 0; index < MAX_ENGINES; index++) {
993 char name[MAX_NAME_LEN];
994 snprintf(name, MAX_NAME_LEN,
995 "/controls/pneumatic/engine[%d]/bleed", index);
998 fgUntie("/controls/pressurization/mode");
999 fgUntie("/controls/pressurization/dump");
1000 for (index = 0; index < MAX_PACKS; index++) {
1001 char name[MAX_NAME_LEN];
1002 snprintf(name, MAX_NAME_LEN,
1003 "/controls/pressurization/pack[%d]/pack-on", index);
1006 fgUntie("/controls/lighting/landing-lights");
1007 fgUntie("/controls/lighting/turn-off-lights");
1008 fgUntie("/controls/lighting/taxi-light");
1009 fgUntie("/controls/lighting/logo-lights");
1010 fgUntie("/controls/lighting/nav-lights");
1011 fgUntie("/controls/lighting/beacon");
1012 fgUntie("/controls/lighting/strobe");
1013 fgUntie("/controls/lighting/panel-norm");
1014 fgUntie("/controls/lighting/instruments-norm");
1015 fgUntie("/controls/lighting/dome-norm");
1017 fgUntie("/controls/armament/master-arm");
1018 fgUntie("/controls/armament/station-select");
1019 fgUntie("/controls/armament/release-all");
1020 for (index = 0; index < MAX_STATIONS; index++) {
1021 char name[MAX_NAME_LEN];
1022 snprintf(name, MAX_NAME_LEN,
1023 "/controls/armament/station[%d]/stick-size", index);
1025 snprintf(name, MAX_NAME_LEN,
1026 "/controls/armament/station[%d]/release-stick", index);
1028 snprintf(name, MAX_NAME_LEN,
1029 "/controls/armament/station[%d]/release-all", index);
1031 snprintf(name, MAX_NAME_LEN,
1032 "/controls/armament/station[%d]/jettison-all", index);
1036 fgUntie("/controls/seat/vertical-adjust");
1037 fgUntie("/controls/seat/fore-aft-adjust");
1038 for (index = 0; index < MAX_EJECTION_SEATS; index++) {
1039 char name[MAX_NAME_LEN];
1040 snprintf(name, MAX_NAME_LEN,
1041 "/controls/seat/eject[%d]/initiate", index);
1043 snprintf(name, MAX_NAME_LEN,
1044 "/controls/seat/eject[%d]/status", index);
1047 fgUntie("/controls/seat/cmd_selector_valve");
1049 fgUntie("/controls/APU/off-start-run");
1050 fgUntie("/controls/APU/fire-switch");
1051 for (index = 0; index < MAX_AUTOPILOTS; index++) {
1052 char name[MAX_NAME_LEN];
1053 snprintf(name, MAX_NAME_LEN,
1054 "/controls/autoflight/autopilot[%d]/engage", index);
1057 fgUntie("/controls/autoflight/autothrottle-arm");
1058 fgUntie("/controls/autoflight/autothrottle-engage");
1059 fgUntie("/controls/autoflight/heading-select");
1060 fgUntie("/controls/autoflight/altitude-select");
1061 fgUntie("/controls/autoflight/bank-angle-select");
1062 fgUntie("/controls/autoflight/vertical-speed-select");
1063 fgUntie("/controls/autoflight/speed-select");
1064 fgUntie("/controls/autoflight/mach-select");
1065 fgUntie("/controls/autoflight/vertical-mode");
1066 fgUntie("/controls/autoflight/lateral-mode");
1071 FGControls::update (double dt)
1077 ////////////////////////////////////////////////////////////////////////
1078 // Setters and adjusters.
1079 ////////////////////////////////////////////////////////////////////////
1082 FGControls::set_aileron (double pos)
1085 CLAMP( &aileron, -1.0, 1.0 );
1087 // check for autocoordination
1088 if ( auto_coordination->getBoolValue() ) {
1089 set_rudder( aileron / 2.0 );
1094 FGControls::move_aileron (double amt)
1097 CLAMP( &aileron, -1.0, 1.0 );
1099 // check for autocoordination
1100 if ( auto_coordination->getBoolValue() ) {
1101 set_rudder( aileron / 2.0 );
1106 FGControls::set_aileron_trim( double pos )
1109 CLAMP( &aileron_trim, -1.0, 1.0 );
1113 FGControls::move_aileron_trim( double amt )
1115 aileron_trim += amt;
1116 CLAMP( &aileron_trim, -1.0, 1.0 );
1120 FGControls::set_elevator( double pos )
1123 CLAMP( &elevator, -1.0, 1.0 );
1127 FGControls::move_elevator( double amt )
1130 CLAMP( &elevator, -1.0, 1.0 );
1134 FGControls::set_elevator_trim( double pos )
1136 elevator_trim = pos;
1137 CLAMP( &elevator_trim, -1.0, 1.0 );
1141 FGControls::move_elevator_trim( double amt )
1143 elevator_trim += amt;
1144 CLAMP( &elevator_trim, -1.0, 1.0 );
1148 FGControls::set_rudder( double pos )
1151 CLAMP( &rudder, -1.0, 1.0 );
1155 FGControls::move_rudder( double amt )
1158 CLAMP( &rudder, -1.0, 1.0 );
1162 FGControls::set_rudder_trim( double pos )
1165 CLAMP( &rudder_trim, -1.0, 1.0 );
1169 FGControls::move_rudder_trim( double amt )
1172 CLAMP( &rudder_trim, -1.0, 1.0 );
1176 FGControls::set_flaps( double pos )
1179 CLAMP( &flaps, 0.0, 1.0 );
1183 FGControls::move_flaps( double amt )
1186 CLAMP( &flaps, 0.0, 1.0 );
1190 FGControls::set_slats( double pos )
1193 CLAMP( &slats, 0.0, 1.0 );
1197 FGControls::move_slats( double amt )
1200 CLAMP( &slats, 0.0, 1.0 );
1204 FGControls::set_BLC( bool val )
1210 FGControls::set_spoilers( double pos )
1213 CLAMP( &spoilers, 0.0, 1.0 );
1217 FGControls::move_spoilers( double amt )
1220 CLAMP( &spoilers, 0.0, 1.0 );
1224 FGControls::set_speedbrake( double pos )
1227 CLAMP( &speedbrake, 0.0, 1.0 );
1231 FGControls::move_speedbrake( double amt )
1234 CLAMP( &speedbrake, 0.0, 1.0 );
1238 FGControls::set_wing_sweep( double pos )
1241 CLAMP( &wing_sweep, 0.0, 1.0 );
1245 FGControls::move_wing_sweep( double amt )
1248 CLAMP( &wing_sweep, 0.0, 1.0 );
1252 FGControls::set_wing_fold( bool val )
1258 FGControls::set_drag_chute( bool val )
1264 FGControls::set_throttle_idle( bool val )
1266 throttle_idle = val;
1270 FGControls::set_throttle( int engine, double pos )
1272 if ( engine == ALL_ENGINES ) {
1273 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1275 CLAMP( &throttle[i], 0.0, 1.0 );
1278 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1279 throttle[engine] = pos;
1280 CLAMP( &throttle[engine], 0.0, 1.0 );
1286 FGControls::move_throttle( int engine, double amt )
1288 if ( engine == ALL_ENGINES ) {
1289 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1291 CLAMP( &throttle[i], 0.0, 1.0 );
1294 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1295 throttle[engine] += amt;
1296 CLAMP( &throttle[engine], 0.0, 1.0 );
1302 FGControls::set_starter( int engine, bool flag )
1304 if ( engine == ALL_ENGINES ) {
1305 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1309 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1310 starter[engine] = flag;
1316 FGControls::set_fuel_pump( int engine, bool val )
1318 if ( engine == ALL_ENGINES ) {
1319 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1323 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1324 fuel_pump[engine] = val;
1330 FGControls::set_fire_switch( int engine, bool val )
1332 if ( engine == ALL_ENGINES ) {
1333 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1334 fire_switch[i] = val;
1337 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1338 fire_switch[engine] = val;
1344 FGControls::set_fire_bottle_discharge( int engine, bool val )
1346 if ( engine == ALL_ENGINES ) {
1347 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1348 fire_bottle_discharge[i] = val;
1351 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1352 fire_bottle_discharge[engine] = val;
1358 FGControls::set_cutoff( int engine, bool val )
1360 if ( engine == ALL_ENGINES ) {
1361 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1365 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1366 cutoff[engine] = val;
1372 FGControls::set_feed_tank( int engine, int tank )
1374 if ( engine == ALL_ENGINES ) {
1375 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1376 feed_tank[i] = tank;
1377 CLAMP( &feed_tank[i], -1, 4 );
1380 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1381 feed_tank[engine] = tank;
1382 CLAMP( &feed_tank[engine], -1, 4 );
1385 // feed_tank[engine] = engine;
1390 FGControls::set_mixture( int engine, double pos )
1392 if ( engine == ALL_ENGINES ) {
1393 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1395 CLAMP( &mixture[i], 0.0, 1.0 );
1398 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1399 mixture[engine] = pos;
1400 CLAMP( &mixture[engine], 0.0, 1.0 );
1406 FGControls::move_mixture( int engine, double amt )
1408 if ( engine == ALL_ENGINES ) {
1409 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1411 CLAMP( &mixture[i], 0.0, 1.0 );
1414 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1415 mixture[engine] += amt;
1416 CLAMP( &mixture[engine], 0.0, 1.0 );
1422 FGControls::set_prop_advance( int engine, double pos )
1424 if ( engine == ALL_ENGINES ) {
1425 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1426 prop_advance[i] = pos;
1427 CLAMP( &prop_advance[i], 0.0, 1.0 );
1430 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1431 prop_advance[engine] = pos;
1432 CLAMP( &prop_advance[engine], 0.0, 1.0 );
1438 FGControls::move_prop_advance( int engine, double amt )
1440 if ( engine == ALL_ENGINES ) {
1441 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1442 prop_advance[i] += amt;
1443 CLAMP( &prop_advance[i], 0.0, 1.0 );
1446 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1447 prop_advance[engine] += amt;
1448 CLAMP( &prop_advance[engine], 0.0, 1.0 );
1454 FGControls::set_magnetos( int engine, int pos )
1456 if ( engine == ALL_ENGINES ) {
1457 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1459 CLAMP( &magnetos[i], 0, 3 );
1462 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1463 magnetos[engine] = pos;
1464 CLAMP( &magnetos[engine], 0, 3 );
1470 FGControls::move_magnetos( int engine, int amt )
1472 if ( engine == ALL_ENGINES ) {
1473 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1475 CLAMP( &magnetos[i], 0, 3 );
1478 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1479 magnetos[engine] += amt;
1480 CLAMP( &magnetos[engine], 0, 3 );
1486 FGControls::set_nitrous_injection( int engine, bool val )
1488 if ( engine == ALL_ENGINES ) {
1489 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1490 nitrous_injection[i] = val;
1493 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1494 nitrous_injection[engine] = val;
1501 FGControls::set_cowl_flaps_norm( int engine, double pos )
1503 if ( engine == ALL_ENGINES ) {
1504 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1505 cowl_flaps_norm[i] = pos;
1506 CLAMP( &cowl_flaps_norm[i], 0.0, 1.0 );
1509 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1510 cowl_flaps_norm[engine] = pos;
1511 CLAMP( &cowl_flaps_norm[engine], 0.0, 1.0 );
1517 FGControls::move_cowl_flaps_norm( int engine, double amt )
1519 if ( engine == ALL_ENGINES ) {
1520 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1521 cowl_flaps_norm[i] += amt;
1522 CLAMP( &cowl_flaps_norm[i], 0.0, 1.0 );
1525 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1526 cowl_flaps_norm[engine] += amt;
1527 CLAMP( &cowl_flaps_norm[engine], 0.0, 1.0 );
1533 FGControls::set_feather( int engine, bool val )
1535 if ( engine == ALL_ENGINES ) {
1536 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1540 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1541 feather[engine] = val;
1547 FGControls::set_ignition( int engine, int pos )
1549 if ( engine == ALL_ENGINES ) {
1550 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1552 CLAMP( &ignition[i], 0, 3 );
1555 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1556 ignition[engine] = pos;
1557 CLAMP( &ignition[engine], 0, 3 );
1563 FGControls::set_augmentation( int engine, bool val )
1565 if ( engine == ALL_ENGINES ) {
1566 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1567 augmentation[i] = val;
1570 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1571 augmentation[engine] = val;
1577 FGControls::set_reverser( int engine, bool val )
1579 if ( engine == ALL_ENGINES ) {
1580 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1584 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1585 reverser[engine] = val;
1591 FGControls::set_water_injection( int engine, bool val )
1593 if ( engine == ALL_ENGINES ) {
1594 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1595 water_injection[i] = val;
1598 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1599 water_injection[engine] = val;
1605 FGControls::set_condition( int engine, double val )
1607 if ( engine == ALL_ENGINES ) {
1608 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1610 CLAMP( &condition[i], 0.0, 1.0 );
1613 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1614 condition[engine] = val;
1615 CLAMP( &condition[engine], 0.0, 1.0 );
1621 FGControls::set_dump_valve( bool val )
1628 FGControls::set_fuel_selector( int tank, bool pos )
1630 if ( tank == ALL_TANKS ) {
1631 for ( int i = 0; i < MAX_TANKS; i++ ) {
1632 fuel_selector[i] = pos;
1635 if ( (tank >= 0) && (tank < MAX_TANKS) ) {
1636 fuel_selector[tank] = pos;
1642 FGControls::set_to_engine( int tank, int engine )
1644 if ( tank == ALL_TANKS ) {
1645 for ( int i = 0; i < MAX_TANKS; i++ ) {
1646 to_engine[i] = engine;
1649 if ( (tank >= 0) && (tank < MAX_TANKS) ) {
1650 to_engine[tank] = engine;
1656 FGControls::set_to_tank( int tank, int dest_tank )
1658 if ( tank == ALL_TANKS ) {
1659 for ( int i = 0; i < MAX_TANKS; i++ ) {
1660 to_tank[i] = dest_tank;
1663 if ( (tank >= 0) && (tank < MAX_TANKS) ) {
1664 to_tank[tank] = dest_tank;
1670 FGControls::set_boost_pump( int index, bool val )
1672 if ( index == -1 ) {
1673 for ( int i = 0; i < (MAX_TANKS * MAX_BOOSTPUMPS); i++ ) {
1674 boost_pump[i] = val;
1677 if ( (index >= 0) && (index < (MAX_TANKS * MAX_BOOSTPUMPS)) ) {
1678 boost_pump[index] = val;
1685 FGControls::set_brake_left( double pos )
1688 CLAMP(&brake_left, 0.0, 1.0);
1692 FGControls::move_brake_left( double amt )
1695 CLAMP( &brake_left, 0.0, 1.0 );
1699 FGControls::set_brake_right( double pos )
1702 CLAMP(&brake_right, 0.0, 1.0);
1706 FGControls::move_brake_right( double amt )
1709 CLAMP( &brake_right, 0.0, 1.0 );
1713 FGControls::set_copilot_brake_left( double pos )
1715 copilot_brake_left = pos;
1716 CLAMP(&brake_left, 0.0, 1.0);
1720 FGControls::set_copilot_brake_right( double pos )
1722 copilot_brake_right = pos;
1723 CLAMP(&brake_right, 0.0, 1.0);
1727 FGControls::set_brake_parking( double pos )
1729 brake_parking = pos;
1730 CLAMP(&brake_parking, 0.0, 1.0);
1734 FGControls::set_steering( double angle )
1737 CLAMP(&steering, -80.0, 80.0);
1741 FGControls::set_nose_wheel_steering( bool nws )
1743 nose_wheel_steering = nws;
1747 FGControls::move_steering( double angle )
1750 CLAMP(&steering, -80.0, 80.0);
1754 FGControls::set_gear_down( bool gear )
1760 FGControls::set_antiskid( bool state )
1766 FGControls::set_tailhook( bool state )
1772 FGControls::set_launchbar( bool state )
1778 FGControls::set_catapult_launch_cmd( bool state )
1780 catapult_launch_cmd = state;
1784 FGControls::set_tailwheel_lock( bool state )
1786 tailwheel_lock = state;
1791 FGControls::set_alternate_extension( int wheel, bool val )
1793 if ( wheel == ALL_WHEELS ) {
1794 for ( int i = 0; i < MAX_WHEELS; i++ ) {
1795 alternate_extension[i] = val;
1798 if ( (wheel >= 0) && (wheel < MAX_WHEELS) ) {
1799 alternate_extension[wheel] = val;
1805 FGControls::set_wing_heat( bool state )
1811 FGControls::set_pitot_heat( bool state )
1817 FGControls::set_wiper( int state )
1823 FGControls::set_window_heat( bool state )
1825 window_heat = state;
1829 FGControls::set_carb_heat( int engine, bool val )
1831 if ( engine == ALL_ENGINES ) {
1832 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1836 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1837 carb_heat[engine] = val;
1843 FGControls::set_inlet_heat( int engine, bool val )
1845 if ( engine == ALL_ENGINES ) {
1846 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1847 inlet_heat[i] = val;
1850 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1851 inlet_heat[engine] = val;
1857 FGControls::set_engine_pump( int system, bool val )
1859 if ( system == ALL_HYD_SYSTEMS ) {
1860 for ( int i = 0; i < MAX_HYD_SYSTEMS; i++ ) {
1861 engine_pump[i] = val;
1864 if ( (system >= 0) && (system < MAX_HYD_SYSTEMS) ) {
1865 engine_pump[system] = val;
1871 FGControls::set_electric_pump( int system, bool val )
1873 if ( system == ALL_HYD_SYSTEMS ) {
1874 for ( int i = 0; i < MAX_HYD_SYSTEMS; i++ ) {
1875 electric_pump[i] = val;
1878 if ( (system >= 0) && (system < MAX_HYD_SYSTEMS) ) {
1879 electric_pump[system] = val;
1885 FGControls::set_battery_switch( bool state )
1887 battery_switch = state;
1891 FGControls::set_external_power( bool state )
1893 external_power = state;
1897 FGControls::set_APU_generator( bool state )
1899 APU_generator = state;
1903 FGControls::set_generator_breaker( int engine, bool val )
1905 if ( engine == ALL_ENGINES ) {
1906 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1907 generator_breaker[i] = val;
1910 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1911 generator_breaker[engine] = val;
1917 FGControls::set_bus_tie( int engine, bool val )
1919 if ( engine == ALL_ENGINES ) {
1920 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1924 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1925 bus_tie[engine] = val;
1931 FGControls::set_APU_bleed( bool state )
1937 FGControls::set_engine_bleed( int engine, bool val )
1939 if ( engine == ALL_ENGINES ) {
1940 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1941 engine_bleed[i] = val;
1944 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1945 engine_bleed[engine] = val;
1951 FGControls::set_mode( int new_mode )
1957 FGControls::set_outflow_valve( double pos )
1959 outflow_valve = pos;
1960 CLAMP( &outflow_valve, 0.0, 1.0 );
1964 FGControls::move_outflow_valve( double amt )
1966 outflow_valve += amt;
1967 CLAMP( &outflow_valve, 0.0, 1.0 );
1971 FGControls::set_dump( bool state )
1977 FGControls::set_pack_on( int pack, bool val )
1979 if ( pack == ALL_PACKS ) {
1980 for ( int i = 0; i < MAX_PACKS; i++ ) {
1984 if ( (pack >= 0) && (pack < MAX_PACKS) ) {
1985 pack_on[pack] = val;
1991 FGControls::set_landing_lights( bool state )
1993 landing_lights = state;
1997 FGControls::set_turn_off_lights( bool state )
1999 turn_off_lights = state;
2003 FGControls::set_taxi_light( bool state )
2009 FGControls::set_logo_lights( bool state )
2011 logo_lights = state;
2015 FGControls::set_nav_lights( bool state )
2021 FGControls::set_beacon( bool state )
2027 FGControls::set_strobe( bool state )
2033 FGControls::set_panel_norm( double intensity )
2035 panel_norm = intensity;
2036 CLAMP( &panel_norm, 0.0, 1.0 );
2040 FGControls::move_panel_norm( double amt )
2043 CLAMP( &panel_norm, 0.0, 1.0 );
2047 FGControls::set_instruments_norm( double intensity )
2049 instruments_norm = intensity;
2050 CLAMP( &instruments_norm, 0.0, 1.0 );
2054 FGControls::move_instruments_norm( double amt )
2056 instruments_norm += amt;
2057 CLAMP( &instruments_norm, 0.0, 1.0 );
2061 FGControls::set_dome_norm( double intensity )
2063 dome_norm = intensity;
2064 CLAMP( &dome_norm, 0.0, 1.0 );
2068 FGControls::move_dome_norm( double amt )
2071 CLAMP( &dome_norm, 0.0, 1.0 );
2075 FGControls::set_master_arm( bool val )
2081 FGControls::set_station_select( int station )
2083 station_select = station;
2084 CLAMP( &station_select, 0, MAX_STATIONS );
2088 FGControls::set_release_ALL( bool val )
2094 FGControls::set_stick_size( int station, int size )
2096 if ( station == ALL_STATIONS ) {
2097 for ( int i = 0; i < MAX_STATIONS; i++ ) {
2098 stick_size[i] = size;
2099 CLAMP( &stick_size[i], 1, 20 );
2102 if ( (station >= 0) && (station < MAX_STATIONS) ) {
2103 stick_size[station] = size;
2104 CLAMP( &stick_size[station], 1, 20 );
2110 FGControls::set_release_stick( int station, bool val )
2112 if ( station == ALL_STATIONS ) {
2113 for ( int i = 0; i < MAX_STATIONS; i++ ) {
2114 release_stick[i] = val;
2117 if ( (station >= 0) && (station < MAX_STATIONS) ) {
2118 release_stick[station] = val;
2124 FGControls::set_release_all( int station, bool val )
2126 if ( station == ALL_STATIONS ) {
2127 for ( int i = 0; i < MAX_STATIONS; i++ ) {
2128 release_all[i] = val;
2131 if ( (station >= 0) && (station < MAX_STATIONS) ) {
2132 release_all[station] = val;
2138 FGControls::set_jettison_all( int station, bool val )
2140 if ( station == ALL_STATIONS ) {
2141 for ( int i = 0; i < MAX_STATIONS; i++ ) {
2142 jettison_all[i] = val;
2145 if ( (station >= 0) && (station < MAX_STATIONS) ) {
2146 jettison_all[station] = val;
2152 FGControls::set_vertical_adjust( double pos )
2154 vertical_adjust = pos;
2155 CLAMP( &vertical_adjust, -1.0, 1.0 );
2159 FGControls::move_vertical_adjust( double amt )
2161 vertical_adjust += amt;
2162 CLAMP( &vertical_adjust, -1.0, 1.0 );
2166 FGControls::set_fore_aft_adjust( double pos )
2168 fore_aft_adjust = pos;
2169 CLAMP( &fore_aft_adjust, -1.0, 1.0 );
2173 FGControls::move_fore_aft_adjust( double amt )
2175 fore_aft_adjust += amt;
2176 CLAMP( &fore_aft_adjust, -1.0, 1.0 );
2180 FGControls::set_ejection_seat( int which_seat, bool val )
2182 if ( which_seat == ALL_EJECTION_SEATS ) {
2183 for ( int i = 0; i < MAX_EJECTION_SEATS; i++ ) {
2187 if ( (which_seat >= 0) && (which_seat <= MAX_EJECTION_SEATS) ) {
2188 if ( eseat_status[which_seat] == SEAT_SAFED ||
2189 eseat_status[which_seat] == SEAT_FAIL )
2191 // we can never eject if SEAT_SAFED or SEAT_FAIL
2195 eject[which_seat] = val;
2201 FGControls::set_eseat_status( int which_seat, int val )
2203 if ( which_seat == ALL_EJECTION_SEATS ) {
2204 for ( int i = 0; i < MAX_EJECTION_SEATS; i++ ) {
2205 eseat_status[i] = val;
2208 if ( (which_seat >=0) && (which_seat <= MAX_EJECTION_SEATS) ) {
2209 eseat_status[which_seat] = val;
2215 FGControls::set_cmd_selector_valve( int val )
2217 cmd_selector_valve = val;
2222 FGControls::set_off_start_run( int pos )
2224 off_start_run = pos;
2225 CLAMP( &off_start_run, 0, 3 );
2229 FGControls::set_APU_fire_switch( bool val )
2231 APU_fire_switch = val;
2235 FGControls::set_autothrottle_arm( bool val )
2237 autothrottle_arm = val;
2241 FGControls::set_autothrottle_engage( bool val )
2243 autothrottle_engage = val;
2247 FGControls::set_heading_select( double heading )
2249 heading_select = heading;
2250 CLAMP( &heading_select, 0.0, 360.0 );
2254 FGControls::move_heading_select( double amt )
2256 heading_select += amt;
2257 CLAMP( &heading_select, 0.0, 360.0 );
2261 FGControls::set_altitude_select( double altitude )
2263 altitude_select = altitude;
2264 CLAMP( &altitude_select, -1000.0, 100000.0 );
2268 FGControls::move_altitude_select( double amt )
2270 altitude_select += amt;
2271 CLAMP( &altitude_select, -1000.0, 100000.0 );
2275 FGControls::set_bank_angle_select( double angle )
2277 bank_angle_select = angle;
2278 CLAMP( &bank_angle_select, 10.0, 30.0 );
2282 FGControls::move_bank_angle_select( double amt )
2284 bank_angle_select += amt;
2285 CLAMP( &bank_angle_select, 10.0, 30.0 );
2289 FGControls::set_vertical_speed_select( double speed )
2291 vertical_speed_select = speed;
2292 CLAMP( &vertical_speed_select, -3000.0, 4000.0 );
2296 FGControls::move_vertical_speed_select( double amt )
2298 vertical_speed_select += amt;
2299 CLAMP( &vertical_speed_select, -3000.0, 4000.0 );
2303 FGControls::set_speed_select( double speed )
2305 speed_select = speed;
2306 CLAMP( &speed_select, 60.0, 400.0 );
2310 FGControls::move_speed_select( double amt )
2312 speed_select += amt;
2313 CLAMP( &speed_select, 60.0, 400.0 );
2317 FGControls::set_mach_select( double mach )
2320 CLAMP( &mach_select, 0.4, 4.0 );
2324 FGControls::move_mach_select( double amt )
2327 CLAMP( &mach_select, 0.4, 4.0 );
2331 FGControls::set_vertical_mode( int mode )
2333 vertical_mode = mode;
2334 CLAMP( &vertical_mode, 0, 4 );
2338 FGControls::set_lateral_mode( int mode )
2340 lateral_mode = mode;
2341 CLAMP( &lateral_mode, 0, 4 );
2345 FGControls::set_autopilot_engage( int ap, bool val )
2347 if ( ap == ALL_AUTOPILOTS ) {
2348 for ( int i = 0; i < MAX_AUTOPILOTS; i++ ) {
2349 autopilot_engage[i] = val;
2352 if ( (ap >= 0) && (ap < MAX_AUTOPILOTS) ) {
2353 autopilot_engage[ap] = val;