1 // controls.cxx -- defines a standard interface to all flight sim controls
3 // Written by Curtis Olson, started May 1997.
5 // Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include <simgear/compiler.h>
25 #include <simgear/debug/logstream.hxx>
26 #include <Main/fg_props.hxx>
28 #include "controls.hxx"
31 static const int MAX_NAME_LEN = 128;
34 ////////////////////////////////////////////////////////////////////////
35 // Inline utility methods.
36 ////////////////////////////////////////////////////////////////////////
39 CLAMP(double *x, double min, double max )
41 if ( *x < min ) { *x = min; }
42 if ( *x > max ) { *x = max; }
46 CLAMP(int *i, int min, int max )
48 if ( *i < min ) { *i = min; }
49 if ( *i > max ) { *i = max; }
53 ////////////////////////////////////////////////////////////////////////
54 // Implementation of FGControls.
55 ////////////////////////////////////////////////////////////////////////
58 FGControls::FGControls() :
73 throttle_idle( true ),
80 tailwheel_lock( false ),
85 battery_switch( true ),
86 external_power( false ),
87 APU_generator( false ),
97 instruments_norm( 0.0 ),
101 release_ALL( false ),
102 vertical_adjust( 0.0 ),
103 fore_aft_adjust( 0.0 ),
106 APU_fire_switch( false ),
107 autothrottle_arm( false ),
108 autothrottle_engage( false ),
109 heading_select( 0.0 ),
110 altitude_select( 50000.0 ),
111 bank_angle_select( 30.0 ),
112 vertical_speed_select( 0.0 ),
121 void FGControls::reset_all()
124 set_aileron_trim( 0.0 );
126 set_elevator_trim( 0.0 );
128 set_rudder_trim( 0.0 );
131 set_speedbrake( 0.0 );
132 set_wing_sweep( 0.0 );
135 set_throttle( ALL_ENGINES, 0.0 );
136 set_starter( ALL_ENGINES, false );
137 set_magnetos( ALL_ENGINES, 0 );
138 set_fuel_pump( ALL_ENGINES, false );
139 set_fire_switch( ALL_ENGINES, false );
140 set_fire_bottle_discharge( ALL_ENGINES, false );
141 set_cutoff( ALL_ENGINES, true );
142 set_nitrous_injection( ALL_ENGINES, false );
143 set_cowl_flaps_norm( ALL_ENGINES, 1.0 );
144 set_feather( ALL_ENGINES, false );
145 set_ignition( ALL_ENGINES, false );
146 set_augmentation( ALL_ENGINES, false );
147 set_reverser( ALL_ENGINES, false );
148 set_water_injection( ALL_ENGINES, false );
149 set_condition( ALL_ENGINES, 0 );
150 throttle_idle = true;
151 set_fuel_selector( ALL_TANKS, true );
156 tailwheel_lock = false;
157 set_carb_heat( ALL_ENGINES, false );
158 set_inlet_heat( ALL_ENGINES, false );
163 set_engine_pump( ALL_HYD_SYSTEMS, true );
164 set_electric_pump( ALL_HYD_SYSTEMS, true );
165 landing_lights = false;
166 turn_off_lights = false;
169 APU_fire_switch = false;
170 autothrottle_arm = false;
171 autothrottle_engage = false;
172 set_autopilot_engage( ALL_AUTOPILOTS, false );
177 FGControls::~FGControls() {
184 throttle_idle = true;
185 for ( int engine = 0; engine < MAX_ENGINES; engine++ ) {
186 throttle[engine] = 0.0;
187 mixture[engine] = 1.0;
188 fuel_pump[engine] = false;
189 prop_advance[engine] = 1.0;
190 magnetos[engine] = 0;
191 starter[engine] = false;
192 ignition[engine] = false;
193 fire_switch[engine] = false;
194 cutoff[engine] = true;
195 augmentation[engine] = false;
196 reverser[engine] = false;
197 water_injection[engine] = false;
198 nitrous_injection[engine] = false;
199 condition[engine] = 0;
202 for ( int wheel = 0; wheel < MAX_WHEELS; wheel++ ) {
204 alternate_extension[wheel] = false;
207 auto_coordination = fgGetNode("/sim/auto-coordination", true);
217 fgTie("/controls/flight/aileron", this,
218 &FGControls::get_aileron, &FGControls::set_aileron);
219 fgSetArchivable("/controls/flight/aileron");
221 fgTie("/controls/flight/aileron-trim", this,
222 &FGControls::get_aileron_trim, &FGControls::set_aileron_trim);
223 fgSetArchivable("/controls/flight/aileron-trim");
225 fgTie("/controls/flight/elevator", this,
226 &FGControls::get_elevator, &FGControls::set_elevator);
227 fgSetArchivable("/controls/flight/elevator");
229 fgTie("/controls/flight/elevator-trim", this,
230 &FGControls::get_elevator_trim, &FGControls::set_elevator_trim);
231 fgSetArchivable("/controls/flight/elevator-trim");
233 fgTie("/controls/flight/rudder", this,
234 &FGControls::get_rudder, &FGControls::set_rudder);
235 fgSetArchivable("/controls/flight/rudder");
237 fgTie("/controls/flight/rudder-trim", this,
238 &FGControls::get_rudder_trim, &FGControls::set_rudder_trim);
239 fgSetArchivable("/controls/flight/rudder-trim");
241 fgTie("/controls/flight/flaps", this,
242 &FGControls::get_flaps, &FGControls::set_flaps);
243 fgSetArchivable("/controls/flight/flaps");
245 fgTie("/controls/flight/slats", this,
246 &FGControls::get_slats, &FGControls::set_slats);
247 fgSetArchivable("/controls/flight/slats");
249 fgTie("/controls/flight/BLC", this,
250 &FGControls::get_BLC, &FGControls::set_BLC);
251 fgSetArchivable("/controls/flight/BLC");
253 fgTie("/controls/flight/spoilers", this,
254 &FGControls::get_spoilers, &FGControls::set_spoilers);
255 fgSetArchivable("/controls/flight/spoilers");
257 fgTie("/controls/flight/speedbrake", this,
258 &FGControls::get_speedbrake, &FGControls::set_speedbrake);
259 fgSetArchivable("/controls/flight/speedbrake");
261 fgTie("/controls/flight/wing-sweep", this,
262 &FGControls::get_wing_sweep, &FGControls::set_wing_sweep);
263 fgSetArchivable("/controls/flight/wing-sweep");
265 fgTie("/controls/flight/wing-fold", this,
266 &FGControls::get_wing_fold, &FGControls::set_wing_fold);
267 fgSetArchivable("/controls/flight/wing-fold");
269 fgTie("/controls/flight/drag-chute", this,
270 &FGControls::get_drag_chute, &FGControls::set_drag_chute);
271 fgSetArchivable("/controls/flight/drag-chute");
274 fgTie("/controls/engines/throttle_idle", this,
275 &FGControls::get_throttle_idle, &FGControls::set_throttle_idle);
276 fgSetArchivable("/controls/engines/throttle_idle");
278 for (index = 0; index < MAX_ENGINES; index++) {
279 char name[MAX_NAME_LEN];
280 snprintf(name, MAX_NAME_LEN,
281 "/controls/engines/engine[%d]/throttle", index);
282 fgTie(name, this, index,
283 &FGControls::get_throttle, &FGControls::set_throttle);
284 fgSetArchivable(name);
286 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/starter", index);
287 fgTie(name, this, index,
288 &FGControls::get_starter, &FGControls::set_starter);
289 fgSetArchivable(name);
291 snprintf(name, MAX_NAME_LEN,
292 "/controls/engines/engine[%d]/fuel-pump", index);
293 fgTie(name, this, index,
294 &FGControls::get_fuel_pump, &FGControls::set_fuel_pump);
295 fgSetArchivable(name);
297 snprintf(name, MAX_NAME_LEN,
298 "/controls/engines/engine[%d]/fire-switch", index);
299 fgTie(name, this, index,
300 &FGControls::get_fire_switch, &FGControls::set_fire_switch);
301 fgSetArchivable(name);
303 snprintf(name, MAX_NAME_LEN,
304 "/controls/engines/engine[%d]/fire-bottle-discharge", index);
305 fgTie(name, this, index,
306 &FGControls::get_fire_bottle_discharge,
307 &FGControls::set_fire_bottle_discharge);
308 fgSetArchivable(name);
310 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/cutoff", index);
311 fgTie(name, this, index,
312 &FGControls::get_cutoff, &FGControls::set_cutoff);
313 fgSetArchivable(name);
315 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/mixture", index);
316 fgTie(name, this, index,
317 &FGControls::get_mixture, &FGControls::set_mixture);
318 fgSetArchivable(name);
320 snprintf(name, MAX_NAME_LEN,
321 "/controls/engines/engine[%d]/propeller-pitch", index);
322 fgTie(name, this, index,
323 &FGControls::get_prop_advance,
324 &FGControls::set_prop_advance);
325 fgSetArchivable(name);
327 snprintf(name, MAX_NAME_LEN,
328 "/controls/engines/engine[%d]/magnetos", index);
329 fgTie(name, this, index,
330 &FGControls::get_magnetos, &FGControls::set_magnetos);
331 fgSetArchivable(name);
333 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/WEP", index);
334 fgTie(name, this, index,
335 &FGControls::get_nitrous_injection,
336 &FGControls::set_nitrous_injection);
337 fgSetArchivable(name);
339 snprintf(name, MAX_NAME_LEN,
340 "/controls/engines/engine[%d]/cowl-flaps-norm", index);
341 fgTie(name, this, index,
342 &FGControls::get_cowl_flaps_norm,
343 &FGControls::set_cowl_flaps_norm);
344 fgSetArchivable(name);
346 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/feather", index);
347 fgTie(name, this, index,
348 &FGControls::get_feather, &FGControls::set_feather);
349 fgSetArchivable(name);
351 snprintf(name, MAX_NAME_LEN,
352 "/controls/engines/engine[%d]/ignition", index);
353 fgTie(name, this, index,
354 &FGControls::get_ignition, &FGControls::set_ignition);
355 fgSetArchivable(name);
357 snprintf(name, MAX_NAME_LEN,
358 "/controls/engines/engine[%d]/augmentation", index);
359 fgTie(name, this, index,
360 &FGControls::get_augmentation,
361 &FGControls::set_augmentation);
362 fgSetArchivable(name);
364 snprintf(name, MAX_NAME_LEN,
365 "/controls/engines/engine[%d]/reverser", index);
366 fgTie(name, this, index,
367 &FGControls::get_reverser, &FGControls::set_reverser);
368 fgSetArchivable(name);
370 snprintf(name, MAX_NAME_LEN,
371 "/controls/engines/engine[%d]/water-injection", index);
372 fgTie(name, this, index,
373 &FGControls::get_water_injection,
374 &FGControls::set_water_injection);
375 fgSetArchivable(name);
377 snprintf(name, MAX_NAME_LEN,
378 "/controls/engines/engine[%d]/condition", index);
379 fgTie(name, this, index,
380 &FGControls::get_condition, &FGControls::set_condition);
381 fgSetArchivable(name);
385 fgTie("/controls/fuel/dump-valve", this,
386 &FGControls::get_dump_valve, &FGControls::set_dump_valve);
387 fgSetArchivable("/controls/fuel/dump-valve");
389 for (index = 0; index < MAX_TANKS; index++) {
390 char name[MAX_NAME_LEN];
391 snprintf(name, MAX_NAME_LEN,
392 "/controls/fuel/tank[%d]/fuel_selector", index);
393 fgTie(name, this, index,
394 &FGControls::get_fuel_selector,
395 &FGControls::set_fuel_selector);
396 fgSetArchivable(name);
398 snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_engine", index);
399 fgTie(name, this, index,
400 &FGControls::get_to_engine, &FGControls::set_to_engine);
401 fgSetArchivable(name);
403 snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_tank", index);
404 fgTie(name, this, index,
405 &FGControls::get_to_tank, &FGControls::set_to_tank);
406 fgSetArchivable(name);
408 for (i = 0; i < MAX_BOOSTPUMPS; i++) {
409 char name[MAX_NAME_LEN];
410 snprintf(name, MAX_NAME_LEN,
411 "/controls/fuel/tank[%d]/boost-pump[%d]", index, i);
412 fgTie(name, this, index * 2 + i,
413 &FGControls::get_boost_pump,
414 &FGControls::set_boost_pump);
415 fgSetArchivable(name);
420 fgTie("/controls/gear/parking-brake", this,
421 &FGControls::get_parking_brake,
422 &FGControls::set_parking_brake);
423 fgSetArchivable("/controls/gear/parking-brake");
425 fgTie("/controls/gear/steering", this,
426 &FGControls::get_steering, &FGControls::set_steering);
427 fgSetArchivable("/controls/gear/steering");
429 fgTie("/controls/gear/gear-down", this,
430 &FGControls::get_gear_down, &FGControls::set_gear_down);
431 fgSetArchivable("/controls/gear/gear-down");
433 fgTie("/controls/gear/antiskid", this,
434 &FGControls::get_antiskid, &FGControls::set_antiskid);
435 fgSetArchivable("/controls/gear/antiskid");
437 fgTie("/controls/gear/tailhook", this,
438 &FGControls::get_tailhook, &FGControls::set_tailhook);
439 fgSetArchivable("/controls/gear/tailhook");
441 fgTie("/controls/gear/tailwheel-lock", this,
442 &FGControls::get_tailwheel_lock,
443 &FGControls::set_tailwheel_lock);
444 fgSetArchivable("/controls/gear/tailwheel-lock");
446 for (index = 0; index < MAX_WHEELS; index++) {
447 char name[MAX_NAME_LEN];
448 snprintf(name, MAX_NAME_LEN, "/controls/gear/wheel[%d]/brake", index);
449 fgTie(name, this, index,
450 &FGControls::get_brake, &FGControls::set_brake);
451 fgSetArchivable(name);
453 snprintf(name, MAX_NAME_LEN,
454 "/controls/gear/wheel[%d]/alternate-extension", index);
455 fgTie(name, this, index,
456 &FGControls::get_alternate_extension,
457 &FGControls::set_alternate_extension);
458 fgSetArchivable(name);
462 fgTie("/controls/anti-ice/wing-heat", this,
463 &FGControls::get_wing_heat, &FGControls::set_wing_heat);
464 fgSetArchivable("/controls/anti-ice/wing-heat");
466 fgTie("/controls/anti-ice/pitot-heat", this,
467 &FGControls::get_pitot_heat, &FGControls::set_pitot_heat);
468 fgSetArchivable("/controls/anti-ice/pitot-heat");
470 fgTie("/controls/anti-ice/wiper", this,
471 &FGControls::get_wiper, &FGControls::set_wiper);
472 fgSetArchivable("/controls/anti-ice/wiper");
474 fgTie("/controls/anti-ice/window-heat", this,
475 &FGControls::get_window_heat, &FGControls::set_window_heat);
476 fgSetArchivable("/controls/anti-ice/window-heat");
478 for (index = 0; index < MAX_ENGINES; index++) {
479 char name[MAX_NAME_LEN];
480 snprintf(name, MAX_NAME_LEN,
481 "/controls/anti-ice/engine[%d]/carb-heat", index);
482 fgTie(name, this, index,
483 &FGControls::get_carb_heat, &FGControls::set_carb_heat);
484 fgSetArchivable(name);
486 snprintf(name, MAX_NAME_LEN,
487 "/controls/anti-ice/engine[%d]/inlet-heat", index);
488 fgTie(name, this, index,
489 &FGControls::get_inlet_heat, &FGControls::set_inlet_heat);
490 fgSetArchivable(name);
494 for (index = 0; index < MAX_HYD_SYSTEMS; index++) {
495 char name[MAX_NAME_LEN];
496 snprintf(name, MAX_NAME_LEN,
497 "/controls/hydraulic/system[%d]/engine-pump", index);
498 fgTie(name, this, index,
499 &FGControls::get_engine_pump, &FGControls::set_engine_pump);
500 fgSetArchivable(name);
502 snprintf(name, MAX_NAME_LEN,
503 "/controls/hydraulic/system[%d]/electric-pump", index);
504 fgTie(name, this, index,
505 &FGControls::get_electric_pump,
506 &FGControls::set_electric_pump);
507 fgSetArchivable(name);
511 fgTie("/controls/electric/battery-switch", this,
512 &FGControls::get_battery_switch,
513 &FGControls::set_battery_switch);
514 fgSetArchivable("/controls/electric/battery-switch");
516 fgTie("/controls/electric/external-power", this,
517 &FGControls::get_external_power,
518 &FGControls::set_external_power);
519 fgSetArchivable("/controls/electric/external-power");
521 fgTie("/controls/electric/APU-generator", this,
522 &FGControls::get_APU_generator,
523 &FGControls::set_APU_generator);
524 fgSetArchivable("/controls/electric/APU-generator");
526 for (index = 0; index < MAX_ENGINES; index++) {
527 char name[MAX_NAME_LEN];
528 snprintf(name, MAX_NAME_LEN,
529 "/controls/electric/engine[%d]/generator", index);
530 fgTie(name, this, index,
531 &FGControls::get_generator_breaker,
532 &FGControls::set_generator_breaker);
533 fgSetArchivable(name);
535 snprintf(name, MAX_NAME_LEN,
536 "/controls/electric/engine[%d]/bus-tie", index);
537 fgTie(name, this, index,
538 &FGControls::get_bus_tie,
539 &FGControls::set_bus_tie);
540 fgSetArchivable(name);
544 fgTie("/controls/pneumatic/APU-bleed", this,
545 &FGControls::get_APU_bleed,
546 &FGControls::set_APU_bleed);
547 fgSetArchivable("/controls/pneumatic/APU-bleed");
549 for (index = 0; index < MAX_ENGINES; index++) {
550 char name[MAX_NAME_LEN];
551 snprintf(name, MAX_NAME_LEN,
552 "/controls/pneumatic/engine[%d]/bleed", index);
553 fgTie(name, this, index,
554 &FGControls::get_engine_bleed,
555 &FGControls::set_engine_bleed);
556 fgSetArchivable(name);
560 fgTie("/controls/pressurization/mode", this,
561 &FGControls::get_mode, &FGControls::set_mode);
562 fgSetArchivable("/controls/pressurization/mode");
564 fgTie("/controls/pressurization/dump", this,
565 &FGControls::get_dump, &FGControls::set_dump);
566 fgSetArchivable("/controls/pressurization/dump");
568 fgTie("/controls/pressurization/outflow-valve", this,
569 &FGControls::get_outflow_valve,
570 &FGControls::set_outflow_valve);
571 fgSetArchivable("/controls/pressurization/outflow-valve");
573 for (index = 0; index < MAX_PACKS; index++) {
574 char name[MAX_NAME_LEN];
575 snprintf(name, MAX_NAME_LEN,
576 "/controls/pressurization/pack[%d]/pack-on", index);
577 fgTie(name, this, index,
578 &FGControls::get_pack_on, &FGControls::set_pack_on);
579 fgSetArchivable(name);
583 fgTie("/controls/lighting/landing-lights", this,
584 &FGControls::get_landing_lights,
585 &FGControls::set_landing_lights);
586 fgSetArchivable("/controls/lighting/landing-lights");
588 fgTie("/controls/lighting/turn-off-lights", this,
589 &FGControls::get_turn_off_lights,
590 &FGControls::set_turn_off_lights);
591 fgSetArchivable("/controls/lighting/turn-off-lights");
593 fgTie("/controls/lighting/taxi-light", this,
594 &FGControls::get_taxi_light, &FGControls::set_taxi_light);
595 fgSetArchivable("/controls/lighting/taxi-light");
597 fgTie("/controls/lighting/logo-lights", this,
598 &FGControls::get_logo_lights, &FGControls::set_logo_lights);
599 fgSetArchivable("/controls/lighting/logo-lights");
601 fgTie("/controls/lighting/nav-lights", this,
602 &FGControls::get_nav_lights, &FGControls::set_nav_lights);
603 fgSetArchivable("/controls/lighting/nav-lights");
605 fgTie("/controls/lighting/beacon", this,
606 &FGControls::get_beacon, &FGControls::set_beacon);
607 fgSetArchivable("/controls/lighting/beacon");
609 fgTie("/controls/lighting/strobe", this,
610 &FGControls::get_strobe, &FGControls::set_strobe);
611 fgSetArchivable("/controls/lighting/strobe");
613 fgTie("/controls/lighting/panel-norm", this,
614 &FGControls::get_panel_norm, &FGControls::set_panel_norm);
615 fgSetArchivable("/controls/lighting/panel-norm");
617 fgTie("/controls/lighting/instruments-norm", this,
618 &FGControls::get_instruments_norm,
619 &FGControls::set_instruments_norm);
620 fgSetArchivable("/controls/lighting/instruments-norm");
622 fgTie("/controls/lighting/dome-norm", this,
623 &FGControls::get_dome_norm, &FGControls::set_dome_norm);
624 fgSetArchivable("/controls/lighting/dome-norm");
626 #ifdef FG_HAVE_ARMAMENT
628 fgTie("/controls/armament/master-arm", this,
629 &FGControls::get_master_arm, &FGControls::set_master_arm);
630 fgSetArchivable("/controls/armament/master-arm");
632 fgTie("/controls/armament/station-select", this,
633 &FGControls::get_station_select,
634 &FGControls::set_station_select);
635 fgSetArchivable("/controls/armament/station-select");
637 fgTie("/controls/armament/release-all", this,
638 &FGControls::get_release_ALL,
639 &FGControls::set_release_ALL);
640 fgSetArchivable("/controls/armament/release-all");
642 for (index = 0; index < MAX_STATIONS; index++) {
643 char name[MAX_NAME_LEN];
644 snprintf(name, MAX_NAME_LEN,
645 "/controls/armament/station[%d]/stick-size", index);
646 fgTie(name, this, index,
647 &FGControls::get_stick_size, &FGControls::set_stick_size);
648 fgSetArchivable(name);
650 snprintf(name, MAX_NAME_LEN,
651 "/controls/armament/station[%d]/release-stick", index);
652 fgTie(name, this, index,
653 &FGControls::get_release_stick, &FGControls::set_release_stick);
654 fgSetArchivable(name);
656 snprintf(name, MAX_NAME_LEN,
657 "/controls/armament/station[%d]/release-all", index);
658 fgTie(name, this, index,
659 &FGControls::get_release_all, &FGControls::set_release_all);
660 fgSetArchivable(name);
662 snprintf(name, MAX_NAME_LEN,
663 "/controls/armament/station[%d]/jettison-all", index);
664 fgTie(name, this, index,
665 &FGControls::get_jettison_all, &FGControls::set_jettison_all);
666 fgSetArchivable(name);
672 fgTie("/controls/seat/vertical-adjust", this,
673 &FGControls::get_vertical_adjust,
674 &FGControls::set_vertical_adjust);
675 fgSetArchivable("/controls/seat/vertical-adjust");
677 fgTie("/controls/seat/fore-aft-adjust", this,
678 &FGControls::get_fore_aft_adjust,
679 &FGControls::set_fore_aft_adjust);
680 fgSetArchivable("/controls/seat/fore-aft-adjust");
682 fgTie("/controls/seat/eject", this,
683 &FGControls::get_eject, &FGControls::set_eject);
684 fgSetArchivable("/controls/seat/eject");
687 fgTie("/controls/APU/off-start-run", this,
688 &FGControls::get_off_start_run,
689 &FGControls::set_off_start_run);
690 fgSetArchivable("/controls/APU/off-start-run");
692 fgTie("/controls/APU/fire-switch", this,
693 &FGControls::get_APU_fire_switch,
694 &FGControls::set_APU_fire_switch);
695 fgSetArchivable("/controls/APU/fire-switch");
698 for (index = 0; index < MAX_AUTOPILOTS; index++) {
699 char name[MAX_NAME_LEN];
700 snprintf(name, MAX_NAME_LEN,
701 "/controls/autoflight/autopilot[%d]/engage", index);
702 fgTie(name, this, index,
703 &FGControls::get_autopilot_engage,
704 &FGControls::set_autopilot_engage);
705 fgSetArchivable(name);
708 fgTie("/controls/autoflight/autothrottle-arm", this,
709 &FGControls::get_autothrottle_arm,
710 &FGControls::set_autothrottle_arm);
711 fgSetArchivable("/controls/autoflight/autothrottle-arm");
713 fgTie("/controls/autoflight/autothrottle-engage", this,
714 &FGControls::get_autothrottle_engage,
715 &FGControls::set_autothrottle_engage);
716 fgSetArchivable("/controls/autoflight/autothrottle-engage");
718 fgTie("/controls/autoflight/heading-select", this,
719 &FGControls::get_heading_select,
720 &FGControls::set_heading_select);
721 fgSetArchivable("/controls/autoflight/heading-select");
723 fgTie("/controls/autoflight/altitude-select", this,
724 &FGControls::get_altitude_select,
725 &FGControls::set_altitude_select);
726 fgSetArchivable("/controls/autoflight/altitude-select");
728 fgTie("/controls/autoflight/bank-angle-select", this,
729 &FGControls::get_bank_angle_select,
730 &FGControls::set_bank_angle_select);
731 fgSetArchivable("/controls/autoflight/bank-angle-select");
733 fgTie("/controls/autoflight/vertical-speed-select", this,
734 &FGControls::get_vertical_speed_select,
735 &FGControls::set_vertical_speed_select);
736 fgSetArchivable("/controls/autoflight/vertical-speed-select");
738 fgTie("/controls/autoflight/speed-select", this,
739 &FGControls::get_speed_select,
740 &FGControls::set_speed_select);
741 fgSetArchivable("/controls/autoflight/speed-select");
743 fgTie("/controls/autoflight/mach-select", this,
744 &FGControls::get_mach_select,
745 &FGControls::set_mach_select);
746 fgSetArchivable("/controls/autoflight/mach-select");
748 fgTie("/controls/autoflight/vertical-mode", this,
749 &FGControls::get_vertical_mode,
750 &FGControls::set_vertical_mode);
751 fgSetArchivable("/controls/autoflight/vertical-mode");
753 fgTie("/controls/autoflight/lateral-mode", this,
754 &FGControls::get_lateral_mode,
755 &FGControls::set_lateral_mode);
756 fgSetArchivable("/controls/autoflight/lateral-mode");
760 void FGControls::unbind ()
763 //Tie control properties.
764 fgUntie("/controls/flight/aileron");
765 fgUntie("/controls/flight/aileron-trim");
766 fgUntie("/controls/flight/elevator");
767 fgUntie("/controls/flight/elevator-trim");
768 fgUntie("/controls/flight/rudder");
769 fgUntie("/controls/flight/rudder-trim");
770 fgUntie("/controls/flight/flaps");
771 fgUntie("/controls/flight/slats");
772 fgUntie("/controls/flight/BLC");
773 fgUntie("/controls/flight/spoilers");
774 fgUntie("/controls/flight/speedbrake");
775 fgUntie("/controls/flight/wing-sweep");
776 fgUntie("/controls/flight/wing-fold");
777 fgUntie("/controls/flight/drag-chute");
778 for (index = 0; index < MAX_ENGINES; index++) {
779 char name[MAX_NAME_LEN];
780 snprintf(name, MAX_NAME_LEN,
781 "/controls/engines/engine[%d]/throttle", index);
783 snprintf(name, MAX_NAME_LEN,
784 "/controls/engines/engine[%d]/starter", index);
786 snprintf(name, MAX_NAME_LEN,
787 "/controls/engines/engine[%d]/fuel_pump", index);
789 snprintf(name, MAX_NAME_LEN,
790 "/controls/engines/engine[%d]/fire-switch", index);
792 snprintf(name, MAX_NAME_LEN,
793 "/controls/engines/engine[%d]/fire-bottle-discharge", index);
795 snprintf(name, MAX_NAME_LEN,
796 "/controls/engines/engine[%d]/throttle_idle", index);
798 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/cutoff", index);
800 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/mixture", index);
802 snprintf(name, MAX_NAME_LEN,
803 "/controls/engines/engine[%d]/propeller-pitch", index);
805 snprintf(name, MAX_NAME_LEN,
806 "/controls/engines/engine[%d]/magnetos", index);
808 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/WEP", index);
810 snprintf(name, MAX_NAME_LEN,
811 "/controls/engines/engine[%d]/cowl-flaps-norm", index);
813 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/feather", index);
815 snprintf(name, MAX_NAME_LEN,
816 "/controls/engines/engine[%d]/ignition", index);
818 snprintf(name, MAX_NAME_LEN,
819 "/controls/engines/engine[%d]/augmentation", index);
821 snprintf(name, MAX_NAME_LEN,
822 "/controls/engines/engine[%d]/reverser", index);
824 snprintf(name, MAX_NAME_LEN,
825 "/controls/engines/engine[%d]/water-injection", index);
827 snprintf(name, MAX_NAME_LEN,
828 "/controls/engines/engine[%d]/condition", index);
831 fgUntie("/controls/fuel/dump-valve");
832 for (index = 0; index < MAX_TANKS; index++) {
833 char name[MAX_NAME_LEN];
834 snprintf(name, MAX_NAME_LEN,
835 "/controls/fuel/tank[%d]/fuel_selector", index);
837 snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_engine", index);
839 snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_tank", index);
841 for (i = 0; index < MAX_BOOSTPUMPS; i++) {
842 snprintf(name, MAX_NAME_LEN,
843 "/controls/fuel/tank[%d]/boost-pump[%d]", index, i);
847 fgUntie("/controls/gear/parking_brake");
848 fgUntie("/controls/gear/steering");
849 fgUntie("/controls/gear/gear_down");
850 fgUntie("/controls/gear/antiskid");
851 fgUntie("/controls/gear/tailhook");
852 fgUntie("/controls/gear/tailwheel-lock");
853 for (index = 0; index < MAX_WHEELS; index++) {
854 char name[MAX_NAME_LEN];
855 snprintf(name, MAX_NAME_LEN, "/controls/gear/wheel[%d]/brakes", index);
857 snprintf(name, MAX_NAME_LEN,
858 "/controls/gear/wheel[%d]/alternate-extension", index);
861 fgUntie("/controls/anti-ice/wing-heat");
862 fgUntie("/controls/anti-ice/pitot-heat");
863 fgUntie("/controls/anti-ice/wiper");
864 fgUntie("/controls/anti-ice/window-heat");
865 for (index = 0; index < MAX_ENGINES; index++) {
866 char name[MAX_NAME_LEN];
867 snprintf(name, MAX_NAME_LEN,
868 "/controls/anti-ice/engine[%d]/carb-heat", index);
870 snprintf(name, MAX_NAME_LEN,
871 "/controls/anti-ice/engine[%d]/inlet-heat", index);
874 for (index = 0; index < MAX_HYD_SYSTEMS; index++) {
875 char name[MAX_NAME_LEN];
876 snprintf(name, MAX_NAME_LEN,
877 "/controls/hydraulic/system[%d]/engine-pump", index);
879 snprintf(name, MAX_NAME_LEN,
880 "/controls/hydraulic/system[%d]/electric-pump", index);
883 fgUntie("/controls/electric/battery-switch");
884 fgUntie("/controls/electric/external-power");
885 fgUntie("/controls/electric/APU-generator");
886 for (index = 0; index < MAX_ENGINES; index++) {
887 char name[MAX_NAME_LEN];
888 snprintf(name, MAX_NAME_LEN,
889 "/controls/electric/engine[%d]/generator", index);
891 snprintf(name, MAX_NAME_LEN,
892 "/controls/electric/engine[%d]/bus-tie", index);
895 fgUntie("/controls/pneumatic/APU-bleed");
896 for (index = 0; index < MAX_ENGINES; index++) {
897 char name[MAX_NAME_LEN];
898 snprintf(name, MAX_NAME_LEN,
899 "/controls/pneumatic/engine[%d]/bleed", index);
902 fgUntie("/controls/pressurization/mode");
903 fgUntie("/controls/pressurization/dump");
904 for (index = 0; index < MAX_PACKS; index++) {
905 char name[MAX_NAME_LEN];
906 snprintf(name, MAX_NAME_LEN,
907 "/controls/pressurization/pack[%d]/pack-on", index);
910 fgUntie("/controls/lighting/landing-lights");
911 fgUntie("/controls/lighting/turn-off-lights");
912 fgUntie("/controls/lighting/taxi-light");
913 fgUntie("/controls/lighting/logo-lights");
914 fgUntie("/controls/lighting/nav-lights");
915 fgUntie("/controls/lighting/beacon");
916 fgUntie("/controls/lighting/strobe");
917 fgUntie("/controls/lighting/panel-norm");
918 fgUntie("/controls/lighting/instruments-norm");
919 fgUntie("/controls/lighting/dome-norm");
921 #ifdef FG_HAVE_ARMAMENT
922 fgUntie("/controls/armament/master-arm");
923 fgUntie("/controls/armament/station-select");
924 fgUntie("/controls/armament/release-all");
925 for (index = 0; index < MAX_STATIONS; index++) {
926 char name[MAX_NAME_LEN];
927 snprintf(name, MAX_NAME_LEN,
928 "/controls/armament/station[%d]/stick-size", index);
930 snprintf(name, MAX_NAME_LEN,
931 "/controls/armament/station[%d]/release-stick", index);
933 snprintf(name, MAX_NAME_LEN,
934 "/controls/armament/station[%d]/release-all", index);
936 snprintf(name, MAX_NAME_LEN,
937 "/controls/armament/station[%d]/jettison-all", index);
941 fgUntie("/controls/seat/vertical-adjust");
942 fgUntie("/controls/seat/fore-aft-adjust");
943 fgUntie("/controls/seat/eject");
944 fgUntie("/controls/APU/off-start-run");
945 fgUntie("/controls/APU/fire-switch");
946 for (index = 0; index < MAX_AUTOPILOTS; index++) {
947 char name[MAX_NAME_LEN];
948 snprintf(name, MAX_NAME_LEN,
949 "/controls/autoflight/autopilot[%d]/engage", index);
952 fgUntie("/controls/autoflight/autothrottle-arm");
953 fgUntie("/controls/autoflight/autothrottle-engage");
954 fgUntie("/controls/autoflight/heading-select");
955 fgUntie("/controls/autoflight/altitude-select");
956 fgUntie("/controls/autoflight/bank-angle-select");
957 fgUntie("/controls/autoflight/vertical-speed-select");
958 fgUntie("/controls/autoflight/speed-select");
959 fgUntie("/controls/autoflight/mach-select");
960 fgUntie("/controls/autoflight/vertical-mode");
961 fgUntie("/controls/autoflight/lateral-mode");
966 FGControls::update (double dt)
972 ////////////////////////////////////////////////////////////////////////
973 // Setters and adjusters.
974 ////////////////////////////////////////////////////////////////////////
977 FGControls::set_aileron (double pos)
980 CLAMP( &aileron, -1.0, 1.0 );
982 // check for autocoordination
983 if ( auto_coordination->getBoolValue() ) {
984 set_rudder( aileron / 2.0 );
989 FGControls::move_aileron (double amt)
992 CLAMP( &aileron, -1.0, 1.0 );
994 // check for autocoordination
995 if ( auto_coordination->getBoolValue() ) {
996 set_rudder( aileron / 2.0 );
1001 FGControls::set_aileron_trim( double pos )
1004 CLAMP( &aileron_trim, -1.0, 1.0 );
1008 FGControls::move_aileron_trim( double amt )
1010 aileron_trim += amt;
1011 CLAMP( &aileron_trim, -1.0, 1.0 );
1015 FGControls::set_elevator( double pos )
1018 CLAMP( &elevator, -1.0, 1.0 );
1022 FGControls::move_elevator( double amt )
1025 CLAMP( &elevator, -1.0, 1.0 );
1029 FGControls::set_elevator_trim( double pos )
1031 elevator_trim = pos;
1032 CLAMP( &elevator_trim, -1.0, 1.0 );
1036 FGControls::move_elevator_trim( double amt )
1038 elevator_trim += amt;
1039 CLAMP( &elevator_trim, -1.0, 1.0 );
1043 FGControls::set_rudder( double pos )
1046 CLAMP( &rudder, -1.0, 1.0 );
1050 FGControls::move_rudder( double amt )
1053 CLAMP( &rudder, -1.0, 1.0 );
1057 FGControls::set_rudder_trim( double pos )
1060 CLAMP( &rudder_trim, -1.0, 1.0 );
1064 FGControls::move_rudder_trim( double amt )
1067 CLAMP( &rudder_trim, -1.0, 1.0 );
1071 FGControls::set_flaps( double pos )
1074 CLAMP( &flaps, 0.0, 1.0 );
1078 FGControls::move_flaps( double amt )
1081 CLAMP( &flaps, 0.0, 1.0 );
1085 FGControls::set_slats( double pos )
1088 CLAMP( &slats, 0.0, 1.0 );
1092 FGControls::move_slats( double amt )
1095 CLAMP( &slats, 0.0, 1.0 );
1099 FGControls::set_BLC( bool val )
1105 FGControls::set_spoilers( double pos )
1108 CLAMP( &spoilers, 0.0, 1.0 );
1112 FGControls::move_spoilers( double amt )
1115 CLAMP( &spoilers, 0.0, 1.0 );
1119 FGControls::set_speedbrake( double pos )
1122 CLAMP( &speedbrake, 0.0, 1.0 );
1126 FGControls::move_speedbrake( double amt )
1129 CLAMP( &speedbrake, 0.0, 1.0 );
1133 FGControls::set_wing_sweep( double pos )
1136 CLAMP( &wing_sweep, 0.0, 1.0 );
1140 FGControls::move_wing_sweep( double amt )
1143 CLAMP( &wing_sweep, 0.0, 1.0 );
1147 FGControls::set_wing_fold( bool val )
1153 FGControls::set_drag_chute( bool val )
1159 FGControls::set_throttle_idle( bool val )
1161 throttle_idle = val;
1165 FGControls::set_throttle( int engine, double pos )
1167 if ( engine == ALL_ENGINES ) {
1168 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1170 CLAMP( &throttle[i], 0.0, 1.0 );
1173 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1174 throttle[engine] = pos;
1175 CLAMP( &throttle[engine], 0.0, 1.0 );
1181 FGControls::move_throttle( int engine, double amt )
1183 if ( engine == ALL_ENGINES ) {
1184 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1186 CLAMP( &throttle[i], 0.0, 1.0 );
1189 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1190 throttle[engine] += amt;
1191 CLAMP( &throttle[engine], 0.0, 1.0 );
1197 FGControls::set_starter( int engine, bool flag )
1199 if ( engine == ALL_ENGINES ) {
1200 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1204 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1205 starter[engine] = flag;
1211 FGControls::set_fuel_pump( int engine, bool val )
1213 if ( engine == ALL_ENGINES ) {
1214 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1218 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1219 fuel_pump[engine] = val;
1225 FGControls::set_fire_switch( int engine, bool val )
1227 if ( engine == ALL_ENGINES ) {
1228 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1229 fire_switch[i] = val;
1232 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1233 fire_switch[engine] = val;
1239 FGControls::set_fire_bottle_discharge( int engine, bool val )
1241 if ( engine == ALL_ENGINES ) {
1242 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1243 fire_bottle_discharge[i] = val;
1246 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1247 fire_bottle_discharge[engine] = val;
1253 FGControls::set_cutoff( int engine, bool val )
1255 if ( engine == ALL_ENGINES ) {
1256 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1260 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1261 cutoff[engine] = val;
1268 FGControls::set_mixture( int engine, double pos )
1270 if ( engine == ALL_ENGINES ) {
1271 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1273 CLAMP( &mixture[i], 0.0, 1.0 );
1276 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1277 mixture[engine] = pos;
1278 CLAMP( &mixture[engine], 0.0, 1.0 );
1284 FGControls::move_mixture( int engine, double amt )
1286 if ( engine == ALL_ENGINES ) {
1287 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1289 CLAMP( &mixture[i], 0.0, 1.0 );
1292 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1293 mixture[engine] += amt;
1294 CLAMP( &mixture[engine], 0.0, 1.0 );
1300 FGControls::set_prop_advance( int engine, double pos )
1302 if ( engine == ALL_ENGINES ) {
1303 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1304 prop_advance[i] = pos;
1305 CLAMP( &prop_advance[i], 0.0, 1.0 );
1308 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1309 prop_advance[engine] = pos;
1310 CLAMP( &prop_advance[engine], 0.0, 1.0 );
1316 FGControls::move_prop_advance( int engine, double amt )
1318 if ( engine == ALL_ENGINES ) {
1319 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1320 prop_advance[i] += amt;
1321 CLAMP( &prop_advance[i], 0.0, 1.0 );
1324 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1325 prop_advance[engine] += amt;
1326 CLAMP( &prop_advance[engine], 0.0, 1.0 );
1332 FGControls::set_magnetos( int engine, int pos )
1334 if ( engine == ALL_ENGINES ) {
1335 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1337 CLAMP( &magnetos[i], 0, 3 );
1340 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1341 magnetos[engine] = pos;
1342 CLAMP( &magnetos[engine], 0, 3 );
1348 FGControls::move_magnetos( int engine, int amt )
1350 if ( engine == ALL_ENGINES ) {
1351 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1353 CLAMP( &magnetos[i], 0, 3 );
1356 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1357 magnetos[engine] += amt;
1358 CLAMP( &magnetos[engine], 0, 3 );
1364 FGControls::set_nitrous_injection( int engine, bool val )
1366 if ( engine == ALL_ENGINES ) {
1367 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1368 nitrous_injection[i] = val;
1371 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1372 nitrous_injection[engine] = val;
1379 FGControls::set_cowl_flaps_norm( int engine, double pos )
1381 if ( engine == ALL_ENGINES ) {
1382 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1383 cowl_flaps_norm[i] = pos;
1384 CLAMP( &cowl_flaps_norm[i], 0.0, 1.0 );
1387 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1388 cowl_flaps_norm[engine] = pos;
1389 CLAMP( &cowl_flaps_norm[engine], 0.0, 1.0 );
1395 FGControls::move_cowl_flaps_norm( int engine, double amt )
1397 if ( engine == ALL_ENGINES ) {
1398 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1399 cowl_flaps_norm[i] += amt;
1400 CLAMP( &cowl_flaps_norm[i], 0.0, 1.0 );
1403 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1404 cowl_flaps_norm[engine] += amt;
1405 CLAMP( &cowl_flaps_norm[engine], 0.0, 1.0 );
1411 FGControls::set_feather( int engine, bool val )
1413 if ( engine == ALL_ENGINES ) {
1414 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1418 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1419 feather[engine] = val;
1425 FGControls::set_ignition( int engine, int pos )
1427 if ( engine == ALL_ENGINES ) {
1428 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1430 CLAMP( &ignition[i], 0, 3 );
1433 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1434 ignition[engine] = pos;
1435 CLAMP( &ignition[engine], 0, 3 );
1441 FGControls::set_augmentation( int engine, bool val )
1443 if ( engine == ALL_ENGINES ) {
1444 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1445 augmentation[i] = val;
1448 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1449 augmentation[engine] = val;
1455 FGControls::set_reverser( int engine, bool val )
1457 if ( engine == ALL_ENGINES ) {
1458 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1462 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1463 reverser[engine] = val;
1469 FGControls::set_water_injection( int engine, bool val )
1471 if ( engine == ALL_ENGINES ) {
1472 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1473 water_injection[i] = val;
1476 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1477 water_injection[engine] = val;
1483 FGControls::set_condition( int engine, int val )
1485 if ( engine == ALL_ENGINES ) {
1486 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1488 CLAMP( &condition[i], 0, 3 );
1491 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1492 condition[engine] = val;
1493 CLAMP( &condition[engine], 0, 3 );
1499 FGControls::set_dump_valve( bool val )
1506 FGControls::set_fuel_selector( int tank, bool pos )
1508 if ( tank == ALL_TANKS ) {
1509 for ( int i = 0; i < MAX_TANKS; i++ ) {
1510 fuel_selector[i] = pos;
1513 if ( (tank >= 0) && (tank < MAX_TANKS) ) {
1514 fuel_selector[tank] = pos;
1520 FGControls::set_to_engine( int tank, int engine )
1522 if ( tank == ALL_TANKS ) {
1523 for ( int i = 0; i < MAX_TANKS; i++ ) {
1524 to_engine[i] = engine;
1527 if ( (tank >= 0) && (tank < MAX_TANKS) ) {
1528 to_engine[tank] = engine;
1534 FGControls::set_to_tank( int tank, int dest_tank )
1536 if ( tank == ALL_TANKS ) {
1537 for ( int i = 0; i < MAX_TANKS; i++ ) {
1538 to_tank[i] = dest_tank;
1541 if ( (tank >= 0) && (tank < MAX_TANKS) ) {
1542 to_tank[tank] = dest_tank;
1548 FGControls::set_boost_pump( int index, bool val )
1550 if ( index == -1 ) {
1551 for ( int i = 0; i < (MAX_TANKS * MAX_BOOSTPUMPS); i++ ) {
1552 boost_pump[i] = val;
1555 if ( (index >= 0) && (index < (MAX_TANKS * MAX_BOOSTPUMPS)) ) {
1556 boost_pump[index] = val;
1563 FGControls::set_parking_brake( double pos )
1565 parking_brake = pos;
1566 CLAMP(&parking_brake, 0.0, 1.0);
1570 FGControls::set_steering( double angle )
1573 CLAMP(&steering, -80.0, 80.0);
1577 FGControls::move_steering( double angle )
1580 CLAMP(&steering, -80.0, 80.0);
1584 FGControls::set_gear_down( bool gear )
1590 FGControls::set_antiskid( bool state )
1596 FGControls::set_tailhook( bool state )
1602 FGControls::set_tailwheel_lock( bool state )
1604 tailwheel_lock = state;
1609 FGControls::set_brake( int wheel, double pos )
1611 if ( wheel == ALL_WHEELS ) {
1612 for ( int i = 0; i < MAX_WHEELS; i++ ) {
1614 CLAMP( &brake[i], 0.0, 1.0 );
1617 if ( (wheel >= 0) && (wheel < MAX_WHEELS) ) {
1619 CLAMP( &brake[wheel], 0.0, 1.0 );
1625 FGControls::move_brake( int wheel, double amt )
1627 if ( wheel == ALL_WHEELS ) {
1628 for ( int i = 0; i < MAX_WHEELS; i++ ) {
1630 CLAMP( &brake[i], 0.0, 1.0 );
1633 if ( (wheel >= 0) && (wheel < MAX_WHEELS) ) {
1634 brake[wheel] += amt;
1635 CLAMP( &brake[wheel], 0.0, 1.0 );
1641 FGControls::set_alternate_extension( int wheel, bool val )
1643 if ( wheel == ALL_WHEELS ) {
1644 for ( int i = 0; i < MAX_WHEELS; i++ ) {
1645 alternate_extension[i] = val;
1648 if ( (wheel >= 0) && (wheel < MAX_WHEELS) ) {
1649 alternate_extension[wheel] = val;
1655 FGControls::set_wing_heat( bool state )
1661 FGControls::set_pitot_heat( bool state )
1667 FGControls::set_wiper( int state )
1673 FGControls::set_window_heat( bool state )
1675 window_heat = state;
1679 FGControls::set_carb_heat( int engine, bool val )
1681 if ( engine == ALL_ENGINES ) {
1682 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1686 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1687 carb_heat[engine] = val;
1693 FGControls::set_inlet_heat( int engine, bool val )
1695 if ( engine == ALL_ENGINES ) {
1696 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1697 inlet_heat[i] = val;
1700 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1701 inlet_heat[engine] = val;
1707 FGControls::set_engine_pump( int system, bool val )
1709 if ( system == ALL_HYD_SYSTEMS ) {
1710 for ( int i = 0; i < MAX_HYD_SYSTEMS; i++ ) {
1711 engine_pump[i] = val;
1714 if ( (system >= 0) && (system < MAX_HYD_SYSTEMS) ) {
1715 engine_pump[system] = val;
1721 FGControls::set_electric_pump( int system, bool val )
1723 if ( system == ALL_HYD_SYSTEMS ) {
1724 for ( int i = 0; i < MAX_HYD_SYSTEMS; i++ ) {
1725 electric_pump[i] = val;
1728 if ( (system >= 0) && (system < MAX_HYD_SYSTEMS) ) {
1729 electric_pump[system] = val;
1735 FGControls::set_battery_switch( bool state )
1737 battery_switch = state;
1741 FGControls::set_external_power( bool state )
1743 external_power = state;
1747 FGControls::set_APU_generator( bool state )
1749 APU_generator = state;
1753 FGControls::set_generator_breaker( int engine, bool val )
1755 if ( engine == ALL_ENGINES ) {
1756 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1757 generator_breaker[i] = val;
1760 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1761 generator_breaker[engine] = val;
1767 FGControls::set_bus_tie( int engine, bool val )
1769 if ( engine == ALL_ENGINES ) {
1770 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1774 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1775 bus_tie[engine] = val;
1781 FGControls::set_APU_bleed( bool state )
1787 FGControls::set_engine_bleed( int engine, bool val )
1789 if ( engine == ALL_ENGINES ) {
1790 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1791 engine_bleed[i] = val;
1794 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1795 engine_bleed[engine] = val;
1801 FGControls::set_mode( int new_mode )
1807 FGControls::set_outflow_valve( double pos )
1809 outflow_valve = pos;
1810 CLAMP( &outflow_valve, 0.0, 1.0 );
1814 FGControls::move_outflow_valve( double amt )
1816 outflow_valve += amt;
1817 CLAMP( &outflow_valve, 0.0, 1.0 );
1821 FGControls::set_dump( bool state )
1827 FGControls::set_pack_on( int pack, bool val )
1829 if ( pack == ALL_PACKS ) {
1830 for ( int i = 0; i < MAX_PACKS; i++ ) {
1834 if ( (pack >= 0) && (pack < MAX_PACKS) ) {
1835 pack_on[pack] = val;
1841 FGControls::set_landing_lights( bool state )
1843 landing_lights = state;
1847 FGControls::set_turn_off_lights( bool state )
1849 turn_off_lights = state;
1853 FGControls::set_taxi_light( bool state )
1859 FGControls::set_logo_lights( bool state )
1861 logo_lights = state;
1865 FGControls::set_nav_lights( bool state )
1871 FGControls::set_beacon( bool state )
1877 FGControls::set_strobe( bool state )
1883 FGControls::set_panel_norm( double intensity )
1885 panel_norm = intensity;
1886 CLAMP( &panel_norm, 0.0, 1.0 );
1890 FGControls::move_panel_norm( double amt )
1893 CLAMP( &panel_norm, 0.0, 1.0 );
1897 FGControls::set_instruments_norm( double intensity )
1899 instruments_norm = intensity;
1900 CLAMP( &instruments_norm, 0.0, 1.0 );
1904 FGControls::move_instruments_norm( double amt )
1906 instruments_norm += amt;
1907 CLAMP( &instruments_norm, 0.0, 1.0 );
1911 FGControls::set_dome_norm( double intensity )
1913 dome_norm = intensity;
1914 CLAMP( &dome_norm, 0.0, 1.0 );
1918 FGControls::move_dome_norm( double amt )
1921 CLAMP( &dome_norm, 0.0, 1.0 );
1924 #ifdef FG_HAVE_ARMAMENT
1927 FGControls::set_master_arm( bool val )
1933 FGControls::set_station_select( int station )
1935 station_select = station;
1936 CLAMP( &station_select, 0, MAX_STATIONS );
1940 FGControls::set_release_ALL( bool val )
1946 FGControls::set_stick_size( int station, int size )
1948 if ( station == ALL_STATIONS ) {
1949 for ( int i = 0; i < MAX_STATIONS; i++ ) {
1950 stick_size[i] = size;
1951 CLAMP( &stick_size[i], 1, 20 );
1954 if ( (station >= 0) && (station < MAX_STATIONS) ) {
1955 stick_size[station] = size;
1956 CLAMP( &stick_size[station], 1, 20 );
1962 FGControls::set_release_stick( int station, bool val )
1964 if ( station == ALL_STATIONS ) {
1965 for ( int i = 0; i < MAX_STATIONS; i++ ) {
1966 release_stick[i] = val;
1969 if ( (station >= 0) && (station < MAX_STATIONS) ) {
1970 release_stick[station] = val;
1976 FGControls::set_release_all( int station, bool val )
1978 if ( station == ALL_STATIONS ) {
1979 for ( int i = 0; i < MAX_STATIONS; i++ ) {
1980 release_all[i] = val;
1983 if ( (station >= 0) && (station < MAX_STATIONS) ) {
1984 release_all[station] = val;
1990 FGControls::set_jettison_all( int station, bool val )
1992 if ( station == ALL_STATIONS ) {
1993 for ( int i = 0; i < MAX_STATIONS; i++ ) {
1994 jettison_all[i] = val;
1997 if ( (station >= 0) && (station < MAX_STATIONS) ) {
1998 jettison_all[station] = val;
2006 FGControls::set_vertical_adjust( double pos )
2008 vertical_adjust = pos;
2009 CLAMP( &vertical_adjust, -1.0, 1.0 );
2013 FGControls::move_vertical_adjust( double amt )
2015 vertical_adjust += amt;
2016 CLAMP( &vertical_adjust, -1.0, 1.0 );
2020 FGControls::set_fore_aft_adjust( double pos )
2022 fore_aft_adjust = pos;
2023 CLAMP( &fore_aft_adjust, -1.0, 1.0 );
2027 FGControls::move_fore_aft_adjust( double amt )
2029 fore_aft_adjust += amt;
2030 CLAMP( &fore_aft_adjust, -1.0, 1.0 );
2034 FGControls::set_eject( bool val )
2040 FGControls::set_off_start_run( int pos )
2042 off_start_run = pos;
2043 CLAMP( &off_start_run, 0, 3 );
2047 FGControls::set_APU_fire_switch( bool val )
2049 APU_fire_switch = val;
2053 FGControls::set_autothrottle_arm( bool val )
2055 autothrottle_arm = val;
2059 FGControls::set_autothrottle_engage( bool val )
2061 autothrottle_engage = val;
2065 FGControls::set_heading_select( double heading )
2067 heading_select = heading;
2068 CLAMP( &heading_select, 0.0, 360.0 );
2072 FGControls::move_heading_select( double amt )
2074 heading_select += amt;
2075 CLAMP( &heading_select, 0.0, 360.0 );
2079 FGControls::set_altitude_select( double altitude )
2081 altitude_select = altitude;
2082 CLAMP( &altitude_select, -1000.0, 100000.0 );
2086 FGControls::move_altitude_select( double amt )
2088 altitude_select += amt;
2089 CLAMP( &altitude_select, -1000.0, 100000.0 );
2093 FGControls::set_bank_angle_select( double angle )
2095 bank_angle_select = angle;
2096 CLAMP( &bank_angle_select, 10.0, 30.0 );
2100 FGControls::move_bank_angle_select( double amt )
2102 bank_angle_select += amt;
2103 CLAMP( &bank_angle_select, 10.0, 30.0 );
2107 FGControls::set_vertical_speed_select( double speed )
2109 vertical_speed_select = speed;
2110 CLAMP( &vertical_speed_select, -3000.0, 4000.0 );
2114 FGControls::move_vertical_speed_select( double amt )
2116 vertical_speed_select += amt;
2117 CLAMP( &vertical_speed_select, -3000.0, 4000.0 );
2121 FGControls::set_speed_select( double speed )
2123 speed_select = speed;
2124 CLAMP( &speed_select, 60.0, 400.0 );
2128 FGControls::move_speed_select( double amt )
2130 speed_select += amt;
2131 CLAMP( &speed_select, 60.0, 400.0 );
2135 FGControls::set_mach_select( double mach )
2138 CLAMP( &mach_select, 0.4, 4.0 );
2142 FGControls::move_mach_select( double amt )
2145 CLAMP( &mach_select, 0.4, 4.0 );
2149 FGControls::set_vertical_mode( int mode )
2151 vertical_mode = mode;
2152 CLAMP( &vertical_mode, 0, 4 );
2156 FGControls::set_lateral_mode( int mode )
2158 lateral_mode = mode;
2159 CLAMP( &lateral_mode, 0, 4 );
2163 FGControls::set_autopilot_engage( int ap, bool val )
2165 if ( ap == ALL_AUTOPILOTS ) {
2166 for ( int i = 0; i < MAX_AUTOPILOTS; i++ ) {
2167 autopilot_engage[i] = val;
2170 if ( (ap >= 0) && (ap < MAX_AUTOPILOTS) ) {
2171 autopilot_engage[ap] = val;