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 ignition[engine] = false;
209 fire_switch[engine] = false;
210 cutoff[engine] = true;
211 augmentation[engine] = false;
212 reverser[engine] = false;
213 water_injection[engine] = false;
214 nitrous_injection[engine] = false;
215 cowl_flaps_norm[engine] = 0.0;
216 condition[engine] = 1.0;
219 brake_left = brake_right
220 = copilot_brake_left = copilot_brake_right
221 = brake_parking = 0.0;
222 for ( int wheel = 0; wheel < MAX_WHEELS; wheel++ ) {
223 alternate_extension[wheel] = false;
226 auto_coordination = fgGetNode("/sim/auto-coordination", true);
236 fgTie("/controls/flight/aileron", this,
237 &FGControls::get_aileron, &FGControls::set_aileron);
238 fgSetArchivable("/controls/flight/aileron");
240 fgTie("/controls/flight/aileron-trim", this,
241 &FGControls::get_aileron_trim, &FGControls::set_aileron_trim);
242 fgSetArchivable("/controls/flight/aileron-trim");
244 fgTie("/controls/flight/elevator", this,
245 &FGControls::get_elevator, &FGControls::set_elevator);
246 fgSetArchivable("/controls/flight/elevator");
248 fgTie("/controls/flight/elevator-trim", this,
249 &FGControls::get_elevator_trim, &FGControls::set_elevator_trim);
250 fgSetArchivable("/controls/flight/elevator-trim");
252 fgTie("/controls/flight/rudder", this,
253 &FGControls::get_rudder, &FGControls::set_rudder);
254 fgSetArchivable("/controls/flight/rudder");
256 fgTie("/controls/flight/rudder-trim", this,
257 &FGControls::get_rudder_trim, &FGControls::set_rudder_trim);
258 fgSetArchivable("/controls/flight/rudder-trim");
260 fgTie("/controls/flight/flaps", this,
261 &FGControls::get_flaps, &FGControls::set_flaps);
262 fgSetArchivable("/controls/flight/flaps");
264 fgTie("/controls/flight/slats", this,
265 &FGControls::get_slats, &FGControls::set_slats);
266 fgSetArchivable("/controls/flight/slats");
268 fgTie("/controls/flight/BLC", this,
269 &FGControls::get_BLC, &FGControls::set_BLC);
270 fgSetArchivable("/controls/flight/BLC");
272 fgTie("/controls/flight/spoilers", this,
273 &FGControls::get_spoilers, &FGControls::set_spoilers);
274 fgSetArchivable("/controls/flight/spoilers");
276 fgTie("/controls/flight/speedbrake", this,
277 &FGControls::get_speedbrake, &FGControls::set_speedbrake);
278 fgSetArchivable("/controls/flight/speedbrake");
280 fgTie("/controls/flight/wing-sweep", this,
281 &FGControls::get_wing_sweep, &FGControls::set_wing_sweep);
282 fgSetArchivable("/controls/flight/wing-sweep");
284 fgTie("/controls/flight/wing-fold", this,
285 &FGControls::get_wing_fold, &FGControls::set_wing_fold);
286 fgSetArchivable("/controls/flight/wing-fold");
288 fgTie("/controls/flight/drag-chute", this,
289 &FGControls::get_drag_chute, &FGControls::set_drag_chute);
290 fgSetArchivable("/controls/flight/drag-chute");
293 fgTie("/controls/engines/throttle_idle", this,
294 &FGControls::get_throttle_idle, &FGControls::set_throttle_idle);
295 fgSetArchivable("/controls/engines/throttle_idle");
297 for (index = 0; index < MAX_ENGINES; index++) {
298 char name[MAX_NAME_LEN];
299 snprintf(name, MAX_NAME_LEN,
300 "/controls/engines/engine[%d]/throttle", index);
301 fgTie(name, this, index,
302 &FGControls::get_throttle, &FGControls::set_throttle);
303 fgSetArchivable(name);
305 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/starter", index);
306 fgTie(name, this, index,
307 &FGControls::get_starter, &FGControls::set_starter);
308 fgSetArchivable(name);
310 snprintf(name, MAX_NAME_LEN,
311 "/controls/engines/engine[%d]/fuel-pump", index);
312 fgTie(name, this, index,
313 &FGControls::get_fuel_pump, &FGControls::set_fuel_pump);
314 fgSetArchivable(name);
316 snprintf(name, MAX_NAME_LEN,
317 "/controls/engines/engine[%d]/fire-switch", index);
318 fgTie(name, this, index,
319 &FGControls::get_fire_switch, &FGControls::set_fire_switch);
320 fgSetArchivable(name);
322 snprintf(name, MAX_NAME_LEN,
323 "/controls/engines/engine[%d]/fire-bottle-discharge", index);
324 fgTie(name, this, index,
325 &FGControls::get_fire_bottle_discharge,
326 &FGControls::set_fire_bottle_discharge);
327 fgSetArchivable(name);
329 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/cutoff", index);
330 fgTie(name, this, index,
331 &FGControls::get_cutoff, &FGControls::set_cutoff);
332 fgSetArchivable(name);
334 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/mixture", index);
335 fgTie(name, this, index,
336 &FGControls::get_mixture, &FGControls::set_mixture);
337 fgSetArchivable(name);
339 snprintf(name, MAX_NAME_LEN,
340 "/controls/engines/engine[%d]/propeller-pitch", index);
341 fgTie(name, this, index,
342 &FGControls::get_prop_advance,
343 &FGControls::set_prop_advance);
344 fgSetArchivable(name);
346 snprintf(name, MAX_NAME_LEN,
347 "/controls/engines/engine[%d]/magnetos", index);
348 fgTie(name, this, index,
349 &FGControls::get_magnetos, &FGControls::set_magnetos);
350 fgSetArchivable(name);
352 snprintf(name, MAX_NAME_LEN,
353 "/controls/engines/engine[%d]/feed_tank", index);
354 fgTie(name, this, index,
355 &FGControls::get_feed_tank, &FGControls::set_feed_tank);
356 fgSetArchivable(name);
359 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/WEP", index);
360 fgTie(name, this, index,
361 &FGControls::get_nitrous_injection,
362 &FGControls::set_nitrous_injection);
363 fgSetArchivable(name);
365 snprintf(name, MAX_NAME_LEN,
366 "/controls/engines/engine[%d]/cowl-flaps-norm", index);
367 fgTie(name, this, index,
368 &FGControls::get_cowl_flaps_norm,
369 &FGControls::set_cowl_flaps_norm);
370 fgSetArchivable(name);
372 snprintf(name, MAX_NAME_LEN,
373 "/controls/engines/engine[%d]/propeller-feather", index);
374 fgTie(name, this, index,
375 &FGControls::get_feather, &FGControls::set_feather);
376 fgSetArchivable(name);
378 snprintf(name, MAX_NAME_LEN,
379 "/controls/engines/engine[%d]/ignition", index);
380 fgTie(name, this, index,
381 &FGControls::get_ignition, &FGControls::set_ignition);
382 fgSetArchivable(name);
384 snprintf(name, MAX_NAME_LEN,
385 "/controls/engines/engine[%d]/augmentation", index);
386 fgTie(name, this, index,
387 &FGControls::get_augmentation,
388 &FGControls::set_augmentation);
389 fgSetArchivable(name);
391 snprintf(name, MAX_NAME_LEN,
392 "/controls/engines/engine[%d]/reverser", index);
393 fgTie(name, this, index,
394 &FGControls::get_reverser, &FGControls::set_reverser);
395 fgSetArchivable(name);
397 snprintf(name, MAX_NAME_LEN,
398 "/controls/engines/engine[%d]/water-injection", index);
399 fgTie(name, this, index,
400 &FGControls::get_water_injection,
401 &FGControls::set_water_injection);
402 fgSetArchivable(name);
404 snprintf(name, MAX_NAME_LEN,
405 "/controls/engines/engine[%d]/condition", index);
406 fgTie(name, this, index,
407 &FGControls::get_condition, &FGControls::set_condition);
408 fgSetArchivable(name);
412 fgTie("/controls/fuel/dump-valve", this,
413 &FGControls::get_dump_valve, &FGControls::set_dump_valve);
414 fgSetArchivable("/controls/fuel/dump-valve");
416 for (index = 0; index < MAX_TANKS; index++) {
417 char name[MAX_NAME_LEN];
418 snprintf(name, MAX_NAME_LEN,
419 "/controls/fuel/tank[%d]/fuel_selector", index);
420 fgTie(name, this, index,
421 &FGControls::get_fuel_selector,
422 &FGControls::set_fuel_selector);
423 fgSetArchivable(name);
425 snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_engine", index);
426 fgTie(name, this, index,
427 &FGControls::get_to_engine, &FGControls::set_to_engine);
428 fgSetArchivable(name);
430 snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_tank", index);
431 fgTie(name, this, index,
432 &FGControls::get_to_tank, &FGControls::set_to_tank);
433 fgSetArchivable(name);
435 for (i = 0; i < MAX_BOOSTPUMPS; i++) {
436 char name[MAX_NAME_LEN];
437 snprintf(name, MAX_NAME_LEN,
438 "/controls/fuel/tank[%d]/boost-pump[%d]", index, i);
439 fgTie(name, this, index * 2 + i,
440 &FGControls::get_boost_pump,
441 &FGControls::set_boost_pump);
442 fgSetArchivable(name);
447 fgTie("/controls/gear/brake-left", this,
448 &FGControls::get_brake_left,
449 &FGControls::set_brake_left);
450 fgSetArchivable("/controls/gear/brake-left");
452 fgTie("/controls/gear/brake-right", this,
453 &FGControls::get_brake_right,
454 &FGControls::set_brake_right);
455 fgSetArchivable("/controls/gear/brake-right");
457 fgTie("/controls/gear/copilot-brake-left", this,
458 &FGControls::get_copilot_brake_left,
459 &FGControls::set_copilot_brake_left);
460 fgSetArchivable("/controls/gear/copilot-brake-left");
462 fgTie("/controls/gear/copilot-brake-right", this,
463 &FGControls::get_copilot_brake_right,
464 &FGControls::set_copilot_brake_right);
465 fgSetArchivable("/controls/gear/copilot-brake-right");
467 fgTie("/controls/gear/brake-parking", this,
468 &FGControls::get_brake_parking,
469 &FGControls::set_brake_parking);
470 fgSetArchivable("/controls/gear/brake-parking");
472 fgTie("/controls/gear/steering", this,
473 &FGControls::get_steering, &FGControls::set_steering);
474 fgSetArchivable("/controls/gear/steering");
476 fgTie("/controls/gear/nose-wheel-steering", this,
477 &FGControls::get_nose_wheel_steering,
478 &FGControls::set_nose_wheel_steering);
479 fgSetArchivable("/controls/gear/nose-wheel-steering");
481 fgTie("/controls/gear/gear-down", this,
482 &FGControls::get_gear_down, &FGControls::set_gear_down);
483 fgSetArchivable("/controls/gear/gear-down");
485 fgTie("/controls/gear/antiskid", this,
486 &FGControls::get_antiskid, &FGControls::set_antiskid);
487 fgSetArchivable("/controls/gear/antiskid");
489 fgTie("/controls/gear/tailhook", this,
490 &FGControls::get_tailhook, &FGControls::set_tailhook);
491 fgSetArchivable("/controls/gear/tailhook");
493 fgTie("/controls/gear/launchbar", this,
494 &FGControls::get_launchbar, &FGControls::set_launchbar);
495 fgSetArchivable("/controls/gear/launchbar");
497 fgTie("/controls/gear/catapult-launch-cmd", this,
498 &FGControls::get_catapult_launch_cmd, &FGControls::set_catapult_launch_cmd);
499 fgSetArchivable("/controls/gear/catapult-launch-cmd");
501 fgTie("/controls/gear/tailwheel-lock", this,
502 &FGControls::get_tailwheel_lock,
503 &FGControls::set_tailwheel_lock);
504 fgSetArchivable("/controls/gear/tailwheel-lock");
506 for (index = 0; index < MAX_WHEELS; index++) {
507 char name[MAX_NAME_LEN];
508 snprintf(name, MAX_NAME_LEN,
509 "/controls/gear/wheel[%d]/alternate-extension", index);
510 fgTie(name, this, index,
511 &FGControls::get_alternate_extension,
512 &FGControls::set_alternate_extension);
513 fgSetArchivable(name);
517 fgTie("/controls/anti-ice/wing-heat", this,
518 &FGControls::get_wing_heat, &FGControls::set_wing_heat);
519 fgSetArchivable("/controls/anti-ice/wing-heat");
521 fgTie("/controls/anti-ice/pitot-heat", this,
522 &FGControls::get_pitot_heat, &FGControls::set_pitot_heat);
523 fgSetArchivable("/controls/anti-ice/pitot-heat");
525 fgTie("/controls/anti-ice/wiper", this,
526 &FGControls::get_wiper, &FGControls::set_wiper);
527 fgSetArchivable("/controls/anti-ice/wiper");
529 fgTie("/controls/anti-ice/window-heat", this,
530 &FGControls::get_window_heat, &FGControls::set_window_heat);
531 fgSetArchivable("/controls/anti-ice/window-heat");
533 for (index = 0; index < MAX_ENGINES; index++) {
534 char name[MAX_NAME_LEN];
535 snprintf(name, MAX_NAME_LEN,
536 "/controls/anti-ice/engine[%d]/carb-heat", index);
537 fgTie(name, this, index,
538 &FGControls::get_carb_heat, &FGControls::set_carb_heat);
539 fgSetArchivable(name);
541 snprintf(name, MAX_NAME_LEN,
542 "/controls/anti-ice/engine[%d]/inlet-heat", index);
543 fgTie(name, this, index,
544 &FGControls::get_inlet_heat, &FGControls::set_inlet_heat);
545 fgSetArchivable(name);
549 for (index = 0; index < MAX_HYD_SYSTEMS; index++) {
550 char name[MAX_NAME_LEN];
551 snprintf(name, MAX_NAME_LEN,
552 "/controls/hydraulic/system[%d]/engine-pump", index);
553 fgTie(name, this, index,
554 &FGControls::get_engine_pump, &FGControls::set_engine_pump);
555 fgSetArchivable(name);
557 snprintf(name, MAX_NAME_LEN,
558 "/controls/hydraulic/system[%d]/electric-pump", index);
559 fgTie(name, this, index,
560 &FGControls::get_electric_pump,
561 &FGControls::set_electric_pump);
562 fgSetArchivable(name);
566 fgTie("/controls/electric/battery-switch", this,
567 &FGControls::get_battery_switch,
568 &FGControls::set_battery_switch);
569 fgSetArchivable("/controls/electric/battery-switch");
571 fgTie("/controls/electric/external-power", this,
572 &FGControls::get_external_power,
573 &FGControls::set_external_power);
574 fgSetArchivable("/controls/electric/external-power");
576 fgTie("/controls/electric/APU-generator", this,
577 &FGControls::get_APU_generator,
578 &FGControls::set_APU_generator);
579 fgSetArchivable("/controls/electric/APU-generator");
581 for (index = 0; index < MAX_ENGINES; index++) {
582 char name[MAX_NAME_LEN];
583 snprintf(name, MAX_NAME_LEN,
584 "/controls/electric/engine[%d]/generator", index);
585 fgTie(name, this, index,
586 &FGControls::get_generator_breaker,
587 &FGControls::set_generator_breaker);
588 fgSetArchivable(name);
590 snprintf(name, MAX_NAME_LEN,
591 "/controls/electric/engine[%d]/bus-tie", index);
592 fgTie(name, this, index,
593 &FGControls::get_bus_tie,
594 &FGControls::set_bus_tie);
595 fgSetArchivable(name);
599 fgTie("/controls/pneumatic/APU-bleed", this,
600 &FGControls::get_APU_bleed,
601 &FGControls::set_APU_bleed);
602 fgSetArchivable("/controls/pneumatic/APU-bleed");
604 for (index = 0; index < MAX_ENGINES; index++) {
605 char name[MAX_NAME_LEN];
606 snprintf(name, MAX_NAME_LEN,
607 "/controls/pneumatic/engine[%d]/bleed", index);
608 fgTie(name, this, index,
609 &FGControls::get_engine_bleed,
610 &FGControls::set_engine_bleed);
611 fgSetArchivable(name);
615 fgTie("/controls/pressurization/mode", this,
616 &FGControls::get_mode, &FGControls::set_mode);
617 fgSetArchivable("/controls/pressurization/mode");
619 fgTie("/controls/pressurization/dump", this,
620 &FGControls::get_dump, &FGControls::set_dump);
621 fgSetArchivable("/controls/pressurization/dump");
623 fgTie("/controls/pressurization/outflow-valve", this,
624 &FGControls::get_outflow_valve,
625 &FGControls::set_outflow_valve);
626 fgSetArchivable("/controls/pressurization/outflow-valve");
628 for (index = 0; index < MAX_PACKS; index++) {
629 char name[MAX_NAME_LEN];
630 snprintf(name, MAX_NAME_LEN,
631 "/controls/pressurization/pack[%d]/pack-on", index);
632 fgTie(name, this, index,
633 &FGControls::get_pack_on, &FGControls::set_pack_on);
634 fgSetArchivable(name);
638 fgTie("/controls/lighting/landing-lights", this,
639 &FGControls::get_landing_lights,
640 &FGControls::set_landing_lights);
641 fgSetArchivable("/controls/lighting/landing-lights");
643 fgTie("/controls/lighting/turn-off-lights", this,
644 &FGControls::get_turn_off_lights,
645 &FGControls::set_turn_off_lights);
646 fgSetArchivable("/controls/lighting/turn-off-lights");
648 fgTie("/controls/lighting/taxi-light", this,
649 &FGControls::get_taxi_light, &FGControls::set_taxi_light);
650 fgSetArchivable("/controls/lighting/taxi-light");
652 fgTie("/controls/lighting/logo-lights", this,
653 &FGControls::get_logo_lights, &FGControls::set_logo_lights);
654 fgSetArchivable("/controls/lighting/logo-lights");
656 fgTie("/controls/lighting/nav-lights", this,
657 &FGControls::get_nav_lights, &FGControls::set_nav_lights);
658 fgSetArchivable("/controls/lighting/nav-lights");
660 fgTie("/controls/lighting/beacon", this,
661 &FGControls::get_beacon, &FGControls::set_beacon);
662 fgSetArchivable("/controls/lighting/beacon");
664 fgTie("/controls/lighting/strobe", this,
665 &FGControls::get_strobe, &FGControls::set_strobe);
666 fgSetArchivable("/controls/lighting/strobe");
668 fgTie("/controls/lighting/panel-norm", this,
669 &FGControls::get_panel_norm, &FGControls::set_panel_norm);
670 fgSetArchivable("/controls/lighting/panel-norm");
672 fgTie("/controls/lighting/instruments-norm", this,
673 &FGControls::get_instruments_norm,
674 &FGControls::set_instruments_norm);
675 fgSetArchivable("/controls/lighting/instruments-norm");
677 fgTie("/controls/lighting/dome-norm", this,
678 &FGControls::get_dome_norm, &FGControls::set_dome_norm);
679 fgSetArchivable("/controls/lighting/dome-norm");
682 fgTie("/controls/armament/master-arm", this,
683 &FGControls::get_master_arm, &FGControls::set_master_arm);
684 fgSetArchivable("/controls/armament/master-arm");
686 fgTie("/controls/armament/station-select", this,
687 &FGControls::get_station_select,
688 &FGControls::set_station_select);
689 fgSetArchivable("/controls/armament/station-select");
691 fgTie("/controls/armament/release-all", this,
692 &FGControls::get_release_ALL,
693 &FGControls::set_release_ALL);
694 fgSetArchivable("/controls/armament/release-all");
696 for (index = 0; index < MAX_STATIONS; index++) {
697 char name[MAX_NAME_LEN];
698 snprintf(name, MAX_NAME_LEN,
699 "/controls/armament/station[%d]/stick-size", index);
700 fgTie(name, this, index,
701 &FGControls::get_stick_size, &FGControls::set_stick_size);
702 fgSetArchivable(name);
704 snprintf(name, MAX_NAME_LEN,
705 "/controls/armament/station[%d]/release-stick", index);
706 fgTie(name, this, index,
707 &FGControls::get_release_stick, &FGControls::set_release_stick);
708 fgSetArchivable(name);
710 snprintf(name, MAX_NAME_LEN,
711 "/controls/armament/station[%d]/release-all", index);
712 fgTie(name, this, index,
713 &FGControls::get_release_all, &FGControls::set_release_all);
714 fgSetArchivable(name);
716 snprintf(name, MAX_NAME_LEN,
717 "/controls/armament/station[%d]/jettison-all", index);
718 fgTie(name, this, index,
719 &FGControls::get_jettison_all, &FGControls::set_jettison_all);
720 fgSetArchivable(name);
724 fgTie("/controls/seat/vertical-adjust", this,
725 &FGControls::get_vertical_adjust,
726 &FGControls::set_vertical_adjust);
727 fgSetArchivable("/controls/seat/vertical-adjust");
729 fgTie("/controls/seat/fore-aft-adjust", this,
730 &FGControls::get_fore_aft_adjust,
731 &FGControls::set_fore_aft_adjust);
732 fgSetArchivable("/controls/seat/fore-aft-adjust");
734 for (index = 0; index < MAX_EJECTION_SEATS; index++) {
735 char name[MAX_NAME_LEN];
736 snprintf(name, MAX_NAME_LEN,
737 "/controls/seat/eject[%d]/initiate", index);
738 fgTie(name, this, index,
739 &FGControls::get_ejection_seat,
740 &FGControls::set_ejection_seat);
741 fgSetArchivable(name);
743 snprintf(name, MAX_NAME_LEN,
744 "/controls/seat/eject[%d]/status", index);
746 fgTie(name, this, index,
747 &FGControls::get_eseat_status,
748 &FGControls::set_eseat_status);
750 fgSetArchivable(name);
753 fgTie("/controls/seat/cmd_selector_valve", this,
754 &FGControls::get_cmd_selector_valve,
755 &FGControls::set_cmd_selector_valve);
756 fgSetArchivable("/controls/seat/eject/cmd_selector_valve");
760 fgTie("/controls/APU/off-start-run", this,
761 &FGControls::get_off_start_run,
762 &FGControls::set_off_start_run);
763 fgSetArchivable("/controls/APU/off-start-run");
765 fgTie("/controls/APU/fire-switch", this,
766 &FGControls::get_APU_fire_switch,
767 &FGControls::set_APU_fire_switch);
768 fgSetArchivable("/controls/APU/fire-switch");
771 for (index = 0; index < MAX_AUTOPILOTS; index++) {
772 char name[MAX_NAME_LEN];
773 snprintf(name, MAX_NAME_LEN,
774 "/controls/autoflight/autopilot[%d]/engage", index);
775 fgTie(name, this, index,
776 &FGControls::get_autopilot_engage,
777 &FGControls::set_autopilot_engage);
778 fgSetArchivable(name);
781 fgTie("/controls/autoflight/autothrottle-arm", this,
782 &FGControls::get_autothrottle_arm,
783 &FGControls::set_autothrottle_arm);
784 fgSetArchivable("/controls/autoflight/autothrottle-arm");
786 fgTie("/controls/autoflight/autothrottle-engage", this,
787 &FGControls::get_autothrottle_engage,
788 &FGControls::set_autothrottle_engage);
789 fgSetArchivable("/controls/autoflight/autothrottle-engage");
791 fgTie("/controls/autoflight/heading-select", this,
792 &FGControls::get_heading_select,
793 &FGControls::set_heading_select);
794 fgSetArchivable("/controls/autoflight/heading-select");
796 fgTie("/controls/autoflight/altitude-select", this,
797 &FGControls::get_altitude_select,
798 &FGControls::set_altitude_select);
799 fgSetArchivable("/controls/autoflight/altitude-select");
801 fgTie("/controls/autoflight/bank-angle-select", this,
802 &FGControls::get_bank_angle_select,
803 &FGControls::set_bank_angle_select);
804 fgSetArchivable("/controls/autoflight/bank-angle-select");
806 fgTie("/controls/autoflight/vertical-speed-select", this,
807 &FGControls::get_vertical_speed_select,
808 &FGControls::set_vertical_speed_select);
809 fgSetArchivable("/controls/autoflight/vertical-speed-select");
811 fgTie("/controls/autoflight/speed-select", this,
812 &FGControls::get_speed_select,
813 &FGControls::set_speed_select);
814 fgSetArchivable("/controls/autoflight/speed-select");
816 fgTie("/controls/autoflight/mach-select", this,
817 &FGControls::get_mach_select,
818 &FGControls::set_mach_select);
819 fgSetArchivable("/controls/autoflight/mach-select");
821 fgTie("/controls/autoflight/vertical-mode", this,
822 &FGControls::get_vertical_mode,
823 &FGControls::set_vertical_mode);
824 fgSetArchivable("/controls/autoflight/vertical-mode");
826 fgTie("/controls/autoflight/lateral-mode", this,
827 &FGControls::get_lateral_mode,
828 &FGControls::set_lateral_mode);
829 fgSetArchivable("/controls/autoflight/lateral-mode");
833 void FGControls::unbind ()
836 //Tie control properties.
837 fgUntie("/controls/flight/aileron");
838 fgUntie("/controls/flight/aileron-trim");
839 fgUntie("/controls/flight/elevator");
840 fgUntie("/controls/flight/elevator-trim");
841 fgUntie("/controls/flight/rudder");
842 fgUntie("/controls/flight/rudder-trim");
843 fgUntie("/controls/flight/flaps");
844 fgUntie("/controls/flight/slats");
845 fgUntie("/controls/flight/BLC");
846 fgUntie("/controls/flight/spoilers");
847 fgUntie("/controls/flight/speedbrake");
848 fgUntie("/controls/flight/wing-sweep");
849 fgUntie("/controls/flight/wing-fold");
850 fgUntie("/controls/flight/drag-chute");
851 for (index = 0; index < MAX_ENGINES; index++) {
852 char name[MAX_NAME_LEN];
853 snprintf(name, MAX_NAME_LEN,
854 "/controls/engines/engine[%d]/throttle", index);
856 snprintf(name, MAX_NAME_LEN,
857 "/controls/engines/engine[%d]/feed_tank", index);
859 snprintf(name, MAX_NAME_LEN,
860 "/controls/engines/engine[%d]/starter", index);
862 snprintf(name, MAX_NAME_LEN,
863 "/controls/engines/engine[%d]/fuel_pump", index);
865 snprintf(name, MAX_NAME_LEN,
866 "/controls/engines/engine[%d]/fire-switch", index);
868 snprintf(name, MAX_NAME_LEN,
869 "/controls/engines/engine[%d]/fire-bottle-discharge", index);
871 snprintf(name, MAX_NAME_LEN,
872 "/controls/engines/engine[%d]/throttle_idle", index);
874 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/cutoff", index);
876 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/mixture", index);
878 snprintf(name, MAX_NAME_LEN,
879 "/controls/engines/engine[%d]/propeller-pitch", index);
881 snprintf(name, MAX_NAME_LEN,
882 "/controls/engines/engine[%d]/magnetos", index);
884 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/WEP", index);
886 snprintf(name, MAX_NAME_LEN,
887 "/controls/engines/engine[%d]/cowl-flaps-norm", index);
889 snprintf(name, MAX_NAME_LEN,
890 "/controls/engines/engine[%d]/propeller-feather", index);
892 snprintf(name, MAX_NAME_LEN,
893 "/controls/engines/engine[%d]/ignition", index);
895 snprintf(name, MAX_NAME_LEN,
896 "/controls/engines/engine[%d]/augmentation", index);
898 snprintf(name, MAX_NAME_LEN,
899 "/controls/engines/engine[%d]/reverser", index);
901 snprintf(name, MAX_NAME_LEN,
902 "/controls/engines/engine[%d]/water-injection", index);
904 snprintf(name, MAX_NAME_LEN,
905 "/controls/engines/engine[%d]/condition", index);
908 fgUntie("/controls/fuel/dump-valve");
909 for (index = 0; index < MAX_TANKS; index++) {
910 char name[MAX_NAME_LEN];
911 snprintf(name, MAX_NAME_LEN,
912 "/controls/fuel/tank[%d]/fuel_selector", index);
914 snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_engine", index);
916 snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_tank", index);
918 for (i = 0; index < MAX_BOOSTPUMPS; i++) {
919 snprintf(name, MAX_NAME_LEN,
920 "/controls/fuel/tank[%d]/boost-pump[%d]", index, i);
924 fgUntie("/controls/gear/brake-left");
925 fgUntie("/controls/gear/brake-right");
926 fgUntie("/controls/gear/brake-parking");
927 fgUntie("/controls/gear/steering");
928 fgUntie("/controls/gear/nose-wheel-steering");
929 fgUntie("/controls/gear/gear-down");
930 fgUntie("/controls/gear/antiskid");
931 fgUntie("/controls/gear/tailhook");
932 fgUntie("/controls/gear/launchbar");
933 fgUntie("/controls/gear/catapult-launch-cmd");
934 fgUntie("/controls/gear/tailwheel-lock");
935 for (index = 0; index < MAX_WHEELS; index++) {
936 char name[MAX_NAME_LEN];
937 snprintf(name, MAX_NAME_LEN,
938 "/controls/gear/wheel[%d]/alternate-extension", index);
941 fgUntie("/controls/anti-ice/wing-heat");
942 fgUntie("/controls/anti-ice/pitot-heat");
943 fgUntie("/controls/anti-ice/wiper");
944 fgUntie("/controls/anti-ice/window-heat");
945 for (index = 0; index < MAX_ENGINES; index++) {
946 char name[MAX_NAME_LEN];
947 snprintf(name, MAX_NAME_LEN,
948 "/controls/anti-ice/engine[%d]/carb-heat", index);
950 snprintf(name, MAX_NAME_LEN,
951 "/controls/anti-ice/engine[%d]/inlet-heat", index);
954 for (index = 0; index < MAX_HYD_SYSTEMS; index++) {
955 char name[MAX_NAME_LEN];
956 snprintf(name, MAX_NAME_LEN,
957 "/controls/hydraulic/system[%d]/engine-pump", index);
959 snprintf(name, MAX_NAME_LEN,
960 "/controls/hydraulic/system[%d]/electric-pump", index);
963 fgUntie("/controls/electric/battery-switch");
964 fgUntie("/controls/electric/external-power");
965 fgUntie("/controls/electric/APU-generator");
966 for (index = 0; index < MAX_ENGINES; index++) {
967 char name[MAX_NAME_LEN];
968 snprintf(name, MAX_NAME_LEN,
969 "/controls/electric/engine[%d]/generator", index);
971 snprintf(name, MAX_NAME_LEN,
972 "/controls/electric/engine[%d]/bus-tie", index);
975 fgUntie("/controls/pneumatic/APU-bleed");
976 for (index = 0; index < MAX_ENGINES; index++) {
977 char name[MAX_NAME_LEN];
978 snprintf(name, MAX_NAME_LEN,
979 "/controls/pneumatic/engine[%d]/bleed", index);
982 fgUntie("/controls/pressurization/mode");
983 fgUntie("/controls/pressurization/dump");
984 for (index = 0; index < MAX_PACKS; index++) {
985 char name[MAX_NAME_LEN];
986 snprintf(name, MAX_NAME_LEN,
987 "/controls/pressurization/pack[%d]/pack-on", index);
990 fgUntie("/controls/lighting/landing-lights");
991 fgUntie("/controls/lighting/turn-off-lights");
992 fgUntie("/controls/lighting/taxi-light");
993 fgUntie("/controls/lighting/logo-lights");
994 fgUntie("/controls/lighting/nav-lights");
995 fgUntie("/controls/lighting/beacon");
996 fgUntie("/controls/lighting/strobe");
997 fgUntie("/controls/lighting/panel-norm");
998 fgUntie("/controls/lighting/instruments-norm");
999 fgUntie("/controls/lighting/dome-norm");
1001 fgUntie("/controls/armament/master-arm");
1002 fgUntie("/controls/armament/station-select");
1003 fgUntie("/controls/armament/release-all");
1004 for (index = 0; index < MAX_STATIONS; index++) {
1005 char name[MAX_NAME_LEN];
1006 snprintf(name, MAX_NAME_LEN,
1007 "/controls/armament/station[%d]/stick-size", index);
1009 snprintf(name, MAX_NAME_LEN,
1010 "/controls/armament/station[%d]/release-stick", index);
1012 snprintf(name, MAX_NAME_LEN,
1013 "/controls/armament/station[%d]/release-all", index);
1015 snprintf(name, MAX_NAME_LEN,
1016 "/controls/armament/station[%d]/jettison-all", index);
1020 fgUntie("/controls/seat/vertical-adjust");
1021 fgUntie("/controls/seat/fore-aft-adjust");
1022 for (index = 0; index < MAX_EJECTION_SEATS; index++) {
1023 char name[MAX_NAME_LEN];
1024 snprintf(name, MAX_NAME_LEN,
1025 "/controls/seat/eject[%d]/initiate", index);
1027 snprintf(name, MAX_NAME_LEN,
1028 "/controls/seat/eject[%d]/status", index);
1031 fgUntie("/controls/seat/cmd_selector_valve");
1033 fgUntie("/controls/APU/off-start-run");
1034 fgUntie("/controls/APU/fire-switch");
1035 for (index = 0; index < MAX_AUTOPILOTS; index++) {
1036 char name[MAX_NAME_LEN];
1037 snprintf(name, MAX_NAME_LEN,
1038 "/controls/autoflight/autopilot[%d]/engage", index);
1041 fgUntie("/controls/autoflight/autothrottle-arm");
1042 fgUntie("/controls/autoflight/autothrottle-engage");
1043 fgUntie("/controls/autoflight/heading-select");
1044 fgUntie("/controls/autoflight/altitude-select");
1045 fgUntie("/controls/autoflight/bank-angle-select");
1046 fgUntie("/controls/autoflight/vertical-speed-select");
1047 fgUntie("/controls/autoflight/speed-select");
1048 fgUntie("/controls/autoflight/mach-select");
1049 fgUntie("/controls/autoflight/vertical-mode");
1050 fgUntie("/controls/autoflight/lateral-mode");
1055 FGControls::update (double dt)
1061 ////////////////////////////////////////////////////////////////////////
1062 // Setters and adjusters.
1063 ////////////////////////////////////////////////////////////////////////
1066 FGControls::set_aileron (double pos)
1069 CLAMP( &aileron, -1.0, 1.0 );
1071 // check for autocoordination
1072 if ( auto_coordination->getBoolValue() ) {
1073 set_rudder( aileron / 2.0 );
1078 FGControls::move_aileron (double amt)
1081 CLAMP( &aileron, -1.0, 1.0 );
1083 // check for autocoordination
1084 if ( auto_coordination->getBoolValue() ) {
1085 set_rudder( aileron / 2.0 );
1090 FGControls::set_aileron_trim( double pos )
1093 CLAMP( &aileron_trim, -1.0, 1.0 );
1097 FGControls::move_aileron_trim( double amt )
1099 aileron_trim += amt;
1100 CLAMP( &aileron_trim, -1.0, 1.0 );
1104 FGControls::set_elevator( double pos )
1107 CLAMP( &elevator, -1.0, 1.0 );
1111 FGControls::move_elevator( double amt )
1114 CLAMP( &elevator, -1.0, 1.0 );
1118 FGControls::set_elevator_trim( double pos )
1120 elevator_trim = pos;
1121 CLAMP( &elevator_trim, -1.0, 1.0 );
1125 FGControls::move_elevator_trim( double amt )
1127 elevator_trim += amt;
1128 CLAMP( &elevator_trim, -1.0, 1.0 );
1132 FGControls::set_rudder( double pos )
1135 CLAMP( &rudder, -1.0, 1.0 );
1139 FGControls::move_rudder( double amt )
1142 CLAMP( &rudder, -1.0, 1.0 );
1146 FGControls::set_rudder_trim( double pos )
1149 CLAMP( &rudder_trim, -1.0, 1.0 );
1153 FGControls::move_rudder_trim( double amt )
1156 CLAMP( &rudder_trim, -1.0, 1.0 );
1160 FGControls::set_flaps( double pos )
1163 CLAMP( &flaps, 0.0, 1.0 );
1167 FGControls::move_flaps( double amt )
1170 CLAMP( &flaps, 0.0, 1.0 );
1174 FGControls::set_slats( double pos )
1177 CLAMP( &slats, 0.0, 1.0 );
1181 FGControls::move_slats( double amt )
1184 CLAMP( &slats, 0.0, 1.0 );
1188 FGControls::set_BLC( bool val )
1194 FGControls::set_spoilers( double pos )
1197 CLAMP( &spoilers, 0.0, 1.0 );
1201 FGControls::move_spoilers( double amt )
1204 CLAMP( &spoilers, 0.0, 1.0 );
1208 FGControls::set_speedbrake( double pos )
1211 CLAMP( &speedbrake, 0.0, 1.0 );
1215 FGControls::move_speedbrake( double amt )
1218 CLAMP( &speedbrake, 0.0, 1.0 );
1222 FGControls::set_wing_sweep( double pos )
1225 CLAMP( &wing_sweep, 0.0, 1.0 );
1229 FGControls::move_wing_sweep( double amt )
1232 CLAMP( &wing_sweep, 0.0, 1.0 );
1236 FGControls::set_wing_fold( bool val )
1242 FGControls::set_drag_chute( bool val )
1248 FGControls::set_throttle_idle( bool val )
1250 throttle_idle = val;
1254 FGControls::set_throttle( int engine, double pos )
1256 if ( engine == ALL_ENGINES ) {
1257 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1259 CLAMP( &throttle[i], 0.0, 1.0 );
1262 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1263 throttle[engine] = pos;
1264 CLAMP( &throttle[engine], 0.0, 1.0 );
1270 FGControls::move_throttle( int engine, double amt )
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] += amt;
1280 CLAMP( &throttle[engine], 0.0, 1.0 );
1286 FGControls::set_starter( int engine, bool flag )
1288 if ( engine == ALL_ENGINES ) {
1289 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1293 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1294 starter[engine] = flag;
1300 FGControls::set_fuel_pump( int engine, bool val )
1302 if ( engine == ALL_ENGINES ) {
1303 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1307 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1308 fuel_pump[engine] = val;
1314 FGControls::set_fire_switch( int engine, bool val )
1316 if ( engine == ALL_ENGINES ) {
1317 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1318 fire_switch[i] = val;
1321 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1322 fire_switch[engine] = val;
1328 FGControls::set_fire_bottle_discharge( int engine, bool val )
1330 if ( engine == ALL_ENGINES ) {
1331 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1332 fire_bottle_discharge[i] = val;
1335 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1336 fire_bottle_discharge[engine] = val;
1342 FGControls::set_cutoff( int engine, bool val )
1344 if ( engine == ALL_ENGINES ) {
1345 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1349 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1350 cutoff[engine] = val;
1356 FGControls::set_feed_tank( int engine, int tank )
1358 if ( engine == ALL_ENGINES ) {
1359 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1360 feed_tank[i] = tank;
1361 CLAMP( &feed_tank[i], -1, 4 );
1364 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1365 feed_tank[engine] = tank;
1366 CLAMP( &feed_tank[engine], -1, 4 );
1369 // feed_tank[engine] = engine;
1374 FGControls::set_mixture( int engine, double pos )
1376 if ( engine == ALL_ENGINES ) {
1377 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1379 CLAMP( &mixture[i], 0.0, 1.0 );
1382 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1383 mixture[engine] = pos;
1384 CLAMP( &mixture[engine], 0.0, 1.0 );
1390 FGControls::move_mixture( int engine, double amt )
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] += amt;
1400 CLAMP( &mixture[engine], 0.0, 1.0 );
1406 FGControls::set_prop_advance( int engine, double pos )
1408 if ( engine == ALL_ENGINES ) {
1409 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1410 prop_advance[i] = pos;
1411 CLAMP( &prop_advance[i], 0.0, 1.0 );
1414 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1415 prop_advance[engine] = pos;
1416 CLAMP( &prop_advance[engine], 0.0, 1.0 );
1422 FGControls::move_prop_advance( int engine, double amt )
1424 if ( engine == ALL_ENGINES ) {
1425 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1426 prop_advance[i] += amt;
1427 CLAMP( &prop_advance[i], 0.0, 1.0 );
1430 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1431 prop_advance[engine] += amt;
1432 CLAMP( &prop_advance[engine], 0.0, 1.0 );
1438 FGControls::set_magnetos( int engine, int pos )
1440 if ( engine == ALL_ENGINES ) {
1441 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1443 CLAMP( &magnetos[i], 0, 3 );
1446 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1447 magnetos[engine] = pos;
1448 CLAMP( &magnetos[engine], 0, 3 );
1454 FGControls::move_magnetos( int engine, int amt )
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] += amt;
1464 CLAMP( &magnetos[engine], 0, 3 );
1470 FGControls::set_nitrous_injection( int engine, bool val )
1472 if ( engine == ALL_ENGINES ) {
1473 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1474 nitrous_injection[i] = val;
1477 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1478 nitrous_injection[engine] = val;
1485 FGControls::set_cowl_flaps_norm( int engine, double pos )
1487 if ( engine == ALL_ENGINES ) {
1488 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1489 cowl_flaps_norm[i] = pos;
1490 CLAMP( &cowl_flaps_norm[i], 0.0, 1.0 );
1493 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1494 cowl_flaps_norm[engine] = pos;
1495 CLAMP( &cowl_flaps_norm[engine], 0.0, 1.0 );
1501 FGControls::move_cowl_flaps_norm( int engine, double amt )
1503 if ( engine == ALL_ENGINES ) {
1504 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1505 cowl_flaps_norm[i] += amt;
1506 CLAMP( &cowl_flaps_norm[i], 0.0, 1.0 );
1509 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1510 cowl_flaps_norm[engine] += amt;
1511 CLAMP( &cowl_flaps_norm[engine], 0.0, 1.0 );
1517 FGControls::set_feather( int engine, bool val )
1519 if ( engine == ALL_ENGINES ) {
1520 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1524 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1525 feather[engine] = val;
1531 FGControls::set_ignition( int engine, int pos )
1533 if ( engine == ALL_ENGINES ) {
1534 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1536 CLAMP( &ignition[i], 0, 3 );
1539 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1540 ignition[engine] = pos;
1541 CLAMP( &ignition[engine], 0, 3 );
1547 FGControls::set_augmentation( int engine, bool val )
1549 if ( engine == ALL_ENGINES ) {
1550 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1551 augmentation[i] = val;
1554 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1555 augmentation[engine] = val;
1561 FGControls::set_reverser( int engine, bool val )
1563 if ( engine == ALL_ENGINES ) {
1564 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1568 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1569 reverser[engine] = val;
1575 FGControls::set_water_injection( int engine, bool val )
1577 if ( engine == ALL_ENGINES ) {
1578 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1579 water_injection[i] = val;
1582 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1583 water_injection[engine] = val;
1589 FGControls::set_condition( int engine, double val )
1591 if ( engine == ALL_ENGINES ) {
1592 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1594 CLAMP( &condition[i], 0.0, 1.0 );
1597 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1598 condition[engine] = val;
1599 CLAMP( &condition[engine], 0.0, 1.0 );
1605 FGControls::set_dump_valve( bool val )
1612 FGControls::set_fuel_selector( int tank, bool pos )
1614 if ( tank == ALL_TANKS ) {
1615 for ( int i = 0; i < MAX_TANKS; i++ ) {
1616 fuel_selector[i] = pos;
1619 if ( (tank >= 0) && (tank < MAX_TANKS) ) {
1620 fuel_selector[tank] = pos;
1626 FGControls::set_to_engine( int tank, int engine )
1628 if ( tank == ALL_TANKS ) {
1629 for ( int i = 0; i < MAX_TANKS; i++ ) {
1630 to_engine[i] = engine;
1633 if ( (tank >= 0) && (tank < MAX_TANKS) ) {
1634 to_engine[tank] = engine;
1640 FGControls::set_to_tank( int tank, int dest_tank )
1642 if ( tank == ALL_TANKS ) {
1643 for ( int i = 0; i < MAX_TANKS; i++ ) {
1644 to_tank[i] = dest_tank;
1647 if ( (tank >= 0) && (tank < MAX_TANKS) ) {
1648 to_tank[tank] = dest_tank;
1654 FGControls::set_boost_pump( int index, bool val )
1656 if ( index == -1 ) {
1657 for ( int i = 0; i < (MAX_TANKS * MAX_BOOSTPUMPS); i++ ) {
1658 boost_pump[i] = val;
1661 if ( (index >= 0) && (index < (MAX_TANKS * MAX_BOOSTPUMPS)) ) {
1662 boost_pump[index] = val;
1669 FGControls::set_brake_left( double pos )
1672 CLAMP(&brake_left, 0.0, 1.0);
1676 FGControls::move_brake_left( double amt )
1679 CLAMP( &brake_left, 0.0, 1.0 );
1683 FGControls::set_brake_right( double pos )
1686 CLAMP(&brake_right, 0.0, 1.0);
1690 FGControls::move_brake_right( double amt )
1693 CLAMP( &brake_right, 0.0, 1.0 );
1697 FGControls::set_copilot_brake_left( double pos )
1699 copilot_brake_left = pos;
1700 CLAMP(&brake_left, 0.0, 1.0);
1704 FGControls::set_copilot_brake_right( double pos )
1706 copilot_brake_right = pos;
1707 CLAMP(&brake_right, 0.0, 1.0);
1711 FGControls::set_brake_parking( double pos )
1713 brake_parking = pos;
1714 CLAMP(&brake_parking, 0.0, 1.0);
1718 FGControls::set_steering( double angle )
1721 CLAMP(&steering, -80.0, 80.0);
1725 FGControls::set_nose_wheel_steering( bool nws )
1727 nose_wheel_steering = nws;
1731 FGControls::move_steering( double angle )
1734 CLAMP(&steering, -80.0, 80.0);
1738 FGControls::set_gear_down( bool gear )
1744 FGControls::set_antiskid( bool state )
1750 FGControls::set_tailhook( bool state )
1756 FGControls::set_launchbar( bool state )
1762 FGControls::set_catapult_launch_cmd( bool state )
1764 catapult_launch_cmd = state;
1768 FGControls::set_tailwheel_lock( bool state )
1770 tailwheel_lock = state;
1775 FGControls::set_alternate_extension( int wheel, bool val )
1777 if ( wheel == ALL_WHEELS ) {
1778 for ( int i = 0; i < MAX_WHEELS; i++ ) {
1779 alternate_extension[i] = val;
1782 if ( (wheel >= 0) && (wheel < MAX_WHEELS) ) {
1783 alternate_extension[wheel] = val;
1789 FGControls::set_wing_heat( bool state )
1795 FGControls::set_pitot_heat( bool state )
1801 FGControls::set_wiper( int state )
1807 FGControls::set_window_heat( bool state )
1809 window_heat = state;
1813 FGControls::set_carb_heat( int engine, bool val )
1815 if ( engine == ALL_ENGINES ) {
1816 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1820 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1821 carb_heat[engine] = val;
1827 FGControls::set_inlet_heat( int engine, bool val )
1829 if ( engine == ALL_ENGINES ) {
1830 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1831 inlet_heat[i] = val;
1834 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1835 inlet_heat[engine] = val;
1841 FGControls::set_engine_pump( int system, bool val )
1843 if ( system == ALL_HYD_SYSTEMS ) {
1844 for ( int i = 0; i < MAX_HYD_SYSTEMS; i++ ) {
1845 engine_pump[i] = val;
1848 if ( (system >= 0) && (system < MAX_HYD_SYSTEMS) ) {
1849 engine_pump[system] = val;
1855 FGControls::set_electric_pump( int system, bool val )
1857 if ( system == ALL_HYD_SYSTEMS ) {
1858 for ( int i = 0; i < MAX_HYD_SYSTEMS; i++ ) {
1859 electric_pump[i] = val;
1862 if ( (system >= 0) && (system < MAX_HYD_SYSTEMS) ) {
1863 electric_pump[system] = val;
1869 FGControls::set_battery_switch( bool state )
1871 battery_switch = state;
1875 FGControls::set_external_power( bool state )
1877 external_power = state;
1881 FGControls::set_APU_generator( bool state )
1883 APU_generator = state;
1887 FGControls::set_generator_breaker( int engine, bool val )
1889 if ( engine == ALL_ENGINES ) {
1890 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1891 generator_breaker[i] = val;
1894 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1895 generator_breaker[engine] = val;
1901 FGControls::set_bus_tie( int engine, bool val )
1903 if ( engine == ALL_ENGINES ) {
1904 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1908 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1909 bus_tie[engine] = val;
1915 FGControls::set_APU_bleed( bool state )
1921 FGControls::set_engine_bleed( int engine, bool val )
1923 if ( engine == ALL_ENGINES ) {
1924 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1925 engine_bleed[i] = val;
1928 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1929 engine_bleed[engine] = val;
1935 FGControls::set_mode( int new_mode )
1941 FGControls::set_outflow_valve( double pos )
1943 outflow_valve = pos;
1944 CLAMP( &outflow_valve, 0.0, 1.0 );
1948 FGControls::move_outflow_valve( double amt )
1950 outflow_valve += amt;
1951 CLAMP( &outflow_valve, 0.0, 1.0 );
1955 FGControls::set_dump( bool state )
1961 FGControls::set_pack_on( int pack, bool val )
1963 if ( pack == ALL_PACKS ) {
1964 for ( int i = 0; i < MAX_PACKS; i++ ) {
1968 if ( (pack >= 0) && (pack < MAX_PACKS) ) {
1969 pack_on[pack] = val;
1975 FGControls::set_landing_lights( bool state )
1977 landing_lights = state;
1981 FGControls::set_turn_off_lights( bool state )
1983 turn_off_lights = state;
1987 FGControls::set_taxi_light( bool state )
1993 FGControls::set_logo_lights( bool state )
1995 logo_lights = state;
1999 FGControls::set_nav_lights( bool state )
2005 FGControls::set_beacon( bool state )
2011 FGControls::set_strobe( bool state )
2017 FGControls::set_panel_norm( double intensity )
2019 panel_norm = intensity;
2020 CLAMP( &panel_norm, 0.0, 1.0 );
2024 FGControls::move_panel_norm( double amt )
2027 CLAMP( &panel_norm, 0.0, 1.0 );
2031 FGControls::set_instruments_norm( double intensity )
2033 instruments_norm = intensity;
2034 CLAMP( &instruments_norm, 0.0, 1.0 );
2038 FGControls::move_instruments_norm( double amt )
2040 instruments_norm += amt;
2041 CLAMP( &instruments_norm, 0.0, 1.0 );
2045 FGControls::set_dome_norm( double intensity )
2047 dome_norm = intensity;
2048 CLAMP( &dome_norm, 0.0, 1.0 );
2052 FGControls::move_dome_norm( double amt )
2055 CLAMP( &dome_norm, 0.0, 1.0 );
2059 FGControls::set_master_arm( bool val )
2065 FGControls::set_station_select( int station )
2067 station_select = station;
2068 CLAMP( &station_select, 0, MAX_STATIONS );
2072 FGControls::set_release_ALL( bool val )
2078 FGControls::set_stick_size( int station, int size )
2080 if ( station == ALL_STATIONS ) {
2081 for ( int i = 0; i < MAX_STATIONS; i++ ) {
2082 stick_size[i] = size;
2083 CLAMP( &stick_size[i], 1, 20 );
2086 if ( (station >= 0) && (station < MAX_STATIONS) ) {
2087 stick_size[station] = size;
2088 CLAMP( &stick_size[station], 1, 20 );
2094 FGControls::set_release_stick( int station, bool val )
2096 if ( station == ALL_STATIONS ) {
2097 for ( int i = 0; i < MAX_STATIONS; i++ ) {
2098 release_stick[i] = val;
2101 if ( (station >= 0) && (station < MAX_STATIONS) ) {
2102 release_stick[station] = val;
2108 FGControls::set_release_all( int station, bool val )
2110 if ( station == ALL_STATIONS ) {
2111 for ( int i = 0; i < MAX_STATIONS; i++ ) {
2112 release_all[i] = val;
2115 if ( (station >= 0) && (station < MAX_STATIONS) ) {
2116 release_all[station] = val;
2122 FGControls::set_jettison_all( int station, bool val )
2124 if ( station == ALL_STATIONS ) {
2125 for ( int i = 0; i < MAX_STATIONS; i++ ) {
2126 jettison_all[i] = val;
2129 if ( (station >= 0) && (station < MAX_STATIONS) ) {
2130 jettison_all[station] = val;
2136 FGControls::set_vertical_adjust( double pos )
2138 vertical_adjust = pos;
2139 CLAMP( &vertical_adjust, -1.0, 1.0 );
2143 FGControls::move_vertical_adjust( double amt )
2145 vertical_adjust += amt;
2146 CLAMP( &vertical_adjust, -1.0, 1.0 );
2150 FGControls::set_fore_aft_adjust( double pos )
2152 fore_aft_adjust = pos;
2153 CLAMP( &fore_aft_adjust, -1.0, 1.0 );
2157 FGControls::move_fore_aft_adjust( double amt )
2159 fore_aft_adjust += amt;
2160 CLAMP( &fore_aft_adjust, -1.0, 1.0 );
2164 FGControls::set_ejection_seat( int which_seat, bool val )
2166 if ( which_seat == ALL_EJECTION_SEATS ) {
2167 for ( int i = 0; i < MAX_EJECTION_SEATS; i++ ) {
2171 if ( (which_seat >= 0) && (which_seat <= MAX_EJECTION_SEATS) ) {
2172 if ( eseat_status[which_seat] == SEAT_SAFED ||
2173 eseat_status[which_seat] == SEAT_FAIL )
2175 // we can never eject if SEAT_SAFED or SEAT_FAIL
2179 eject[which_seat] = val;
2185 FGControls::set_eseat_status( int which_seat, int val )
2187 if ( which_seat == ALL_EJECTION_SEATS ) {
2188 for ( int i = 0; i < MAX_EJECTION_SEATS; i++ ) {
2189 eseat_status[i] = val;
2192 if ( (which_seat >=0) && (which_seat <= MAX_EJECTION_SEATS) ) {
2193 eseat_status[which_seat] = val;
2199 FGControls::set_cmd_selector_valve( int val )
2201 cmd_selector_valve = val;
2206 FGControls::set_off_start_run( int pos )
2208 off_start_run = pos;
2209 CLAMP( &off_start_run, 0, 3 );
2213 FGControls::set_APU_fire_switch( bool val )
2215 APU_fire_switch = val;
2219 FGControls::set_autothrottle_arm( bool val )
2221 autothrottle_arm = val;
2225 FGControls::set_autothrottle_engage( bool val )
2227 autothrottle_engage = val;
2231 FGControls::set_heading_select( double heading )
2233 heading_select = heading;
2234 CLAMP( &heading_select, 0.0, 360.0 );
2238 FGControls::move_heading_select( double amt )
2240 heading_select += amt;
2241 CLAMP( &heading_select, 0.0, 360.0 );
2245 FGControls::set_altitude_select( double altitude )
2247 altitude_select = altitude;
2248 CLAMP( &altitude_select, -1000.0, 100000.0 );
2252 FGControls::move_altitude_select( double amt )
2254 altitude_select += amt;
2255 CLAMP( &altitude_select, -1000.0, 100000.0 );
2259 FGControls::set_bank_angle_select( double angle )
2261 bank_angle_select = angle;
2262 CLAMP( &bank_angle_select, 10.0, 30.0 );
2266 FGControls::move_bank_angle_select( double amt )
2268 bank_angle_select += amt;
2269 CLAMP( &bank_angle_select, 10.0, 30.0 );
2273 FGControls::set_vertical_speed_select( double speed )
2275 vertical_speed_select = speed;
2276 CLAMP( &vertical_speed_select, -3000.0, 4000.0 );
2280 FGControls::move_vertical_speed_select( double amt )
2282 vertical_speed_select += amt;
2283 CLAMP( &vertical_speed_select, -3000.0, 4000.0 );
2287 FGControls::set_speed_select( double speed )
2289 speed_select = speed;
2290 CLAMP( &speed_select, 60.0, 400.0 );
2294 FGControls::move_speed_select( double amt )
2296 speed_select += amt;
2297 CLAMP( &speed_select, 60.0, 400.0 );
2301 FGControls::set_mach_select( double mach )
2304 CLAMP( &mach_select, 0.4, 4.0 );
2308 FGControls::move_mach_select( double amt )
2311 CLAMP( &mach_select, 0.4, 4.0 );
2315 FGControls::set_vertical_mode( int mode )
2317 vertical_mode = mode;
2318 CLAMP( &vertical_mode, 0, 4 );
2322 FGControls::set_lateral_mode( int mode )
2324 lateral_mode = mode;
2325 CLAMP( &lateral_mode, 0, 4 );
2329 FGControls::set_autopilot_engage( int ap, bool val )
2331 if ( ap == ALL_AUTOPILOTS ) {
2332 for ( int i = 0; i < MAX_AUTOPILOTS; i++ ) {
2333 autopilot_engage[i] = val;
2336 if ( (ap >= 0) && (ap < MAX_AUTOPILOTS) ) {
2337 autopilot_engage[ap] = val;