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.
24 #include <simgear/compiler.h>
25 #include <simgear/debug/logstream.hxx>
26 #include <Main/fg_props.hxx>
28 #include "controls.hxx"
31 static const int MAX_NAME_LEN = 128;
34 ////////////////////////////////////////////////////////////////////////
35 // Inline utility methods.
36 ////////////////////////////////////////////////////////////////////////
39 CLAMP(double *x, double min, double max )
41 if ( *x < min ) { *x = min; }
42 if ( *x > max ) { *x = max; }
46 CLAMP(int *i, int min, int max )
48 if ( *i < min ) { *i = min; }
49 if ( *i > max ) { *i = max; }
53 ////////////////////////////////////////////////////////////////////////
54 // Implementation of FGControls.
55 ////////////////////////////////////////////////////////////////////////
58 FGControls::FGControls() :
73 throttle_idle( true ),
77 copilot_brake_left( 0.0 ),
78 copilot_brake_right( 0.0 ),
81 nose_wheel_steering( true ),
86 catapult_launch_cmd( false ),
87 tailwheel_lock( true ),
92 battery_switch( true ),
93 external_power( false ),
94 APU_generator( false ),
100 logo_lights( false ),
105 instruments_norm( 0.0 ),
109 release_ALL( false ),
110 vertical_adjust( 0.0 ),
111 fore_aft_adjust( 0.0 ),
113 APU_fire_switch( false ),
114 autothrottle_arm( false ),
115 autothrottle_engage( false ),
116 heading_select( 0.0 ),
117 altitude_select( 50000.0 ),
118 bank_angle_select( 30.0 ),
119 vertical_speed_select( 0.0 ),
128 void FGControls::reset_all()
131 set_aileron_trim( 0.0 );
133 set_elevator_trim( 0.0 );
135 set_rudder_trim( 0.0 );
138 set_speedbrake( 0.0 );
139 set_wing_sweep( 0.0 );
142 set_throttle( ALL_ENGINES, 0.0 );
143 set_starter( ALL_ENGINES, false );
144 set_magnetos( ALL_ENGINES, 0 );
145 set_fuel_pump( ALL_ENGINES, false );
146 set_fire_switch( ALL_ENGINES, false );
147 set_fire_bottle_discharge( ALL_ENGINES, false );
148 set_cutoff( ALL_ENGINES, true );
149 set_nitrous_injection( ALL_ENGINES, false );
150 set_cowl_flaps_norm( ALL_ENGINES, 1.0 );
151 set_feather( ALL_ENGINES, false );
152 set_ignition( ALL_ENGINES, false );
153 set_augmentation( ALL_ENGINES, false );
154 set_reverser( ALL_ENGINES, false );
155 set_water_injection( ALL_ENGINES, false );
156 set_condition( ALL_ENGINES, 1.0 );
157 throttle_idle = true;
158 set_fuel_selector( ALL_TANKS, true );
161 nose_wheel_steering = true;
165 catapult_launch_cmd = false;
166 tailwheel_lock = true;
167 set_carb_heat( ALL_ENGINES, false );
168 set_inlet_heat( ALL_ENGINES, false );
173 set_engine_pump( ALL_HYD_SYSTEMS, true );
174 set_electric_pump( ALL_HYD_SYSTEMS, true );
175 landing_lights = false;
176 turn_off_lights = false;
178 set_ejection_seat( ALL_EJECTION_SEATS, false );
179 set_eseat_status( ALL_EJECTION_SEATS, SEAT_SAFED );
180 set_cmd_selector_valve( CMD_SEL_NORM );
181 APU_fire_switch = false;
182 autothrottle_arm = false;
183 autothrottle_engage = false;
184 set_autopilot_engage( ALL_AUTOPILOTS, false );
189 FGControls::~FGControls() {
196 throttle_idle = true;
197 for ( int engine = 0; engine < MAX_ENGINES; engine++ ) {
198 throttle[engine] = 0.0;
199 mixture[engine] = 1.0;
200 fuel_pump[engine] = false;
201 prop_advance[engine] = 1.0;
202 magnetos[engine] = 0;
203 feed_tank[engine] = -1; // set to -1 to turn off all tanks 0 feeds all engines from center body tank
204 starter[engine] = false;
205 ignition[engine] = false;
206 fire_switch[engine] = false;
207 cutoff[engine] = true;
208 augmentation[engine] = false;
209 reverser[engine] = false;
210 water_injection[engine] = false;
211 nitrous_injection[engine] = false;
212 cowl_flaps_norm[engine] = 0.0;
213 condition[engine] = 1.0;
216 brake_left = brake_right
217 = copilot_brake_left = copilot_brake_right
218 = brake_parking = 0.0;
219 for ( int wheel = 0; wheel < MAX_WHEELS; wheel++ ) {
220 alternate_extension[wheel] = false;
223 auto_coordination = fgGetNode("/sim/auto-coordination", true);
233 fgTie("/controls/flight/aileron", this,
234 &FGControls::get_aileron, &FGControls::set_aileron);
235 fgSetArchivable("/controls/flight/aileron");
237 fgTie("/controls/flight/aileron-trim", this,
238 &FGControls::get_aileron_trim, &FGControls::set_aileron_trim);
239 fgSetArchivable("/controls/flight/aileron-trim");
241 fgTie("/controls/flight/elevator", this,
242 &FGControls::get_elevator, &FGControls::set_elevator);
243 fgSetArchivable("/controls/flight/elevator");
245 fgTie("/controls/flight/elevator-trim", this,
246 &FGControls::get_elevator_trim, &FGControls::set_elevator_trim);
247 fgSetArchivable("/controls/flight/elevator-trim");
249 fgTie("/controls/flight/rudder", this,
250 &FGControls::get_rudder, &FGControls::set_rudder);
251 fgSetArchivable("/controls/flight/rudder");
253 fgTie("/controls/flight/rudder-trim", this,
254 &FGControls::get_rudder_trim, &FGControls::set_rudder_trim);
255 fgSetArchivable("/controls/flight/rudder-trim");
257 fgTie("/controls/flight/flaps", this,
258 &FGControls::get_flaps, &FGControls::set_flaps);
259 fgSetArchivable("/controls/flight/flaps");
261 fgTie("/controls/flight/slats", this,
262 &FGControls::get_slats, &FGControls::set_slats);
263 fgSetArchivable("/controls/flight/slats");
265 fgTie("/controls/flight/BLC", this,
266 &FGControls::get_BLC, &FGControls::set_BLC);
267 fgSetArchivable("/controls/flight/BLC");
269 fgTie("/controls/flight/spoilers", this,
270 &FGControls::get_spoilers, &FGControls::set_spoilers);
271 fgSetArchivable("/controls/flight/spoilers");
273 fgTie("/controls/flight/speedbrake", this,
274 &FGControls::get_speedbrake, &FGControls::set_speedbrake);
275 fgSetArchivable("/controls/flight/speedbrake");
277 fgTie("/controls/flight/wing-sweep", this,
278 &FGControls::get_wing_sweep, &FGControls::set_wing_sweep);
279 fgSetArchivable("/controls/flight/wing-sweep");
281 fgTie("/controls/flight/wing-fold", this,
282 &FGControls::get_wing_fold, &FGControls::set_wing_fold);
283 fgSetArchivable("/controls/flight/wing-fold");
285 fgTie("/controls/flight/drag-chute", this,
286 &FGControls::get_drag_chute, &FGControls::set_drag_chute);
287 fgSetArchivable("/controls/flight/drag-chute");
290 fgTie("/controls/engines/throttle_idle", this,
291 &FGControls::get_throttle_idle, &FGControls::set_throttle_idle);
292 fgSetArchivable("/controls/engines/throttle_idle");
294 for (index = 0; index < MAX_ENGINES; index++) {
295 char name[MAX_NAME_LEN];
296 snprintf(name, MAX_NAME_LEN,
297 "/controls/engines/engine[%d]/throttle", index);
298 fgTie(name, this, index,
299 &FGControls::get_throttle, &FGControls::set_throttle);
300 fgSetArchivable(name);
302 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/starter", index);
303 fgTie(name, this, index,
304 &FGControls::get_starter, &FGControls::set_starter);
305 fgSetArchivable(name);
307 snprintf(name, MAX_NAME_LEN,
308 "/controls/engines/engine[%d]/fuel-pump", index);
309 fgTie(name, this, index,
310 &FGControls::get_fuel_pump, &FGControls::set_fuel_pump);
311 fgSetArchivable(name);
313 snprintf(name, MAX_NAME_LEN,
314 "/controls/engines/engine[%d]/fire-switch", index);
315 fgTie(name, this, index,
316 &FGControls::get_fire_switch, &FGControls::set_fire_switch);
317 fgSetArchivable(name);
319 snprintf(name, MAX_NAME_LEN,
320 "/controls/engines/engine[%d]/fire-bottle-discharge", index);
321 fgTie(name, this, index,
322 &FGControls::get_fire_bottle_discharge,
323 &FGControls::set_fire_bottle_discharge);
324 fgSetArchivable(name);
326 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/cutoff", index);
327 fgTie(name, this, index,
328 &FGControls::get_cutoff, &FGControls::set_cutoff);
329 fgSetArchivable(name);
331 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/mixture", index);
332 fgTie(name, this, index,
333 &FGControls::get_mixture, &FGControls::set_mixture);
334 fgSetArchivable(name);
336 snprintf(name, MAX_NAME_LEN,
337 "/controls/engines/engine[%d]/propeller-pitch", index);
338 fgTie(name, this, index,
339 &FGControls::get_prop_advance,
340 &FGControls::set_prop_advance);
341 fgSetArchivable(name);
343 snprintf(name, MAX_NAME_LEN,
344 "/controls/engines/engine[%d]/magnetos", index);
345 fgTie(name, this, index,
346 &FGControls::get_magnetos, &FGControls::set_magnetos);
347 fgSetArchivable(name);
349 snprintf(name, MAX_NAME_LEN,
350 "/controls/engines/engine[%d]/feed_tank", index);
351 fgTie(name, this, index,
352 &FGControls::get_feed_tank, &FGControls::set_feed_tank);
353 fgSetArchivable(name);
356 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/WEP", index);
357 fgTie(name, this, index,
358 &FGControls::get_nitrous_injection,
359 &FGControls::set_nitrous_injection);
360 fgSetArchivable(name);
362 snprintf(name, MAX_NAME_LEN,
363 "/controls/engines/engine[%d]/cowl-flaps-norm", index);
364 fgTie(name, this, index,
365 &FGControls::get_cowl_flaps_norm,
366 &FGControls::set_cowl_flaps_norm);
367 fgSetArchivable(name);
369 snprintf(name, MAX_NAME_LEN,
370 "/controls/engines/engine[%d]/propeller-feather", index);
371 fgTie(name, this, index,
372 &FGControls::get_feather, &FGControls::set_feather);
373 fgSetArchivable(name);
375 snprintf(name, MAX_NAME_LEN,
376 "/controls/engines/engine[%d]/ignition", index);
377 fgTie(name, this, index,
378 &FGControls::get_ignition, &FGControls::set_ignition);
379 fgSetArchivable(name);
381 snprintf(name, MAX_NAME_LEN,
382 "/controls/engines/engine[%d]/augmentation", index);
383 fgTie(name, this, index,
384 &FGControls::get_augmentation,
385 &FGControls::set_augmentation);
386 fgSetArchivable(name);
388 snprintf(name, MAX_NAME_LEN,
389 "/controls/engines/engine[%d]/reverser", index);
390 fgTie(name, this, index,
391 &FGControls::get_reverser, &FGControls::set_reverser);
392 fgSetArchivable(name);
394 snprintf(name, MAX_NAME_LEN,
395 "/controls/engines/engine[%d]/water-injection", index);
396 fgTie(name, this, index,
397 &FGControls::get_water_injection,
398 &FGControls::set_water_injection);
399 fgSetArchivable(name);
401 snprintf(name, MAX_NAME_LEN,
402 "/controls/engines/engine[%d]/condition", index);
403 fgTie(name, this, index,
404 &FGControls::get_condition, &FGControls::set_condition);
405 fgSetArchivable(name);
409 fgTie("/controls/fuel/dump-valve", this,
410 &FGControls::get_dump_valve, &FGControls::set_dump_valve);
411 fgSetArchivable("/controls/fuel/dump-valve");
413 for (index = 0; index < MAX_TANKS; index++) {
414 char name[MAX_NAME_LEN];
415 snprintf(name, MAX_NAME_LEN,
416 "/controls/fuel/tank[%d]/fuel_selector", index);
417 fgTie(name, this, index,
418 &FGControls::get_fuel_selector,
419 &FGControls::set_fuel_selector);
420 fgSetArchivable(name);
422 snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_engine", index);
423 fgTie(name, this, index,
424 &FGControls::get_to_engine, &FGControls::set_to_engine);
425 fgSetArchivable(name);
427 snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_tank", index);
428 fgTie(name, this, index,
429 &FGControls::get_to_tank, &FGControls::set_to_tank);
430 fgSetArchivable(name);
432 for (i = 0; i < MAX_BOOSTPUMPS; i++) {
433 char name[MAX_NAME_LEN];
434 snprintf(name, MAX_NAME_LEN,
435 "/controls/fuel/tank[%d]/boost-pump[%d]", index, i);
436 fgTie(name, this, index * 2 + i,
437 &FGControls::get_boost_pump,
438 &FGControls::set_boost_pump);
439 fgSetArchivable(name);
444 fgTie("/controls/gear/brake-left", this,
445 &FGControls::get_brake_left,
446 &FGControls::set_brake_left);
447 fgSetArchivable("/controls/gear/brake-left");
449 fgTie("/controls/gear/brake-right", this,
450 &FGControls::get_brake_right,
451 &FGControls::set_brake_right);
452 fgSetArchivable("/controls/gear/brake-right");
454 fgTie("/controls/gear/copilot-brake-left", this,
455 &FGControls::get_copilot_brake_left,
456 &FGControls::set_copilot_brake_left);
457 fgSetArchivable("/controls/gear/copilot-brake-left");
459 fgTie("/controls/gear/copilot-brake-right", this,
460 &FGControls::get_copilot_brake_right,
461 &FGControls::set_copilot_brake_right);
462 fgSetArchivable("/controls/gear/copilot-brake-right");
464 fgTie("/controls/gear/brake-parking", this,
465 &FGControls::get_brake_parking,
466 &FGControls::set_brake_parking);
467 fgSetArchivable("/controls/gear/brake-parking");
469 fgTie("/controls/gear/steering", this,
470 &FGControls::get_steering, &FGControls::set_steering);
471 fgSetArchivable("/controls/gear/steering");
473 fgTie("/controls/gear/nose-wheel-steering", this,
474 &FGControls::get_nose_wheel_steering,
475 &FGControls::set_nose_wheel_steering);
476 fgSetArchivable("/controls/gear/nose-wheel-steering");
478 fgTie("/controls/gear/gear-down", this,
479 &FGControls::get_gear_down, &FGControls::set_gear_down);
480 fgSetArchivable("/controls/gear/gear-down");
482 fgTie("/controls/gear/antiskid", this,
483 &FGControls::get_antiskid, &FGControls::set_antiskid);
484 fgSetArchivable("/controls/gear/antiskid");
486 fgTie("/controls/gear/tailhook", this,
487 &FGControls::get_tailhook, &FGControls::set_tailhook);
488 fgSetArchivable("/controls/gear/tailhook");
490 fgTie("/controls/gear/launchbar", this,
491 &FGControls::get_launchbar, &FGControls::set_launchbar);
492 fgSetArchivable("/controls/gear/launchbar");
494 fgTie("/controls/gear/catapult-launch-cmd", this,
495 &FGControls::get_catapult_launch_cmd, &FGControls::set_catapult_launch_cmd);
496 fgSetArchivable("/controls/gear/catapult-launch-cmd");
498 fgTie("/controls/gear/tailwheel-lock", this,
499 &FGControls::get_tailwheel_lock,
500 &FGControls::set_tailwheel_lock);
501 fgSetArchivable("/controls/gear/tailwheel-lock");
503 for (index = 0; index < MAX_WHEELS; index++) {
504 char name[MAX_NAME_LEN];
505 snprintf(name, MAX_NAME_LEN,
506 "/controls/gear/wheel[%d]/alternate-extension", index);
507 fgTie(name, this, index,
508 &FGControls::get_alternate_extension,
509 &FGControls::set_alternate_extension);
510 fgSetArchivable(name);
514 fgTie("/controls/anti-ice/wing-heat", this,
515 &FGControls::get_wing_heat, &FGControls::set_wing_heat);
516 fgSetArchivable("/controls/anti-ice/wing-heat");
518 fgTie("/controls/anti-ice/pitot-heat", this,
519 &FGControls::get_pitot_heat, &FGControls::set_pitot_heat);
520 fgSetArchivable("/controls/anti-ice/pitot-heat");
522 fgTie("/controls/anti-ice/wiper", this,
523 &FGControls::get_wiper, &FGControls::set_wiper);
524 fgSetArchivable("/controls/anti-ice/wiper");
526 fgTie("/controls/anti-ice/window-heat", this,
527 &FGControls::get_window_heat, &FGControls::set_window_heat);
528 fgSetArchivable("/controls/anti-ice/window-heat");
530 for (index = 0; index < MAX_ENGINES; index++) {
531 char name[MAX_NAME_LEN];
532 snprintf(name, MAX_NAME_LEN,
533 "/controls/anti-ice/engine[%d]/carb-heat", index);
534 fgTie(name, this, index,
535 &FGControls::get_carb_heat, &FGControls::set_carb_heat);
536 fgSetArchivable(name);
538 snprintf(name, MAX_NAME_LEN,
539 "/controls/anti-ice/engine[%d]/inlet-heat", index);
540 fgTie(name, this, index,
541 &FGControls::get_inlet_heat, &FGControls::set_inlet_heat);
542 fgSetArchivable(name);
546 for (index = 0; index < MAX_HYD_SYSTEMS; index++) {
547 char name[MAX_NAME_LEN];
548 snprintf(name, MAX_NAME_LEN,
549 "/controls/hydraulic/system[%d]/engine-pump", index);
550 fgTie(name, this, index,
551 &FGControls::get_engine_pump, &FGControls::set_engine_pump);
552 fgSetArchivable(name);
554 snprintf(name, MAX_NAME_LEN,
555 "/controls/hydraulic/system[%d]/electric-pump", index);
556 fgTie(name, this, index,
557 &FGControls::get_electric_pump,
558 &FGControls::set_electric_pump);
559 fgSetArchivable(name);
563 fgTie("/controls/electric/battery-switch", this,
564 &FGControls::get_battery_switch,
565 &FGControls::set_battery_switch);
566 fgSetArchivable("/controls/electric/battery-switch");
568 fgTie("/controls/electric/external-power", this,
569 &FGControls::get_external_power,
570 &FGControls::set_external_power);
571 fgSetArchivable("/controls/electric/external-power");
573 fgTie("/controls/electric/APU-generator", this,
574 &FGControls::get_APU_generator,
575 &FGControls::set_APU_generator);
576 fgSetArchivable("/controls/electric/APU-generator");
578 for (index = 0; index < MAX_ENGINES; index++) {
579 char name[MAX_NAME_LEN];
580 snprintf(name, MAX_NAME_LEN,
581 "/controls/electric/engine[%d]/generator", index);
582 fgTie(name, this, index,
583 &FGControls::get_generator_breaker,
584 &FGControls::set_generator_breaker);
585 fgSetArchivable(name);
587 snprintf(name, MAX_NAME_LEN,
588 "/controls/electric/engine[%d]/bus-tie", index);
589 fgTie(name, this, index,
590 &FGControls::get_bus_tie,
591 &FGControls::set_bus_tie);
592 fgSetArchivable(name);
596 fgTie("/controls/pneumatic/APU-bleed", this,
597 &FGControls::get_APU_bleed,
598 &FGControls::set_APU_bleed);
599 fgSetArchivable("/controls/pneumatic/APU-bleed");
601 for (index = 0; index < MAX_ENGINES; index++) {
602 char name[MAX_NAME_LEN];
603 snprintf(name, MAX_NAME_LEN,
604 "/controls/pneumatic/engine[%d]/bleed", index);
605 fgTie(name, this, index,
606 &FGControls::get_engine_bleed,
607 &FGControls::set_engine_bleed);
608 fgSetArchivable(name);
612 fgTie("/controls/pressurization/mode", this,
613 &FGControls::get_mode, &FGControls::set_mode);
614 fgSetArchivable("/controls/pressurization/mode");
616 fgTie("/controls/pressurization/dump", this,
617 &FGControls::get_dump, &FGControls::set_dump);
618 fgSetArchivable("/controls/pressurization/dump");
620 fgTie("/controls/pressurization/outflow-valve", this,
621 &FGControls::get_outflow_valve,
622 &FGControls::set_outflow_valve);
623 fgSetArchivable("/controls/pressurization/outflow-valve");
625 for (index = 0; index < MAX_PACKS; index++) {
626 char name[MAX_NAME_LEN];
627 snprintf(name, MAX_NAME_LEN,
628 "/controls/pressurization/pack[%d]/pack-on", index);
629 fgTie(name, this, index,
630 &FGControls::get_pack_on, &FGControls::set_pack_on);
631 fgSetArchivable(name);
635 fgTie("/controls/lighting/landing-lights", this,
636 &FGControls::get_landing_lights,
637 &FGControls::set_landing_lights);
638 fgSetArchivable("/controls/lighting/landing-lights");
640 fgTie("/controls/lighting/turn-off-lights", this,
641 &FGControls::get_turn_off_lights,
642 &FGControls::set_turn_off_lights);
643 fgSetArchivable("/controls/lighting/turn-off-lights");
645 fgTie("/controls/lighting/taxi-light", this,
646 &FGControls::get_taxi_light, &FGControls::set_taxi_light);
647 fgSetArchivable("/controls/lighting/taxi-light");
649 fgTie("/controls/lighting/logo-lights", this,
650 &FGControls::get_logo_lights, &FGControls::set_logo_lights);
651 fgSetArchivable("/controls/lighting/logo-lights");
653 fgTie("/controls/lighting/nav-lights", this,
654 &FGControls::get_nav_lights, &FGControls::set_nav_lights);
655 fgSetArchivable("/controls/lighting/nav-lights");
657 fgTie("/controls/lighting/beacon", this,
658 &FGControls::get_beacon, &FGControls::set_beacon);
659 fgSetArchivable("/controls/lighting/beacon");
661 fgTie("/controls/lighting/strobe", this,
662 &FGControls::get_strobe, &FGControls::set_strobe);
663 fgSetArchivable("/controls/lighting/strobe");
665 fgTie("/controls/lighting/panel-norm", this,
666 &FGControls::get_panel_norm, &FGControls::set_panel_norm);
667 fgSetArchivable("/controls/lighting/panel-norm");
669 fgTie("/controls/lighting/instruments-norm", this,
670 &FGControls::get_instruments_norm,
671 &FGControls::set_instruments_norm);
672 fgSetArchivable("/controls/lighting/instruments-norm");
674 fgTie("/controls/lighting/dome-norm", this,
675 &FGControls::get_dome_norm, &FGControls::set_dome_norm);
676 fgSetArchivable("/controls/lighting/dome-norm");
679 fgTie("/controls/armament/master-arm", this,
680 &FGControls::get_master_arm, &FGControls::set_master_arm);
681 fgSetArchivable("/controls/armament/master-arm");
683 fgTie("/controls/armament/station-select", this,
684 &FGControls::get_station_select,
685 &FGControls::set_station_select);
686 fgSetArchivable("/controls/armament/station-select");
688 fgTie("/controls/armament/release-all", this,
689 &FGControls::get_release_ALL,
690 &FGControls::set_release_ALL);
691 fgSetArchivable("/controls/armament/release-all");
693 for (index = 0; index < MAX_STATIONS; index++) {
694 char name[MAX_NAME_LEN];
695 snprintf(name, MAX_NAME_LEN,
696 "/controls/armament/station[%d]/stick-size", index);
697 fgTie(name, this, index,
698 &FGControls::get_stick_size, &FGControls::set_stick_size);
699 fgSetArchivable(name);
701 snprintf(name, MAX_NAME_LEN,
702 "/controls/armament/station[%d]/release-stick", index);
703 fgTie(name, this, index,
704 &FGControls::get_release_stick, &FGControls::set_release_stick);
705 fgSetArchivable(name);
707 snprintf(name, MAX_NAME_LEN,
708 "/controls/armament/station[%d]/release-all", index);
709 fgTie(name, this, index,
710 &FGControls::get_release_all, &FGControls::set_release_all);
711 fgSetArchivable(name);
713 snprintf(name, MAX_NAME_LEN,
714 "/controls/armament/station[%d]/jettison-all", index);
715 fgTie(name, this, index,
716 &FGControls::get_jettison_all, &FGControls::set_jettison_all);
717 fgSetArchivable(name);
721 fgTie("/controls/seat/vertical-adjust", this,
722 &FGControls::get_vertical_adjust,
723 &FGControls::set_vertical_adjust);
724 fgSetArchivable("/controls/seat/vertical-adjust");
726 fgTie("/controls/seat/fore-aft-adjust", this,
727 &FGControls::get_fore_aft_adjust,
728 &FGControls::set_fore_aft_adjust);
729 fgSetArchivable("/controls/seat/fore-aft-adjust");
731 for (index = 0; index < MAX_EJECTION_SEATS; index++) {
732 char name[MAX_NAME_LEN];
733 snprintf(name, MAX_NAME_LEN,
734 "/controls/seat/eject[%d]/initiate", index);
735 fgTie(name, this, index,
736 &FGControls::get_ejection_seat,
737 &FGControls::set_ejection_seat);
738 fgSetArchivable(name);
740 snprintf(name, MAX_NAME_LEN,
741 "/controls/seat/eject[%d]/status", index);
743 fgTie(name, this, index,
744 &FGControls::get_eseat_status,
745 &FGControls::set_eseat_status);
747 fgSetArchivable(name);
750 fgTie("/controls/seat/cmd_selector_valve", this,
751 &FGControls::get_cmd_selector_valve,
752 &FGControls::set_cmd_selector_valve);
753 fgSetArchivable("/controls/seat/eject/cmd_selector_valve");
757 fgTie("/controls/APU/off-start-run", this,
758 &FGControls::get_off_start_run,
759 &FGControls::set_off_start_run);
760 fgSetArchivable("/controls/APU/off-start-run");
762 fgTie("/controls/APU/fire-switch", this,
763 &FGControls::get_APU_fire_switch,
764 &FGControls::set_APU_fire_switch);
765 fgSetArchivable("/controls/APU/fire-switch");
768 for (index = 0; index < MAX_AUTOPILOTS; index++) {
769 char name[MAX_NAME_LEN];
770 snprintf(name, MAX_NAME_LEN,
771 "/controls/autoflight/autopilot[%d]/engage", index);
772 fgTie(name, this, index,
773 &FGControls::get_autopilot_engage,
774 &FGControls::set_autopilot_engage);
775 fgSetArchivable(name);
778 fgTie("/controls/autoflight/autothrottle-arm", this,
779 &FGControls::get_autothrottle_arm,
780 &FGControls::set_autothrottle_arm);
781 fgSetArchivable("/controls/autoflight/autothrottle-arm");
783 fgTie("/controls/autoflight/autothrottle-engage", this,
784 &FGControls::get_autothrottle_engage,
785 &FGControls::set_autothrottle_engage);
786 fgSetArchivable("/controls/autoflight/autothrottle-engage");
788 fgTie("/controls/autoflight/heading-select", this,
789 &FGControls::get_heading_select,
790 &FGControls::set_heading_select);
791 fgSetArchivable("/controls/autoflight/heading-select");
793 fgTie("/controls/autoflight/altitude-select", this,
794 &FGControls::get_altitude_select,
795 &FGControls::set_altitude_select);
796 fgSetArchivable("/controls/autoflight/altitude-select");
798 fgTie("/controls/autoflight/bank-angle-select", this,
799 &FGControls::get_bank_angle_select,
800 &FGControls::set_bank_angle_select);
801 fgSetArchivable("/controls/autoflight/bank-angle-select");
803 fgTie("/controls/autoflight/vertical-speed-select", this,
804 &FGControls::get_vertical_speed_select,
805 &FGControls::set_vertical_speed_select);
806 fgSetArchivable("/controls/autoflight/vertical-speed-select");
808 fgTie("/controls/autoflight/speed-select", this,
809 &FGControls::get_speed_select,
810 &FGControls::set_speed_select);
811 fgSetArchivable("/controls/autoflight/speed-select");
813 fgTie("/controls/autoflight/mach-select", this,
814 &FGControls::get_mach_select,
815 &FGControls::set_mach_select);
816 fgSetArchivable("/controls/autoflight/mach-select");
818 fgTie("/controls/autoflight/vertical-mode", this,
819 &FGControls::get_vertical_mode,
820 &FGControls::set_vertical_mode);
821 fgSetArchivable("/controls/autoflight/vertical-mode");
823 fgTie("/controls/autoflight/lateral-mode", this,
824 &FGControls::get_lateral_mode,
825 &FGControls::set_lateral_mode);
826 fgSetArchivable("/controls/autoflight/lateral-mode");
830 void FGControls::unbind ()
833 //Tie control properties.
834 fgUntie("/controls/flight/aileron");
835 fgUntie("/controls/flight/aileron-trim");
836 fgUntie("/controls/flight/elevator");
837 fgUntie("/controls/flight/elevator-trim");
838 fgUntie("/controls/flight/rudder");
839 fgUntie("/controls/flight/rudder-trim");
840 fgUntie("/controls/flight/flaps");
841 fgUntie("/controls/flight/slats");
842 fgUntie("/controls/flight/BLC");
843 fgUntie("/controls/flight/spoilers");
844 fgUntie("/controls/flight/speedbrake");
845 fgUntie("/controls/flight/wing-sweep");
846 fgUntie("/controls/flight/wing-fold");
847 fgUntie("/controls/flight/drag-chute");
848 for (index = 0; index < MAX_ENGINES; index++) {
849 char name[MAX_NAME_LEN];
850 snprintf(name, MAX_NAME_LEN,
851 "/controls/engines/engine[%d]/throttle", index);
853 snprintf(name, MAX_NAME_LEN,
854 "/controls/engines/engine[%d]/feed_tank", index);
856 snprintf(name, MAX_NAME_LEN,
857 "/controls/engines/engine[%d]/starter", index);
859 snprintf(name, MAX_NAME_LEN,
860 "/controls/engines/engine[%d]/fuel_pump", index);
862 snprintf(name, MAX_NAME_LEN,
863 "/controls/engines/engine[%d]/fire-switch", index);
865 snprintf(name, MAX_NAME_LEN,
866 "/controls/engines/engine[%d]/fire-bottle-discharge", index);
868 snprintf(name, MAX_NAME_LEN,
869 "/controls/engines/engine[%d]/throttle_idle", index);
871 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/cutoff", index);
873 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/mixture", index);
875 snprintf(name, MAX_NAME_LEN,
876 "/controls/engines/engine[%d]/propeller-pitch", index);
878 snprintf(name, MAX_NAME_LEN,
879 "/controls/engines/engine[%d]/magnetos", index);
881 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/WEP", index);
883 snprintf(name, MAX_NAME_LEN,
884 "/controls/engines/engine[%d]/cowl-flaps-norm", index);
886 snprintf(name, MAX_NAME_LEN,
887 "/controls/engines/engine[%d]/propeller-feather", index);
889 snprintf(name, MAX_NAME_LEN,
890 "/controls/engines/engine[%d]/ignition", index);
892 snprintf(name, MAX_NAME_LEN,
893 "/controls/engines/engine[%d]/augmentation", index);
895 snprintf(name, MAX_NAME_LEN,
896 "/controls/engines/engine[%d]/reverser", index);
898 snprintf(name, MAX_NAME_LEN,
899 "/controls/engines/engine[%d]/water-injection", index);
901 snprintf(name, MAX_NAME_LEN,
902 "/controls/engines/engine[%d]/condition", index);
905 fgUntie("/controls/fuel/dump-valve");
906 for (index = 0; index < MAX_TANKS; index++) {
907 char name[MAX_NAME_LEN];
908 snprintf(name, MAX_NAME_LEN,
909 "/controls/fuel/tank[%d]/fuel_selector", index);
911 snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_engine", index);
913 snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_tank", index);
915 for (i = 0; index < MAX_BOOSTPUMPS; i++) {
916 snprintf(name, MAX_NAME_LEN,
917 "/controls/fuel/tank[%d]/boost-pump[%d]", index, i);
921 fgUntie("/controls/gear/brake-left");
922 fgUntie("/controls/gear/brake-right");
923 fgUntie("/controls/gear/brake-parking");
924 fgUntie("/controls/gear/steering");
925 fgUntie("/controls/gear/nose-wheel-steering");
926 fgUntie("/controls/gear/gear-down");
927 fgUntie("/controls/gear/antiskid");
928 fgUntie("/controls/gear/tailhook");
929 fgUntie("/controls/gear/launchbar");
930 fgUntie("/controls/gear/catapult-launch-cmd");
931 fgUntie("/controls/gear/tailwheel-lock");
932 for (index = 0; index < MAX_WHEELS; index++) {
933 char name[MAX_NAME_LEN];
934 snprintf(name, MAX_NAME_LEN,
935 "/controls/gear/wheel[%d]/alternate-extension", index);
938 fgUntie("/controls/anti-ice/wing-heat");
939 fgUntie("/controls/anti-ice/pitot-heat");
940 fgUntie("/controls/anti-ice/wiper");
941 fgUntie("/controls/anti-ice/window-heat");
942 for (index = 0; index < MAX_ENGINES; index++) {
943 char name[MAX_NAME_LEN];
944 snprintf(name, MAX_NAME_LEN,
945 "/controls/anti-ice/engine[%d]/carb-heat", index);
947 snprintf(name, MAX_NAME_LEN,
948 "/controls/anti-ice/engine[%d]/inlet-heat", index);
951 for (index = 0; index < MAX_HYD_SYSTEMS; index++) {
952 char name[MAX_NAME_LEN];
953 snprintf(name, MAX_NAME_LEN,
954 "/controls/hydraulic/system[%d]/engine-pump", index);
956 snprintf(name, MAX_NAME_LEN,
957 "/controls/hydraulic/system[%d]/electric-pump", index);
960 fgUntie("/controls/electric/battery-switch");
961 fgUntie("/controls/electric/external-power");
962 fgUntie("/controls/electric/APU-generator");
963 for (index = 0; index < MAX_ENGINES; index++) {
964 char name[MAX_NAME_LEN];
965 snprintf(name, MAX_NAME_LEN,
966 "/controls/electric/engine[%d]/generator", index);
968 snprintf(name, MAX_NAME_LEN,
969 "/controls/electric/engine[%d]/bus-tie", index);
972 fgUntie("/controls/pneumatic/APU-bleed");
973 for (index = 0; index < MAX_ENGINES; index++) {
974 char name[MAX_NAME_LEN];
975 snprintf(name, MAX_NAME_LEN,
976 "/controls/pneumatic/engine[%d]/bleed", index);
979 fgUntie("/controls/pressurization/mode");
980 fgUntie("/controls/pressurization/dump");
981 for (index = 0; index < MAX_PACKS; index++) {
982 char name[MAX_NAME_LEN];
983 snprintf(name, MAX_NAME_LEN,
984 "/controls/pressurization/pack[%d]/pack-on", index);
987 fgUntie("/controls/lighting/landing-lights");
988 fgUntie("/controls/lighting/turn-off-lights");
989 fgUntie("/controls/lighting/taxi-light");
990 fgUntie("/controls/lighting/logo-lights");
991 fgUntie("/controls/lighting/nav-lights");
992 fgUntie("/controls/lighting/beacon");
993 fgUntie("/controls/lighting/strobe");
994 fgUntie("/controls/lighting/panel-norm");
995 fgUntie("/controls/lighting/instruments-norm");
996 fgUntie("/controls/lighting/dome-norm");
998 fgUntie("/controls/armament/master-arm");
999 fgUntie("/controls/armament/station-select");
1000 fgUntie("/controls/armament/release-all");
1001 for (index = 0; index < MAX_STATIONS; index++) {
1002 char name[MAX_NAME_LEN];
1003 snprintf(name, MAX_NAME_LEN,
1004 "/controls/armament/station[%d]/stick-size", index);
1006 snprintf(name, MAX_NAME_LEN,
1007 "/controls/armament/station[%d]/release-stick", index);
1009 snprintf(name, MAX_NAME_LEN,
1010 "/controls/armament/station[%d]/release-all", index);
1012 snprintf(name, MAX_NAME_LEN,
1013 "/controls/armament/station[%d]/jettison-all", index);
1017 fgUntie("/controls/seat/vertical-adjust");
1018 fgUntie("/controls/seat/fore-aft-adjust");
1019 for (index = 0; index < MAX_EJECTION_SEATS; index++) {
1020 char name[MAX_NAME_LEN];
1021 snprintf(name, MAX_NAME_LEN,
1022 "/controls/seat/eject[%d]/initiate", index);
1024 snprintf(name, MAX_NAME_LEN,
1025 "/controls/seat/eject[%d]/status", index);
1028 fgUntie("/controls/seat/cmd_selector_valve");
1030 fgUntie("/controls/APU/off-start-run");
1031 fgUntie("/controls/APU/fire-switch");
1032 for (index = 0; index < MAX_AUTOPILOTS; index++) {
1033 char name[MAX_NAME_LEN];
1034 snprintf(name, MAX_NAME_LEN,
1035 "/controls/autoflight/autopilot[%d]/engage", index);
1038 fgUntie("/controls/autoflight/autothrottle-arm");
1039 fgUntie("/controls/autoflight/autothrottle-engage");
1040 fgUntie("/controls/autoflight/heading-select");
1041 fgUntie("/controls/autoflight/altitude-select");
1042 fgUntie("/controls/autoflight/bank-angle-select");
1043 fgUntie("/controls/autoflight/vertical-speed-select");
1044 fgUntie("/controls/autoflight/speed-select");
1045 fgUntie("/controls/autoflight/mach-select");
1046 fgUntie("/controls/autoflight/vertical-mode");
1047 fgUntie("/controls/autoflight/lateral-mode");
1052 FGControls::update (double dt)
1058 ////////////////////////////////////////////////////////////////////////
1059 // Setters and adjusters.
1060 ////////////////////////////////////////////////////////////////////////
1063 FGControls::set_aileron (double pos)
1066 CLAMP( &aileron, -1.0, 1.0 );
1068 // check for autocoordination
1069 if ( auto_coordination->getBoolValue() ) {
1070 set_rudder( aileron / 2.0 );
1075 FGControls::move_aileron (double amt)
1078 CLAMP( &aileron, -1.0, 1.0 );
1080 // check for autocoordination
1081 if ( auto_coordination->getBoolValue() ) {
1082 set_rudder( aileron / 2.0 );
1087 FGControls::set_aileron_trim( double pos )
1090 CLAMP( &aileron_trim, -1.0, 1.0 );
1094 FGControls::move_aileron_trim( double amt )
1096 aileron_trim += amt;
1097 CLAMP( &aileron_trim, -1.0, 1.0 );
1101 FGControls::set_elevator( double pos )
1104 CLAMP( &elevator, -1.0, 1.0 );
1108 FGControls::move_elevator( double amt )
1111 CLAMP( &elevator, -1.0, 1.0 );
1115 FGControls::set_elevator_trim( double pos )
1117 elevator_trim = pos;
1118 CLAMP( &elevator_trim, -1.0, 1.0 );
1122 FGControls::move_elevator_trim( double amt )
1124 elevator_trim += amt;
1125 CLAMP( &elevator_trim, -1.0, 1.0 );
1129 FGControls::set_rudder( double pos )
1132 CLAMP( &rudder, -1.0, 1.0 );
1136 FGControls::move_rudder( double amt )
1139 CLAMP( &rudder, -1.0, 1.0 );
1143 FGControls::set_rudder_trim( double pos )
1146 CLAMP( &rudder_trim, -1.0, 1.0 );
1150 FGControls::move_rudder_trim( double amt )
1153 CLAMP( &rudder_trim, -1.0, 1.0 );
1157 FGControls::set_flaps( double pos )
1160 CLAMP( &flaps, 0.0, 1.0 );
1164 FGControls::move_flaps( double amt )
1167 CLAMP( &flaps, 0.0, 1.0 );
1171 FGControls::set_slats( double pos )
1174 CLAMP( &slats, 0.0, 1.0 );
1178 FGControls::move_slats( double amt )
1181 CLAMP( &slats, 0.0, 1.0 );
1185 FGControls::set_BLC( bool val )
1191 FGControls::set_spoilers( double pos )
1194 CLAMP( &spoilers, 0.0, 1.0 );
1198 FGControls::move_spoilers( double amt )
1201 CLAMP( &spoilers, 0.0, 1.0 );
1205 FGControls::set_speedbrake( double pos )
1208 CLAMP( &speedbrake, 0.0, 1.0 );
1212 FGControls::move_speedbrake( double amt )
1215 CLAMP( &speedbrake, 0.0, 1.0 );
1219 FGControls::set_wing_sweep( double pos )
1222 CLAMP( &wing_sweep, 0.0, 1.0 );
1226 FGControls::move_wing_sweep( double amt )
1229 CLAMP( &wing_sweep, 0.0, 1.0 );
1233 FGControls::set_wing_fold( bool val )
1239 FGControls::set_drag_chute( bool val )
1245 FGControls::set_throttle_idle( bool val )
1247 throttle_idle = val;
1251 FGControls::set_throttle( int engine, double pos )
1253 if ( engine == ALL_ENGINES ) {
1254 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1256 CLAMP( &throttle[i], 0.0, 1.0 );
1259 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1260 throttle[engine] = pos;
1261 CLAMP( &throttle[engine], 0.0, 1.0 );
1267 FGControls::move_throttle( int engine, double amt )
1269 if ( engine == ALL_ENGINES ) {
1270 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1272 CLAMP( &throttle[i], 0.0, 1.0 );
1275 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1276 throttle[engine] += amt;
1277 CLAMP( &throttle[engine], 0.0, 1.0 );
1283 FGControls::set_starter( int engine, bool flag )
1285 if ( engine == ALL_ENGINES ) {
1286 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1290 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1291 starter[engine] = flag;
1297 FGControls::set_fuel_pump( int engine, bool val )
1299 if ( engine == ALL_ENGINES ) {
1300 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1304 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1305 fuel_pump[engine] = val;
1311 FGControls::set_fire_switch( int engine, bool val )
1313 if ( engine == ALL_ENGINES ) {
1314 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1315 fire_switch[i] = val;
1318 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1319 fire_switch[engine] = val;
1325 FGControls::set_fire_bottle_discharge( int engine, bool val )
1327 if ( engine == ALL_ENGINES ) {
1328 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1329 fire_bottle_discharge[i] = val;
1332 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1333 fire_bottle_discharge[engine] = val;
1339 FGControls::set_cutoff( int engine, bool val )
1341 if ( engine == ALL_ENGINES ) {
1342 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1346 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1347 cutoff[engine] = val;
1353 FGControls::set_feed_tank( int engine, int tank )
1355 if ( engine == ALL_ENGINES ) {
1356 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1357 feed_tank[i] = tank;
1358 CLAMP( &feed_tank[i], -1, 4 );
1361 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1362 feed_tank[engine] = tank;
1363 CLAMP( &feed_tank[engine], -1, 4 );
1366 // feed_tank[engine] = engine;
1371 FGControls::set_mixture( int engine, double pos )
1373 if ( engine == ALL_ENGINES ) {
1374 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1376 CLAMP( &mixture[i], 0.0, 1.0 );
1379 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1380 mixture[engine] = pos;
1381 CLAMP( &mixture[engine], 0.0, 1.0 );
1387 FGControls::move_mixture( int engine, double amt )
1389 if ( engine == ALL_ENGINES ) {
1390 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1392 CLAMP( &mixture[i], 0.0, 1.0 );
1395 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1396 mixture[engine] += amt;
1397 CLAMP( &mixture[engine], 0.0, 1.0 );
1403 FGControls::set_prop_advance( int engine, double pos )
1405 if ( engine == ALL_ENGINES ) {
1406 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1407 prop_advance[i] = pos;
1408 CLAMP( &prop_advance[i], 0.0, 1.0 );
1411 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1412 prop_advance[engine] = pos;
1413 CLAMP( &prop_advance[engine], 0.0, 1.0 );
1419 FGControls::move_prop_advance( int engine, double amt )
1421 if ( engine == ALL_ENGINES ) {
1422 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1423 prop_advance[i] += amt;
1424 CLAMP( &prop_advance[i], 0.0, 1.0 );
1427 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1428 prop_advance[engine] += amt;
1429 CLAMP( &prop_advance[engine], 0.0, 1.0 );
1435 FGControls::set_magnetos( int engine, int pos )
1437 if ( engine == ALL_ENGINES ) {
1438 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1440 CLAMP( &magnetos[i], 0, 3 );
1443 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1444 magnetos[engine] = pos;
1445 CLAMP( &magnetos[engine], 0, 3 );
1451 FGControls::move_magnetos( int engine, int amt )
1453 if ( engine == ALL_ENGINES ) {
1454 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1456 CLAMP( &magnetos[i], 0, 3 );
1459 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1460 magnetos[engine] += amt;
1461 CLAMP( &magnetos[engine], 0, 3 );
1467 FGControls::set_nitrous_injection( int engine, bool val )
1469 if ( engine == ALL_ENGINES ) {
1470 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1471 nitrous_injection[i] = val;
1474 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1475 nitrous_injection[engine] = val;
1482 FGControls::set_cowl_flaps_norm( int engine, double pos )
1484 if ( engine == ALL_ENGINES ) {
1485 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1486 cowl_flaps_norm[i] = pos;
1487 CLAMP( &cowl_flaps_norm[i], 0.0, 1.0 );
1490 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1491 cowl_flaps_norm[engine] = pos;
1492 CLAMP( &cowl_flaps_norm[engine], 0.0, 1.0 );
1498 FGControls::move_cowl_flaps_norm( int engine, double amt )
1500 if ( engine == ALL_ENGINES ) {
1501 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1502 cowl_flaps_norm[i] += amt;
1503 CLAMP( &cowl_flaps_norm[i], 0.0, 1.0 );
1506 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1507 cowl_flaps_norm[engine] += amt;
1508 CLAMP( &cowl_flaps_norm[engine], 0.0, 1.0 );
1514 FGControls::set_feather( int engine, bool val )
1516 if ( engine == ALL_ENGINES ) {
1517 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1521 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1522 feather[engine] = val;
1528 FGControls::set_ignition( int engine, int pos )
1530 if ( engine == ALL_ENGINES ) {
1531 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1533 CLAMP( &ignition[i], 0, 3 );
1536 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1537 ignition[engine] = pos;
1538 CLAMP( &ignition[engine], 0, 3 );
1544 FGControls::set_augmentation( int engine, bool val )
1546 if ( engine == ALL_ENGINES ) {
1547 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1548 augmentation[i] = val;
1551 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1552 augmentation[engine] = val;
1558 FGControls::set_reverser( int engine, bool val )
1560 if ( engine == ALL_ENGINES ) {
1561 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1565 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1566 reverser[engine] = val;
1572 FGControls::set_water_injection( int engine, bool val )
1574 if ( engine == ALL_ENGINES ) {
1575 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1576 water_injection[i] = val;
1579 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1580 water_injection[engine] = val;
1586 FGControls::set_condition( int engine, double val )
1588 if ( engine == ALL_ENGINES ) {
1589 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1591 CLAMP( &condition[i], 0.0, 1.0 );
1594 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1595 condition[engine] = val;
1596 CLAMP( &condition[engine], 0.0, 1.0 );
1602 FGControls::set_dump_valve( bool val )
1609 FGControls::set_fuel_selector( int tank, bool pos )
1611 if ( tank == ALL_TANKS ) {
1612 for ( int i = 0; i < MAX_TANKS; i++ ) {
1613 fuel_selector[i] = pos;
1616 if ( (tank >= 0) && (tank < MAX_TANKS) ) {
1617 fuel_selector[tank] = pos;
1623 FGControls::set_to_engine( int tank, int engine )
1625 if ( tank == ALL_TANKS ) {
1626 for ( int i = 0; i < MAX_TANKS; i++ ) {
1627 to_engine[i] = engine;
1630 if ( (tank >= 0) && (tank < MAX_TANKS) ) {
1631 to_engine[tank] = engine;
1637 FGControls::set_to_tank( int tank, int dest_tank )
1639 if ( tank == ALL_TANKS ) {
1640 for ( int i = 0; i < MAX_TANKS; i++ ) {
1641 to_tank[i] = dest_tank;
1644 if ( (tank >= 0) && (tank < MAX_TANKS) ) {
1645 to_tank[tank] = dest_tank;
1651 FGControls::set_boost_pump( int index, bool val )
1653 if ( index == -1 ) {
1654 for ( int i = 0; i < (MAX_TANKS * MAX_BOOSTPUMPS); i++ ) {
1655 boost_pump[i] = val;
1658 if ( (index >= 0) && (index < (MAX_TANKS * MAX_BOOSTPUMPS)) ) {
1659 boost_pump[index] = val;
1666 FGControls::set_brake_left( double pos )
1669 CLAMP(&brake_left, 0.0, 1.0);
1673 FGControls::move_brake_left( double amt )
1676 CLAMP( &brake_left, 0.0, 1.0 );
1680 FGControls::set_brake_right( double pos )
1683 CLAMP(&brake_right, 0.0, 1.0);
1687 FGControls::move_brake_right( double amt )
1690 CLAMP( &brake_right, 0.0, 1.0 );
1694 FGControls::set_copilot_brake_left( double pos )
1696 copilot_brake_left = pos;
1697 CLAMP(&brake_left, 0.0, 1.0);
1701 FGControls::set_copilot_brake_right( double pos )
1703 copilot_brake_right = pos;
1704 CLAMP(&brake_right, 0.0, 1.0);
1708 FGControls::set_brake_parking( double pos )
1710 brake_parking = pos;
1711 CLAMP(&brake_parking, 0.0, 1.0);
1715 FGControls::set_steering( double angle )
1718 CLAMP(&steering, -80.0, 80.0);
1722 FGControls::set_nose_wheel_steering( bool nws )
1724 nose_wheel_steering = nws;
1728 FGControls::move_steering( double angle )
1731 CLAMP(&steering, -80.0, 80.0);
1735 FGControls::set_gear_down( bool gear )
1741 FGControls::set_antiskid( bool state )
1747 FGControls::set_tailhook( bool state )
1753 FGControls::set_launchbar( bool state )
1759 FGControls::set_catapult_launch_cmd( bool state )
1761 catapult_launch_cmd = state;
1765 FGControls::set_tailwheel_lock( bool state )
1767 tailwheel_lock = state;
1772 FGControls::set_alternate_extension( int wheel, bool val )
1774 if ( wheel == ALL_WHEELS ) {
1775 for ( int i = 0; i < MAX_WHEELS; i++ ) {
1776 alternate_extension[i] = val;
1779 if ( (wheel >= 0) && (wheel < MAX_WHEELS) ) {
1780 alternate_extension[wheel] = val;
1786 FGControls::set_wing_heat( bool state )
1792 FGControls::set_pitot_heat( bool state )
1798 FGControls::set_wiper( int state )
1804 FGControls::set_window_heat( bool state )
1806 window_heat = state;
1810 FGControls::set_carb_heat( int engine, bool val )
1812 if ( engine == ALL_ENGINES ) {
1813 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1817 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1818 carb_heat[engine] = val;
1824 FGControls::set_inlet_heat( int engine, bool val )
1826 if ( engine == ALL_ENGINES ) {
1827 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1828 inlet_heat[i] = val;
1831 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1832 inlet_heat[engine] = val;
1838 FGControls::set_engine_pump( int system, bool val )
1840 if ( system == ALL_HYD_SYSTEMS ) {
1841 for ( int i = 0; i < MAX_HYD_SYSTEMS; i++ ) {
1842 engine_pump[i] = val;
1845 if ( (system >= 0) && (system < MAX_HYD_SYSTEMS) ) {
1846 engine_pump[system] = val;
1852 FGControls::set_electric_pump( int system, bool val )
1854 if ( system == ALL_HYD_SYSTEMS ) {
1855 for ( int i = 0; i < MAX_HYD_SYSTEMS; i++ ) {
1856 electric_pump[i] = val;
1859 if ( (system >= 0) && (system < MAX_HYD_SYSTEMS) ) {
1860 electric_pump[system] = val;
1866 FGControls::set_battery_switch( bool state )
1868 battery_switch = state;
1872 FGControls::set_external_power( bool state )
1874 external_power = state;
1878 FGControls::set_APU_generator( bool state )
1880 APU_generator = state;
1884 FGControls::set_generator_breaker( int engine, bool val )
1886 if ( engine == ALL_ENGINES ) {
1887 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1888 generator_breaker[i] = val;
1891 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1892 generator_breaker[engine] = val;
1898 FGControls::set_bus_tie( int engine, bool val )
1900 if ( engine == ALL_ENGINES ) {
1901 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1905 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1906 bus_tie[engine] = val;
1912 FGControls::set_APU_bleed( bool state )
1918 FGControls::set_engine_bleed( int engine, bool val )
1920 if ( engine == ALL_ENGINES ) {
1921 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1922 engine_bleed[i] = val;
1925 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1926 engine_bleed[engine] = val;
1932 FGControls::set_mode( int new_mode )
1938 FGControls::set_outflow_valve( double pos )
1940 outflow_valve = pos;
1941 CLAMP( &outflow_valve, 0.0, 1.0 );
1945 FGControls::move_outflow_valve( double amt )
1947 outflow_valve += amt;
1948 CLAMP( &outflow_valve, 0.0, 1.0 );
1952 FGControls::set_dump( bool state )
1958 FGControls::set_pack_on( int pack, bool val )
1960 if ( pack == ALL_PACKS ) {
1961 for ( int i = 0; i < MAX_PACKS; i++ ) {
1965 if ( (pack >= 0) && (pack < MAX_PACKS) ) {
1966 pack_on[pack] = val;
1972 FGControls::set_landing_lights( bool state )
1974 landing_lights = state;
1978 FGControls::set_turn_off_lights( bool state )
1980 turn_off_lights = state;
1984 FGControls::set_taxi_light( bool state )
1990 FGControls::set_logo_lights( bool state )
1992 logo_lights = state;
1996 FGControls::set_nav_lights( bool state )
2002 FGControls::set_beacon( bool state )
2008 FGControls::set_strobe( bool state )
2014 FGControls::set_panel_norm( double intensity )
2016 panel_norm = intensity;
2017 CLAMP( &panel_norm, 0.0, 1.0 );
2021 FGControls::move_panel_norm( double amt )
2024 CLAMP( &panel_norm, 0.0, 1.0 );
2028 FGControls::set_instruments_norm( double intensity )
2030 instruments_norm = intensity;
2031 CLAMP( &instruments_norm, 0.0, 1.0 );
2035 FGControls::move_instruments_norm( double amt )
2037 instruments_norm += amt;
2038 CLAMP( &instruments_norm, 0.0, 1.0 );
2042 FGControls::set_dome_norm( double intensity )
2044 dome_norm = intensity;
2045 CLAMP( &dome_norm, 0.0, 1.0 );
2049 FGControls::move_dome_norm( double amt )
2052 CLAMP( &dome_norm, 0.0, 1.0 );
2056 FGControls::set_master_arm( bool val )
2062 FGControls::set_station_select( int station )
2064 station_select = station;
2065 CLAMP( &station_select, 0, MAX_STATIONS );
2069 FGControls::set_release_ALL( bool val )
2075 FGControls::set_stick_size( int station, int size )
2077 if ( station == ALL_STATIONS ) {
2078 for ( int i = 0; i < MAX_STATIONS; i++ ) {
2079 stick_size[i] = size;
2080 CLAMP( &stick_size[i], 1, 20 );
2083 if ( (station >= 0) && (station < MAX_STATIONS) ) {
2084 stick_size[station] = size;
2085 CLAMP( &stick_size[station], 1, 20 );
2091 FGControls::set_release_stick( int station, bool val )
2093 if ( station == ALL_STATIONS ) {
2094 for ( int i = 0; i < MAX_STATIONS; i++ ) {
2095 release_stick[i] = val;
2098 if ( (station >= 0) && (station < MAX_STATIONS) ) {
2099 release_stick[station] = val;
2105 FGControls::set_release_all( int station, bool val )
2107 if ( station == ALL_STATIONS ) {
2108 for ( int i = 0; i < MAX_STATIONS; i++ ) {
2109 release_all[i] = val;
2112 if ( (station >= 0) && (station < MAX_STATIONS) ) {
2113 release_all[station] = val;
2119 FGControls::set_jettison_all( int station, bool val )
2121 if ( station == ALL_STATIONS ) {
2122 for ( int i = 0; i < MAX_STATIONS; i++ ) {
2123 jettison_all[i] = val;
2126 if ( (station >= 0) && (station < MAX_STATIONS) ) {
2127 jettison_all[station] = val;
2133 FGControls::set_vertical_adjust( double pos )
2135 vertical_adjust = pos;
2136 CLAMP( &vertical_adjust, -1.0, 1.0 );
2140 FGControls::move_vertical_adjust( double amt )
2142 vertical_adjust += amt;
2143 CLAMP( &vertical_adjust, -1.0, 1.0 );
2147 FGControls::set_fore_aft_adjust( double pos )
2149 fore_aft_adjust = pos;
2150 CLAMP( &fore_aft_adjust, -1.0, 1.0 );
2154 FGControls::move_fore_aft_adjust( double amt )
2156 fore_aft_adjust += amt;
2157 CLAMP( &fore_aft_adjust, -1.0, 1.0 );
2161 FGControls::set_ejection_seat( int which_seat, bool val )
2163 if ( which_seat == ALL_EJECTION_SEATS ) {
2164 for ( int i = 0; i < MAX_EJECTION_SEATS; i++ ) {
2168 if ( (which_seat >= 0) && (which_seat <= MAX_EJECTION_SEATS) ) {
2169 if ( eseat_status[which_seat] == SEAT_SAFED ||
2170 eseat_status[which_seat] == SEAT_FAIL )
2172 // we can never eject if SEAT_SAFED or SEAT_FAIL
2176 eject[which_seat] = val;
2182 FGControls::set_eseat_status( int which_seat, int val )
2184 if ( which_seat == ALL_EJECTION_SEATS ) {
2185 for ( int i = 0; i < MAX_EJECTION_SEATS; i++ ) {
2186 eseat_status[i] = val;
2189 if ( (which_seat >=0) && (which_seat <= MAX_EJECTION_SEATS) ) {
2190 eseat_status[which_seat] = val;
2196 FGControls::set_cmd_selector_valve( int val )
2198 cmd_selector_valve = val;
2203 FGControls::set_off_start_run( int pos )
2205 off_start_run = pos;
2206 CLAMP( &off_start_run, 0, 3 );
2210 FGControls::set_APU_fire_switch( bool val )
2212 APU_fire_switch = val;
2216 FGControls::set_autothrottle_arm( bool val )
2218 autothrottle_arm = val;
2222 FGControls::set_autothrottle_engage( bool val )
2224 autothrottle_engage = val;
2228 FGControls::set_heading_select( double heading )
2230 heading_select = heading;
2231 CLAMP( &heading_select, 0.0, 360.0 );
2235 FGControls::move_heading_select( double amt )
2237 heading_select += amt;
2238 CLAMP( &heading_select, 0.0, 360.0 );
2242 FGControls::set_altitude_select( double altitude )
2244 altitude_select = altitude;
2245 CLAMP( &altitude_select, -1000.0, 100000.0 );
2249 FGControls::move_altitude_select( double amt )
2251 altitude_select += amt;
2252 CLAMP( &altitude_select, -1000.0, 100000.0 );
2256 FGControls::set_bank_angle_select( double angle )
2258 bank_angle_select = angle;
2259 CLAMP( &bank_angle_select, 10.0, 30.0 );
2263 FGControls::move_bank_angle_select( double amt )
2265 bank_angle_select += amt;
2266 CLAMP( &bank_angle_select, 10.0, 30.0 );
2270 FGControls::set_vertical_speed_select( double speed )
2272 vertical_speed_select = speed;
2273 CLAMP( &vertical_speed_select, -3000.0, 4000.0 );
2277 FGControls::move_vertical_speed_select( double amt )
2279 vertical_speed_select += amt;
2280 CLAMP( &vertical_speed_select, -3000.0, 4000.0 );
2284 FGControls::set_speed_select( double speed )
2286 speed_select = speed;
2287 CLAMP( &speed_select, 60.0, 400.0 );
2291 FGControls::move_speed_select( double amt )
2293 speed_select += amt;
2294 CLAMP( &speed_select, 60.0, 400.0 );
2298 FGControls::set_mach_select( double mach )
2301 CLAMP( &mach_select, 0.4, 4.0 );
2305 FGControls::move_mach_select( double amt )
2308 CLAMP( &mach_select, 0.4, 4.0 );
2312 FGControls::set_vertical_mode( int mode )
2314 vertical_mode = mode;
2315 CLAMP( &vertical_mode, 0, 4 );
2319 FGControls::set_lateral_mode( int mode )
2321 lateral_mode = mode;
2322 CLAMP( &lateral_mode, 0, 4 );
2326 FGControls::set_autopilot_engage( int ap, bool val )
2328 if ( ap == ALL_AUTOPILOTS ) {
2329 for ( int i = 0; i < MAX_AUTOPILOTS; i++ ) {
2330 autopilot_engage[i] = val;
2333 if ( (ap >= 0) && (ap < MAX_AUTOPILOTS) ) {
2334 autopilot_engage[ap] = val;