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 for( int pump = 0; pump < MAX_TANKS * MAX_BOOSTPUMPS; pump++ ) {
233 boost_pump[pump] = false;
236 brake_left = brake_right
237 = copilot_brake_left = copilot_brake_right
238 = brake_parking = 0.0;
239 for ( int wheel = 0; wheel < MAX_WHEELS; wheel++ ) {
240 alternate_extension[wheel] = false;
243 auto_coordination = fgGetNode("/sim/auto-coordination", true);
253 fgTie("/controls/flight/aileron", this,
254 &FGControls::get_aileron, &FGControls::set_aileron);
255 fgSetArchivable("/controls/flight/aileron");
257 fgTie("/controls/flight/aileron-trim", this,
258 &FGControls::get_aileron_trim, &FGControls::set_aileron_trim);
259 fgSetArchivable("/controls/flight/aileron-trim");
261 fgTie("/controls/flight/elevator", this,
262 &FGControls::get_elevator, &FGControls::set_elevator);
263 fgSetArchivable("/controls/flight/elevator");
265 fgTie("/controls/flight/elevator-trim", this,
266 &FGControls::get_elevator_trim, &FGControls::set_elevator_trim);
267 fgSetArchivable("/controls/flight/elevator-trim");
269 fgTie("/controls/flight/rudder", this,
270 &FGControls::get_rudder, &FGControls::set_rudder);
271 fgSetArchivable("/controls/flight/rudder");
273 fgTie("/controls/flight/rudder-trim", this,
274 &FGControls::get_rudder_trim, &FGControls::set_rudder_trim);
275 fgSetArchivable("/controls/flight/rudder-trim");
277 fgTie("/controls/flight/flaps", this,
278 &FGControls::get_flaps, &FGControls::set_flaps);
279 fgSetArchivable("/controls/flight/flaps");
281 fgTie("/controls/flight/slats", this,
282 &FGControls::get_slats, &FGControls::set_slats);
283 fgSetArchivable("/controls/flight/slats");
285 fgTie("/controls/flight/BLC", this,
286 &FGControls::get_BLC, &FGControls::set_BLC);
287 fgSetArchivable("/controls/flight/BLC");
289 fgTie("/controls/flight/spoilers", this,
290 &FGControls::get_spoilers, &FGControls::set_spoilers);
291 fgSetArchivable("/controls/flight/spoilers");
293 fgTie("/controls/flight/speedbrake", this,
294 &FGControls::get_speedbrake, &FGControls::set_speedbrake);
295 fgSetArchivable("/controls/flight/speedbrake");
297 fgTie("/controls/flight/wing-sweep", this,
298 &FGControls::get_wing_sweep, &FGControls::set_wing_sweep);
299 fgSetArchivable("/controls/flight/wing-sweep");
301 fgTie("/controls/flight/wing-fold", this,
302 &FGControls::get_wing_fold, &FGControls::set_wing_fold);
303 fgSetArchivable("/controls/flight/wing-fold");
305 fgTie("/controls/flight/drag-chute", this,
306 &FGControls::get_drag_chute, &FGControls::set_drag_chute);
307 fgSetArchivable("/controls/flight/drag-chute");
310 fgTie("/controls/engines/throttle_idle", this,
311 &FGControls::get_throttle_idle, &FGControls::set_throttle_idle);
312 fgSetArchivable("/controls/engines/throttle_idle");
314 for (index = 0; index < MAX_ENGINES; index++) {
315 char name[MAX_NAME_LEN];
316 snprintf(name, MAX_NAME_LEN,
317 "/controls/engines/engine[%d]/throttle", index);
318 fgTie(name, this, index,
319 &FGControls::get_throttle, &FGControls::set_throttle);
320 fgSetArchivable(name);
322 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/starter", index);
323 fgTie(name, this, index,
324 &FGControls::get_starter, &FGControls::set_starter);
325 fgSetArchivable(name);
327 snprintf(name, MAX_NAME_LEN,
328 "/controls/engines/engine[%d]/fuel-pump", index);
329 fgTie(name, this, index,
330 &FGControls::get_fuel_pump, &FGControls::set_fuel_pump);
331 fgSetArchivable(name);
333 snprintf(name, MAX_NAME_LEN,
334 "/controls/engines/engine[%d]/fire-switch", index);
335 fgTie(name, this, index,
336 &FGControls::get_fire_switch, &FGControls::set_fire_switch);
337 fgSetArchivable(name);
339 snprintf(name, MAX_NAME_LEN,
340 "/controls/engines/engine[%d]/fire-bottle-discharge", index);
341 fgTie(name, this, index,
342 &FGControls::get_fire_bottle_discharge,
343 &FGControls::set_fire_bottle_discharge);
344 fgSetArchivable(name);
346 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/cutoff", index);
347 fgTie(name, this, index,
348 &FGControls::get_cutoff, &FGControls::set_cutoff);
349 fgSetArchivable(name);
351 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/mixture", index);
352 fgTie(name, this, index,
353 &FGControls::get_mixture, &FGControls::set_mixture);
354 fgSetArchivable(name);
356 snprintf(name, MAX_NAME_LEN,
357 "/controls/engines/engine[%d]/propeller-pitch", index);
358 fgTie(name, this, index,
359 &FGControls::get_prop_advance,
360 &FGControls::set_prop_advance);
361 fgSetArchivable(name);
363 snprintf(name, MAX_NAME_LEN,
364 "/controls/engines/engine[%d]/magnetos", index);
365 fgTie(name, this, index,
366 &FGControls::get_magnetos, &FGControls::set_magnetos);
367 fgSetArchivable(name);
369 snprintf(name, MAX_NAME_LEN,
370 "/controls/engines/engine[%d]/feed_tank", index);
371 fgTie(name, this, index,
372 &FGControls::get_feed_tank, &FGControls::set_feed_tank);
373 fgSetArchivable(name);
376 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/WEP", index);
377 fgTie(name, this, index,
378 &FGControls::get_nitrous_injection,
379 &FGControls::set_nitrous_injection);
380 fgSetArchivable(name);
382 snprintf(name, MAX_NAME_LEN,
383 "/controls/engines/engine[%d]/cowl-flaps-norm", index);
384 fgTie(name, this, index,
385 &FGControls::get_cowl_flaps_norm,
386 &FGControls::set_cowl_flaps_norm);
387 fgSetArchivable(name);
389 snprintf(name, MAX_NAME_LEN,
390 "/controls/engines/engine[%d]/propeller-feather", index);
391 fgTie(name, this, index,
392 &FGControls::get_feather, &FGControls::set_feather);
393 fgSetArchivable(name);
395 snprintf(name, MAX_NAME_LEN,
396 "/controls/engines/engine[%d]/ignition", index);
397 fgTie(name, this, index,
398 &FGControls::get_ignition, &FGControls::set_ignition);
399 fgSetArchivable(name);
401 snprintf(name, MAX_NAME_LEN,
402 "/controls/engines/engine[%d]/augmentation", index);
403 fgTie(name, this, index,
404 &FGControls::get_augmentation,
405 &FGControls::set_augmentation);
406 fgSetArchivable(name);
408 snprintf(name, MAX_NAME_LEN,
409 "/controls/engines/engine[%d]/reverser", index);
410 fgTie(name, this, index,
411 &FGControls::get_reverser, &FGControls::set_reverser);
412 fgSetArchivable(name);
414 snprintf(name, MAX_NAME_LEN,
415 "/controls/engines/engine[%d]/water-injection", index);
416 fgTie(name, this, index,
417 &FGControls::get_water_injection,
418 &FGControls::set_water_injection);
419 fgSetArchivable(name);
421 snprintf(name, MAX_NAME_LEN,
422 "/controls/engines/engine[%d]/condition", index);
423 fgTie(name, this, index,
424 &FGControls::get_condition, &FGControls::set_condition);
425 fgSetArchivable(name);
429 fgTie("/controls/fuel/dump-valve", this,
430 &FGControls::get_dump_valve, &FGControls::set_dump_valve);
431 fgSetArchivable("/controls/fuel/dump-valve");
433 for (index = 0; index < MAX_TANKS; index++) {
434 char name[MAX_NAME_LEN];
435 snprintf(name, MAX_NAME_LEN,
436 "/controls/fuel/tank[%d]/fuel_selector", index);
437 fgTie(name, this, index,
438 &FGControls::get_fuel_selector,
439 &FGControls::set_fuel_selector);
440 fgSetArchivable(name);
442 snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_engine", index);
443 fgTie(name, this, index,
444 &FGControls::get_to_engine, &FGControls::set_to_engine);
445 fgSetArchivable(name);
447 snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_tank", index);
448 fgTie(name, this, index,
449 &FGControls::get_to_tank, &FGControls::set_to_tank);
450 fgSetArchivable(name);
452 for (i = 0; i < MAX_BOOSTPUMPS; i++) {
453 char name[MAX_NAME_LEN];
454 snprintf(name, MAX_NAME_LEN,
455 "/controls/fuel/tank[%d]/boost-pump[%d]", index, i);
456 fgTie(name, this, index * 2 + i,
457 &FGControls::get_boost_pump,
458 &FGControls::set_boost_pump);
459 fgSetArchivable(name);
464 fgTie("/controls/gear/brake-left", this,
465 &FGControls::get_brake_left,
466 &FGControls::set_brake_left);
467 fgSetArchivable("/controls/gear/brake-left");
469 fgTie("/controls/gear/brake-right", this,
470 &FGControls::get_brake_right,
471 &FGControls::set_brake_right);
472 fgSetArchivable("/controls/gear/brake-right");
474 fgTie("/controls/gear/copilot-brake-left", this,
475 &FGControls::get_copilot_brake_left,
476 &FGControls::set_copilot_brake_left);
477 fgSetArchivable("/controls/gear/copilot-brake-left");
479 fgTie("/controls/gear/copilot-brake-right", this,
480 &FGControls::get_copilot_brake_right,
481 &FGControls::set_copilot_brake_right);
482 fgSetArchivable("/controls/gear/copilot-brake-right");
484 fgTie("/controls/gear/brake-parking", this,
485 &FGControls::get_brake_parking,
486 &FGControls::set_brake_parking);
487 fgSetArchivable("/controls/gear/brake-parking");
489 fgTie("/controls/gear/steering", this,
490 &FGControls::get_steering, &FGControls::set_steering);
491 fgSetArchivable("/controls/gear/steering");
493 fgTie("/controls/gear/nose-wheel-steering", this,
494 &FGControls::get_nose_wheel_steering,
495 &FGControls::set_nose_wheel_steering);
496 fgSetArchivable("/controls/gear/nose-wheel-steering");
498 fgTie("/controls/gear/gear-down", this,
499 &FGControls::get_gear_down, &FGControls::set_gear_down);
500 fgSetArchivable("/controls/gear/gear-down");
502 fgTie("/controls/gear/antiskid", this,
503 &FGControls::get_antiskid, &FGControls::set_antiskid);
504 fgSetArchivable("/controls/gear/antiskid");
506 fgTie("/controls/gear/tailhook", this,
507 &FGControls::get_tailhook, &FGControls::set_tailhook);
508 fgSetArchivable("/controls/gear/tailhook");
510 fgTie("/controls/gear/launchbar", this,
511 &FGControls::get_launchbar, &FGControls::set_launchbar);
512 fgSetArchivable("/controls/gear/launchbar");
514 fgTie("/controls/gear/catapult-launch-cmd", this,
515 &FGControls::get_catapult_launch_cmd, &FGControls::set_catapult_launch_cmd);
516 fgSetArchivable("/controls/gear/catapult-launch-cmd");
518 fgTie("/controls/gear/tailwheel-lock", this,
519 &FGControls::get_tailwheel_lock,
520 &FGControls::set_tailwheel_lock);
521 fgSetArchivable("/controls/gear/tailwheel-lock");
523 for (index = 0; index < MAX_WHEELS; index++) {
524 char name[MAX_NAME_LEN];
525 snprintf(name, MAX_NAME_LEN,
526 "/controls/gear/wheel[%d]/alternate-extension", index);
527 fgTie(name, this, index,
528 &FGControls::get_alternate_extension,
529 &FGControls::set_alternate_extension);
530 fgSetArchivable(name);
534 fgTie("/controls/anti-ice/wing-heat", this,
535 &FGControls::get_wing_heat, &FGControls::set_wing_heat);
536 fgSetArchivable("/controls/anti-ice/wing-heat");
538 fgTie("/controls/anti-ice/pitot-heat", this,
539 &FGControls::get_pitot_heat, &FGControls::set_pitot_heat);
540 fgSetArchivable("/controls/anti-ice/pitot-heat");
542 fgTie("/controls/anti-ice/wiper", this,
543 &FGControls::get_wiper, &FGControls::set_wiper);
544 fgSetArchivable("/controls/anti-ice/wiper");
546 fgTie("/controls/anti-ice/window-heat", this,
547 &FGControls::get_window_heat, &FGControls::set_window_heat);
548 fgSetArchivable("/controls/anti-ice/window-heat");
550 for (index = 0; index < MAX_ENGINES; index++) {
551 char name[MAX_NAME_LEN];
552 snprintf(name, MAX_NAME_LEN,
553 "/controls/anti-ice/engine[%d]/carb-heat", index);
554 fgTie(name, this, index,
555 &FGControls::get_carb_heat, &FGControls::set_carb_heat);
556 fgSetArchivable(name);
558 snprintf(name, MAX_NAME_LEN,
559 "/controls/anti-ice/engine[%d]/inlet-heat", index);
560 fgTie(name, this, index,
561 &FGControls::get_inlet_heat, &FGControls::set_inlet_heat);
562 fgSetArchivable(name);
566 for (index = 0; index < MAX_HYD_SYSTEMS; index++) {
567 char name[MAX_NAME_LEN];
568 snprintf(name, MAX_NAME_LEN,
569 "/controls/hydraulic/system[%d]/engine-pump", index);
570 fgTie(name, this, index,
571 &FGControls::get_engine_pump, &FGControls::set_engine_pump);
572 fgSetArchivable(name);
574 snprintf(name, MAX_NAME_LEN,
575 "/controls/hydraulic/system[%d]/electric-pump", index);
576 fgTie(name, this, index,
577 &FGControls::get_electric_pump,
578 &FGControls::set_electric_pump);
579 fgSetArchivable(name);
583 fgTie("/controls/electric/battery-switch", this,
584 &FGControls::get_battery_switch,
585 &FGControls::set_battery_switch);
586 fgSetArchivable("/controls/electric/battery-switch");
588 fgTie("/controls/electric/external-power", this,
589 &FGControls::get_external_power,
590 &FGControls::set_external_power);
591 fgSetArchivable("/controls/electric/external-power");
593 fgTie("/controls/electric/APU-generator", this,
594 &FGControls::get_APU_generator,
595 &FGControls::set_APU_generator);
596 fgSetArchivable("/controls/electric/APU-generator");
598 for (index = 0; index < MAX_ENGINES; index++) {
599 char name[MAX_NAME_LEN];
600 snprintf(name, MAX_NAME_LEN,
601 "/controls/electric/engine[%d]/generator", index);
602 fgTie(name, this, index,
603 &FGControls::get_generator_breaker,
604 &FGControls::set_generator_breaker);
605 fgSetArchivable(name);
607 snprintf(name, MAX_NAME_LEN,
608 "/controls/electric/engine[%d]/bus-tie", index);
609 fgTie(name, this, index,
610 &FGControls::get_bus_tie,
611 &FGControls::set_bus_tie);
612 fgSetArchivable(name);
616 fgTie("/controls/pneumatic/APU-bleed", this,
617 &FGControls::get_APU_bleed,
618 &FGControls::set_APU_bleed);
619 fgSetArchivable("/controls/pneumatic/APU-bleed");
621 for (index = 0; index < MAX_ENGINES; index++) {
622 char name[MAX_NAME_LEN];
623 snprintf(name, MAX_NAME_LEN,
624 "/controls/pneumatic/engine[%d]/bleed", index);
625 fgTie(name, this, index,
626 &FGControls::get_engine_bleed,
627 &FGControls::set_engine_bleed);
628 fgSetArchivable(name);
632 fgTie("/controls/pressurization/mode", this,
633 &FGControls::get_mode, &FGControls::set_mode);
634 fgSetArchivable("/controls/pressurization/mode");
636 fgTie("/controls/pressurization/dump", this,
637 &FGControls::get_dump, &FGControls::set_dump);
638 fgSetArchivable("/controls/pressurization/dump");
640 fgTie("/controls/pressurization/outflow-valve", this,
641 &FGControls::get_outflow_valve,
642 &FGControls::set_outflow_valve);
643 fgSetArchivable("/controls/pressurization/outflow-valve");
645 for (index = 0; index < MAX_PACKS; index++) {
646 char name[MAX_NAME_LEN];
647 snprintf(name, MAX_NAME_LEN,
648 "/controls/pressurization/pack[%d]/pack-on", index);
649 fgTie(name, this, index,
650 &FGControls::get_pack_on, &FGControls::set_pack_on);
651 fgSetArchivable(name);
655 fgTie("/controls/lighting/landing-lights", this,
656 &FGControls::get_landing_lights,
657 &FGControls::set_landing_lights);
658 fgSetArchivable("/controls/lighting/landing-lights");
660 fgTie("/controls/lighting/turn-off-lights", this,
661 &FGControls::get_turn_off_lights,
662 &FGControls::set_turn_off_lights);
663 fgSetArchivable("/controls/lighting/turn-off-lights");
665 fgTie("/controls/lighting/taxi-light", this,
666 &FGControls::get_taxi_light, &FGControls::set_taxi_light);
667 fgSetArchivable("/controls/lighting/taxi-light");
669 fgTie("/controls/lighting/logo-lights", this,
670 &FGControls::get_logo_lights, &FGControls::set_logo_lights);
671 fgSetArchivable("/controls/lighting/logo-lights");
673 fgTie("/controls/lighting/nav-lights", this,
674 &FGControls::get_nav_lights, &FGControls::set_nav_lights);
675 fgSetArchivable("/controls/lighting/nav-lights");
677 fgTie("/controls/lighting/beacon", this,
678 &FGControls::get_beacon, &FGControls::set_beacon);
679 fgSetArchivable("/controls/lighting/beacon");
681 fgTie("/controls/lighting/strobe", this,
682 &FGControls::get_strobe, &FGControls::set_strobe);
683 fgSetArchivable("/controls/lighting/strobe");
685 fgTie("/controls/lighting/panel-norm", this,
686 &FGControls::get_panel_norm, &FGControls::set_panel_norm);
687 fgSetArchivable("/controls/lighting/panel-norm");
689 fgTie("/controls/lighting/instruments-norm", this,
690 &FGControls::get_instruments_norm,
691 &FGControls::set_instruments_norm);
692 fgSetArchivable("/controls/lighting/instruments-norm");
694 fgTie("/controls/lighting/dome-norm", this,
695 &FGControls::get_dome_norm, &FGControls::set_dome_norm);
696 fgSetArchivable("/controls/lighting/dome-norm");
699 fgTie("/controls/armament/master-arm", this,
700 &FGControls::get_master_arm, &FGControls::set_master_arm);
701 fgSetArchivable("/controls/armament/master-arm");
703 fgTie("/controls/armament/station-select", this,
704 &FGControls::get_station_select,
705 &FGControls::set_station_select);
706 fgSetArchivable("/controls/armament/station-select");
708 fgTie("/controls/armament/release-all", this,
709 &FGControls::get_release_ALL,
710 &FGControls::set_release_ALL);
711 fgSetArchivable("/controls/armament/release-all");
713 for (index = 0; index < MAX_STATIONS; index++) {
714 char name[MAX_NAME_LEN];
715 snprintf(name, MAX_NAME_LEN,
716 "/controls/armament/station[%d]/stick-size", index);
717 fgTie(name, this, index,
718 &FGControls::get_stick_size, &FGControls::set_stick_size);
719 fgSetArchivable(name);
721 snprintf(name, MAX_NAME_LEN,
722 "/controls/armament/station[%d]/release-stick", index);
723 fgTie(name, this, index,
724 &FGControls::get_release_stick, &FGControls::set_release_stick);
725 fgSetArchivable(name);
727 snprintf(name, MAX_NAME_LEN,
728 "/controls/armament/station[%d]/release-all", index);
729 fgTie(name, this, index,
730 &FGControls::get_release_all, &FGControls::set_release_all);
731 fgSetArchivable(name);
733 snprintf(name, MAX_NAME_LEN,
734 "/controls/armament/station[%d]/jettison-all", index);
735 fgTie(name, this, index,
736 &FGControls::get_jettison_all, &FGControls::set_jettison_all);
737 fgSetArchivable(name);
741 fgTie("/controls/seat/vertical-adjust", this,
742 &FGControls::get_vertical_adjust,
743 &FGControls::set_vertical_adjust);
744 fgSetArchivable("/controls/seat/vertical-adjust");
746 fgTie("/controls/seat/fore-aft-adjust", this,
747 &FGControls::get_fore_aft_adjust,
748 &FGControls::set_fore_aft_adjust);
749 fgSetArchivable("/controls/seat/fore-aft-adjust");
751 for (index = 0; index < MAX_EJECTION_SEATS; index++) {
752 char name[MAX_NAME_LEN];
753 snprintf(name, MAX_NAME_LEN,
754 "/controls/seat/eject[%d]/initiate", index);
755 fgTie(name, this, index,
756 &FGControls::get_ejection_seat,
757 &FGControls::set_ejection_seat);
758 fgSetArchivable(name);
760 snprintf(name, MAX_NAME_LEN,
761 "/controls/seat/eject[%d]/status", index);
763 fgTie(name, this, index,
764 &FGControls::get_eseat_status,
765 &FGControls::set_eseat_status);
767 fgSetArchivable(name);
770 fgTie("/controls/seat/cmd_selector_valve", this,
771 &FGControls::get_cmd_selector_valve,
772 &FGControls::set_cmd_selector_valve);
773 fgSetArchivable("/controls/seat/eject/cmd_selector_valve");
777 fgTie("/controls/APU/off-start-run", this,
778 &FGControls::get_off_start_run,
779 &FGControls::set_off_start_run);
780 fgSetArchivable("/controls/APU/off-start-run");
782 fgTie("/controls/APU/fire-switch", this,
783 &FGControls::get_APU_fire_switch,
784 &FGControls::set_APU_fire_switch);
785 fgSetArchivable("/controls/APU/fire-switch");
788 for (index = 0; index < MAX_AUTOPILOTS; index++) {
789 char name[MAX_NAME_LEN];
790 snprintf(name, MAX_NAME_LEN,
791 "/controls/autoflight/autopilot[%d]/engage", index);
792 fgTie(name, this, index,
793 &FGControls::get_autopilot_engage,
794 &FGControls::set_autopilot_engage);
795 fgSetArchivable(name);
798 fgTie("/controls/autoflight/autothrottle-arm", this,
799 &FGControls::get_autothrottle_arm,
800 &FGControls::set_autothrottle_arm);
801 fgSetArchivable("/controls/autoflight/autothrottle-arm");
803 fgTie("/controls/autoflight/autothrottle-engage", this,
804 &FGControls::get_autothrottle_engage,
805 &FGControls::set_autothrottle_engage);
806 fgSetArchivable("/controls/autoflight/autothrottle-engage");
808 fgTie("/controls/autoflight/heading-select", this,
809 &FGControls::get_heading_select,
810 &FGControls::set_heading_select);
811 fgSetArchivable("/controls/autoflight/heading-select");
813 fgTie("/controls/autoflight/altitude-select", this,
814 &FGControls::get_altitude_select,
815 &FGControls::set_altitude_select);
816 fgSetArchivable("/controls/autoflight/altitude-select");
818 fgTie("/controls/autoflight/bank-angle-select", this,
819 &FGControls::get_bank_angle_select,
820 &FGControls::set_bank_angle_select);
821 fgSetArchivable("/controls/autoflight/bank-angle-select");
823 fgTie("/controls/autoflight/vertical-speed-select", this,
824 &FGControls::get_vertical_speed_select,
825 &FGControls::set_vertical_speed_select);
826 fgSetArchivable("/controls/autoflight/vertical-speed-select");
828 fgTie("/controls/autoflight/speed-select", this,
829 &FGControls::get_speed_select,
830 &FGControls::set_speed_select);
831 fgSetArchivable("/controls/autoflight/speed-select");
833 fgTie("/controls/autoflight/mach-select", this,
834 &FGControls::get_mach_select,
835 &FGControls::set_mach_select);
836 fgSetArchivable("/controls/autoflight/mach-select");
838 fgTie("/controls/autoflight/vertical-mode", this,
839 &FGControls::get_vertical_mode,
840 &FGControls::set_vertical_mode);
841 fgSetArchivable("/controls/autoflight/vertical-mode");
843 fgTie("/controls/autoflight/lateral-mode", this,
844 &FGControls::get_lateral_mode,
845 &FGControls::set_lateral_mode);
846 fgSetArchivable("/controls/autoflight/lateral-mode");
850 void FGControls::unbind ()
853 //Tie control properties.
854 fgUntie("/controls/flight/aileron");
855 fgUntie("/controls/flight/aileron-trim");
856 fgUntie("/controls/flight/elevator");
857 fgUntie("/controls/flight/elevator-trim");
858 fgUntie("/controls/flight/rudder");
859 fgUntie("/controls/flight/rudder-trim");
860 fgUntie("/controls/flight/flaps");
861 fgUntie("/controls/flight/slats");
862 fgUntie("/controls/flight/BLC");
863 fgUntie("/controls/flight/spoilers");
864 fgUntie("/controls/flight/speedbrake");
865 fgUntie("/controls/flight/wing-sweep");
866 fgUntie("/controls/flight/wing-fold");
867 fgUntie("/controls/flight/drag-chute");
868 for (index = 0; index < MAX_ENGINES; index++) {
869 char name[MAX_NAME_LEN];
870 snprintf(name, MAX_NAME_LEN,
871 "/controls/engines/engine[%d]/throttle", index);
873 snprintf(name, MAX_NAME_LEN,
874 "/controls/engines/engine[%d]/feed_tank", index);
876 snprintf(name, MAX_NAME_LEN,
877 "/controls/engines/engine[%d]/starter", index);
879 snprintf(name, MAX_NAME_LEN,
880 "/controls/engines/engine[%d]/fuel_pump", index);
882 snprintf(name, MAX_NAME_LEN,
883 "/controls/engines/engine[%d]/fire-switch", index);
885 snprintf(name, MAX_NAME_LEN,
886 "/controls/engines/engine[%d]/fire-bottle-discharge", index);
888 snprintf(name, MAX_NAME_LEN,
889 "/controls/engines/engine[%d]/throttle_idle", index);
891 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/cutoff", index);
893 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/mixture", index);
895 snprintf(name, MAX_NAME_LEN,
896 "/controls/engines/engine[%d]/propeller-pitch", index);
898 snprintf(name, MAX_NAME_LEN,
899 "/controls/engines/engine[%d]/magnetos", index);
901 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/WEP", index);
903 snprintf(name, MAX_NAME_LEN,
904 "/controls/engines/engine[%d]/cowl-flaps-norm", index);
906 snprintf(name, MAX_NAME_LEN,
907 "/controls/engines/engine[%d]/propeller-feather", index);
909 snprintf(name, MAX_NAME_LEN,
910 "/controls/engines/engine[%d]/ignition", index);
912 snprintf(name, MAX_NAME_LEN,
913 "/controls/engines/engine[%d]/augmentation", index);
915 snprintf(name, MAX_NAME_LEN,
916 "/controls/engines/engine[%d]/reverser", index);
918 snprintf(name, MAX_NAME_LEN,
919 "/controls/engines/engine[%d]/water-injection", index);
921 snprintf(name, MAX_NAME_LEN,
922 "/controls/engines/engine[%d]/condition", index);
925 fgUntie("/controls/fuel/dump-valve");
926 for (index = 0; index < MAX_TANKS; index++) {
927 char name[MAX_NAME_LEN];
928 snprintf(name, MAX_NAME_LEN,
929 "/controls/fuel/tank[%d]/fuel_selector", index);
931 snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_engine", index);
933 snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_tank", index);
935 for (i = 0; index < MAX_BOOSTPUMPS; i++) {
936 snprintf(name, MAX_NAME_LEN,
937 "/controls/fuel/tank[%d]/boost-pump[%d]", index, i);
941 fgUntie("/controls/gear/brake-left");
942 fgUntie("/controls/gear/brake-right");
943 fgUntie("/controls/gear/brake-parking");
944 fgUntie("/controls/gear/steering");
945 fgUntie("/controls/gear/nose-wheel-steering");
946 fgUntie("/controls/gear/gear-down");
947 fgUntie("/controls/gear/antiskid");
948 fgUntie("/controls/gear/tailhook");
949 fgUntie("/controls/gear/launchbar");
950 fgUntie("/controls/gear/catapult-launch-cmd");
951 fgUntie("/controls/gear/tailwheel-lock");
952 for (index = 0; index < MAX_WHEELS; index++) {
953 char name[MAX_NAME_LEN];
954 snprintf(name, MAX_NAME_LEN,
955 "/controls/gear/wheel[%d]/alternate-extension", index);
958 fgUntie("/controls/anti-ice/wing-heat");
959 fgUntie("/controls/anti-ice/pitot-heat");
960 fgUntie("/controls/anti-ice/wiper");
961 fgUntie("/controls/anti-ice/window-heat");
962 for (index = 0; index < MAX_ENGINES; index++) {
963 char name[MAX_NAME_LEN];
964 snprintf(name, MAX_NAME_LEN,
965 "/controls/anti-ice/engine[%d]/carb-heat", index);
967 snprintf(name, MAX_NAME_LEN,
968 "/controls/anti-ice/engine[%d]/inlet-heat", index);
971 for (index = 0; index < MAX_HYD_SYSTEMS; index++) {
972 char name[MAX_NAME_LEN];
973 snprintf(name, MAX_NAME_LEN,
974 "/controls/hydraulic/system[%d]/engine-pump", index);
976 snprintf(name, MAX_NAME_LEN,
977 "/controls/hydraulic/system[%d]/electric-pump", index);
980 fgUntie("/controls/electric/battery-switch");
981 fgUntie("/controls/electric/external-power");
982 fgUntie("/controls/electric/APU-generator");
983 for (index = 0; index < MAX_ENGINES; index++) {
984 char name[MAX_NAME_LEN];
985 snprintf(name, MAX_NAME_LEN,
986 "/controls/electric/engine[%d]/generator", index);
988 snprintf(name, MAX_NAME_LEN,
989 "/controls/electric/engine[%d]/bus-tie", index);
992 fgUntie("/controls/pneumatic/APU-bleed");
993 for (index = 0; index < MAX_ENGINES; index++) {
994 char name[MAX_NAME_LEN];
995 snprintf(name, MAX_NAME_LEN,
996 "/controls/pneumatic/engine[%d]/bleed", index);
999 fgUntie("/controls/pressurization/mode");
1000 fgUntie("/controls/pressurization/dump");
1001 for (index = 0; index < MAX_PACKS; index++) {
1002 char name[MAX_NAME_LEN];
1003 snprintf(name, MAX_NAME_LEN,
1004 "/controls/pressurization/pack[%d]/pack-on", index);
1007 fgUntie("/controls/lighting/landing-lights");
1008 fgUntie("/controls/lighting/turn-off-lights");
1009 fgUntie("/controls/lighting/taxi-light");
1010 fgUntie("/controls/lighting/logo-lights");
1011 fgUntie("/controls/lighting/nav-lights");
1012 fgUntie("/controls/lighting/beacon");
1013 fgUntie("/controls/lighting/strobe");
1014 fgUntie("/controls/lighting/panel-norm");
1015 fgUntie("/controls/lighting/instruments-norm");
1016 fgUntie("/controls/lighting/dome-norm");
1018 fgUntie("/controls/armament/master-arm");
1019 fgUntie("/controls/armament/station-select");
1020 fgUntie("/controls/armament/release-all");
1021 for (index = 0; index < MAX_STATIONS; index++) {
1022 char name[MAX_NAME_LEN];
1023 snprintf(name, MAX_NAME_LEN,
1024 "/controls/armament/station[%d]/stick-size", index);
1026 snprintf(name, MAX_NAME_LEN,
1027 "/controls/armament/station[%d]/release-stick", index);
1029 snprintf(name, MAX_NAME_LEN,
1030 "/controls/armament/station[%d]/release-all", index);
1032 snprintf(name, MAX_NAME_LEN,
1033 "/controls/armament/station[%d]/jettison-all", index);
1037 fgUntie("/controls/seat/vertical-adjust");
1038 fgUntie("/controls/seat/fore-aft-adjust");
1039 for (index = 0; index < MAX_EJECTION_SEATS; index++) {
1040 char name[MAX_NAME_LEN];
1041 snprintf(name, MAX_NAME_LEN,
1042 "/controls/seat/eject[%d]/initiate", index);
1044 snprintf(name, MAX_NAME_LEN,
1045 "/controls/seat/eject[%d]/status", index);
1048 fgUntie("/controls/seat/cmd_selector_valve");
1050 fgUntie("/controls/APU/off-start-run");
1051 fgUntie("/controls/APU/fire-switch");
1052 for (index = 0; index < MAX_AUTOPILOTS; index++) {
1053 char name[MAX_NAME_LEN];
1054 snprintf(name, MAX_NAME_LEN,
1055 "/controls/autoflight/autopilot[%d]/engage", index);
1058 fgUntie("/controls/autoflight/autothrottle-arm");
1059 fgUntie("/controls/autoflight/autothrottle-engage");
1060 fgUntie("/controls/autoflight/heading-select");
1061 fgUntie("/controls/autoflight/altitude-select");
1062 fgUntie("/controls/autoflight/bank-angle-select");
1063 fgUntie("/controls/autoflight/vertical-speed-select");
1064 fgUntie("/controls/autoflight/speed-select");
1065 fgUntie("/controls/autoflight/mach-select");
1066 fgUntie("/controls/autoflight/vertical-mode");
1067 fgUntie("/controls/autoflight/lateral-mode");
1072 FGControls::update (double dt)
1078 ////////////////////////////////////////////////////////////////////////
1079 // Setters and adjusters.
1080 ////////////////////////////////////////////////////////////////////////
1083 FGControls::set_aileron (double pos)
1086 CLAMP( &aileron, -1.0, 1.0 );
1088 // check for autocoordination
1089 if ( auto_coordination->getBoolValue() ) {
1090 set_rudder( aileron / 2.0 );
1095 FGControls::move_aileron (double amt)
1098 CLAMP( &aileron, -1.0, 1.0 );
1100 // check for autocoordination
1101 if ( auto_coordination->getBoolValue() ) {
1102 set_rudder( aileron / 2.0 );
1107 FGControls::set_aileron_trim( double pos )
1110 CLAMP( &aileron_trim, -1.0, 1.0 );
1114 FGControls::move_aileron_trim( double amt )
1116 aileron_trim += amt;
1117 CLAMP( &aileron_trim, -1.0, 1.0 );
1121 FGControls::set_elevator( double pos )
1124 CLAMP( &elevator, -1.0, 1.0 );
1128 FGControls::move_elevator( double amt )
1131 CLAMP( &elevator, -1.0, 1.0 );
1135 FGControls::set_elevator_trim( double pos )
1137 elevator_trim = pos;
1138 CLAMP( &elevator_trim, -1.0, 1.0 );
1142 FGControls::move_elevator_trim( double amt )
1144 elevator_trim += amt;
1145 CLAMP( &elevator_trim, -1.0, 1.0 );
1149 FGControls::set_rudder( double pos )
1152 CLAMP( &rudder, -1.0, 1.0 );
1156 FGControls::move_rudder( double amt )
1159 CLAMP( &rudder, -1.0, 1.0 );
1163 FGControls::set_rudder_trim( double pos )
1166 CLAMP( &rudder_trim, -1.0, 1.0 );
1170 FGControls::move_rudder_trim( double amt )
1173 CLAMP( &rudder_trim, -1.0, 1.0 );
1177 FGControls::set_flaps( double pos )
1180 CLAMP( &flaps, 0.0, 1.0 );
1184 FGControls::move_flaps( double amt )
1187 CLAMP( &flaps, 0.0, 1.0 );
1191 FGControls::set_slats( double pos )
1194 CLAMP( &slats, 0.0, 1.0 );
1198 FGControls::move_slats( double amt )
1201 CLAMP( &slats, 0.0, 1.0 );
1205 FGControls::set_BLC( bool val )
1211 FGControls::set_spoilers( double pos )
1214 CLAMP( &spoilers, 0.0, 1.0 );
1218 FGControls::move_spoilers( double amt )
1221 CLAMP( &spoilers, 0.0, 1.0 );
1225 FGControls::set_speedbrake( double pos )
1228 CLAMP( &speedbrake, 0.0, 1.0 );
1232 FGControls::move_speedbrake( double amt )
1235 CLAMP( &speedbrake, 0.0, 1.0 );
1239 FGControls::set_wing_sweep( double pos )
1242 CLAMP( &wing_sweep, 0.0, 1.0 );
1246 FGControls::move_wing_sweep( double amt )
1249 CLAMP( &wing_sweep, 0.0, 1.0 );
1253 FGControls::set_wing_fold( bool val )
1259 FGControls::set_drag_chute( bool val )
1265 FGControls::set_throttle_idle( bool val )
1267 throttle_idle = val;
1271 FGControls::set_throttle( int engine, double pos )
1273 if ( engine == ALL_ENGINES ) {
1274 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1276 CLAMP( &throttle[i], 0.0, 1.0 );
1279 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1280 throttle[engine] = pos;
1281 CLAMP( &throttle[engine], 0.0, 1.0 );
1287 FGControls::move_throttle( int engine, double amt )
1289 if ( engine == ALL_ENGINES ) {
1290 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1292 CLAMP( &throttle[i], 0.0, 1.0 );
1295 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1296 throttle[engine] += amt;
1297 CLAMP( &throttle[engine], 0.0, 1.0 );
1303 FGControls::set_starter( int engine, bool flag )
1305 if ( engine == ALL_ENGINES ) {
1306 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1310 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1311 starter[engine] = flag;
1317 FGControls::set_fuel_pump( int engine, bool val )
1319 if ( engine == ALL_ENGINES ) {
1320 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1324 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1325 fuel_pump[engine] = val;
1331 FGControls::set_fire_switch( int engine, bool val )
1333 if ( engine == ALL_ENGINES ) {
1334 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1335 fire_switch[i] = val;
1338 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1339 fire_switch[engine] = val;
1345 FGControls::set_fire_bottle_discharge( int engine, bool val )
1347 if ( engine == ALL_ENGINES ) {
1348 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1349 fire_bottle_discharge[i] = val;
1352 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1353 fire_bottle_discharge[engine] = val;
1359 FGControls::set_cutoff( int engine, bool val )
1361 if ( engine == ALL_ENGINES ) {
1362 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1366 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1367 cutoff[engine] = val;
1373 FGControls::set_feed_tank( int engine, int tank )
1375 if ( engine == ALL_ENGINES ) {
1376 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1377 feed_tank[i] = tank;
1378 CLAMP( &feed_tank[i], -1, 4 );
1381 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1382 feed_tank[engine] = tank;
1383 CLAMP( &feed_tank[engine], -1, 4 );
1386 // feed_tank[engine] = engine;
1391 FGControls::set_mixture( int engine, double pos )
1393 if ( engine == ALL_ENGINES ) {
1394 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1396 CLAMP( &mixture[i], 0.0, 1.0 );
1399 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1400 mixture[engine] = pos;
1401 CLAMP( &mixture[engine], 0.0, 1.0 );
1407 FGControls::move_mixture( int engine, double amt )
1409 if ( engine == ALL_ENGINES ) {
1410 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1412 CLAMP( &mixture[i], 0.0, 1.0 );
1415 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1416 mixture[engine] += amt;
1417 CLAMP( &mixture[engine], 0.0, 1.0 );
1423 FGControls::set_prop_advance( int engine, double pos )
1425 if ( engine == ALL_ENGINES ) {
1426 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1427 prop_advance[i] = pos;
1428 CLAMP( &prop_advance[i], 0.0, 1.0 );
1431 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1432 prop_advance[engine] = pos;
1433 CLAMP( &prop_advance[engine], 0.0, 1.0 );
1439 FGControls::move_prop_advance( int engine, double amt )
1441 if ( engine == ALL_ENGINES ) {
1442 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1443 prop_advance[i] += amt;
1444 CLAMP( &prop_advance[i], 0.0, 1.0 );
1447 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1448 prop_advance[engine] += amt;
1449 CLAMP( &prop_advance[engine], 0.0, 1.0 );
1455 FGControls::set_magnetos( int engine, int pos )
1457 if ( engine == ALL_ENGINES ) {
1458 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1460 CLAMP( &magnetos[i], 0, 3 );
1463 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1464 magnetos[engine] = pos;
1465 CLAMP( &magnetos[engine], 0, 3 );
1471 FGControls::move_magnetos( int engine, int amt )
1473 if ( engine == ALL_ENGINES ) {
1474 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1476 CLAMP( &magnetos[i], 0, 3 );
1479 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1480 magnetos[engine] += amt;
1481 CLAMP( &magnetos[engine], 0, 3 );
1487 FGControls::set_nitrous_injection( int engine, bool val )
1489 if ( engine == ALL_ENGINES ) {
1490 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1491 nitrous_injection[i] = val;
1494 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1495 nitrous_injection[engine] = val;
1502 FGControls::set_cowl_flaps_norm( int engine, double pos )
1504 if ( engine == ALL_ENGINES ) {
1505 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1506 cowl_flaps_norm[i] = pos;
1507 CLAMP( &cowl_flaps_norm[i], 0.0, 1.0 );
1510 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1511 cowl_flaps_norm[engine] = pos;
1512 CLAMP( &cowl_flaps_norm[engine], 0.0, 1.0 );
1518 FGControls::move_cowl_flaps_norm( int engine, double amt )
1520 if ( engine == ALL_ENGINES ) {
1521 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1522 cowl_flaps_norm[i] += amt;
1523 CLAMP( &cowl_flaps_norm[i], 0.0, 1.0 );
1526 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1527 cowl_flaps_norm[engine] += amt;
1528 CLAMP( &cowl_flaps_norm[engine], 0.0, 1.0 );
1534 FGControls::set_feather( int engine, bool val )
1536 if ( engine == ALL_ENGINES ) {
1537 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1541 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1542 feather[engine] = val;
1548 FGControls::set_ignition( int engine, int pos )
1550 if ( engine == ALL_ENGINES ) {
1551 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1553 CLAMP( &ignition[i], 0, 3 );
1556 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1557 ignition[engine] = pos;
1558 CLAMP( &ignition[engine], 0, 3 );
1564 FGControls::set_augmentation( int engine, bool val )
1566 if ( engine == ALL_ENGINES ) {
1567 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1568 augmentation[i] = val;
1571 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1572 augmentation[engine] = val;
1578 FGControls::set_reverser( int engine, bool val )
1580 if ( engine == ALL_ENGINES ) {
1581 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1585 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1586 reverser[engine] = val;
1592 FGControls::set_water_injection( int engine, bool val )
1594 if ( engine == ALL_ENGINES ) {
1595 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1596 water_injection[i] = val;
1599 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1600 water_injection[engine] = val;
1606 FGControls::set_condition( int engine, double val )
1608 if ( engine == ALL_ENGINES ) {
1609 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1611 CLAMP( &condition[i], 0.0, 1.0 );
1614 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1615 condition[engine] = val;
1616 CLAMP( &condition[engine], 0.0, 1.0 );
1622 FGControls::set_dump_valve( bool val )
1629 FGControls::set_fuel_selector( int tank, bool pos )
1631 if ( tank == ALL_TANKS ) {
1632 for ( int i = 0; i < MAX_TANKS; i++ ) {
1633 fuel_selector[i] = pos;
1636 if ( (tank >= 0) && (tank < MAX_TANKS) ) {
1637 fuel_selector[tank] = pos;
1643 FGControls::set_to_engine( int tank, int engine )
1645 if ( tank == ALL_TANKS ) {
1646 for ( int i = 0; i < MAX_TANKS; i++ ) {
1647 to_engine[i] = engine;
1650 if ( (tank >= 0) && (tank < MAX_TANKS) ) {
1651 to_engine[tank] = engine;
1657 FGControls::set_to_tank( int tank, int dest_tank )
1659 if ( tank == ALL_TANKS ) {
1660 for ( int i = 0; i < MAX_TANKS; i++ ) {
1661 to_tank[i] = dest_tank;
1664 if ( (tank >= 0) && (tank < MAX_TANKS) ) {
1665 to_tank[tank] = dest_tank;
1671 FGControls::set_boost_pump( int index, bool val )
1673 if ( index == -1 ) {
1674 for ( int i = 0; i < (MAX_TANKS * MAX_BOOSTPUMPS); i++ ) {
1675 boost_pump[i] = val;
1678 if ( (index >= 0) && (index < (MAX_TANKS * MAX_BOOSTPUMPS)) ) {
1679 boost_pump[index] = val;
1686 FGControls::set_brake_left( double pos )
1689 CLAMP(&brake_left, 0.0, 1.0);
1693 FGControls::move_brake_left( double amt )
1696 CLAMP( &brake_left, 0.0, 1.0 );
1700 FGControls::set_brake_right( double pos )
1703 CLAMP(&brake_right, 0.0, 1.0);
1707 FGControls::move_brake_right( double amt )
1710 CLAMP( &brake_right, 0.0, 1.0 );
1714 FGControls::set_copilot_brake_left( double pos )
1716 copilot_brake_left = pos;
1717 CLAMP(&brake_left, 0.0, 1.0);
1721 FGControls::set_copilot_brake_right( double pos )
1723 copilot_brake_right = pos;
1724 CLAMP(&brake_right, 0.0, 1.0);
1728 FGControls::set_brake_parking( double pos )
1730 brake_parking = pos;
1731 CLAMP(&brake_parking, 0.0, 1.0);
1735 FGControls::set_steering( double angle )
1738 CLAMP(&steering, -80.0, 80.0);
1742 FGControls::set_nose_wheel_steering( bool nws )
1744 nose_wheel_steering = nws;
1748 FGControls::move_steering( double angle )
1751 CLAMP(&steering, -80.0, 80.0);
1755 FGControls::set_gear_down( bool gear )
1761 FGControls::set_antiskid( bool state )
1767 FGControls::set_tailhook( bool state )
1773 FGControls::set_launchbar( bool state )
1779 FGControls::set_catapult_launch_cmd( bool state )
1781 catapult_launch_cmd = state;
1785 FGControls::set_tailwheel_lock( bool state )
1787 tailwheel_lock = state;
1792 FGControls::set_alternate_extension( int wheel, bool val )
1794 if ( wheel == ALL_WHEELS ) {
1795 for ( int i = 0; i < MAX_WHEELS; i++ ) {
1796 alternate_extension[i] = val;
1799 if ( (wheel >= 0) && (wheel < MAX_WHEELS) ) {
1800 alternate_extension[wheel] = val;
1806 FGControls::set_wing_heat( bool state )
1812 FGControls::set_pitot_heat( bool state )
1818 FGControls::set_wiper( int state )
1824 FGControls::set_window_heat( bool state )
1826 window_heat = state;
1830 FGControls::set_carb_heat( int engine, bool val )
1832 if ( engine == ALL_ENGINES ) {
1833 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1837 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1838 carb_heat[engine] = val;
1844 FGControls::set_inlet_heat( int engine, bool val )
1846 if ( engine == ALL_ENGINES ) {
1847 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1848 inlet_heat[i] = val;
1851 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1852 inlet_heat[engine] = val;
1858 FGControls::set_engine_pump( int system, bool val )
1860 if ( system == ALL_HYD_SYSTEMS ) {
1861 for ( int i = 0; i < MAX_HYD_SYSTEMS; i++ ) {
1862 engine_pump[i] = val;
1865 if ( (system >= 0) && (system < MAX_HYD_SYSTEMS) ) {
1866 engine_pump[system] = val;
1872 FGControls::set_electric_pump( int system, bool val )
1874 if ( system == ALL_HYD_SYSTEMS ) {
1875 for ( int i = 0; i < MAX_HYD_SYSTEMS; i++ ) {
1876 electric_pump[i] = val;
1879 if ( (system >= 0) && (system < MAX_HYD_SYSTEMS) ) {
1880 electric_pump[system] = val;
1886 FGControls::set_battery_switch( bool state )
1888 battery_switch = state;
1892 FGControls::set_external_power( bool state )
1894 external_power = state;
1898 FGControls::set_APU_generator( bool state )
1900 APU_generator = state;
1904 FGControls::set_generator_breaker( int engine, bool val )
1906 if ( engine == ALL_ENGINES ) {
1907 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1908 generator_breaker[i] = val;
1911 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1912 generator_breaker[engine] = val;
1918 FGControls::set_bus_tie( int engine, bool val )
1920 if ( engine == ALL_ENGINES ) {
1921 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1925 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1926 bus_tie[engine] = val;
1932 FGControls::set_APU_bleed( bool state )
1938 FGControls::set_engine_bleed( int engine, bool val )
1940 if ( engine == ALL_ENGINES ) {
1941 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1942 engine_bleed[i] = val;
1945 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1946 engine_bleed[engine] = val;
1952 FGControls::set_mode( int new_mode )
1958 FGControls::set_outflow_valve( double pos )
1960 outflow_valve = pos;
1961 CLAMP( &outflow_valve, 0.0, 1.0 );
1965 FGControls::move_outflow_valve( double amt )
1967 outflow_valve += amt;
1968 CLAMP( &outflow_valve, 0.0, 1.0 );
1972 FGControls::set_dump( bool state )
1978 FGControls::set_pack_on( int pack, bool val )
1980 if ( pack == ALL_PACKS ) {
1981 for ( int i = 0; i < MAX_PACKS; i++ ) {
1985 if ( (pack >= 0) && (pack < MAX_PACKS) ) {
1986 pack_on[pack] = val;
1992 FGControls::set_landing_lights( bool state )
1994 landing_lights = state;
1998 FGControls::set_turn_off_lights( bool state )
2000 turn_off_lights = state;
2004 FGControls::set_taxi_light( bool state )
2010 FGControls::set_logo_lights( bool state )
2012 logo_lights = state;
2016 FGControls::set_nav_lights( bool state )
2022 FGControls::set_beacon( bool state )
2028 FGControls::set_strobe( bool state )
2034 FGControls::set_panel_norm( double intensity )
2036 panel_norm = intensity;
2037 CLAMP( &panel_norm, 0.0, 1.0 );
2041 FGControls::move_panel_norm( double amt )
2044 CLAMP( &panel_norm, 0.0, 1.0 );
2048 FGControls::set_instruments_norm( double intensity )
2050 instruments_norm = intensity;
2051 CLAMP( &instruments_norm, 0.0, 1.0 );
2055 FGControls::move_instruments_norm( double amt )
2057 instruments_norm += amt;
2058 CLAMP( &instruments_norm, 0.0, 1.0 );
2062 FGControls::set_dome_norm( double intensity )
2064 dome_norm = intensity;
2065 CLAMP( &dome_norm, 0.0, 1.0 );
2069 FGControls::move_dome_norm( double amt )
2072 CLAMP( &dome_norm, 0.0, 1.0 );
2076 FGControls::set_master_arm( bool val )
2082 FGControls::set_station_select( int station )
2084 station_select = station;
2085 CLAMP( &station_select, 0, MAX_STATIONS );
2089 FGControls::set_release_ALL( bool val )
2095 FGControls::set_stick_size( int station, int size )
2097 if ( station == ALL_STATIONS ) {
2098 for ( int i = 0; i < MAX_STATIONS; i++ ) {
2099 stick_size[i] = size;
2100 CLAMP( &stick_size[i], 1, 20 );
2103 if ( (station >= 0) && (station < MAX_STATIONS) ) {
2104 stick_size[station] = size;
2105 CLAMP( &stick_size[station], 1, 20 );
2111 FGControls::set_release_stick( int station, bool val )
2113 if ( station == ALL_STATIONS ) {
2114 for ( int i = 0; i < MAX_STATIONS; i++ ) {
2115 release_stick[i] = val;
2118 if ( (station >= 0) && (station < MAX_STATIONS) ) {
2119 release_stick[station] = val;
2125 FGControls::set_release_all( int station, bool val )
2127 if ( station == ALL_STATIONS ) {
2128 for ( int i = 0; i < MAX_STATIONS; i++ ) {
2129 release_all[i] = val;
2132 if ( (station >= 0) && (station < MAX_STATIONS) ) {
2133 release_all[station] = val;
2139 FGControls::set_jettison_all( int station, bool val )
2141 if ( station == ALL_STATIONS ) {
2142 for ( int i = 0; i < MAX_STATIONS; i++ ) {
2143 jettison_all[i] = val;
2146 if ( (station >= 0) && (station < MAX_STATIONS) ) {
2147 jettison_all[station] = val;
2153 FGControls::set_vertical_adjust( double pos )
2155 vertical_adjust = pos;
2156 CLAMP( &vertical_adjust, -1.0, 1.0 );
2160 FGControls::move_vertical_adjust( double amt )
2162 vertical_adjust += amt;
2163 CLAMP( &vertical_adjust, -1.0, 1.0 );
2167 FGControls::set_fore_aft_adjust( double pos )
2169 fore_aft_adjust = pos;
2170 CLAMP( &fore_aft_adjust, -1.0, 1.0 );
2174 FGControls::move_fore_aft_adjust( double amt )
2176 fore_aft_adjust += amt;
2177 CLAMP( &fore_aft_adjust, -1.0, 1.0 );
2181 FGControls::set_ejection_seat( int which_seat, bool val )
2183 if ( which_seat == ALL_EJECTION_SEATS ) {
2184 for ( int i = 0; i < MAX_EJECTION_SEATS; i++ ) {
2188 if ( (which_seat >= 0) && (which_seat <= MAX_EJECTION_SEATS) ) {
2189 if ( eseat_status[which_seat] == SEAT_SAFED ||
2190 eseat_status[which_seat] == SEAT_FAIL )
2192 // we can never eject if SEAT_SAFED or SEAT_FAIL
2196 eject[which_seat] = val;
2202 FGControls::set_eseat_status( int which_seat, int val )
2204 if ( which_seat == ALL_EJECTION_SEATS ) {
2205 for ( int i = 0; i < MAX_EJECTION_SEATS; i++ ) {
2206 eseat_status[i] = val;
2209 if ( (which_seat >=0) && (which_seat <= MAX_EJECTION_SEATS) ) {
2210 eseat_status[which_seat] = val;
2216 FGControls::set_cmd_selector_valve( int val )
2218 cmd_selector_valve = val;
2223 FGControls::set_off_start_run( int pos )
2225 off_start_run = pos;
2226 CLAMP( &off_start_run, 0, 3 );
2230 FGControls::set_APU_fire_switch( bool val )
2232 APU_fire_switch = val;
2236 FGControls::set_autothrottle_arm( bool val )
2238 autothrottle_arm = val;
2242 FGControls::set_autothrottle_engage( bool val )
2244 autothrottle_engage = val;
2248 FGControls::set_heading_select( double heading )
2250 heading_select = heading;
2251 CLAMP( &heading_select, 0.0, 360.0 );
2255 FGControls::move_heading_select( double amt )
2257 heading_select += amt;
2258 CLAMP( &heading_select, 0.0, 360.0 );
2262 FGControls::set_altitude_select( double altitude )
2264 altitude_select = altitude;
2265 CLAMP( &altitude_select, -1000.0, 100000.0 );
2269 FGControls::move_altitude_select( double amt )
2271 altitude_select += amt;
2272 CLAMP( &altitude_select, -1000.0, 100000.0 );
2276 FGControls::set_bank_angle_select( double angle )
2278 bank_angle_select = angle;
2279 CLAMP( &bank_angle_select, 10.0, 30.0 );
2283 FGControls::move_bank_angle_select( double amt )
2285 bank_angle_select += amt;
2286 CLAMP( &bank_angle_select, 10.0, 30.0 );
2290 FGControls::set_vertical_speed_select( double speed )
2292 vertical_speed_select = speed;
2293 CLAMP( &vertical_speed_select, -3000.0, 4000.0 );
2297 FGControls::move_vertical_speed_select( double amt )
2299 vertical_speed_select += amt;
2300 CLAMP( &vertical_speed_select, -3000.0, 4000.0 );
2304 FGControls::set_speed_select( double speed )
2306 speed_select = speed;
2307 CLAMP( &speed_select, 60.0, 400.0 );
2311 FGControls::move_speed_select( double amt )
2313 speed_select += amt;
2314 CLAMP( &speed_select, 60.0, 400.0 );
2318 FGControls::set_mach_select( double mach )
2321 CLAMP( &mach_select, 0.4, 4.0 );
2325 FGControls::move_mach_select( double amt )
2328 CLAMP( &mach_select, 0.4, 4.0 );
2332 FGControls::set_vertical_mode( int mode )
2334 vertical_mode = mode;
2335 CLAMP( &vertical_mode, 0, 4 );
2339 FGControls::set_lateral_mode( int mode )
2341 lateral_mode = mode;
2342 CLAMP( &lateral_mode, 0, 4 );
2346 FGControls::set_autopilot_engage( int ap, bool val )
2348 if ( ap == ALL_AUTOPILOTS ) {
2349 for ( int i = 0; i < MAX_AUTOPILOTS; i++ ) {
2350 autopilot_engage[i] = val;
2353 if ( (ap >= 0) && (ap < MAX_AUTOPILOTS) ) {
2354 autopilot_engage[ap] = val;