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, 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] = 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, "/controls/engines/engine[%d]/feather", index);
352 fgTie(name, this, index,
353 &FGControls::get_feather, &FGControls::set_feather);
354 fgSetArchivable(name);
356 snprintf(name, MAX_NAME_LEN,
357 "/controls/engines/engine[%d]/ignition", index);
358 fgTie(name, this, index,
359 &FGControls::get_ignition, &FGControls::set_ignition);
360 fgSetArchivable(name);
362 snprintf(name, MAX_NAME_LEN,
363 "/controls/engines/engine[%d]/augmentation", index);
364 fgTie(name, this, index,
365 &FGControls::get_augmentation,
366 &FGControls::set_augmentation);
367 fgSetArchivable(name);
369 snprintf(name, MAX_NAME_LEN,
370 "/controls/engines/engine[%d]/reverser", index);
371 fgTie(name, this, index,
372 &FGControls::get_reverser, &FGControls::set_reverser);
373 fgSetArchivable(name);
375 snprintf(name, MAX_NAME_LEN,
376 "/controls/engines/engine[%d]/water-injection", index);
377 fgTie(name, this, index,
378 &FGControls::get_water_injection,
379 &FGControls::set_water_injection);
380 fgSetArchivable(name);
382 snprintf(name, MAX_NAME_LEN,
383 "/controls/engines/engine[%d]/condition", index);
384 fgTie(name, this, index,
385 &FGControls::get_condition, &FGControls::set_condition);
386 fgSetArchivable(name);
390 fgTie("/controls/fuel/dump-valve", this,
391 &FGControls::get_dump_valve, &FGControls::set_dump_valve);
392 fgSetArchivable("/controls/fuel/dump-valve");
394 for (index = 0; index < MAX_TANKS; index++) {
395 char name[MAX_NAME_LEN];
396 snprintf(name, MAX_NAME_LEN,
397 "/controls/fuel/tank[%d]/fuel_selector", index);
398 fgTie(name, this, index,
399 &FGControls::get_fuel_selector,
400 &FGControls::set_fuel_selector);
401 fgSetArchivable(name);
403 snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_engine", index);
404 fgTie(name, this, index,
405 &FGControls::get_to_engine, &FGControls::set_to_engine);
406 fgSetArchivable(name);
408 snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_tank", index);
409 fgTie(name, this, index,
410 &FGControls::get_to_tank, &FGControls::set_to_tank);
411 fgSetArchivable(name);
413 for (i = 0; i < MAX_BOOSTPUMPS; i++) {
414 char name[MAX_NAME_LEN];
415 snprintf(name, MAX_NAME_LEN,
416 "/controls/fuel/tank[%d]/boost-pump[%d]", index, i);
417 fgTie(name, this, index * 2 + i,
418 &FGControls::get_boost_pump,
419 &FGControls::set_boost_pump);
420 fgSetArchivable(name);
425 fgTie("/controls/gear/brake-left", this,
426 &FGControls::get_brake_left,
427 &FGControls::set_brake_left);
428 fgSetArchivable("/controls/gear/brake-left");
430 fgTie("/controls/gear/brake-right", this,
431 &FGControls::get_brake_right,
432 &FGControls::set_brake_right);
433 fgSetArchivable("/controls/gear/brake-right");
435 fgTie("/controls/gear/brake-parking", this,
436 &FGControls::get_brake_parking,
437 &FGControls::set_brake_parking);
438 fgSetArchivable("/controls/gear/brake-parking");
440 fgTie("/controls/gear/steering", this,
441 &FGControls::get_steering, &FGControls::set_steering);
442 fgSetArchivable("/controls/gear/steering");
444 fgTie("/controls/gear/gear-down", this,
445 &FGControls::get_gear_down, &FGControls::set_gear_down);
446 fgSetArchivable("/controls/gear/gear-down");
448 fgTie("/controls/gear/antiskid", this,
449 &FGControls::get_antiskid, &FGControls::set_antiskid);
450 fgSetArchivable("/controls/gear/antiskid");
452 fgTie("/controls/gear/tailhook", this,
453 &FGControls::get_tailhook, &FGControls::set_tailhook);
454 fgSetArchivable("/controls/gear/tailhook");
456 fgTie("/controls/gear/tailwheel-lock", this,
457 &FGControls::get_tailwheel_lock,
458 &FGControls::set_tailwheel_lock);
459 fgSetArchivable("/controls/gear/tailwheel-lock");
461 for (index = 0; index < MAX_WHEELS; index++) {
462 char name[MAX_NAME_LEN];
463 snprintf(name, MAX_NAME_LEN,
464 "/controls/gear/wheel[%d]/alternate-extension", index);
465 fgTie(name, this, index,
466 &FGControls::get_alternate_extension,
467 &FGControls::set_alternate_extension);
468 fgSetArchivable(name);
472 fgTie("/controls/anti-ice/wing-heat", this,
473 &FGControls::get_wing_heat, &FGControls::set_wing_heat);
474 fgSetArchivable("/controls/anti-ice/wing-heat");
476 fgTie("/controls/anti-ice/pitot-heat", this,
477 &FGControls::get_pitot_heat, &FGControls::set_pitot_heat);
478 fgSetArchivable("/controls/anti-ice/pitot-heat");
480 fgTie("/controls/anti-ice/wiper", this,
481 &FGControls::get_wiper, &FGControls::set_wiper);
482 fgSetArchivable("/controls/anti-ice/wiper");
484 fgTie("/controls/anti-ice/window-heat", this,
485 &FGControls::get_window_heat, &FGControls::set_window_heat);
486 fgSetArchivable("/controls/anti-ice/window-heat");
488 for (index = 0; index < MAX_ENGINES; index++) {
489 char name[MAX_NAME_LEN];
490 snprintf(name, MAX_NAME_LEN,
491 "/controls/anti-ice/engine[%d]/carb-heat", index);
492 fgTie(name, this, index,
493 &FGControls::get_carb_heat, &FGControls::set_carb_heat);
494 fgSetArchivable(name);
496 snprintf(name, MAX_NAME_LEN,
497 "/controls/anti-ice/engine[%d]/inlet-heat", index);
498 fgTie(name, this, index,
499 &FGControls::get_inlet_heat, &FGControls::set_inlet_heat);
500 fgSetArchivable(name);
504 for (index = 0; index < MAX_HYD_SYSTEMS; index++) {
505 char name[MAX_NAME_LEN];
506 snprintf(name, MAX_NAME_LEN,
507 "/controls/hydraulic/system[%d]/engine-pump", index);
508 fgTie(name, this, index,
509 &FGControls::get_engine_pump, &FGControls::set_engine_pump);
510 fgSetArchivable(name);
512 snprintf(name, MAX_NAME_LEN,
513 "/controls/hydraulic/system[%d]/electric-pump", index);
514 fgTie(name, this, index,
515 &FGControls::get_electric_pump,
516 &FGControls::set_electric_pump);
517 fgSetArchivable(name);
521 fgTie("/controls/electric/battery-switch", this,
522 &FGControls::get_battery_switch,
523 &FGControls::set_battery_switch);
524 fgSetArchivable("/controls/electric/battery-switch");
526 fgTie("/controls/electric/external-power", this,
527 &FGControls::get_external_power,
528 &FGControls::set_external_power);
529 fgSetArchivable("/controls/electric/external-power");
531 fgTie("/controls/electric/APU-generator", this,
532 &FGControls::get_APU_generator,
533 &FGControls::set_APU_generator);
534 fgSetArchivable("/controls/electric/APU-generator");
536 for (index = 0; index < MAX_ENGINES; index++) {
537 char name[MAX_NAME_LEN];
538 snprintf(name, MAX_NAME_LEN,
539 "/controls/electric/engine[%d]/generator", index);
540 fgTie(name, this, index,
541 &FGControls::get_generator_breaker,
542 &FGControls::set_generator_breaker);
543 fgSetArchivable(name);
545 snprintf(name, MAX_NAME_LEN,
546 "/controls/electric/engine[%d]/bus-tie", index);
547 fgTie(name, this, index,
548 &FGControls::get_bus_tie,
549 &FGControls::set_bus_tie);
550 fgSetArchivable(name);
554 fgTie("/controls/pneumatic/APU-bleed", this,
555 &FGControls::get_APU_bleed,
556 &FGControls::set_APU_bleed);
557 fgSetArchivable("/controls/pneumatic/APU-bleed");
559 for (index = 0; index < MAX_ENGINES; index++) {
560 char name[MAX_NAME_LEN];
561 snprintf(name, MAX_NAME_LEN,
562 "/controls/pneumatic/engine[%d]/bleed", index);
563 fgTie(name, this, index,
564 &FGControls::get_engine_bleed,
565 &FGControls::set_engine_bleed);
566 fgSetArchivable(name);
570 fgTie("/controls/pressurization/mode", this,
571 &FGControls::get_mode, &FGControls::set_mode);
572 fgSetArchivable("/controls/pressurization/mode");
574 fgTie("/controls/pressurization/dump", this,
575 &FGControls::get_dump, &FGControls::set_dump);
576 fgSetArchivable("/controls/pressurization/dump");
578 fgTie("/controls/pressurization/outflow-valve", this,
579 &FGControls::get_outflow_valve,
580 &FGControls::set_outflow_valve);
581 fgSetArchivable("/controls/pressurization/outflow-valve");
583 for (index = 0; index < MAX_PACKS; index++) {
584 char name[MAX_NAME_LEN];
585 snprintf(name, MAX_NAME_LEN,
586 "/controls/pressurization/pack[%d]/pack-on", index);
587 fgTie(name, this, index,
588 &FGControls::get_pack_on, &FGControls::set_pack_on);
589 fgSetArchivable(name);
593 fgTie("/controls/lighting/landing-lights", this,
594 &FGControls::get_landing_lights,
595 &FGControls::set_landing_lights);
596 fgSetArchivable("/controls/lighting/landing-lights");
598 fgTie("/controls/lighting/turn-off-lights", this,
599 &FGControls::get_turn_off_lights,
600 &FGControls::set_turn_off_lights);
601 fgSetArchivable("/controls/lighting/turn-off-lights");
603 fgTie("/controls/lighting/taxi-light", this,
604 &FGControls::get_taxi_light, &FGControls::set_taxi_light);
605 fgSetArchivable("/controls/lighting/taxi-light");
607 fgTie("/controls/lighting/logo-lights", this,
608 &FGControls::get_logo_lights, &FGControls::set_logo_lights);
609 fgSetArchivable("/controls/lighting/logo-lights");
611 fgTie("/controls/lighting/nav-lights", this,
612 &FGControls::get_nav_lights, &FGControls::set_nav_lights);
613 fgSetArchivable("/controls/lighting/nav-lights");
615 fgTie("/controls/lighting/beacon", this,
616 &FGControls::get_beacon, &FGControls::set_beacon);
617 fgSetArchivable("/controls/lighting/beacon");
619 fgTie("/controls/lighting/strobe", this,
620 &FGControls::get_strobe, &FGControls::set_strobe);
621 fgSetArchivable("/controls/lighting/strobe");
623 fgTie("/controls/lighting/panel-norm", this,
624 &FGControls::get_panel_norm, &FGControls::set_panel_norm);
625 fgSetArchivable("/controls/lighting/panel-norm");
627 fgTie("/controls/lighting/instruments-norm", this,
628 &FGControls::get_instruments_norm,
629 &FGControls::set_instruments_norm);
630 fgSetArchivable("/controls/lighting/instruments-norm");
632 fgTie("/controls/lighting/dome-norm", this,
633 &FGControls::get_dome_norm, &FGControls::set_dome_norm);
634 fgSetArchivable("/controls/lighting/dome-norm");
636 #ifdef FG_HAVE_ARMAMENT
638 fgTie("/controls/armament/master-arm", this,
639 &FGControls::get_master_arm, &FGControls::set_master_arm);
640 fgSetArchivable("/controls/armament/master-arm");
642 fgTie("/controls/armament/station-select", this,
643 &FGControls::get_station_select,
644 &FGControls::set_station_select);
645 fgSetArchivable("/controls/armament/station-select");
647 fgTie("/controls/armament/release-all", this,
648 &FGControls::get_release_ALL,
649 &FGControls::set_release_ALL);
650 fgSetArchivable("/controls/armament/release-all");
652 for (index = 0; index < MAX_STATIONS; index++) {
653 char name[MAX_NAME_LEN];
654 snprintf(name, MAX_NAME_LEN,
655 "/controls/armament/station[%d]/stick-size", index);
656 fgTie(name, this, index,
657 &FGControls::get_stick_size, &FGControls::set_stick_size);
658 fgSetArchivable(name);
660 snprintf(name, MAX_NAME_LEN,
661 "/controls/armament/station[%d]/release-stick", index);
662 fgTie(name, this, index,
663 &FGControls::get_release_stick, &FGControls::set_release_stick);
664 fgSetArchivable(name);
666 snprintf(name, MAX_NAME_LEN,
667 "/controls/armament/station[%d]/release-all", index);
668 fgTie(name, this, index,
669 &FGControls::get_release_all, &FGControls::set_release_all);
670 fgSetArchivable(name);
672 snprintf(name, MAX_NAME_LEN,
673 "/controls/armament/station[%d]/jettison-all", index);
674 fgTie(name, this, index,
675 &FGControls::get_jettison_all, &FGControls::set_jettison_all);
676 fgSetArchivable(name);
682 fgTie("/controls/seat/vertical-adjust", this,
683 &FGControls::get_vertical_adjust,
684 &FGControls::set_vertical_adjust);
685 fgSetArchivable("/controls/seat/vertical-adjust");
687 fgTie("/controls/seat/fore-aft-adjust", this,
688 &FGControls::get_fore_aft_adjust,
689 &FGControls::set_fore_aft_adjust);
690 fgSetArchivable("/controls/seat/fore-aft-adjust");
692 for (index = 0; index < MAX_EJECTION_SEATS; index++) {
693 char name[MAX_NAME_LEN];
694 snprintf(name, MAX_NAME_LEN,
695 "/controls/seat/eject[%d]/initiate", index);
696 fgTie(name, this, index,
697 &FGControls::get_ejection_seat,
698 &FGControls::set_ejection_seat);
699 fgSetArchivable(name);
701 snprintf(name, MAX_NAME_LEN,
702 "/controls/seat/eject[%d]/status", index);
704 fgTie(name, this, index,
705 &FGControls::get_eseat_status,
706 &FGControls::set_eseat_status);
708 fgSetArchivable(name);
711 fgTie("/controls/seat/cmd_selector_valve", this,
712 &FGControls::get_cmd_selector_valve,
713 &FGControls::set_cmd_selector_valve);
714 fgSetArchivable("/controls/seat/eject/cmd_selector_valve");
718 fgTie("/controls/APU/off-start-run", this,
719 &FGControls::get_off_start_run,
720 &FGControls::set_off_start_run);
721 fgSetArchivable("/controls/APU/off-start-run");
723 fgTie("/controls/APU/fire-switch", this,
724 &FGControls::get_APU_fire_switch,
725 &FGControls::set_APU_fire_switch);
726 fgSetArchivable("/controls/APU/fire-switch");
729 for (index = 0; index < MAX_AUTOPILOTS; index++) {
730 char name[MAX_NAME_LEN];
731 snprintf(name, MAX_NAME_LEN,
732 "/controls/autoflight/autopilot[%d]/engage", index);
733 fgTie(name, this, index,
734 &FGControls::get_autopilot_engage,
735 &FGControls::set_autopilot_engage);
736 fgSetArchivable(name);
739 fgTie("/controls/autoflight/autothrottle-arm", this,
740 &FGControls::get_autothrottle_arm,
741 &FGControls::set_autothrottle_arm);
742 fgSetArchivable("/controls/autoflight/autothrottle-arm");
744 fgTie("/controls/autoflight/autothrottle-engage", this,
745 &FGControls::get_autothrottle_engage,
746 &FGControls::set_autothrottle_engage);
747 fgSetArchivable("/controls/autoflight/autothrottle-engage");
749 fgTie("/controls/autoflight/heading-select", this,
750 &FGControls::get_heading_select,
751 &FGControls::set_heading_select);
752 fgSetArchivable("/controls/autoflight/heading-select");
754 fgTie("/controls/autoflight/altitude-select", this,
755 &FGControls::get_altitude_select,
756 &FGControls::set_altitude_select);
757 fgSetArchivable("/controls/autoflight/altitude-select");
759 fgTie("/controls/autoflight/bank-angle-select", this,
760 &FGControls::get_bank_angle_select,
761 &FGControls::set_bank_angle_select);
762 fgSetArchivable("/controls/autoflight/bank-angle-select");
764 fgTie("/controls/autoflight/vertical-speed-select", this,
765 &FGControls::get_vertical_speed_select,
766 &FGControls::set_vertical_speed_select);
767 fgSetArchivable("/controls/autoflight/vertical-speed-select");
769 fgTie("/controls/autoflight/speed-select", this,
770 &FGControls::get_speed_select,
771 &FGControls::set_speed_select);
772 fgSetArchivable("/controls/autoflight/speed-select");
774 fgTie("/controls/autoflight/mach-select", this,
775 &FGControls::get_mach_select,
776 &FGControls::set_mach_select);
777 fgSetArchivable("/controls/autoflight/mach-select");
779 fgTie("/controls/autoflight/vertical-mode", this,
780 &FGControls::get_vertical_mode,
781 &FGControls::set_vertical_mode);
782 fgSetArchivable("/controls/autoflight/vertical-mode");
784 fgTie("/controls/autoflight/lateral-mode", this,
785 &FGControls::get_lateral_mode,
786 &FGControls::set_lateral_mode);
787 fgSetArchivable("/controls/autoflight/lateral-mode");
791 void FGControls::unbind ()
794 //Tie control properties.
795 fgUntie("/controls/flight/aileron");
796 fgUntie("/controls/flight/aileron-trim");
797 fgUntie("/controls/flight/elevator");
798 fgUntie("/controls/flight/elevator-trim");
799 fgUntie("/controls/flight/rudder");
800 fgUntie("/controls/flight/rudder-trim");
801 fgUntie("/controls/flight/flaps");
802 fgUntie("/controls/flight/slats");
803 fgUntie("/controls/flight/BLC");
804 fgUntie("/controls/flight/spoilers");
805 fgUntie("/controls/flight/speedbrake");
806 fgUntie("/controls/flight/wing-sweep");
807 fgUntie("/controls/flight/wing-fold");
808 fgUntie("/controls/flight/drag-chute");
809 for (index = 0; index < MAX_ENGINES; index++) {
810 char name[MAX_NAME_LEN];
811 snprintf(name, MAX_NAME_LEN,
812 "/controls/engines/engine[%d]/throttle", index);
814 snprintf(name, MAX_NAME_LEN,
815 "/controls/engines/engine[%d]/starter", index);
817 snprintf(name, MAX_NAME_LEN,
818 "/controls/engines/engine[%d]/fuel_pump", index);
820 snprintf(name, MAX_NAME_LEN,
821 "/controls/engines/engine[%d]/fire-switch", index);
823 snprintf(name, MAX_NAME_LEN,
824 "/controls/engines/engine[%d]/fire-bottle-discharge", index);
826 snprintf(name, MAX_NAME_LEN,
827 "/controls/engines/engine[%d]/throttle_idle", index);
829 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/cutoff", index);
831 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/mixture", index);
833 snprintf(name, MAX_NAME_LEN,
834 "/controls/engines/engine[%d]/propeller-pitch", index);
836 snprintf(name, MAX_NAME_LEN,
837 "/controls/engines/engine[%d]/magnetos", index);
839 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/WEP", index);
841 snprintf(name, MAX_NAME_LEN,
842 "/controls/engines/engine[%d]/cowl-flaps-norm", index);
844 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/feather", index);
846 snprintf(name, MAX_NAME_LEN,
847 "/controls/engines/engine[%d]/ignition", index);
849 snprintf(name, MAX_NAME_LEN,
850 "/controls/engines/engine[%d]/augmentation", index);
852 snprintf(name, MAX_NAME_LEN,
853 "/controls/engines/engine[%d]/reverser", index);
855 snprintf(name, MAX_NAME_LEN,
856 "/controls/engines/engine[%d]/water-injection", index);
858 snprintf(name, MAX_NAME_LEN,
859 "/controls/engines/engine[%d]/condition", index);
862 fgUntie("/controls/fuel/dump-valve");
863 for (index = 0; index < MAX_TANKS; index++) {
864 char name[MAX_NAME_LEN];
865 snprintf(name, MAX_NAME_LEN,
866 "/controls/fuel/tank[%d]/fuel_selector", index);
868 snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_engine", index);
870 snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_tank", index);
872 for (i = 0; index < MAX_BOOSTPUMPS; i++) {
873 snprintf(name, MAX_NAME_LEN,
874 "/controls/fuel/tank[%d]/boost-pump[%d]", index, i);
878 fgUntie("/controls/gear/brake-left");
879 fgUntie("/controls/gear/brake-right");
880 fgUntie("/controls/gear/brake-parking");
881 fgUntie("/controls/gear/steering");
882 fgUntie("/controls/gear/gear_down");
883 fgUntie("/controls/gear/antiskid");
884 fgUntie("/controls/gear/tailhook");
885 fgUntie("/controls/gear/tailwheel-lock");
886 for (index = 0; index < MAX_WHEELS; index++) {
887 char name[MAX_NAME_LEN];
888 snprintf(name, MAX_NAME_LEN,
889 "/controls/gear/wheel[%d]/alternate-extension", index);
892 fgUntie("/controls/anti-ice/wing-heat");
893 fgUntie("/controls/anti-ice/pitot-heat");
894 fgUntie("/controls/anti-ice/wiper");
895 fgUntie("/controls/anti-ice/window-heat");
896 for (index = 0; index < MAX_ENGINES; index++) {
897 char name[MAX_NAME_LEN];
898 snprintf(name, MAX_NAME_LEN,
899 "/controls/anti-ice/engine[%d]/carb-heat", index);
901 snprintf(name, MAX_NAME_LEN,
902 "/controls/anti-ice/engine[%d]/inlet-heat", index);
905 for (index = 0; index < MAX_HYD_SYSTEMS; index++) {
906 char name[MAX_NAME_LEN];
907 snprintf(name, MAX_NAME_LEN,
908 "/controls/hydraulic/system[%d]/engine-pump", index);
910 snprintf(name, MAX_NAME_LEN,
911 "/controls/hydraulic/system[%d]/electric-pump", index);
914 fgUntie("/controls/electric/battery-switch");
915 fgUntie("/controls/electric/external-power");
916 fgUntie("/controls/electric/APU-generator");
917 for (index = 0; index < MAX_ENGINES; index++) {
918 char name[MAX_NAME_LEN];
919 snprintf(name, MAX_NAME_LEN,
920 "/controls/electric/engine[%d]/generator", index);
922 snprintf(name, MAX_NAME_LEN,
923 "/controls/electric/engine[%d]/bus-tie", index);
926 fgUntie("/controls/pneumatic/APU-bleed");
927 for (index = 0; index < MAX_ENGINES; index++) {
928 char name[MAX_NAME_LEN];
929 snprintf(name, MAX_NAME_LEN,
930 "/controls/pneumatic/engine[%d]/bleed", index);
933 fgUntie("/controls/pressurization/mode");
934 fgUntie("/controls/pressurization/dump");
935 for (index = 0; index < MAX_PACKS; index++) {
936 char name[MAX_NAME_LEN];
937 snprintf(name, MAX_NAME_LEN,
938 "/controls/pressurization/pack[%d]/pack-on", index);
941 fgUntie("/controls/lighting/landing-lights");
942 fgUntie("/controls/lighting/turn-off-lights");
943 fgUntie("/controls/lighting/taxi-light");
944 fgUntie("/controls/lighting/logo-lights");
945 fgUntie("/controls/lighting/nav-lights");
946 fgUntie("/controls/lighting/beacon");
947 fgUntie("/controls/lighting/strobe");
948 fgUntie("/controls/lighting/panel-norm");
949 fgUntie("/controls/lighting/instruments-norm");
950 fgUntie("/controls/lighting/dome-norm");
952 #ifdef FG_HAVE_ARMAMENT
953 fgUntie("/controls/armament/master-arm");
954 fgUntie("/controls/armament/station-select");
955 fgUntie("/controls/armament/release-all");
956 for (index = 0; index < MAX_STATIONS; index++) {
957 char name[MAX_NAME_LEN];
958 snprintf(name, MAX_NAME_LEN,
959 "/controls/armament/station[%d]/stick-size", index);
961 snprintf(name, MAX_NAME_LEN,
962 "/controls/armament/station[%d]/release-stick", index);
964 snprintf(name, MAX_NAME_LEN,
965 "/controls/armament/station[%d]/release-all", index);
967 snprintf(name, MAX_NAME_LEN,
968 "/controls/armament/station[%d]/jettison-all", index);
972 fgUntie("/controls/seat/vertical-adjust");
973 fgUntie("/controls/seat/fore-aft-adjust");
974 for (index = 0; index < MAX_EJECTION_SEATS; index++) {
975 char name[MAX_NAME_LEN];
976 snprintf(name, MAX_NAME_LEN,
977 "/controls/seat/eject[%d]/initiate", index);
979 snprintf(name, MAX_NAME_LEN,
980 "/controls/seat/eject[%d]/status", index);
983 fgUntie("/controls/seat/cmd_selector_valve");
985 fgUntie("/controls/APU/off-start-run");
986 fgUntie("/controls/APU/fire-switch");
987 for (index = 0; index < MAX_AUTOPILOTS; index++) {
988 char name[MAX_NAME_LEN];
989 snprintf(name, MAX_NAME_LEN,
990 "/controls/autoflight/autopilot[%d]/engage", index);
993 fgUntie("/controls/autoflight/autothrottle-arm");
994 fgUntie("/controls/autoflight/autothrottle-engage");
995 fgUntie("/controls/autoflight/heading-select");
996 fgUntie("/controls/autoflight/altitude-select");
997 fgUntie("/controls/autoflight/bank-angle-select");
998 fgUntie("/controls/autoflight/vertical-speed-select");
999 fgUntie("/controls/autoflight/speed-select");
1000 fgUntie("/controls/autoflight/mach-select");
1001 fgUntie("/controls/autoflight/vertical-mode");
1002 fgUntie("/controls/autoflight/lateral-mode");
1007 FGControls::update (double dt)
1013 ////////////////////////////////////////////////////////////////////////
1014 // Setters and adjusters.
1015 ////////////////////////////////////////////////////////////////////////
1018 FGControls::set_aileron (double pos)
1021 CLAMP( &aileron, -1.0, 1.0 );
1023 // check for autocoordination
1024 if ( auto_coordination->getBoolValue() ) {
1025 set_rudder( aileron / 2.0 );
1030 FGControls::move_aileron (double amt)
1033 CLAMP( &aileron, -1.0, 1.0 );
1035 // check for autocoordination
1036 if ( auto_coordination->getBoolValue() ) {
1037 set_rudder( aileron / 2.0 );
1042 FGControls::set_aileron_trim( double pos )
1045 CLAMP( &aileron_trim, -1.0, 1.0 );
1049 FGControls::move_aileron_trim( double amt )
1051 aileron_trim += amt;
1052 CLAMP( &aileron_trim, -1.0, 1.0 );
1056 FGControls::set_elevator( double pos )
1059 CLAMP( &elevator, -1.0, 1.0 );
1063 FGControls::move_elevator( double amt )
1066 CLAMP( &elevator, -1.0, 1.0 );
1070 FGControls::set_elevator_trim( double pos )
1072 elevator_trim = pos;
1073 CLAMP( &elevator_trim, -1.0, 1.0 );
1077 FGControls::move_elevator_trim( double amt )
1079 elevator_trim += amt;
1080 CLAMP( &elevator_trim, -1.0, 1.0 );
1084 FGControls::set_rudder( double pos )
1087 CLAMP( &rudder, -1.0, 1.0 );
1091 FGControls::move_rudder( double amt )
1094 CLAMP( &rudder, -1.0, 1.0 );
1098 FGControls::set_rudder_trim( double pos )
1101 CLAMP( &rudder_trim, -1.0, 1.0 );
1105 FGControls::move_rudder_trim( double amt )
1108 CLAMP( &rudder_trim, -1.0, 1.0 );
1112 FGControls::set_flaps( double pos )
1115 CLAMP( &flaps, 0.0, 1.0 );
1119 FGControls::move_flaps( double amt )
1122 CLAMP( &flaps, 0.0, 1.0 );
1126 FGControls::set_slats( double pos )
1129 CLAMP( &slats, 0.0, 1.0 );
1133 FGControls::move_slats( double amt )
1136 CLAMP( &slats, 0.0, 1.0 );
1140 FGControls::set_BLC( bool val )
1146 FGControls::set_spoilers( double pos )
1149 CLAMP( &spoilers, 0.0, 1.0 );
1153 FGControls::move_spoilers( double amt )
1156 CLAMP( &spoilers, 0.0, 1.0 );
1160 FGControls::set_speedbrake( double pos )
1163 CLAMP( &speedbrake, 0.0, 1.0 );
1167 FGControls::move_speedbrake( double amt )
1170 CLAMP( &speedbrake, 0.0, 1.0 );
1174 FGControls::set_wing_sweep( double pos )
1177 CLAMP( &wing_sweep, 0.0, 1.0 );
1181 FGControls::move_wing_sweep( double amt )
1184 CLAMP( &wing_sweep, 0.0, 1.0 );
1188 FGControls::set_wing_fold( bool val )
1194 FGControls::set_drag_chute( bool val )
1200 FGControls::set_throttle_idle( bool val )
1202 throttle_idle = val;
1206 FGControls::set_throttle( int engine, double pos )
1208 if ( engine == ALL_ENGINES ) {
1209 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1211 CLAMP( &throttle[i], 0.0, 1.0 );
1214 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1215 throttle[engine] = pos;
1216 CLAMP( &throttle[engine], 0.0, 1.0 );
1222 FGControls::move_throttle( int engine, double amt )
1224 if ( engine == ALL_ENGINES ) {
1225 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1227 CLAMP( &throttle[i], 0.0, 1.0 );
1230 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1231 throttle[engine] += amt;
1232 CLAMP( &throttle[engine], 0.0, 1.0 );
1238 FGControls::set_starter( int engine, bool flag )
1240 if ( engine == ALL_ENGINES ) {
1241 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1245 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1246 starter[engine] = flag;
1252 FGControls::set_fuel_pump( int engine, bool val )
1254 if ( engine == ALL_ENGINES ) {
1255 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1259 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1260 fuel_pump[engine] = val;
1266 FGControls::set_fire_switch( int engine, bool val )
1268 if ( engine == ALL_ENGINES ) {
1269 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1270 fire_switch[i] = val;
1273 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1274 fire_switch[engine] = val;
1280 FGControls::set_fire_bottle_discharge( int engine, bool val )
1282 if ( engine == ALL_ENGINES ) {
1283 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1284 fire_bottle_discharge[i] = val;
1287 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1288 fire_bottle_discharge[engine] = val;
1294 FGControls::set_cutoff( int engine, bool val )
1296 if ( engine == ALL_ENGINES ) {
1297 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1301 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1302 cutoff[engine] = val;
1309 FGControls::set_mixture( int engine, double pos )
1311 if ( engine == ALL_ENGINES ) {
1312 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1314 CLAMP( &mixture[i], 0.0, 1.0 );
1317 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1318 mixture[engine] = pos;
1319 CLAMP( &mixture[engine], 0.0, 1.0 );
1325 FGControls::move_mixture( int engine, double amt )
1327 if ( engine == ALL_ENGINES ) {
1328 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1330 CLAMP( &mixture[i], 0.0, 1.0 );
1333 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1334 mixture[engine] += amt;
1335 CLAMP( &mixture[engine], 0.0, 1.0 );
1341 FGControls::set_prop_advance( int engine, double pos )
1343 if ( engine == ALL_ENGINES ) {
1344 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1345 prop_advance[i] = pos;
1346 CLAMP( &prop_advance[i], 0.0, 1.0 );
1349 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1350 prop_advance[engine] = pos;
1351 CLAMP( &prop_advance[engine], 0.0, 1.0 );
1357 FGControls::move_prop_advance( int engine, double amt )
1359 if ( engine == ALL_ENGINES ) {
1360 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1361 prop_advance[i] += amt;
1362 CLAMP( &prop_advance[i], 0.0, 1.0 );
1365 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1366 prop_advance[engine] += amt;
1367 CLAMP( &prop_advance[engine], 0.0, 1.0 );
1373 FGControls::set_magnetos( int engine, int pos )
1375 if ( engine == ALL_ENGINES ) {
1376 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1378 CLAMP( &magnetos[i], 0, 3 );
1381 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1382 magnetos[engine] = pos;
1383 CLAMP( &magnetos[engine], 0, 3 );
1389 FGControls::move_magnetos( int engine, int amt )
1391 if ( engine == ALL_ENGINES ) {
1392 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1394 CLAMP( &magnetos[i], 0, 3 );
1397 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1398 magnetos[engine] += amt;
1399 CLAMP( &magnetos[engine], 0, 3 );
1405 FGControls::set_nitrous_injection( int engine, bool val )
1407 if ( engine == ALL_ENGINES ) {
1408 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1409 nitrous_injection[i] = val;
1412 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1413 nitrous_injection[engine] = val;
1420 FGControls::set_cowl_flaps_norm( int engine, double pos )
1422 if ( engine == ALL_ENGINES ) {
1423 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1424 cowl_flaps_norm[i] = pos;
1425 CLAMP( &cowl_flaps_norm[i], 0.0, 1.0 );
1428 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1429 cowl_flaps_norm[engine] = pos;
1430 CLAMP( &cowl_flaps_norm[engine], 0.0, 1.0 );
1436 FGControls::move_cowl_flaps_norm( int engine, double amt )
1438 if ( engine == ALL_ENGINES ) {
1439 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1440 cowl_flaps_norm[i] += amt;
1441 CLAMP( &cowl_flaps_norm[i], 0.0, 1.0 );
1444 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1445 cowl_flaps_norm[engine] += amt;
1446 CLAMP( &cowl_flaps_norm[engine], 0.0, 1.0 );
1452 FGControls::set_feather( int engine, bool val )
1454 if ( engine == ALL_ENGINES ) {
1455 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1459 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1460 feather[engine] = val;
1466 FGControls::set_ignition( int engine, int pos )
1468 if ( engine == ALL_ENGINES ) {
1469 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1471 CLAMP( &ignition[i], 0, 3 );
1474 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1475 ignition[engine] = pos;
1476 CLAMP( &ignition[engine], 0, 3 );
1482 FGControls::set_augmentation( int engine, bool val )
1484 if ( engine == ALL_ENGINES ) {
1485 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1486 augmentation[i] = val;
1489 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1490 augmentation[engine] = val;
1496 FGControls::set_reverser( int engine, bool val )
1498 if ( engine == ALL_ENGINES ) {
1499 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1503 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1504 reverser[engine] = val;
1510 FGControls::set_water_injection( int engine, bool val )
1512 if ( engine == ALL_ENGINES ) {
1513 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1514 water_injection[i] = val;
1517 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1518 water_injection[engine] = val;
1524 FGControls::set_condition( int engine, int val )
1526 if ( engine == ALL_ENGINES ) {
1527 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1529 CLAMP( &condition[i], 0, 3 );
1532 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1533 condition[engine] = val;
1534 CLAMP( &condition[engine], 0, 3 );
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;