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 ),
98 instruments_norm( 0.0 ),
102 release_ALL( false ),
103 vertical_adjust( 0.0 ),
104 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;
168 set_ejection_seat( ALL_EJECTION_SEATS, false );
169 set_eseat_status( ALL_EJECTION_SEATS, SEAT_SAFED );
170 set_cmd_selector_valve( CMD_SEL_NORM );
171 APU_fire_switch = false;
172 autothrottle_arm = false;
173 autothrottle_engage = false;
174 set_autopilot_engage( ALL_AUTOPILOTS, false );
179 FGControls::~FGControls() {
186 throttle_idle = true;
187 for ( int engine = 0; engine < MAX_ENGINES; engine++ ) {
188 throttle[engine] = 0.0;
189 mixture[engine] = 1.0;
190 fuel_pump[engine] = false;
191 prop_advance[engine] = 1.0;
192 magnetos[engine] = 0;
193 starter[engine] = false;
194 ignition[engine] = false;
195 fire_switch[engine] = false;
196 cutoff[engine] = true;
197 augmentation[engine] = false;
198 reverser[engine] = false;
199 water_injection[engine] = false;
200 nitrous_injection[engine] = false;
201 cowl_flaps_norm[engine] = 0.0;
202 condition[engine] = 0;
205 for ( int wheel = 0; wheel < MAX_WHEELS; wheel++ ) {
207 alternate_extension[wheel] = false;
210 auto_coordination = fgGetNode("/sim/auto-coordination", true);
220 fgTie("/controls/flight/aileron", this,
221 &FGControls::get_aileron, &FGControls::set_aileron);
222 fgSetArchivable("/controls/flight/aileron");
224 fgTie("/controls/flight/aileron-trim", this,
225 &FGControls::get_aileron_trim, &FGControls::set_aileron_trim);
226 fgSetArchivable("/controls/flight/aileron-trim");
228 fgTie("/controls/flight/elevator", this,
229 &FGControls::get_elevator, &FGControls::set_elevator);
230 fgSetArchivable("/controls/flight/elevator");
232 fgTie("/controls/flight/elevator-trim", this,
233 &FGControls::get_elevator_trim, &FGControls::set_elevator_trim);
234 fgSetArchivable("/controls/flight/elevator-trim");
236 fgTie("/controls/flight/rudder", this,
237 &FGControls::get_rudder, &FGControls::set_rudder);
238 fgSetArchivable("/controls/flight/rudder");
240 fgTie("/controls/flight/rudder-trim", this,
241 &FGControls::get_rudder_trim, &FGControls::set_rudder_trim);
242 fgSetArchivable("/controls/flight/rudder-trim");
244 fgTie("/controls/flight/flaps", this,
245 &FGControls::get_flaps, &FGControls::set_flaps);
246 fgSetArchivable("/controls/flight/flaps");
248 fgTie("/controls/flight/slats", this,
249 &FGControls::get_slats, &FGControls::set_slats);
250 fgSetArchivable("/controls/flight/slats");
252 fgTie("/controls/flight/BLC", this,
253 &FGControls::get_BLC, &FGControls::set_BLC);
254 fgSetArchivable("/controls/flight/BLC");
256 fgTie("/controls/flight/spoilers", this,
257 &FGControls::get_spoilers, &FGControls::set_spoilers);
258 fgSetArchivable("/controls/flight/spoilers");
260 fgTie("/controls/flight/speedbrake", this,
261 &FGControls::get_speedbrake, &FGControls::set_speedbrake);
262 fgSetArchivable("/controls/flight/speedbrake");
264 fgTie("/controls/flight/wing-sweep", this,
265 &FGControls::get_wing_sweep, &FGControls::set_wing_sweep);
266 fgSetArchivable("/controls/flight/wing-sweep");
268 fgTie("/controls/flight/wing-fold", this,
269 &FGControls::get_wing_fold, &FGControls::set_wing_fold);
270 fgSetArchivable("/controls/flight/wing-fold");
272 fgTie("/controls/flight/drag-chute", this,
273 &FGControls::get_drag_chute, &FGControls::set_drag_chute);
274 fgSetArchivable("/controls/flight/drag-chute");
277 fgTie("/controls/engines/throttle_idle", this,
278 &FGControls::get_throttle_idle, &FGControls::set_throttle_idle);
279 fgSetArchivable("/controls/engines/throttle_idle");
281 for (index = 0; index < MAX_ENGINES; index++) {
282 char name[MAX_NAME_LEN];
283 snprintf(name, MAX_NAME_LEN,
284 "/controls/engines/engine[%d]/throttle", index);
285 fgTie(name, this, index,
286 &FGControls::get_throttle, &FGControls::set_throttle);
287 fgSetArchivable(name);
289 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/starter", index);
290 fgTie(name, this, index,
291 &FGControls::get_starter, &FGControls::set_starter);
292 fgSetArchivable(name);
294 snprintf(name, MAX_NAME_LEN,
295 "/controls/engines/engine[%d]/fuel-pump", index);
296 fgTie(name, this, index,
297 &FGControls::get_fuel_pump, &FGControls::set_fuel_pump);
298 fgSetArchivable(name);
300 snprintf(name, MAX_NAME_LEN,
301 "/controls/engines/engine[%d]/fire-switch", index);
302 fgTie(name, this, index,
303 &FGControls::get_fire_switch, &FGControls::set_fire_switch);
304 fgSetArchivable(name);
306 snprintf(name, MAX_NAME_LEN,
307 "/controls/engines/engine[%d]/fire-bottle-discharge", index);
308 fgTie(name, this, index,
309 &FGControls::get_fire_bottle_discharge,
310 &FGControls::set_fire_bottle_discharge);
311 fgSetArchivable(name);
313 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/cutoff", index);
314 fgTie(name, this, index,
315 &FGControls::get_cutoff, &FGControls::set_cutoff);
316 fgSetArchivable(name);
318 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/mixture", index);
319 fgTie(name, this, index,
320 &FGControls::get_mixture, &FGControls::set_mixture);
321 fgSetArchivable(name);
323 snprintf(name, MAX_NAME_LEN,
324 "/controls/engines/engine[%d]/propeller-pitch", index);
325 fgTie(name, this, index,
326 &FGControls::get_prop_advance,
327 &FGControls::set_prop_advance);
328 fgSetArchivable(name);
330 snprintf(name, MAX_NAME_LEN,
331 "/controls/engines/engine[%d]/magnetos", index);
332 fgTie(name, this, index,
333 &FGControls::get_magnetos, &FGControls::set_magnetos);
334 fgSetArchivable(name);
336 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/WEP", index);
337 fgTie(name, this, index,
338 &FGControls::get_nitrous_injection,
339 &FGControls::set_nitrous_injection);
340 fgSetArchivable(name);
342 snprintf(name, MAX_NAME_LEN,
343 "/controls/engines/engine[%d]/cowl-flaps-norm", index);
344 fgTie(name, this, index,
345 &FGControls::get_cowl_flaps_norm,
346 &FGControls::set_cowl_flaps_norm);
347 fgSetArchivable(name);
349 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/feather", index);
350 fgTie(name, this, index,
351 &FGControls::get_feather, &FGControls::set_feather);
352 fgSetArchivable(name);
354 snprintf(name, MAX_NAME_LEN,
355 "/controls/engines/engine[%d]/ignition", index);
356 fgTie(name, this, index,
357 &FGControls::get_ignition, &FGControls::set_ignition);
358 fgSetArchivable(name);
360 snprintf(name, MAX_NAME_LEN,
361 "/controls/engines/engine[%d]/augmentation", index);
362 fgTie(name, this, index,
363 &FGControls::get_augmentation,
364 &FGControls::set_augmentation);
365 fgSetArchivable(name);
367 snprintf(name, MAX_NAME_LEN,
368 "/controls/engines/engine[%d]/reverser", index);
369 fgTie(name, this, index,
370 &FGControls::get_reverser, &FGControls::set_reverser);
371 fgSetArchivable(name);
373 snprintf(name, MAX_NAME_LEN,
374 "/controls/engines/engine[%d]/water-injection", index);
375 fgTie(name, this, index,
376 &FGControls::get_water_injection,
377 &FGControls::set_water_injection);
378 fgSetArchivable(name);
380 snprintf(name, MAX_NAME_LEN,
381 "/controls/engines/engine[%d]/condition", index);
382 fgTie(name, this, index,
383 &FGControls::get_condition, &FGControls::set_condition);
384 fgSetArchivable(name);
388 fgTie("/controls/fuel/dump-valve", this,
389 &FGControls::get_dump_valve, &FGControls::set_dump_valve);
390 fgSetArchivable("/controls/fuel/dump-valve");
392 for (index = 0; index < MAX_TANKS; index++) {
393 char name[MAX_NAME_LEN];
394 snprintf(name, MAX_NAME_LEN,
395 "/controls/fuel/tank[%d]/fuel_selector", index);
396 fgTie(name, this, index,
397 &FGControls::get_fuel_selector,
398 &FGControls::set_fuel_selector);
399 fgSetArchivable(name);
401 snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_engine", index);
402 fgTie(name, this, index,
403 &FGControls::get_to_engine, &FGControls::set_to_engine);
404 fgSetArchivable(name);
406 snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_tank", index);
407 fgTie(name, this, index,
408 &FGControls::get_to_tank, &FGControls::set_to_tank);
409 fgSetArchivable(name);
411 for (i = 0; i < MAX_BOOSTPUMPS; i++) {
412 char name[MAX_NAME_LEN];
413 snprintf(name, MAX_NAME_LEN,
414 "/controls/fuel/tank[%d]/boost-pump[%d]", index, i);
415 fgTie(name, this, index * 2 + i,
416 &FGControls::get_boost_pump,
417 &FGControls::set_boost_pump);
418 fgSetArchivable(name);
423 fgTie("/controls/gear/parking-brake", this,
424 &FGControls::get_parking_brake,
425 &FGControls::set_parking_brake);
426 fgSetArchivable("/controls/gear/parking-brake");
428 fgTie("/controls/gear/steering", this,
429 &FGControls::get_steering, &FGControls::set_steering);
430 fgSetArchivable("/controls/gear/steering");
432 fgTie("/controls/gear/gear-down", this,
433 &FGControls::get_gear_down, &FGControls::set_gear_down);
434 fgSetArchivable("/controls/gear/gear-down");
436 fgTie("/controls/gear/antiskid", this,
437 &FGControls::get_antiskid, &FGControls::set_antiskid);
438 fgSetArchivable("/controls/gear/antiskid");
440 fgTie("/controls/gear/tailhook", this,
441 &FGControls::get_tailhook, &FGControls::set_tailhook);
442 fgSetArchivable("/controls/gear/tailhook");
444 fgTie("/controls/gear/tailwheel-lock", this,
445 &FGControls::get_tailwheel_lock,
446 &FGControls::set_tailwheel_lock);
447 fgSetArchivable("/controls/gear/tailwheel-lock");
449 for (index = 0; index < MAX_WHEELS; index++) {
450 char name[MAX_NAME_LEN];
451 snprintf(name, MAX_NAME_LEN, "/controls/gear/wheel[%d]/brake", index);
452 fgTie(name, this, index,
453 &FGControls::get_brake, &FGControls::set_brake);
454 fgSetArchivable(name);
456 snprintf(name, MAX_NAME_LEN,
457 "/controls/gear/wheel[%d]/alternate-extension", index);
458 fgTie(name, this, index,
459 &FGControls::get_alternate_extension,
460 &FGControls::set_alternate_extension);
461 fgSetArchivable(name);
465 fgTie("/controls/anti-ice/wing-heat", this,
466 &FGControls::get_wing_heat, &FGControls::set_wing_heat);
467 fgSetArchivable("/controls/anti-ice/wing-heat");
469 fgTie("/controls/anti-ice/pitot-heat", this,
470 &FGControls::get_pitot_heat, &FGControls::set_pitot_heat);
471 fgSetArchivable("/controls/anti-ice/pitot-heat");
473 fgTie("/controls/anti-ice/wiper", this,
474 &FGControls::get_wiper, &FGControls::set_wiper);
475 fgSetArchivable("/controls/anti-ice/wiper");
477 fgTie("/controls/anti-ice/window-heat", this,
478 &FGControls::get_window_heat, &FGControls::set_window_heat);
479 fgSetArchivable("/controls/anti-ice/window-heat");
481 for (index = 0; index < MAX_ENGINES; index++) {
482 char name[MAX_NAME_LEN];
483 snprintf(name, MAX_NAME_LEN,
484 "/controls/anti-ice/engine[%d]/carb-heat", index);
485 fgTie(name, this, index,
486 &FGControls::get_carb_heat, &FGControls::set_carb_heat);
487 fgSetArchivable(name);
489 snprintf(name, MAX_NAME_LEN,
490 "/controls/anti-ice/engine[%d]/inlet-heat", index);
491 fgTie(name, this, index,
492 &FGControls::get_inlet_heat, &FGControls::set_inlet_heat);
493 fgSetArchivable(name);
497 for (index = 0; index < MAX_HYD_SYSTEMS; index++) {
498 char name[MAX_NAME_LEN];
499 snprintf(name, MAX_NAME_LEN,
500 "/controls/hydraulic/system[%d]/engine-pump", index);
501 fgTie(name, this, index,
502 &FGControls::get_engine_pump, &FGControls::set_engine_pump);
503 fgSetArchivable(name);
505 snprintf(name, MAX_NAME_LEN,
506 "/controls/hydraulic/system[%d]/electric-pump", index);
507 fgTie(name, this, index,
508 &FGControls::get_electric_pump,
509 &FGControls::set_electric_pump);
510 fgSetArchivable(name);
514 fgTie("/controls/electric/battery-switch", this,
515 &FGControls::get_battery_switch,
516 &FGControls::set_battery_switch);
517 fgSetArchivable("/controls/electric/battery-switch");
519 fgTie("/controls/electric/external-power", this,
520 &FGControls::get_external_power,
521 &FGControls::set_external_power);
522 fgSetArchivable("/controls/electric/external-power");
524 fgTie("/controls/electric/APU-generator", this,
525 &FGControls::get_APU_generator,
526 &FGControls::set_APU_generator);
527 fgSetArchivable("/controls/electric/APU-generator");
529 for (index = 0; index < MAX_ENGINES; index++) {
530 char name[MAX_NAME_LEN];
531 snprintf(name, MAX_NAME_LEN,
532 "/controls/electric/engine[%d]/generator", index);
533 fgTie(name, this, index,
534 &FGControls::get_generator_breaker,
535 &FGControls::set_generator_breaker);
536 fgSetArchivable(name);
538 snprintf(name, MAX_NAME_LEN,
539 "/controls/electric/engine[%d]/bus-tie", index);
540 fgTie(name, this, index,
541 &FGControls::get_bus_tie,
542 &FGControls::set_bus_tie);
543 fgSetArchivable(name);
547 fgTie("/controls/pneumatic/APU-bleed", this,
548 &FGControls::get_APU_bleed,
549 &FGControls::set_APU_bleed);
550 fgSetArchivable("/controls/pneumatic/APU-bleed");
552 for (index = 0; index < MAX_ENGINES; index++) {
553 char name[MAX_NAME_LEN];
554 snprintf(name, MAX_NAME_LEN,
555 "/controls/pneumatic/engine[%d]/bleed", index);
556 fgTie(name, this, index,
557 &FGControls::get_engine_bleed,
558 &FGControls::set_engine_bleed);
559 fgSetArchivable(name);
563 fgTie("/controls/pressurization/mode", this,
564 &FGControls::get_mode, &FGControls::set_mode);
565 fgSetArchivable("/controls/pressurization/mode");
567 fgTie("/controls/pressurization/dump", this,
568 &FGControls::get_dump, &FGControls::set_dump);
569 fgSetArchivable("/controls/pressurization/dump");
571 fgTie("/controls/pressurization/outflow-valve", this,
572 &FGControls::get_outflow_valve,
573 &FGControls::set_outflow_valve);
574 fgSetArchivable("/controls/pressurization/outflow-valve");
576 for (index = 0; index < MAX_PACKS; index++) {
577 char name[MAX_NAME_LEN];
578 snprintf(name, MAX_NAME_LEN,
579 "/controls/pressurization/pack[%d]/pack-on", index);
580 fgTie(name, this, index,
581 &FGControls::get_pack_on, &FGControls::set_pack_on);
582 fgSetArchivable(name);
586 fgTie("/controls/lighting/landing-lights", this,
587 &FGControls::get_landing_lights,
588 &FGControls::set_landing_lights);
589 fgSetArchivable("/controls/lighting/landing-lights");
591 fgTie("/controls/lighting/turn-off-lights", this,
592 &FGControls::get_turn_off_lights,
593 &FGControls::set_turn_off_lights);
594 fgSetArchivable("/controls/lighting/turn-off-lights");
596 fgTie("/controls/lighting/taxi-light", this,
597 &FGControls::get_taxi_light, &FGControls::set_taxi_light);
598 fgSetArchivable("/controls/lighting/taxi-light");
600 fgTie("/controls/lighting/logo-lights", this,
601 &FGControls::get_logo_lights, &FGControls::set_logo_lights);
602 fgSetArchivable("/controls/lighting/logo-lights");
604 fgTie("/controls/lighting/nav-lights", this,
605 &FGControls::get_nav_lights, &FGControls::set_nav_lights);
606 fgSetArchivable("/controls/lighting/nav-lights");
608 fgTie("/controls/lighting/beacon", this,
609 &FGControls::get_beacon, &FGControls::set_beacon);
610 fgSetArchivable("/controls/lighting/beacon");
612 fgTie("/controls/lighting/strobe", this,
613 &FGControls::get_strobe, &FGControls::set_strobe);
614 fgSetArchivable("/controls/lighting/strobe");
616 fgTie("/controls/lighting/panel-norm", this,
617 &FGControls::get_panel_norm, &FGControls::set_panel_norm);
618 fgSetArchivable("/controls/lighting/panel-norm");
620 fgTie("/controls/lighting/instruments-norm", this,
621 &FGControls::get_instruments_norm,
622 &FGControls::set_instruments_norm);
623 fgSetArchivable("/controls/lighting/instruments-norm");
625 fgTie("/controls/lighting/dome-norm", this,
626 &FGControls::get_dome_norm, &FGControls::set_dome_norm);
627 fgSetArchivable("/controls/lighting/dome-norm");
629 #ifdef FG_HAVE_ARMAMENT
631 fgTie("/controls/armament/master-arm", this,
632 &FGControls::get_master_arm, &FGControls::set_master_arm);
633 fgSetArchivable("/controls/armament/master-arm");
635 fgTie("/controls/armament/station-select", this,
636 &FGControls::get_station_select,
637 &FGControls::set_station_select);
638 fgSetArchivable("/controls/armament/station-select");
640 fgTie("/controls/armament/release-all", this,
641 &FGControls::get_release_ALL,
642 &FGControls::set_release_ALL);
643 fgSetArchivable("/controls/armament/release-all");
645 for (index = 0; index < MAX_STATIONS; index++) {
646 char name[MAX_NAME_LEN];
647 snprintf(name, MAX_NAME_LEN,
648 "/controls/armament/station[%d]/stick-size", index);
649 fgTie(name, this, index,
650 &FGControls::get_stick_size, &FGControls::set_stick_size);
651 fgSetArchivable(name);
653 snprintf(name, MAX_NAME_LEN,
654 "/controls/armament/station[%d]/release-stick", index);
655 fgTie(name, this, index,
656 &FGControls::get_release_stick, &FGControls::set_release_stick);
657 fgSetArchivable(name);
659 snprintf(name, MAX_NAME_LEN,
660 "/controls/armament/station[%d]/release-all", index);
661 fgTie(name, this, index,
662 &FGControls::get_release_all, &FGControls::set_release_all);
663 fgSetArchivable(name);
665 snprintf(name, MAX_NAME_LEN,
666 "/controls/armament/station[%d]/jettison-all", index);
667 fgTie(name, this, index,
668 &FGControls::get_jettison_all, &FGControls::set_jettison_all);
669 fgSetArchivable(name);
675 fgTie("/controls/seat/vertical-adjust", this,
676 &FGControls::get_vertical_adjust,
677 &FGControls::set_vertical_adjust);
678 fgSetArchivable("/controls/seat/vertical-adjust");
680 fgTie("/controls/seat/fore-aft-adjust", this,
681 &FGControls::get_fore_aft_adjust,
682 &FGControls::set_fore_aft_adjust);
683 fgSetArchivable("/controls/seat/fore-aft-adjust");
685 for (index = 0; index < MAX_EJECTION_SEATS; index++) {
686 char name[MAX_NAME_LEN];
687 snprintf(name, MAX_NAME_LEN,
688 "/controls/seat/eject[%d]/initiate", index);
689 fgTie(name, this, index,
690 &FGControls::get_ejection_seat,
691 &FGControls::set_ejection_seat);
692 fgSetArchivable(name);
694 snprintf(name, MAX_NAME_LEN,
695 "/controls/seat/eject[%d]/status", index);
697 fgTie(name, this, index,
698 &FGControls::get_eseat_status,
699 &FGControls::set_eseat_status);
701 fgSetArchivable(name);
704 fgTie("/controls/seat/cmd_selector_valve", this,
705 &FGControls::get_cmd_selector_valve,
706 &FGControls::set_cmd_selector_valve);
707 fgSetArchivable("/controls/seat/eject/cmd_selector_valve");
711 fgTie("/controls/APU/off-start-run", this,
712 &FGControls::get_off_start_run,
713 &FGControls::set_off_start_run);
714 fgSetArchivable("/controls/APU/off-start-run");
716 fgTie("/controls/APU/fire-switch", this,
717 &FGControls::get_APU_fire_switch,
718 &FGControls::set_APU_fire_switch);
719 fgSetArchivable("/controls/APU/fire-switch");
722 for (index = 0; index < MAX_AUTOPILOTS; index++) {
723 char name[MAX_NAME_LEN];
724 snprintf(name, MAX_NAME_LEN,
725 "/controls/autoflight/autopilot[%d]/engage", index);
726 fgTie(name, this, index,
727 &FGControls::get_autopilot_engage,
728 &FGControls::set_autopilot_engage);
729 fgSetArchivable(name);
732 fgTie("/controls/autoflight/autothrottle-arm", this,
733 &FGControls::get_autothrottle_arm,
734 &FGControls::set_autothrottle_arm);
735 fgSetArchivable("/controls/autoflight/autothrottle-arm");
737 fgTie("/controls/autoflight/autothrottle-engage", this,
738 &FGControls::get_autothrottle_engage,
739 &FGControls::set_autothrottle_engage);
740 fgSetArchivable("/controls/autoflight/autothrottle-engage");
742 fgTie("/controls/autoflight/heading-select", this,
743 &FGControls::get_heading_select,
744 &FGControls::set_heading_select);
745 fgSetArchivable("/controls/autoflight/heading-select");
747 fgTie("/controls/autoflight/altitude-select", this,
748 &FGControls::get_altitude_select,
749 &FGControls::set_altitude_select);
750 fgSetArchivable("/controls/autoflight/altitude-select");
752 fgTie("/controls/autoflight/bank-angle-select", this,
753 &FGControls::get_bank_angle_select,
754 &FGControls::set_bank_angle_select);
755 fgSetArchivable("/controls/autoflight/bank-angle-select");
757 fgTie("/controls/autoflight/vertical-speed-select", this,
758 &FGControls::get_vertical_speed_select,
759 &FGControls::set_vertical_speed_select);
760 fgSetArchivable("/controls/autoflight/vertical-speed-select");
762 fgTie("/controls/autoflight/speed-select", this,
763 &FGControls::get_speed_select,
764 &FGControls::set_speed_select);
765 fgSetArchivable("/controls/autoflight/speed-select");
767 fgTie("/controls/autoflight/mach-select", this,
768 &FGControls::get_mach_select,
769 &FGControls::set_mach_select);
770 fgSetArchivable("/controls/autoflight/mach-select");
772 fgTie("/controls/autoflight/vertical-mode", this,
773 &FGControls::get_vertical_mode,
774 &FGControls::set_vertical_mode);
775 fgSetArchivable("/controls/autoflight/vertical-mode");
777 fgTie("/controls/autoflight/lateral-mode", this,
778 &FGControls::get_lateral_mode,
779 &FGControls::set_lateral_mode);
780 fgSetArchivable("/controls/autoflight/lateral-mode");
784 void FGControls::unbind ()
787 //Tie control properties.
788 fgUntie("/controls/flight/aileron");
789 fgUntie("/controls/flight/aileron-trim");
790 fgUntie("/controls/flight/elevator");
791 fgUntie("/controls/flight/elevator-trim");
792 fgUntie("/controls/flight/rudder");
793 fgUntie("/controls/flight/rudder-trim");
794 fgUntie("/controls/flight/flaps");
795 fgUntie("/controls/flight/slats");
796 fgUntie("/controls/flight/BLC");
797 fgUntie("/controls/flight/spoilers");
798 fgUntie("/controls/flight/speedbrake");
799 fgUntie("/controls/flight/wing-sweep");
800 fgUntie("/controls/flight/wing-fold");
801 fgUntie("/controls/flight/drag-chute");
802 for (index = 0; index < MAX_ENGINES; index++) {
803 char name[MAX_NAME_LEN];
804 snprintf(name, MAX_NAME_LEN,
805 "/controls/engines/engine[%d]/throttle", index);
807 snprintf(name, MAX_NAME_LEN,
808 "/controls/engines/engine[%d]/starter", index);
810 snprintf(name, MAX_NAME_LEN,
811 "/controls/engines/engine[%d]/fuel_pump", index);
813 snprintf(name, MAX_NAME_LEN,
814 "/controls/engines/engine[%d]/fire-switch", index);
816 snprintf(name, MAX_NAME_LEN,
817 "/controls/engines/engine[%d]/fire-bottle-discharge", index);
819 snprintf(name, MAX_NAME_LEN,
820 "/controls/engines/engine[%d]/throttle_idle", index);
822 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/cutoff", index);
824 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/mixture", index);
826 snprintf(name, MAX_NAME_LEN,
827 "/controls/engines/engine[%d]/propeller-pitch", index);
829 snprintf(name, MAX_NAME_LEN,
830 "/controls/engines/engine[%d]/magnetos", index);
832 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/WEP", index);
834 snprintf(name, MAX_NAME_LEN,
835 "/controls/engines/engine[%d]/cowl-flaps-norm", index);
837 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/feather", index);
839 snprintf(name, MAX_NAME_LEN,
840 "/controls/engines/engine[%d]/ignition", index);
842 snprintf(name, MAX_NAME_LEN,
843 "/controls/engines/engine[%d]/augmentation", index);
845 snprintf(name, MAX_NAME_LEN,
846 "/controls/engines/engine[%d]/reverser", index);
848 snprintf(name, MAX_NAME_LEN,
849 "/controls/engines/engine[%d]/water-injection", index);
851 snprintf(name, MAX_NAME_LEN,
852 "/controls/engines/engine[%d]/condition", index);
855 fgUntie("/controls/fuel/dump-valve");
856 for (index = 0; index < MAX_TANKS; index++) {
857 char name[MAX_NAME_LEN];
858 snprintf(name, MAX_NAME_LEN,
859 "/controls/fuel/tank[%d]/fuel_selector", index);
861 snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_engine", index);
863 snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_tank", index);
865 for (i = 0; index < MAX_BOOSTPUMPS; i++) {
866 snprintf(name, MAX_NAME_LEN,
867 "/controls/fuel/tank[%d]/boost-pump[%d]", index, i);
871 fgUntie("/controls/gear/parking_brake");
872 fgUntie("/controls/gear/steering");
873 fgUntie("/controls/gear/gear_down");
874 fgUntie("/controls/gear/antiskid");
875 fgUntie("/controls/gear/tailhook");
876 fgUntie("/controls/gear/tailwheel-lock");
877 for (index = 0; index < MAX_WHEELS; index++) {
878 char name[MAX_NAME_LEN];
879 snprintf(name, MAX_NAME_LEN, "/controls/gear/wheel[%d]/brakes", index);
881 snprintf(name, MAX_NAME_LEN,
882 "/controls/gear/wheel[%d]/alternate-extension", index);
885 fgUntie("/controls/anti-ice/wing-heat");
886 fgUntie("/controls/anti-ice/pitot-heat");
887 fgUntie("/controls/anti-ice/wiper");
888 fgUntie("/controls/anti-ice/window-heat");
889 for (index = 0; index < MAX_ENGINES; index++) {
890 char name[MAX_NAME_LEN];
891 snprintf(name, MAX_NAME_LEN,
892 "/controls/anti-ice/engine[%d]/carb-heat", index);
894 snprintf(name, MAX_NAME_LEN,
895 "/controls/anti-ice/engine[%d]/inlet-heat", index);
898 for (index = 0; index < MAX_HYD_SYSTEMS; index++) {
899 char name[MAX_NAME_LEN];
900 snprintf(name, MAX_NAME_LEN,
901 "/controls/hydraulic/system[%d]/engine-pump", index);
903 snprintf(name, MAX_NAME_LEN,
904 "/controls/hydraulic/system[%d]/electric-pump", index);
907 fgUntie("/controls/electric/battery-switch");
908 fgUntie("/controls/electric/external-power");
909 fgUntie("/controls/electric/APU-generator");
910 for (index = 0; index < MAX_ENGINES; index++) {
911 char name[MAX_NAME_LEN];
912 snprintf(name, MAX_NAME_LEN,
913 "/controls/electric/engine[%d]/generator", index);
915 snprintf(name, MAX_NAME_LEN,
916 "/controls/electric/engine[%d]/bus-tie", index);
919 fgUntie("/controls/pneumatic/APU-bleed");
920 for (index = 0; index < MAX_ENGINES; index++) {
921 char name[MAX_NAME_LEN];
922 snprintf(name, MAX_NAME_LEN,
923 "/controls/pneumatic/engine[%d]/bleed", index);
926 fgUntie("/controls/pressurization/mode");
927 fgUntie("/controls/pressurization/dump");
928 for (index = 0; index < MAX_PACKS; index++) {
929 char name[MAX_NAME_LEN];
930 snprintf(name, MAX_NAME_LEN,
931 "/controls/pressurization/pack[%d]/pack-on", index);
934 fgUntie("/controls/lighting/landing-lights");
935 fgUntie("/controls/lighting/turn-off-lights");
936 fgUntie("/controls/lighting/taxi-light");
937 fgUntie("/controls/lighting/logo-lights");
938 fgUntie("/controls/lighting/nav-lights");
939 fgUntie("/controls/lighting/beacon");
940 fgUntie("/controls/lighting/strobe");
941 fgUntie("/controls/lighting/panel-norm");
942 fgUntie("/controls/lighting/instruments-norm");
943 fgUntie("/controls/lighting/dome-norm");
945 #ifdef FG_HAVE_ARMAMENT
946 fgUntie("/controls/armament/master-arm");
947 fgUntie("/controls/armament/station-select");
948 fgUntie("/controls/armament/release-all");
949 for (index = 0; index < MAX_STATIONS; index++) {
950 char name[MAX_NAME_LEN];
951 snprintf(name, MAX_NAME_LEN,
952 "/controls/armament/station[%d]/stick-size", index);
954 snprintf(name, MAX_NAME_LEN,
955 "/controls/armament/station[%d]/release-stick", index);
957 snprintf(name, MAX_NAME_LEN,
958 "/controls/armament/station[%d]/release-all", index);
960 snprintf(name, MAX_NAME_LEN,
961 "/controls/armament/station[%d]/jettison-all", index);
965 fgUntie("/controls/seat/vertical-adjust");
966 fgUntie("/controls/seat/fore-aft-adjust");
967 for (index = 0; index < MAX_EJECTION_SEATS; index++) {
968 char name[MAX_NAME_LEN];
969 snprintf(name, MAX_NAME_LEN,
970 "/controls/seat/eject[%d]/initiate", index);
972 snprintf(name, MAX_NAME_LEN,
973 "/controls/seat/eject[%d]/status", index);
976 fgUntie("/controls/seat/cmd_selector_valve");
978 fgUntie("/controls/APU/off-start-run");
979 fgUntie("/controls/APU/fire-switch");
980 for (index = 0; index < MAX_AUTOPILOTS; index++) {
981 char name[MAX_NAME_LEN];
982 snprintf(name, MAX_NAME_LEN,
983 "/controls/autoflight/autopilot[%d]/engage", index);
986 fgUntie("/controls/autoflight/autothrottle-arm");
987 fgUntie("/controls/autoflight/autothrottle-engage");
988 fgUntie("/controls/autoflight/heading-select");
989 fgUntie("/controls/autoflight/altitude-select");
990 fgUntie("/controls/autoflight/bank-angle-select");
991 fgUntie("/controls/autoflight/vertical-speed-select");
992 fgUntie("/controls/autoflight/speed-select");
993 fgUntie("/controls/autoflight/mach-select");
994 fgUntie("/controls/autoflight/vertical-mode");
995 fgUntie("/controls/autoflight/lateral-mode");
1000 FGControls::update (double dt)
1006 ////////////////////////////////////////////////////////////////////////
1007 // Setters and adjusters.
1008 ////////////////////////////////////////////////////////////////////////
1011 FGControls::set_aileron (double pos)
1014 CLAMP( &aileron, -1.0, 1.0 );
1016 // check for autocoordination
1017 if ( auto_coordination->getBoolValue() ) {
1018 set_rudder( aileron / 2.0 );
1023 FGControls::move_aileron (double amt)
1026 CLAMP( &aileron, -1.0, 1.0 );
1028 // check for autocoordination
1029 if ( auto_coordination->getBoolValue() ) {
1030 set_rudder( aileron / 2.0 );
1035 FGControls::set_aileron_trim( double pos )
1038 CLAMP( &aileron_trim, -1.0, 1.0 );
1042 FGControls::move_aileron_trim( double amt )
1044 aileron_trim += amt;
1045 CLAMP( &aileron_trim, -1.0, 1.0 );
1049 FGControls::set_elevator( double pos )
1052 CLAMP( &elevator, -1.0, 1.0 );
1056 FGControls::move_elevator( double amt )
1059 CLAMP( &elevator, -1.0, 1.0 );
1063 FGControls::set_elevator_trim( double pos )
1065 elevator_trim = pos;
1066 CLAMP( &elevator_trim, -1.0, 1.0 );
1070 FGControls::move_elevator_trim( double amt )
1072 elevator_trim += amt;
1073 CLAMP( &elevator_trim, -1.0, 1.0 );
1077 FGControls::set_rudder( double pos )
1080 CLAMP( &rudder, -1.0, 1.0 );
1084 FGControls::move_rudder( double amt )
1087 CLAMP( &rudder, -1.0, 1.0 );
1091 FGControls::set_rudder_trim( double pos )
1094 CLAMP( &rudder_trim, -1.0, 1.0 );
1098 FGControls::move_rudder_trim( double amt )
1101 CLAMP( &rudder_trim, -1.0, 1.0 );
1105 FGControls::set_flaps( double pos )
1108 CLAMP( &flaps, 0.0, 1.0 );
1112 FGControls::move_flaps( double amt )
1115 CLAMP( &flaps, 0.0, 1.0 );
1119 FGControls::set_slats( double pos )
1122 CLAMP( &slats, 0.0, 1.0 );
1126 FGControls::move_slats( double amt )
1129 CLAMP( &slats, 0.0, 1.0 );
1133 FGControls::set_BLC( bool val )
1139 FGControls::set_spoilers( double pos )
1142 CLAMP( &spoilers, 0.0, 1.0 );
1146 FGControls::move_spoilers( double amt )
1149 CLAMP( &spoilers, 0.0, 1.0 );
1153 FGControls::set_speedbrake( double pos )
1156 CLAMP( &speedbrake, 0.0, 1.0 );
1160 FGControls::move_speedbrake( double amt )
1163 CLAMP( &speedbrake, 0.0, 1.0 );
1167 FGControls::set_wing_sweep( double pos )
1170 CLAMP( &wing_sweep, 0.0, 1.0 );
1174 FGControls::move_wing_sweep( double amt )
1177 CLAMP( &wing_sweep, 0.0, 1.0 );
1181 FGControls::set_wing_fold( bool val )
1187 FGControls::set_drag_chute( bool val )
1193 FGControls::set_throttle_idle( bool val )
1195 throttle_idle = val;
1199 FGControls::set_throttle( int engine, double pos )
1201 if ( engine == ALL_ENGINES ) {
1202 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1204 CLAMP( &throttle[i], 0.0, 1.0 );
1207 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1208 throttle[engine] = pos;
1209 CLAMP( &throttle[engine], 0.0, 1.0 );
1215 FGControls::move_throttle( int engine, double amt )
1217 if ( engine == ALL_ENGINES ) {
1218 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1220 CLAMP( &throttle[i], 0.0, 1.0 );
1223 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1224 throttle[engine] += amt;
1225 CLAMP( &throttle[engine], 0.0, 1.0 );
1231 FGControls::set_starter( int engine, bool flag )
1233 if ( engine == ALL_ENGINES ) {
1234 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1238 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1239 starter[engine] = flag;
1245 FGControls::set_fuel_pump( int engine, bool val )
1247 if ( engine == ALL_ENGINES ) {
1248 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1252 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1253 fuel_pump[engine] = val;
1259 FGControls::set_fire_switch( int engine, bool val )
1261 if ( engine == ALL_ENGINES ) {
1262 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1263 fire_switch[i] = val;
1266 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1267 fire_switch[engine] = val;
1273 FGControls::set_fire_bottle_discharge( int engine, bool val )
1275 if ( engine == ALL_ENGINES ) {
1276 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1277 fire_bottle_discharge[i] = val;
1280 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1281 fire_bottle_discharge[engine] = val;
1287 FGControls::set_cutoff( int engine, bool val )
1289 if ( engine == ALL_ENGINES ) {
1290 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1294 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1295 cutoff[engine] = val;
1302 FGControls::set_mixture( int engine, double pos )
1304 if ( engine == ALL_ENGINES ) {
1305 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1307 CLAMP( &mixture[i], 0.0, 1.0 );
1310 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1311 mixture[engine] = pos;
1312 CLAMP( &mixture[engine], 0.0, 1.0 );
1318 FGControls::move_mixture( int engine, double amt )
1320 if ( engine == ALL_ENGINES ) {
1321 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1323 CLAMP( &mixture[i], 0.0, 1.0 );
1326 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1327 mixture[engine] += amt;
1328 CLAMP( &mixture[engine], 0.0, 1.0 );
1334 FGControls::set_prop_advance( int engine, double pos )
1336 if ( engine == ALL_ENGINES ) {
1337 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1338 prop_advance[i] = pos;
1339 CLAMP( &prop_advance[i], 0.0, 1.0 );
1342 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1343 prop_advance[engine] = pos;
1344 CLAMP( &prop_advance[engine], 0.0, 1.0 );
1350 FGControls::move_prop_advance( int engine, double amt )
1352 if ( engine == ALL_ENGINES ) {
1353 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1354 prop_advance[i] += amt;
1355 CLAMP( &prop_advance[i], 0.0, 1.0 );
1358 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1359 prop_advance[engine] += amt;
1360 CLAMP( &prop_advance[engine], 0.0, 1.0 );
1366 FGControls::set_magnetos( int engine, int pos )
1368 if ( engine == ALL_ENGINES ) {
1369 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1371 CLAMP( &magnetos[i], 0, 3 );
1374 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1375 magnetos[engine] = pos;
1376 CLAMP( &magnetos[engine], 0, 3 );
1382 FGControls::move_magnetos( int engine, int amt )
1384 if ( engine == ALL_ENGINES ) {
1385 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1387 CLAMP( &magnetos[i], 0, 3 );
1390 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1391 magnetos[engine] += amt;
1392 CLAMP( &magnetos[engine], 0, 3 );
1398 FGControls::set_nitrous_injection( int engine, bool val )
1400 if ( engine == ALL_ENGINES ) {
1401 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1402 nitrous_injection[i] = val;
1405 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1406 nitrous_injection[engine] = val;
1413 FGControls::set_cowl_flaps_norm( int engine, double pos )
1415 if ( engine == ALL_ENGINES ) {
1416 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1417 cowl_flaps_norm[i] = pos;
1418 CLAMP( &cowl_flaps_norm[i], 0.0, 1.0 );
1421 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1422 cowl_flaps_norm[engine] = pos;
1423 CLAMP( &cowl_flaps_norm[engine], 0.0, 1.0 );
1429 FGControls::move_cowl_flaps_norm( int engine, double amt )
1431 if ( engine == ALL_ENGINES ) {
1432 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1433 cowl_flaps_norm[i] += amt;
1434 CLAMP( &cowl_flaps_norm[i], 0.0, 1.0 );
1437 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1438 cowl_flaps_norm[engine] += amt;
1439 CLAMP( &cowl_flaps_norm[engine], 0.0, 1.0 );
1445 FGControls::set_feather( int engine, bool val )
1447 if ( engine == ALL_ENGINES ) {
1448 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1452 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1453 feather[engine] = val;
1459 FGControls::set_ignition( int engine, int pos )
1461 if ( engine == ALL_ENGINES ) {
1462 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1464 CLAMP( &ignition[i], 0, 3 );
1467 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1468 ignition[engine] = pos;
1469 CLAMP( &ignition[engine], 0, 3 );
1475 FGControls::set_augmentation( int engine, bool val )
1477 if ( engine == ALL_ENGINES ) {
1478 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1479 augmentation[i] = val;
1482 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1483 augmentation[engine] = val;
1489 FGControls::set_reverser( int engine, bool val )
1491 if ( engine == ALL_ENGINES ) {
1492 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1496 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1497 reverser[engine] = val;
1503 FGControls::set_water_injection( int engine, bool val )
1505 if ( engine == ALL_ENGINES ) {
1506 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1507 water_injection[i] = val;
1510 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1511 water_injection[engine] = val;
1517 FGControls::set_condition( int engine, int val )
1519 if ( engine == ALL_ENGINES ) {
1520 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1522 CLAMP( &condition[i], 0, 3 );
1525 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1526 condition[engine] = val;
1527 CLAMP( &condition[engine], 0, 3 );
1533 FGControls::set_dump_valve( bool val )
1540 FGControls::set_fuel_selector( int tank, bool pos )
1542 if ( tank == ALL_TANKS ) {
1543 for ( int i = 0; i < MAX_TANKS; i++ ) {
1544 fuel_selector[i] = pos;
1547 if ( (tank >= 0) && (tank < MAX_TANKS) ) {
1548 fuel_selector[tank] = pos;
1554 FGControls::set_to_engine( int tank, int engine )
1556 if ( tank == ALL_TANKS ) {
1557 for ( int i = 0; i < MAX_TANKS; i++ ) {
1558 to_engine[i] = engine;
1561 if ( (tank >= 0) && (tank < MAX_TANKS) ) {
1562 to_engine[tank] = engine;
1568 FGControls::set_to_tank( int tank, int dest_tank )
1570 if ( tank == ALL_TANKS ) {
1571 for ( int i = 0; i < MAX_TANKS; i++ ) {
1572 to_tank[i] = dest_tank;
1575 if ( (tank >= 0) && (tank < MAX_TANKS) ) {
1576 to_tank[tank] = dest_tank;
1582 FGControls::set_boost_pump( int index, bool val )
1584 if ( index == -1 ) {
1585 for ( int i = 0; i < (MAX_TANKS * MAX_BOOSTPUMPS); i++ ) {
1586 boost_pump[i] = val;
1589 if ( (index >= 0) && (index < (MAX_TANKS * MAX_BOOSTPUMPS)) ) {
1590 boost_pump[index] = val;
1597 FGControls::set_parking_brake( double pos )
1599 parking_brake = pos;
1600 CLAMP(&parking_brake, 0.0, 1.0);
1604 FGControls::set_steering( double angle )
1607 CLAMP(&steering, -80.0, 80.0);
1611 FGControls::move_steering( double angle )
1614 CLAMP(&steering, -80.0, 80.0);
1618 FGControls::set_gear_down( bool gear )
1624 FGControls::set_antiskid( bool state )
1630 FGControls::set_tailhook( bool state )
1636 FGControls::set_tailwheel_lock( bool state )
1638 tailwheel_lock = state;
1643 FGControls::set_brake( int wheel, double pos )
1645 if ( wheel == ALL_WHEELS ) {
1646 for ( int i = 0; i < MAX_WHEELS; i++ ) {
1648 CLAMP( &brake[i], 0.0, 1.0 );
1651 if ( (wheel >= 0) && (wheel < MAX_WHEELS) ) {
1653 CLAMP( &brake[wheel], 0.0, 1.0 );
1659 FGControls::move_brake( int wheel, double amt )
1661 if ( wheel == ALL_WHEELS ) {
1662 for ( int i = 0; i < MAX_WHEELS; i++ ) {
1664 CLAMP( &brake[i], 0.0, 1.0 );
1667 if ( (wheel >= 0) && (wheel < MAX_WHEELS) ) {
1668 brake[wheel] += amt;
1669 CLAMP( &brake[wheel], 0.0, 1.0 );
1675 FGControls::set_alternate_extension( int wheel, bool val )
1677 if ( wheel == ALL_WHEELS ) {
1678 for ( int i = 0; i < MAX_WHEELS; i++ ) {
1679 alternate_extension[i] = val;
1682 if ( (wheel >= 0) && (wheel < MAX_WHEELS) ) {
1683 alternate_extension[wheel] = val;
1689 FGControls::set_wing_heat( bool state )
1695 FGControls::set_pitot_heat( bool state )
1701 FGControls::set_wiper( int state )
1707 FGControls::set_window_heat( bool state )
1709 window_heat = state;
1713 FGControls::set_carb_heat( int engine, bool val )
1715 if ( engine == ALL_ENGINES ) {
1716 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1720 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1721 carb_heat[engine] = val;
1727 FGControls::set_inlet_heat( int engine, bool val )
1729 if ( engine == ALL_ENGINES ) {
1730 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1731 inlet_heat[i] = val;
1734 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1735 inlet_heat[engine] = val;
1741 FGControls::set_engine_pump( int system, bool val )
1743 if ( system == ALL_HYD_SYSTEMS ) {
1744 for ( int i = 0; i < MAX_HYD_SYSTEMS; i++ ) {
1745 engine_pump[i] = val;
1748 if ( (system >= 0) && (system < MAX_HYD_SYSTEMS) ) {
1749 engine_pump[system] = val;
1755 FGControls::set_electric_pump( int system, bool val )
1757 if ( system == ALL_HYD_SYSTEMS ) {
1758 for ( int i = 0; i < MAX_HYD_SYSTEMS; i++ ) {
1759 electric_pump[i] = val;
1762 if ( (system >= 0) && (system < MAX_HYD_SYSTEMS) ) {
1763 electric_pump[system] = val;
1769 FGControls::set_battery_switch( bool state )
1771 battery_switch = state;
1775 FGControls::set_external_power( bool state )
1777 external_power = state;
1781 FGControls::set_APU_generator( bool state )
1783 APU_generator = state;
1787 FGControls::set_generator_breaker( int engine, bool val )
1789 if ( engine == ALL_ENGINES ) {
1790 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1791 generator_breaker[i] = val;
1794 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1795 generator_breaker[engine] = val;
1801 FGControls::set_bus_tie( int engine, bool val )
1803 if ( engine == ALL_ENGINES ) {
1804 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1808 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1809 bus_tie[engine] = val;
1815 FGControls::set_APU_bleed( bool state )
1821 FGControls::set_engine_bleed( int engine, bool val )
1823 if ( engine == ALL_ENGINES ) {
1824 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1825 engine_bleed[i] = val;
1828 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1829 engine_bleed[engine] = val;
1835 FGControls::set_mode( int new_mode )
1841 FGControls::set_outflow_valve( double pos )
1843 outflow_valve = pos;
1844 CLAMP( &outflow_valve, 0.0, 1.0 );
1848 FGControls::move_outflow_valve( double amt )
1850 outflow_valve += amt;
1851 CLAMP( &outflow_valve, 0.0, 1.0 );
1855 FGControls::set_dump( bool state )
1861 FGControls::set_pack_on( int pack, bool val )
1863 if ( pack == ALL_PACKS ) {
1864 for ( int i = 0; i < MAX_PACKS; i++ ) {
1868 if ( (pack >= 0) && (pack < MAX_PACKS) ) {
1869 pack_on[pack] = val;
1875 FGControls::set_landing_lights( bool state )
1877 landing_lights = state;
1881 FGControls::set_turn_off_lights( bool state )
1883 turn_off_lights = state;
1887 FGControls::set_taxi_light( bool state )
1893 FGControls::set_logo_lights( bool state )
1895 logo_lights = state;
1899 FGControls::set_nav_lights( bool state )
1905 FGControls::set_beacon( bool state )
1911 FGControls::set_strobe( bool state )
1917 FGControls::set_panel_norm( double intensity )
1919 panel_norm = intensity;
1920 CLAMP( &panel_norm, 0.0, 1.0 );
1924 FGControls::move_panel_norm( double amt )
1927 CLAMP( &panel_norm, 0.0, 1.0 );
1931 FGControls::set_instruments_norm( double intensity )
1933 instruments_norm = intensity;
1934 CLAMP( &instruments_norm, 0.0, 1.0 );
1938 FGControls::move_instruments_norm( double amt )
1940 instruments_norm += amt;
1941 CLAMP( &instruments_norm, 0.0, 1.0 );
1945 FGControls::set_dome_norm( double intensity )
1947 dome_norm = intensity;
1948 CLAMP( &dome_norm, 0.0, 1.0 );
1952 FGControls::move_dome_norm( double amt )
1955 CLAMP( &dome_norm, 0.0, 1.0 );
1958 #ifdef FG_HAVE_ARMAMENT
1961 FGControls::set_master_arm( bool val )
1967 FGControls::set_station_select( int station )
1969 station_select = station;
1970 CLAMP( &station_select, 0, MAX_STATIONS );
1974 FGControls::set_release_ALL( bool val )
1980 FGControls::set_stick_size( int station, int size )
1982 if ( station == ALL_STATIONS ) {
1983 for ( int i = 0; i < MAX_STATIONS; i++ ) {
1984 stick_size[i] = size;
1985 CLAMP( &stick_size[i], 1, 20 );
1988 if ( (station >= 0) && (station < MAX_STATIONS) ) {
1989 stick_size[station] = size;
1990 CLAMP( &stick_size[station], 1, 20 );
1996 FGControls::set_release_stick( int station, bool val )
1998 if ( station == ALL_STATIONS ) {
1999 for ( int i = 0; i < MAX_STATIONS; i++ ) {
2000 release_stick[i] = val;
2003 if ( (station >= 0) && (station < MAX_STATIONS) ) {
2004 release_stick[station] = val;
2010 FGControls::set_release_all( int station, bool val )
2012 if ( station == ALL_STATIONS ) {
2013 for ( int i = 0; i < MAX_STATIONS; i++ ) {
2014 release_all[i] = val;
2017 if ( (station >= 0) && (station < MAX_STATIONS) ) {
2018 release_all[station] = val;
2024 FGControls::set_jettison_all( int station, bool val )
2026 if ( station == ALL_STATIONS ) {
2027 for ( int i = 0; i < MAX_STATIONS; i++ ) {
2028 jettison_all[i] = val;
2031 if ( (station >= 0) && (station < MAX_STATIONS) ) {
2032 jettison_all[station] = val;
2040 FGControls::set_vertical_adjust( double pos )
2042 vertical_adjust = pos;
2043 CLAMP( &vertical_adjust, -1.0, 1.0 );
2047 FGControls::move_vertical_adjust( double amt )
2049 vertical_adjust += amt;
2050 CLAMP( &vertical_adjust, -1.0, 1.0 );
2054 FGControls::set_fore_aft_adjust( double pos )
2056 fore_aft_adjust = pos;
2057 CLAMP( &fore_aft_adjust, -1.0, 1.0 );
2061 FGControls::move_fore_aft_adjust( double amt )
2063 fore_aft_adjust += amt;
2064 CLAMP( &fore_aft_adjust, -1.0, 1.0 );
2068 FGControls::set_ejection_seat( int which_seat, bool val )
2070 if ( which_seat == ALL_EJECTION_SEATS ) {
2071 for ( int i = 0; i < MAX_EJECTION_SEATS; i++ ) {
2075 if ( (which_seat >= 0) && (which_seat <= MAX_EJECTION_SEATS) ) {
2076 if ( eseat_status[which_seat] == SEAT_SAFED ||
2077 eseat_status[which_seat] == SEAT_FAIL )
2079 // we can never eject if SEAT_SAFED or SEAT_FAIL
2083 eject[which_seat] = val;
2089 FGControls::set_eseat_status( int which_seat, int val )
2091 if ( which_seat == ALL_EJECTION_SEATS ) {
2092 for ( int i = 0; i < MAX_EJECTION_SEATS; i++ ) {
2093 eseat_status[i] = val;
2096 if ( (which_seat >=0) && (which_seat <= MAX_EJECTION_SEATS) ) {
2097 eseat_status[which_seat] = val;
2103 FGControls::set_cmd_selector_valve( int val )
2105 cmd_selector_valve = val;
2110 FGControls::set_off_start_run( int pos )
2112 off_start_run = pos;
2113 CLAMP( &off_start_run, 0, 3 );
2117 FGControls::set_APU_fire_switch( bool val )
2119 APU_fire_switch = val;
2123 FGControls::set_autothrottle_arm( bool val )
2125 autothrottle_arm = val;
2129 FGControls::set_autothrottle_engage( bool val )
2131 autothrottle_engage = val;
2135 FGControls::set_heading_select( double heading )
2137 heading_select = heading;
2138 CLAMP( &heading_select, 0.0, 360.0 );
2142 FGControls::move_heading_select( double amt )
2144 heading_select += amt;
2145 CLAMP( &heading_select, 0.0, 360.0 );
2149 FGControls::set_altitude_select( double altitude )
2151 altitude_select = altitude;
2152 CLAMP( &altitude_select, -1000.0, 100000.0 );
2156 FGControls::move_altitude_select( double amt )
2158 altitude_select += amt;
2159 CLAMP( &altitude_select, -1000.0, 100000.0 );
2163 FGControls::set_bank_angle_select( double angle )
2165 bank_angle_select = angle;
2166 CLAMP( &bank_angle_select, 10.0, 30.0 );
2170 FGControls::move_bank_angle_select( double amt )
2172 bank_angle_select += amt;
2173 CLAMP( &bank_angle_select, 10.0, 30.0 );
2177 FGControls::set_vertical_speed_select( double speed )
2179 vertical_speed_select = speed;
2180 CLAMP( &vertical_speed_select, -3000.0, 4000.0 );
2184 FGControls::move_vertical_speed_select( double amt )
2186 vertical_speed_select += amt;
2187 CLAMP( &vertical_speed_select, -3000.0, 4000.0 );
2191 FGControls::set_speed_select( double speed )
2193 speed_select = speed;
2194 CLAMP( &speed_select, 60.0, 400.0 );
2198 FGControls::move_speed_select( double amt )
2200 speed_select += amt;
2201 CLAMP( &speed_select, 60.0, 400.0 );
2205 FGControls::set_mach_select( double mach )
2208 CLAMP( &mach_select, 0.4, 4.0 );
2212 FGControls::move_mach_select( double amt )
2215 CLAMP( &mach_select, 0.4, 4.0 );
2219 FGControls::set_vertical_mode( int mode )
2221 vertical_mode = mode;
2222 CLAMP( &vertical_mode, 0, 4 );
2226 FGControls::set_lateral_mode( int mode )
2228 lateral_mode = mode;
2229 CLAMP( &lateral_mode, 0, 4 );
2233 FGControls::set_autopilot_engage( int ap, bool val )
2235 if ( ap == ALL_AUTOPILOTS ) {
2236 for ( int i = 0; i < MAX_AUTOPILOTS; i++ ) {
2237 autopilot_engage[i] = val;
2240 if ( (ap >= 0) && (ap < MAX_AUTOPILOTS) ) {
2241 autopilot_engage[ap] = val;