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 ),
82 tailwheel_lock( false ),
87 battery_switch( true ),
88 external_power( false ),
89 APU_generator( false ),
100 instruments_norm( 0.0 ),
104 release_ALL( false ),
105 vertical_adjust( 0.0 ),
106 fore_aft_adjust( 0.0 ),
108 APU_fire_switch( false ),
109 autothrottle_arm( false ),
110 autothrottle_engage( false ),
111 heading_select( 0.0 ),
112 altitude_select( 50000.0 ),
113 bank_angle_select( 30.0 ),
114 vertical_speed_select( 0.0 ),
123 void FGControls::reset_all()
126 set_aileron_trim( 0.0 );
128 set_elevator_trim( 0.0 );
130 set_rudder_trim( 0.0 );
133 set_speedbrake( 0.0 );
134 set_wing_sweep( 0.0 );
137 set_throttle( ALL_ENGINES, 0.0 );
138 set_starter( ALL_ENGINES, false );
139 set_magnetos( ALL_ENGINES, 0 );
140 set_fuel_pump( ALL_ENGINES, false );
141 set_fire_switch( ALL_ENGINES, false );
142 set_fire_bottle_discharge( ALL_ENGINES, false );
143 set_cutoff( ALL_ENGINES, true );
144 set_nitrous_injection( ALL_ENGINES, false );
145 set_cowl_flaps_norm( ALL_ENGINES, 1.0 );
146 set_feather( ALL_ENGINES, false );
147 set_ignition( ALL_ENGINES, false );
148 set_augmentation( ALL_ENGINES, false );
149 set_reverser( ALL_ENGINES, false );
150 set_water_injection( ALL_ENGINES, false );
151 set_condition( ALL_ENGINES, 1.0 );
152 throttle_idle = true;
153 set_fuel_selector( ALL_TANKS, true );
158 tailwheel_lock = false;
159 set_carb_heat( ALL_ENGINES, false );
160 set_inlet_heat( ALL_ENGINES, false );
165 set_engine_pump( ALL_HYD_SYSTEMS, true );
166 set_electric_pump( ALL_HYD_SYSTEMS, true );
167 landing_lights = false;
168 turn_off_lights = false;
170 set_ejection_seat( ALL_EJECTION_SEATS, false );
171 set_eseat_status( ALL_EJECTION_SEATS, SEAT_SAFED );
172 set_cmd_selector_valve( CMD_SEL_NORM );
173 APU_fire_switch = false;
174 autothrottle_arm = false;
175 autothrottle_engage = false;
176 set_autopilot_engage( ALL_AUTOPILOTS, false );
181 FGControls::~FGControls() {
188 throttle_idle = true;
189 for ( int engine = 0; engine < MAX_ENGINES; engine++ ) {
190 throttle[engine] = 0.0;
191 mixture[engine] = 1.0;
192 fuel_pump[engine] = false;
193 prop_advance[engine] = 1.0;
194 magnetos[engine] = 0;
195 starter[engine] = false;
196 ignition[engine] = false;
197 fire_switch[engine] = false;
198 cutoff[engine] = true;
199 augmentation[engine] = false;
200 reverser[engine] = false;
201 water_injection[engine] = false;
202 nitrous_injection[engine] = false;
203 cowl_flaps_norm[engine] = 0.0;
204 condition[engine] = 1.0;
207 brake_left = brake_right = brake_parking = 0.0;
208 for ( int wheel = 0; wheel < MAX_WHEELS; wheel++ ) {
209 alternate_extension[wheel] = false;
212 auto_coordination = fgGetNode("/sim/auto-coordination", true);
222 fgTie("/controls/flight/aileron", this,
223 &FGControls::get_aileron, &FGControls::set_aileron);
224 fgSetArchivable("/controls/flight/aileron");
226 fgTie("/controls/flight/aileron-trim", this,
227 &FGControls::get_aileron_trim, &FGControls::set_aileron_trim);
228 fgSetArchivable("/controls/flight/aileron-trim");
230 fgTie("/controls/flight/elevator", this,
231 &FGControls::get_elevator, &FGControls::set_elevator);
232 fgSetArchivable("/controls/flight/elevator");
234 fgTie("/controls/flight/elevator-trim", this,
235 &FGControls::get_elevator_trim, &FGControls::set_elevator_trim);
236 fgSetArchivable("/controls/flight/elevator-trim");
238 fgTie("/controls/flight/rudder", this,
239 &FGControls::get_rudder, &FGControls::set_rudder);
240 fgSetArchivable("/controls/flight/rudder");
242 fgTie("/controls/flight/rudder-trim", this,
243 &FGControls::get_rudder_trim, &FGControls::set_rudder_trim);
244 fgSetArchivable("/controls/flight/rudder-trim");
246 fgTie("/controls/flight/flaps", this,
247 &FGControls::get_flaps, &FGControls::set_flaps);
248 fgSetArchivable("/controls/flight/flaps");
250 fgTie("/controls/flight/slats", this,
251 &FGControls::get_slats, &FGControls::set_slats);
252 fgSetArchivable("/controls/flight/slats");
254 fgTie("/controls/flight/BLC", this,
255 &FGControls::get_BLC, &FGControls::set_BLC);
256 fgSetArchivable("/controls/flight/BLC");
258 fgTie("/controls/flight/spoilers", this,
259 &FGControls::get_spoilers, &FGControls::set_spoilers);
260 fgSetArchivable("/controls/flight/spoilers");
262 fgTie("/controls/flight/speedbrake", this,
263 &FGControls::get_speedbrake, &FGControls::set_speedbrake);
264 fgSetArchivable("/controls/flight/speedbrake");
266 fgTie("/controls/flight/wing-sweep", this,
267 &FGControls::get_wing_sweep, &FGControls::set_wing_sweep);
268 fgSetArchivable("/controls/flight/wing-sweep");
270 fgTie("/controls/flight/wing-fold", this,
271 &FGControls::get_wing_fold, &FGControls::set_wing_fold);
272 fgSetArchivable("/controls/flight/wing-fold");
274 fgTie("/controls/flight/drag-chute", this,
275 &FGControls::get_drag_chute, &FGControls::set_drag_chute);
276 fgSetArchivable("/controls/flight/drag-chute");
279 fgTie("/controls/engines/throttle_idle", this,
280 &FGControls::get_throttle_idle, &FGControls::set_throttle_idle);
281 fgSetArchivable("/controls/engines/throttle_idle");
283 for (index = 0; index < MAX_ENGINES; index++) {
284 char name[MAX_NAME_LEN];
285 snprintf(name, MAX_NAME_LEN,
286 "/controls/engines/engine[%d]/throttle", index);
287 fgTie(name, this, index,
288 &FGControls::get_throttle, &FGControls::set_throttle);
289 fgSetArchivable(name);
291 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/starter", index);
292 fgTie(name, this, index,
293 &FGControls::get_starter, &FGControls::set_starter);
294 fgSetArchivable(name);
296 snprintf(name, MAX_NAME_LEN,
297 "/controls/engines/engine[%d]/fuel-pump", index);
298 fgTie(name, this, index,
299 &FGControls::get_fuel_pump, &FGControls::set_fuel_pump);
300 fgSetArchivable(name);
302 snprintf(name, MAX_NAME_LEN,
303 "/controls/engines/engine[%d]/fire-switch", index);
304 fgTie(name, this, index,
305 &FGControls::get_fire_switch, &FGControls::set_fire_switch);
306 fgSetArchivable(name);
308 snprintf(name, MAX_NAME_LEN,
309 "/controls/engines/engine[%d]/fire-bottle-discharge", index);
310 fgTie(name, this, index,
311 &FGControls::get_fire_bottle_discharge,
312 &FGControls::set_fire_bottle_discharge);
313 fgSetArchivable(name);
315 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/cutoff", index);
316 fgTie(name, this, index,
317 &FGControls::get_cutoff, &FGControls::set_cutoff);
318 fgSetArchivable(name);
320 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/mixture", index);
321 fgTie(name, this, index,
322 &FGControls::get_mixture, &FGControls::set_mixture);
323 fgSetArchivable(name);
325 snprintf(name, MAX_NAME_LEN,
326 "/controls/engines/engine[%d]/propeller-pitch", index);
327 fgTie(name, this, index,
328 &FGControls::get_prop_advance,
329 &FGControls::set_prop_advance);
330 fgSetArchivable(name);
332 snprintf(name, MAX_NAME_LEN,
333 "/controls/engines/engine[%d]/magnetos", index);
334 fgTie(name, this, index,
335 &FGControls::get_magnetos, &FGControls::set_magnetos);
336 fgSetArchivable(name);
338 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/WEP", index);
339 fgTie(name, this, index,
340 &FGControls::get_nitrous_injection,
341 &FGControls::set_nitrous_injection);
342 fgSetArchivable(name);
344 snprintf(name, MAX_NAME_LEN,
345 "/controls/engines/engine[%d]/cowl-flaps-norm", index);
346 fgTie(name, this, index,
347 &FGControls::get_cowl_flaps_norm,
348 &FGControls::set_cowl_flaps_norm);
349 fgSetArchivable(name);
351 snprintf(name, MAX_NAME_LEN,
352 "/controls/engines/engine[%d]/propeller-feather", index);
353 fgTie(name, this, index,
354 &FGControls::get_feather, &FGControls::set_feather);
355 fgSetArchivable(name);
357 snprintf(name, MAX_NAME_LEN,
358 "/controls/engines/engine[%d]/ignition", index);
359 fgTie(name, this, index,
360 &FGControls::get_ignition, &FGControls::set_ignition);
361 fgSetArchivable(name);
363 snprintf(name, MAX_NAME_LEN,
364 "/controls/engines/engine[%d]/augmentation", index);
365 fgTie(name, this, index,
366 &FGControls::get_augmentation,
367 &FGControls::set_augmentation);
368 fgSetArchivable(name);
370 snprintf(name, MAX_NAME_LEN,
371 "/controls/engines/engine[%d]/reverser", index);
372 fgTie(name, this, index,
373 &FGControls::get_reverser, &FGControls::set_reverser);
374 fgSetArchivable(name);
376 snprintf(name, MAX_NAME_LEN,
377 "/controls/engines/engine[%d]/water-injection", index);
378 fgTie(name, this, index,
379 &FGControls::get_water_injection,
380 &FGControls::set_water_injection);
381 fgSetArchivable(name);
383 snprintf(name, MAX_NAME_LEN,
384 "/controls/engines/engine[%d]/condition", index);
385 fgTie(name, this, index,
386 &FGControls::get_condition, &FGControls::set_condition);
387 fgSetArchivable(name);
391 fgTie("/controls/fuel/dump-valve", this,
392 &FGControls::get_dump_valve, &FGControls::set_dump_valve);
393 fgSetArchivable("/controls/fuel/dump-valve");
395 for (index = 0; index < MAX_TANKS; index++) {
396 char name[MAX_NAME_LEN];
397 snprintf(name, MAX_NAME_LEN,
398 "/controls/fuel/tank[%d]/fuel_selector", index);
399 fgTie(name, this, index,
400 &FGControls::get_fuel_selector,
401 &FGControls::set_fuel_selector);
402 fgSetArchivable(name);
404 snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_engine", index);
405 fgTie(name, this, index,
406 &FGControls::get_to_engine, &FGControls::set_to_engine);
407 fgSetArchivable(name);
409 snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_tank", index);
410 fgTie(name, this, index,
411 &FGControls::get_to_tank, &FGControls::set_to_tank);
412 fgSetArchivable(name);
414 for (i = 0; i < MAX_BOOSTPUMPS; i++) {
415 char name[MAX_NAME_LEN];
416 snprintf(name, MAX_NAME_LEN,
417 "/controls/fuel/tank[%d]/boost-pump[%d]", index, i);
418 fgTie(name, this, index * 2 + i,
419 &FGControls::get_boost_pump,
420 &FGControls::set_boost_pump);
421 fgSetArchivable(name);
426 fgTie("/controls/gear/brake-left", this,
427 &FGControls::get_brake_left,
428 &FGControls::set_brake_left);
429 fgSetArchivable("/controls/gear/brake-left");
431 fgTie("/controls/gear/brake-right", this,
432 &FGControls::get_brake_right,
433 &FGControls::set_brake_right);
434 fgSetArchivable("/controls/gear/brake-right");
436 fgTie("/controls/gear/brake-parking", this,
437 &FGControls::get_brake_parking,
438 &FGControls::set_brake_parking);
439 fgSetArchivable("/controls/gear/brake-parking");
441 fgTie("/controls/gear/steering", this,
442 &FGControls::get_steering, &FGControls::set_steering);
443 fgSetArchivable("/controls/gear/steering");
445 fgTie("/controls/gear/gear-down", this,
446 &FGControls::get_gear_down, &FGControls::set_gear_down);
447 fgSetArchivable("/controls/gear/gear-down");
449 fgTie("/controls/gear/antiskid", this,
450 &FGControls::get_antiskid, &FGControls::set_antiskid);
451 fgSetArchivable("/controls/gear/antiskid");
453 fgTie("/controls/gear/tailhook", this,
454 &FGControls::get_tailhook, &FGControls::set_tailhook);
455 fgSetArchivable("/controls/gear/tailhook");
457 fgTie("/controls/gear/tailwheel-lock", this,
458 &FGControls::get_tailwheel_lock,
459 &FGControls::set_tailwheel_lock);
460 fgSetArchivable("/controls/gear/tailwheel-lock");
462 for (index = 0; index < MAX_WHEELS; index++) {
463 char name[MAX_NAME_LEN];
464 snprintf(name, MAX_NAME_LEN,
465 "/controls/gear/wheel[%d]/alternate-extension", index);
466 fgTie(name, this, index,
467 &FGControls::get_alternate_extension,
468 &FGControls::set_alternate_extension);
469 fgSetArchivable(name);
473 fgTie("/controls/anti-ice/wing-heat", this,
474 &FGControls::get_wing_heat, &FGControls::set_wing_heat);
475 fgSetArchivable("/controls/anti-ice/wing-heat");
477 fgTie("/controls/anti-ice/pitot-heat", this,
478 &FGControls::get_pitot_heat, &FGControls::set_pitot_heat);
479 fgSetArchivable("/controls/anti-ice/pitot-heat");
481 fgTie("/controls/anti-ice/wiper", this,
482 &FGControls::get_wiper, &FGControls::set_wiper);
483 fgSetArchivable("/controls/anti-ice/wiper");
485 fgTie("/controls/anti-ice/window-heat", this,
486 &FGControls::get_window_heat, &FGControls::set_window_heat);
487 fgSetArchivable("/controls/anti-ice/window-heat");
489 for (index = 0; index < MAX_ENGINES; index++) {
490 char name[MAX_NAME_LEN];
491 snprintf(name, MAX_NAME_LEN,
492 "/controls/anti-ice/engine[%d]/carb-heat", index);
493 fgTie(name, this, index,
494 &FGControls::get_carb_heat, &FGControls::set_carb_heat);
495 fgSetArchivable(name);
497 snprintf(name, MAX_NAME_LEN,
498 "/controls/anti-ice/engine[%d]/inlet-heat", index);
499 fgTie(name, this, index,
500 &FGControls::get_inlet_heat, &FGControls::set_inlet_heat);
501 fgSetArchivable(name);
505 for (index = 0; index < MAX_HYD_SYSTEMS; index++) {
506 char name[MAX_NAME_LEN];
507 snprintf(name, MAX_NAME_LEN,
508 "/controls/hydraulic/system[%d]/engine-pump", index);
509 fgTie(name, this, index,
510 &FGControls::get_engine_pump, &FGControls::set_engine_pump);
511 fgSetArchivable(name);
513 snprintf(name, MAX_NAME_LEN,
514 "/controls/hydraulic/system[%d]/electric-pump", index);
515 fgTie(name, this, index,
516 &FGControls::get_electric_pump,
517 &FGControls::set_electric_pump);
518 fgSetArchivable(name);
522 fgTie("/controls/electric/battery-switch", this,
523 &FGControls::get_battery_switch,
524 &FGControls::set_battery_switch);
525 fgSetArchivable("/controls/electric/battery-switch");
527 fgTie("/controls/electric/external-power", this,
528 &FGControls::get_external_power,
529 &FGControls::set_external_power);
530 fgSetArchivable("/controls/electric/external-power");
532 fgTie("/controls/electric/APU-generator", this,
533 &FGControls::get_APU_generator,
534 &FGControls::set_APU_generator);
535 fgSetArchivable("/controls/electric/APU-generator");
537 for (index = 0; index < MAX_ENGINES; index++) {
538 char name[MAX_NAME_LEN];
539 snprintf(name, MAX_NAME_LEN,
540 "/controls/electric/engine[%d]/generator", index);
541 fgTie(name, this, index,
542 &FGControls::get_generator_breaker,
543 &FGControls::set_generator_breaker);
544 fgSetArchivable(name);
546 snprintf(name, MAX_NAME_LEN,
547 "/controls/electric/engine[%d]/bus-tie", index);
548 fgTie(name, this, index,
549 &FGControls::get_bus_tie,
550 &FGControls::set_bus_tie);
551 fgSetArchivable(name);
555 fgTie("/controls/pneumatic/APU-bleed", this,
556 &FGControls::get_APU_bleed,
557 &FGControls::set_APU_bleed);
558 fgSetArchivable("/controls/pneumatic/APU-bleed");
560 for (index = 0; index < MAX_ENGINES; index++) {
561 char name[MAX_NAME_LEN];
562 snprintf(name, MAX_NAME_LEN,
563 "/controls/pneumatic/engine[%d]/bleed", index);
564 fgTie(name, this, index,
565 &FGControls::get_engine_bleed,
566 &FGControls::set_engine_bleed);
567 fgSetArchivable(name);
571 fgTie("/controls/pressurization/mode", this,
572 &FGControls::get_mode, &FGControls::set_mode);
573 fgSetArchivable("/controls/pressurization/mode");
575 fgTie("/controls/pressurization/dump", this,
576 &FGControls::get_dump, &FGControls::set_dump);
577 fgSetArchivable("/controls/pressurization/dump");
579 fgTie("/controls/pressurization/outflow-valve", this,
580 &FGControls::get_outflow_valve,
581 &FGControls::set_outflow_valve);
582 fgSetArchivable("/controls/pressurization/outflow-valve");
584 for (index = 0; index < MAX_PACKS; index++) {
585 char name[MAX_NAME_LEN];
586 snprintf(name, MAX_NAME_LEN,
587 "/controls/pressurization/pack[%d]/pack-on", index);
588 fgTie(name, this, index,
589 &FGControls::get_pack_on, &FGControls::set_pack_on);
590 fgSetArchivable(name);
594 fgTie("/controls/lighting/landing-lights", this,
595 &FGControls::get_landing_lights,
596 &FGControls::set_landing_lights);
597 fgSetArchivable("/controls/lighting/landing-lights");
599 fgTie("/controls/lighting/turn-off-lights", this,
600 &FGControls::get_turn_off_lights,
601 &FGControls::set_turn_off_lights);
602 fgSetArchivable("/controls/lighting/turn-off-lights");
604 fgTie("/controls/lighting/taxi-light", this,
605 &FGControls::get_taxi_light, &FGControls::set_taxi_light);
606 fgSetArchivable("/controls/lighting/taxi-light");
608 fgTie("/controls/lighting/logo-lights", this,
609 &FGControls::get_logo_lights, &FGControls::set_logo_lights);
610 fgSetArchivable("/controls/lighting/logo-lights");
612 fgTie("/controls/lighting/nav-lights", this,
613 &FGControls::get_nav_lights, &FGControls::set_nav_lights);
614 fgSetArchivable("/controls/lighting/nav-lights");
616 fgTie("/controls/lighting/beacon", this,
617 &FGControls::get_beacon, &FGControls::set_beacon);
618 fgSetArchivable("/controls/lighting/beacon");
620 fgTie("/controls/lighting/strobe", this,
621 &FGControls::get_strobe, &FGControls::set_strobe);
622 fgSetArchivable("/controls/lighting/strobe");
624 fgTie("/controls/lighting/panel-norm", this,
625 &FGControls::get_panel_norm, &FGControls::set_panel_norm);
626 fgSetArchivable("/controls/lighting/panel-norm");
628 fgTie("/controls/lighting/instruments-norm", this,
629 &FGControls::get_instruments_norm,
630 &FGControls::set_instruments_norm);
631 fgSetArchivable("/controls/lighting/instruments-norm");
633 fgTie("/controls/lighting/dome-norm", this,
634 &FGControls::get_dome_norm, &FGControls::set_dome_norm);
635 fgSetArchivable("/controls/lighting/dome-norm");
637 #ifdef FG_HAVE_ARMAMENT
639 fgTie("/controls/armament/master-arm", this,
640 &FGControls::get_master_arm, &FGControls::set_master_arm);
641 fgSetArchivable("/controls/armament/master-arm");
643 fgTie("/controls/armament/station-select", this,
644 &FGControls::get_station_select,
645 &FGControls::set_station_select);
646 fgSetArchivable("/controls/armament/station-select");
648 fgTie("/controls/armament/release-all", this,
649 &FGControls::get_release_ALL,
650 &FGControls::set_release_ALL);
651 fgSetArchivable("/controls/armament/release-all");
653 for (index = 0; index < MAX_STATIONS; index++) {
654 char name[MAX_NAME_LEN];
655 snprintf(name, MAX_NAME_LEN,
656 "/controls/armament/station[%d]/stick-size", index);
657 fgTie(name, this, index,
658 &FGControls::get_stick_size, &FGControls::set_stick_size);
659 fgSetArchivable(name);
661 snprintf(name, MAX_NAME_LEN,
662 "/controls/armament/station[%d]/release-stick", index);
663 fgTie(name, this, index,
664 &FGControls::get_release_stick, &FGControls::set_release_stick);
665 fgSetArchivable(name);
667 snprintf(name, MAX_NAME_LEN,
668 "/controls/armament/station[%d]/release-all", index);
669 fgTie(name, this, index,
670 &FGControls::get_release_all, &FGControls::set_release_all);
671 fgSetArchivable(name);
673 snprintf(name, MAX_NAME_LEN,
674 "/controls/armament/station[%d]/jettison-all", index);
675 fgTie(name, this, index,
676 &FGControls::get_jettison_all, &FGControls::set_jettison_all);
677 fgSetArchivable(name);
683 fgTie("/controls/seat/vertical-adjust", this,
684 &FGControls::get_vertical_adjust,
685 &FGControls::set_vertical_adjust);
686 fgSetArchivable("/controls/seat/vertical-adjust");
688 fgTie("/controls/seat/fore-aft-adjust", this,
689 &FGControls::get_fore_aft_adjust,
690 &FGControls::set_fore_aft_adjust);
691 fgSetArchivable("/controls/seat/fore-aft-adjust");
693 for (index = 0; index < MAX_EJECTION_SEATS; index++) {
694 char name[MAX_NAME_LEN];
695 snprintf(name, MAX_NAME_LEN,
696 "/controls/seat/eject[%d]/initiate", index);
697 fgTie(name, this, index,
698 &FGControls::get_ejection_seat,
699 &FGControls::set_ejection_seat);
700 fgSetArchivable(name);
702 snprintf(name, MAX_NAME_LEN,
703 "/controls/seat/eject[%d]/status", index);
705 fgTie(name, this, index,
706 &FGControls::get_eseat_status,
707 &FGControls::set_eseat_status);
709 fgSetArchivable(name);
712 fgTie("/controls/seat/cmd_selector_valve", this,
713 &FGControls::get_cmd_selector_valve,
714 &FGControls::set_cmd_selector_valve);
715 fgSetArchivable("/controls/seat/eject/cmd_selector_valve");
719 fgTie("/controls/APU/off-start-run", this,
720 &FGControls::get_off_start_run,
721 &FGControls::set_off_start_run);
722 fgSetArchivable("/controls/APU/off-start-run");
724 fgTie("/controls/APU/fire-switch", this,
725 &FGControls::get_APU_fire_switch,
726 &FGControls::set_APU_fire_switch);
727 fgSetArchivable("/controls/APU/fire-switch");
730 for (index = 0; index < MAX_AUTOPILOTS; index++) {
731 char name[MAX_NAME_LEN];
732 snprintf(name, MAX_NAME_LEN,
733 "/controls/autoflight/autopilot[%d]/engage", index);
734 fgTie(name, this, index,
735 &FGControls::get_autopilot_engage,
736 &FGControls::set_autopilot_engage);
737 fgSetArchivable(name);
740 fgTie("/controls/autoflight/autothrottle-arm", this,
741 &FGControls::get_autothrottle_arm,
742 &FGControls::set_autothrottle_arm);
743 fgSetArchivable("/controls/autoflight/autothrottle-arm");
745 fgTie("/controls/autoflight/autothrottle-engage", this,
746 &FGControls::get_autothrottle_engage,
747 &FGControls::set_autothrottle_engage);
748 fgSetArchivable("/controls/autoflight/autothrottle-engage");
750 fgTie("/controls/autoflight/heading-select", this,
751 &FGControls::get_heading_select,
752 &FGControls::set_heading_select);
753 fgSetArchivable("/controls/autoflight/heading-select");
755 fgTie("/controls/autoflight/altitude-select", this,
756 &FGControls::get_altitude_select,
757 &FGControls::set_altitude_select);
758 fgSetArchivable("/controls/autoflight/altitude-select");
760 fgTie("/controls/autoflight/bank-angle-select", this,
761 &FGControls::get_bank_angle_select,
762 &FGControls::set_bank_angle_select);
763 fgSetArchivable("/controls/autoflight/bank-angle-select");
765 fgTie("/controls/autoflight/vertical-speed-select", this,
766 &FGControls::get_vertical_speed_select,
767 &FGControls::set_vertical_speed_select);
768 fgSetArchivable("/controls/autoflight/vertical-speed-select");
770 fgTie("/controls/autoflight/speed-select", this,
771 &FGControls::get_speed_select,
772 &FGControls::set_speed_select);
773 fgSetArchivable("/controls/autoflight/speed-select");
775 fgTie("/controls/autoflight/mach-select", this,
776 &FGControls::get_mach_select,
777 &FGControls::set_mach_select);
778 fgSetArchivable("/controls/autoflight/mach-select");
780 fgTie("/controls/autoflight/vertical-mode", this,
781 &FGControls::get_vertical_mode,
782 &FGControls::set_vertical_mode);
783 fgSetArchivable("/controls/autoflight/vertical-mode");
785 fgTie("/controls/autoflight/lateral-mode", this,
786 &FGControls::get_lateral_mode,
787 &FGControls::set_lateral_mode);
788 fgSetArchivable("/controls/autoflight/lateral-mode");
792 void FGControls::unbind ()
795 //Tie control properties.
796 fgUntie("/controls/flight/aileron");
797 fgUntie("/controls/flight/aileron-trim");
798 fgUntie("/controls/flight/elevator");
799 fgUntie("/controls/flight/elevator-trim");
800 fgUntie("/controls/flight/rudder");
801 fgUntie("/controls/flight/rudder-trim");
802 fgUntie("/controls/flight/flaps");
803 fgUntie("/controls/flight/slats");
804 fgUntie("/controls/flight/BLC");
805 fgUntie("/controls/flight/spoilers");
806 fgUntie("/controls/flight/speedbrake");
807 fgUntie("/controls/flight/wing-sweep");
808 fgUntie("/controls/flight/wing-fold");
809 fgUntie("/controls/flight/drag-chute");
810 for (index = 0; index < MAX_ENGINES; index++) {
811 char name[MAX_NAME_LEN];
812 snprintf(name, MAX_NAME_LEN,
813 "/controls/engines/engine[%d]/throttle", index);
815 snprintf(name, MAX_NAME_LEN,
816 "/controls/engines/engine[%d]/starter", index);
818 snprintf(name, MAX_NAME_LEN,
819 "/controls/engines/engine[%d]/fuel_pump", index);
821 snprintf(name, MAX_NAME_LEN,
822 "/controls/engines/engine[%d]/fire-switch", index);
824 snprintf(name, MAX_NAME_LEN,
825 "/controls/engines/engine[%d]/fire-bottle-discharge", index);
827 snprintf(name, MAX_NAME_LEN,
828 "/controls/engines/engine[%d]/throttle_idle", index);
830 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/cutoff", index);
832 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/mixture", index);
834 snprintf(name, MAX_NAME_LEN,
835 "/controls/engines/engine[%d]/propeller-pitch", index);
837 snprintf(name, MAX_NAME_LEN,
838 "/controls/engines/engine[%d]/magnetos", index);
840 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/WEP", index);
842 snprintf(name, MAX_NAME_LEN,
843 "/controls/engines/engine[%d]/cowl-flaps-norm", index);
845 snprintf(name, MAX_NAME_LEN,
846 "/controls/engines/engine[%d]/propeller-feather", index);
848 snprintf(name, MAX_NAME_LEN,
849 "/controls/engines/engine[%d]/ignition", index);
851 snprintf(name, MAX_NAME_LEN,
852 "/controls/engines/engine[%d]/augmentation", index);
854 snprintf(name, MAX_NAME_LEN,
855 "/controls/engines/engine[%d]/reverser", index);
857 snprintf(name, MAX_NAME_LEN,
858 "/controls/engines/engine[%d]/water-injection", index);
860 snprintf(name, MAX_NAME_LEN,
861 "/controls/engines/engine[%d]/condition", index);
864 fgUntie("/controls/fuel/dump-valve");
865 for (index = 0; index < MAX_TANKS; index++) {
866 char name[MAX_NAME_LEN];
867 snprintf(name, MAX_NAME_LEN,
868 "/controls/fuel/tank[%d]/fuel_selector", index);
870 snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_engine", index);
872 snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_tank", index);
874 for (i = 0; index < MAX_BOOSTPUMPS; i++) {
875 snprintf(name, MAX_NAME_LEN,
876 "/controls/fuel/tank[%d]/boost-pump[%d]", index, i);
880 fgUntie("/controls/gear/brake-left");
881 fgUntie("/controls/gear/brake-right");
882 fgUntie("/controls/gear/brake-parking");
883 fgUntie("/controls/gear/steering");
884 fgUntie("/controls/gear/gear_down");
885 fgUntie("/controls/gear/antiskid");
886 fgUntie("/controls/gear/tailhook");
887 fgUntie("/controls/gear/tailwheel-lock");
888 for (index = 0; index < MAX_WHEELS; index++) {
889 char name[MAX_NAME_LEN];
890 snprintf(name, MAX_NAME_LEN,
891 "/controls/gear/wheel[%d]/alternate-extension", index);
894 fgUntie("/controls/anti-ice/wing-heat");
895 fgUntie("/controls/anti-ice/pitot-heat");
896 fgUntie("/controls/anti-ice/wiper");
897 fgUntie("/controls/anti-ice/window-heat");
898 for (index = 0; index < MAX_ENGINES; index++) {
899 char name[MAX_NAME_LEN];
900 snprintf(name, MAX_NAME_LEN,
901 "/controls/anti-ice/engine[%d]/carb-heat", index);
903 snprintf(name, MAX_NAME_LEN,
904 "/controls/anti-ice/engine[%d]/inlet-heat", index);
907 for (index = 0; index < MAX_HYD_SYSTEMS; index++) {
908 char name[MAX_NAME_LEN];
909 snprintf(name, MAX_NAME_LEN,
910 "/controls/hydraulic/system[%d]/engine-pump", index);
912 snprintf(name, MAX_NAME_LEN,
913 "/controls/hydraulic/system[%d]/electric-pump", index);
916 fgUntie("/controls/electric/battery-switch");
917 fgUntie("/controls/electric/external-power");
918 fgUntie("/controls/electric/APU-generator");
919 for (index = 0; index < MAX_ENGINES; index++) {
920 char name[MAX_NAME_LEN];
921 snprintf(name, MAX_NAME_LEN,
922 "/controls/electric/engine[%d]/generator", index);
924 snprintf(name, MAX_NAME_LEN,
925 "/controls/electric/engine[%d]/bus-tie", index);
928 fgUntie("/controls/pneumatic/APU-bleed");
929 for (index = 0; index < MAX_ENGINES; index++) {
930 char name[MAX_NAME_LEN];
931 snprintf(name, MAX_NAME_LEN,
932 "/controls/pneumatic/engine[%d]/bleed", index);
935 fgUntie("/controls/pressurization/mode");
936 fgUntie("/controls/pressurization/dump");
937 for (index = 0; index < MAX_PACKS; index++) {
938 char name[MAX_NAME_LEN];
939 snprintf(name, MAX_NAME_LEN,
940 "/controls/pressurization/pack[%d]/pack-on", index);
943 fgUntie("/controls/lighting/landing-lights");
944 fgUntie("/controls/lighting/turn-off-lights");
945 fgUntie("/controls/lighting/taxi-light");
946 fgUntie("/controls/lighting/logo-lights");
947 fgUntie("/controls/lighting/nav-lights");
948 fgUntie("/controls/lighting/beacon");
949 fgUntie("/controls/lighting/strobe");
950 fgUntie("/controls/lighting/panel-norm");
951 fgUntie("/controls/lighting/instruments-norm");
952 fgUntie("/controls/lighting/dome-norm");
954 #ifdef FG_HAVE_ARMAMENT
955 fgUntie("/controls/armament/master-arm");
956 fgUntie("/controls/armament/station-select");
957 fgUntie("/controls/armament/release-all");
958 for (index = 0; index < MAX_STATIONS; index++) {
959 char name[MAX_NAME_LEN];
960 snprintf(name, MAX_NAME_LEN,
961 "/controls/armament/station[%d]/stick-size", index);
963 snprintf(name, MAX_NAME_LEN,
964 "/controls/armament/station[%d]/release-stick", index);
966 snprintf(name, MAX_NAME_LEN,
967 "/controls/armament/station[%d]/release-all", index);
969 snprintf(name, MAX_NAME_LEN,
970 "/controls/armament/station[%d]/jettison-all", index);
974 fgUntie("/controls/seat/vertical-adjust");
975 fgUntie("/controls/seat/fore-aft-adjust");
976 for (index = 0; index < MAX_EJECTION_SEATS; index++) {
977 char name[MAX_NAME_LEN];
978 snprintf(name, MAX_NAME_LEN,
979 "/controls/seat/eject[%d]/initiate", index);
981 snprintf(name, MAX_NAME_LEN,
982 "/controls/seat/eject[%d]/status", index);
985 fgUntie("/controls/seat/cmd_selector_valve");
987 fgUntie("/controls/APU/off-start-run");
988 fgUntie("/controls/APU/fire-switch");
989 for (index = 0; index < MAX_AUTOPILOTS; index++) {
990 char name[MAX_NAME_LEN];
991 snprintf(name, MAX_NAME_LEN,
992 "/controls/autoflight/autopilot[%d]/engage", index);
995 fgUntie("/controls/autoflight/autothrottle-arm");
996 fgUntie("/controls/autoflight/autothrottle-engage");
997 fgUntie("/controls/autoflight/heading-select");
998 fgUntie("/controls/autoflight/altitude-select");
999 fgUntie("/controls/autoflight/bank-angle-select");
1000 fgUntie("/controls/autoflight/vertical-speed-select");
1001 fgUntie("/controls/autoflight/speed-select");
1002 fgUntie("/controls/autoflight/mach-select");
1003 fgUntie("/controls/autoflight/vertical-mode");
1004 fgUntie("/controls/autoflight/lateral-mode");
1009 FGControls::update (double dt)
1015 ////////////////////////////////////////////////////////////////////////
1016 // Setters and adjusters.
1017 ////////////////////////////////////////////////////////////////////////
1020 FGControls::set_aileron (double pos)
1023 CLAMP( &aileron, -1.0, 1.0 );
1025 // check for autocoordination
1026 if ( auto_coordination->getBoolValue() ) {
1027 set_rudder( aileron / 2.0 );
1032 FGControls::move_aileron (double amt)
1035 CLAMP( &aileron, -1.0, 1.0 );
1037 // check for autocoordination
1038 if ( auto_coordination->getBoolValue() ) {
1039 set_rudder( aileron / 2.0 );
1044 FGControls::set_aileron_trim( double pos )
1047 CLAMP( &aileron_trim, -1.0, 1.0 );
1051 FGControls::move_aileron_trim( double amt )
1053 aileron_trim += amt;
1054 CLAMP( &aileron_trim, -1.0, 1.0 );
1058 FGControls::set_elevator( double pos )
1061 CLAMP( &elevator, -1.0, 1.0 );
1065 FGControls::move_elevator( double amt )
1068 CLAMP( &elevator, -1.0, 1.0 );
1072 FGControls::set_elevator_trim( double pos )
1074 elevator_trim = pos;
1075 CLAMP( &elevator_trim, -1.0, 1.0 );
1079 FGControls::move_elevator_trim( double amt )
1081 elevator_trim += amt;
1082 CLAMP( &elevator_trim, -1.0, 1.0 );
1086 FGControls::set_rudder( double pos )
1089 CLAMP( &rudder, -1.0, 1.0 );
1093 FGControls::move_rudder( double amt )
1096 CLAMP( &rudder, -1.0, 1.0 );
1100 FGControls::set_rudder_trim( double pos )
1103 CLAMP( &rudder_trim, -1.0, 1.0 );
1107 FGControls::move_rudder_trim( double amt )
1110 CLAMP( &rudder_trim, -1.0, 1.0 );
1114 FGControls::set_flaps( double pos )
1117 CLAMP( &flaps, 0.0, 1.0 );
1121 FGControls::move_flaps( double amt )
1124 CLAMP( &flaps, 0.0, 1.0 );
1128 FGControls::set_slats( double pos )
1131 CLAMP( &slats, 0.0, 1.0 );
1135 FGControls::move_slats( double amt )
1138 CLAMP( &slats, 0.0, 1.0 );
1142 FGControls::set_BLC( bool val )
1148 FGControls::set_spoilers( double pos )
1151 CLAMP( &spoilers, 0.0, 1.0 );
1155 FGControls::move_spoilers( double amt )
1158 CLAMP( &spoilers, 0.0, 1.0 );
1162 FGControls::set_speedbrake( double pos )
1165 CLAMP( &speedbrake, 0.0, 1.0 );
1169 FGControls::move_speedbrake( double amt )
1172 CLAMP( &speedbrake, 0.0, 1.0 );
1176 FGControls::set_wing_sweep( double pos )
1179 CLAMP( &wing_sweep, 0.0, 1.0 );
1183 FGControls::move_wing_sweep( double amt )
1186 CLAMP( &wing_sweep, 0.0, 1.0 );
1190 FGControls::set_wing_fold( bool val )
1196 FGControls::set_drag_chute( bool val )
1202 FGControls::set_throttle_idle( bool val )
1204 throttle_idle = val;
1208 FGControls::set_throttle( int engine, double pos )
1210 if ( engine == ALL_ENGINES ) {
1211 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1213 CLAMP( &throttle[i], 0.0, 1.0 );
1216 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1217 throttle[engine] = pos;
1218 CLAMP( &throttle[engine], 0.0, 1.0 );
1224 FGControls::move_throttle( int engine, double amt )
1226 if ( engine == ALL_ENGINES ) {
1227 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1229 CLAMP( &throttle[i], 0.0, 1.0 );
1232 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1233 throttle[engine] += amt;
1234 CLAMP( &throttle[engine], 0.0, 1.0 );
1240 FGControls::set_starter( int engine, bool flag )
1242 if ( engine == ALL_ENGINES ) {
1243 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1247 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1248 starter[engine] = flag;
1254 FGControls::set_fuel_pump( int engine, bool val )
1256 if ( engine == ALL_ENGINES ) {
1257 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1261 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1262 fuel_pump[engine] = val;
1268 FGControls::set_fire_switch( int engine, bool val )
1270 if ( engine == ALL_ENGINES ) {
1271 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1272 fire_switch[i] = val;
1275 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1276 fire_switch[engine] = val;
1282 FGControls::set_fire_bottle_discharge( int engine, bool val )
1284 if ( engine == ALL_ENGINES ) {
1285 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1286 fire_bottle_discharge[i] = val;
1289 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1290 fire_bottle_discharge[engine] = val;
1296 FGControls::set_cutoff( int engine, bool val )
1298 if ( engine == ALL_ENGINES ) {
1299 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1303 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1304 cutoff[engine] = val;
1311 FGControls::set_mixture( int engine, double pos )
1313 if ( engine == ALL_ENGINES ) {
1314 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1316 CLAMP( &mixture[i], 0.0, 1.0 );
1319 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1320 mixture[engine] = pos;
1321 CLAMP( &mixture[engine], 0.0, 1.0 );
1327 FGControls::move_mixture( int engine, double amt )
1329 if ( engine == ALL_ENGINES ) {
1330 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1332 CLAMP( &mixture[i], 0.0, 1.0 );
1335 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1336 mixture[engine] += amt;
1337 CLAMP( &mixture[engine], 0.0, 1.0 );
1343 FGControls::set_prop_advance( int engine, double pos )
1345 if ( engine == ALL_ENGINES ) {
1346 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1347 prop_advance[i] = pos;
1348 CLAMP( &prop_advance[i], 0.0, 1.0 );
1351 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1352 prop_advance[engine] = pos;
1353 CLAMP( &prop_advance[engine], 0.0, 1.0 );
1359 FGControls::move_prop_advance( int engine, double amt )
1361 if ( engine == ALL_ENGINES ) {
1362 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1363 prop_advance[i] += amt;
1364 CLAMP( &prop_advance[i], 0.0, 1.0 );
1367 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1368 prop_advance[engine] += amt;
1369 CLAMP( &prop_advance[engine], 0.0, 1.0 );
1375 FGControls::set_magnetos( int engine, int pos )
1377 if ( engine == ALL_ENGINES ) {
1378 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1380 CLAMP( &magnetos[i], 0, 3 );
1383 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1384 magnetos[engine] = pos;
1385 CLAMP( &magnetos[engine], 0, 3 );
1391 FGControls::move_magnetos( int engine, int amt )
1393 if ( engine == ALL_ENGINES ) {
1394 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1396 CLAMP( &magnetos[i], 0, 3 );
1399 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1400 magnetos[engine] += amt;
1401 CLAMP( &magnetos[engine], 0, 3 );
1407 FGControls::set_nitrous_injection( int engine, bool val )
1409 if ( engine == ALL_ENGINES ) {
1410 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1411 nitrous_injection[i] = val;
1414 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1415 nitrous_injection[engine] = val;
1422 FGControls::set_cowl_flaps_norm( int engine, double pos )
1424 if ( engine == ALL_ENGINES ) {
1425 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1426 cowl_flaps_norm[i] = pos;
1427 CLAMP( &cowl_flaps_norm[i], 0.0, 1.0 );
1430 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1431 cowl_flaps_norm[engine] = pos;
1432 CLAMP( &cowl_flaps_norm[engine], 0.0, 1.0 );
1438 FGControls::move_cowl_flaps_norm( int engine, double amt )
1440 if ( engine == ALL_ENGINES ) {
1441 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1442 cowl_flaps_norm[i] += amt;
1443 CLAMP( &cowl_flaps_norm[i], 0.0, 1.0 );
1446 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1447 cowl_flaps_norm[engine] += amt;
1448 CLAMP( &cowl_flaps_norm[engine], 0.0, 1.0 );
1454 FGControls::set_feather( int engine, bool val )
1456 if ( engine == ALL_ENGINES ) {
1457 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1461 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1462 feather[engine] = val;
1468 FGControls::set_ignition( int engine, int pos )
1470 if ( engine == ALL_ENGINES ) {
1471 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1473 CLAMP( &ignition[i], 0, 3 );
1476 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1477 ignition[engine] = pos;
1478 CLAMP( &ignition[engine], 0, 3 );
1484 FGControls::set_augmentation( int engine, bool val )
1486 if ( engine == ALL_ENGINES ) {
1487 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1488 augmentation[i] = val;
1491 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1492 augmentation[engine] = val;
1498 FGControls::set_reverser( int engine, bool val )
1500 if ( engine == ALL_ENGINES ) {
1501 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1505 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1506 reverser[engine] = val;
1512 FGControls::set_water_injection( int engine, bool val )
1514 if ( engine == ALL_ENGINES ) {
1515 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1516 water_injection[i] = val;
1519 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1520 water_injection[engine] = val;
1526 FGControls::set_condition( int engine, double val )
1528 if ( engine == ALL_ENGINES ) {
1529 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1533 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1534 condition[engine] = val;
1540 FGControls::set_dump_valve( bool val )
1547 FGControls::set_fuel_selector( int tank, bool pos )
1549 if ( tank == ALL_TANKS ) {
1550 for ( int i = 0; i < MAX_TANKS; i++ ) {
1551 fuel_selector[i] = pos;
1554 if ( (tank >= 0) && (tank < MAX_TANKS) ) {
1555 fuel_selector[tank] = pos;
1561 FGControls::set_to_engine( int tank, int engine )
1563 if ( tank == ALL_TANKS ) {
1564 for ( int i = 0; i < MAX_TANKS; i++ ) {
1565 to_engine[i] = engine;
1568 if ( (tank >= 0) && (tank < MAX_TANKS) ) {
1569 to_engine[tank] = engine;
1575 FGControls::set_to_tank( int tank, int dest_tank )
1577 if ( tank == ALL_TANKS ) {
1578 for ( int i = 0; i < MAX_TANKS; i++ ) {
1579 to_tank[i] = dest_tank;
1582 if ( (tank >= 0) && (tank < MAX_TANKS) ) {
1583 to_tank[tank] = dest_tank;
1589 FGControls::set_boost_pump( int index, bool val )
1591 if ( index == -1 ) {
1592 for ( int i = 0; i < (MAX_TANKS * MAX_BOOSTPUMPS); i++ ) {
1593 boost_pump[i] = val;
1596 if ( (index >= 0) && (index < (MAX_TANKS * MAX_BOOSTPUMPS)) ) {
1597 boost_pump[index] = val;
1604 FGControls::set_brake_left( double pos )
1607 CLAMP(&brake_left, 0.0, 1.0);
1611 FGControls::move_brake_left( double amt )
1614 CLAMP( &brake_left, 0.0, 1.0 );
1618 FGControls::set_brake_right( double pos )
1621 CLAMP(&brake_right, 0.0, 1.0);
1625 FGControls::move_brake_right( double amt )
1628 CLAMP( &brake_right, 0.0, 1.0 );
1632 FGControls::set_brake_parking( double pos )
1634 brake_parking = pos;
1635 CLAMP(&brake_parking, 0.0, 1.0);
1639 FGControls::set_steering( double angle )
1642 CLAMP(&steering, -80.0, 80.0);
1646 FGControls::move_steering( double angle )
1649 CLAMP(&steering, -80.0, 80.0);
1653 FGControls::set_gear_down( bool gear )
1659 FGControls::set_antiskid( bool state )
1665 FGControls::set_tailhook( bool state )
1671 FGControls::set_tailwheel_lock( bool state )
1673 tailwheel_lock = state;
1678 FGControls::set_alternate_extension( int wheel, bool val )
1680 if ( wheel == ALL_WHEELS ) {
1681 for ( int i = 0; i < MAX_WHEELS; i++ ) {
1682 alternate_extension[i] = val;
1685 if ( (wheel >= 0) && (wheel < MAX_WHEELS) ) {
1686 alternate_extension[wheel] = val;
1692 FGControls::set_wing_heat( bool state )
1698 FGControls::set_pitot_heat( bool state )
1704 FGControls::set_wiper( int state )
1710 FGControls::set_window_heat( bool state )
1712 window_heat = state;
1716 FGControls::set_carb_heat( int engine, bool val )
1718 if ( engine == ALL_ENGINES ) {
1719 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1723 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1724 carb_heat[engine] = val;
1730 FGControls::set_inlet_heat( int engine, bool val )
1732 if ( engine == ALL_ENGINES ) {
1733 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1734 inlet_heat[i] = val;
1737 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1738 inlet_heat[engine] = val;
1744 FGControls::set_engine_pump( int system, bool val )
1746 if ( system == ALL_HYD_SYSTEMS ) {
1747 for ( int i = 0; i < MAX_HYD_SYSTEMS; i++ ) {
1748 engine_pump[i] = val;
1751 if ( (system >= 0) && (system < MAX_HYD_SYSTEMS) ) {
1752 engine_pump[system] = val;
1758 FGControls::set_electric_pump( int system, bool val )
1760 if ( system == ALL_HYD_SYSTEMS ) {
1761 for ( int i = 0; i < MAX_HYD_SYSTEMS; i++ ) {
1762 electric_pump[i] = val;
1765 if ( (system >= 0) && (system < MAX_HYD_SYSTEMS) ) {
1766 electric_pump[system] = val;
1772 FGControls::set_battery_switch( bool state )
1774 battery_switch = state;
1778 FGControls::set_external_power( bool state )
1780 external_power = state;
1784 FGControls::set_APU_generator( bool state )
1786 APU_generator = state;
1790 FGControls::set_generator_breaker( int engine, bool val )
1792 if ( engine == ALL_ENGINES ) {
1793 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1794 generator_breaker[i] = val;
1797 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1798 generator_breaker[engine] = val;
1804 FGControls::set_bus_tie( int engine, bool val )
1806 if ( engine == ALL_ENGINES ) {
1807 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1811 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1812 bus_tie[engine] = val;
1818 FGControls::set_APU_bleed( bool state )
1824 FGControls::set_engine_bleed( int engine, bool val )
1826 if ( engine == ALL_ENGINES ) {
1827 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1828 engine_bleed[i] = val;
1831 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1832 engine_bleed[engine] = val;
1838 FGControls::set_mode( int new_mode )
1844 FGControls::set_outflow_valve( double pos )
1846 outflow_valve = pos;
1847 CLAMP( &outflow_valve, 0.0, 1.0 );
1851 FGControls::move_outflow_valve( double amt )
1853 outflow_valve += amt;
1854 CLAMP( &outflow_valve, 0.0, 1.0 );
1858 FGControls::set_dump( bool state )
1864 FGControls::set_pack_on( int pack, bool val )
1866 if ( pack == ALL_PACKS ) {
1867 for ( int i = 0; i < MAX_PACKS; i++ ) {
1871 if ( (pack >= 0) && (pack < MAX_PACKS) ) {
1872 pack_on[pack] = val;
1878 FGControls::set_landing_lights( bool state )
1880 landing_lights = state;
1884 FGControls::set_turn_off_lights( bool state )
1886 turn_off_lights = state;
1890 FGControls::set_taxi_light( bool state )
1896 FGControls::set_logo_lights( bool state )
1898 logo_lights = state;
1902 FGControls::set_nav_lights( bool state )
1908 FGControls::set_beacon( bool state )
1914 FGControls::set_strobe( bool state )
1920 FGControls::set_panel_norm( double intensity )
1922 panel_norm = intensity;
1923 CLAMP( &panel_norm, 0.0, 1.0 );
1927 FGControls::move_panel_norm( double amt )
1930 CLAMP( &panel_norm, 0.0, 1.0 );
1934 FGControls::set_instruments_norm( double intensity )
1936 instruments_norm = intensity;
1937 CLAMP( &instruments_norm, 0.0, 1.0 );
1941 FGControls::move_instruments_norm( double amt )
1943 instruments_norm += amt;
1944 CLAMP( &instruments_norm, 0.0, 1.0 );
1948 FGControls::set_dome_norm( double intensity )
1950 dome_norm = intensity;
1951 CLAMP( &dome_norm, 0.0, 1.0 );
1955 FGControls::move_dome_norm( double amt )
1958 CLAMP( &dome_norm, 0.0, 1.0 );
1961 #ifdef FG_HAVE_ARMAMENT
1964 FGControls::set_master_arm( bool val )
1970 FGControls::set_station_select( int station )
1972 station_select = station;
1973 CLAMP( &station_select, 0, MAX_STATIONS );
1977 FGControls::set_release_ALL( bool val )
1983 FGControls::set_stick_size( int station, int size )
1985 if ( station == ALL_STATIONS ) {
1986 for ( int i = 0; i < MAX_STATIONS; i++ ) {
1987 stick_size[i] = size;
1988 CLAMP( &stick_size[i], 1, 20 );
1991 if ( (station >= 0) && (station < MAX_STATIONS) ) {
1992 stick_size[station] = size;
1993 CLAMP( &stick_size[station], 1, 20 );
1999 FGControls::set_release_stick( int station, bool val )
2001 if ( station == ALL_STATIONS ) {
2002 for ( int i = 0; i < MAX_STATIONS; i++ ) {
2003 release_stick[i] = val;
2006 if ( (station >= 0) && (station < MAX_STATIONS) ) {
2007 release_stick[station] = val;
2013 FGControls::set_release_all( int station, bool val )
2015 if ( station == ALL_STATIONS ) {
2016 for ( int i = 0; i < MAX_STATIONS; i++ ) {
2017 release_all[i] = val;
2020 if ( (station >= 0) && (station < MAX_STATIONS) ) {
2021 release_all[station] = val;
2027 FGControls::set_jettison_all( int station, bool val )
2029 if ( station == ALL_STATIONS ) {
2030 for ( int i = 0; i < MAX_STATIONS; i++ ) {
2031 jettison_all[i] = val;
2034 if ( (station >= 0) && (station < MAX_STATIONS) ) {
2035 jettison_all[station] = val;
2043 FGControls::set_vertical_adjust( double pos )
2045 vertical_adjust = pos;
2046 CLAMP( &vertical_adjust, -1.0, 1.0 );
2050 FGControls::move_vertical_adjust( double amt )
2052 vertical_adjust += amt;
2053 CLAMP( &vertical_adjust, -1.0, 1.0 );
2057 FGControls::set_fore_aft_adjust( double pos )
2059 fore_aft_adjust = pos;
2060 CLAMP( &fore_aft_adjust, -1.0, 1.0 );
2064 FGControls::move_fore_aft_adjust( double amt )
2066 fore_aft_adjust += amt;
2067 CLAMP( &fore_aft_adjust, -1.0, 1.0 );
2071 FGControls::set_ejection_seat( int which_seat, bool val )
2073 if ( which_seat == ALL_EJECTION_SEATS ) {
2074 for ( int i = 0; i < MAX_EJECTION_SEATS; i++ ) {
2078 if ( (which_seat >= 0) && (which_seat <= MAX_EJECTION_SEATS) ) {
2079 if ( eseat_status[which_seat] == SEAT_SAFED ||
2080 eseat_status[which_seat] == SEAT_FAIL )
2082 // we can never eject if SEAT_SAFED or SEAT_FAIL
2086 eject[which_seat] = val;
2092 FGControls::set_eseat_status( int which_seat, int val )
2094 if ( which_seat == ALL_EJECTION_SEATS ) {
2095 for ( int i = 0; i < MAX_EJECTION_SEATS; i++ ) {
2096 eseat_status[i] = val;
2099 if ( (which_seat >=0) && (which_seat <= MAX_EJECTION_SEATS) ) {
2100 eseat_status[which_seat] = val;
2106 FGControls::set_cmd_selector_valve( int val )
2108 cmd_selector_valve = val;
2113 FGControls::set_off_start_run( int pos )
2115 off_start_run = pos;
2116 CLAMP( &off_start_run, 0, 3 );
2120 FGControls::set_APU_fire_switch( bool val )
2122 APU_fire_switch = val;
2126 FGControls::set_autothrottle_arm( bool val )
2128 autothrottle_arm = val;
2132 FGControls::set_autothrottle_engage( bool val )
2134 autothrottle_engage = val;
2138 FGControls::set_heading_select( double heading )
2140 heading_select = heading;
2141 CLAMP( &heading_select, 0.0, 360.0 );
2145 FGControls::move_heading_select( double amt )
2147 heading_select += amt;
2148 CLAMP( &heading_select, 0.0, 360.0 );
2152 FGControls::set_altitude_select( double altitude )
2154 altitude_select = altitude;
2155 CLAMP( &altitude_select, -1000.0, 100000.0 );
2159 FGControls::move_altitude_select( double amt )
2161 altitude_select += amt;
2162 CLAMP( &altitude_select, -1000.0, 100000.0 );
2166 FGControls::set_bank_angle_select( double angle )
2168 bank_angle_select = angle;
2169 CLAMP( &bank_angle_select, 10.0, 30.0 );
2173 FGControls::move_bank_angle_select( double amt )
2175 bank_angle_select += amt;
2176 CLAMP( &bank_angle_select, 10.0, 30.0 );
2180 FGControls::set_vertical_speed_select( double speed )
2182 vertical_speed_select = speed;
2183 CLAMP( &vertical_speed_select, -3000.0, 4000.0 );
2187 FGControls::move_vertical_speed_select( double amt )
2189 vertical_speed_select += amt;
2190 CLAMP( &vertical_speed_select, -3000.0, 4000.0 );
2194 FGControls::set_speed_select( double speed )
2196 speed_select = speed;
2197 CLAMP( &speed_select, 60.0, 400.0 );
2201 FGControls::move_speed_select( double amt )
2203 speed_select += amt;
2204 CLAMP( &speed_select, 60.0, 400.0 );
2208 FGControls::set_mach_select( double mach )
2211 CLAMP( &mach_select, 0.4, 4.0 );
2215 FGControls::move_mach_select( double amt )
2218 CLAMP( &mach_select, 0.4, 4.0 );
2222 FGControls::set_vertical_mode( int mode )
2224 vertical_mode = mode;
2225 CLAMP( &vertical_mode, 0, 4 );
2229 FGControls::set_lateral_mode( int mode )
2231 lateral_mode = mode;
2232 CLAMP( &lateral_mode, 0, 4 );
2236 FGControls::set_autopilot_engage( int ap, bool val )
2238 if ( ap == ALL_AUTOPILOTS ) {
2239 for ( int i = 0; i < MAX_AUTOPILOTS; i++ ) {
2240 autopilot_engage[i] = val;
2243 if ( (ap >= 0) && (ap < MAX_AUTOPILOTS) ) {
2244 autopilot_engage[ap] = val;