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 ),
77 copilot_brake_left( 0.0 ),
78 copilot_brake_right( 0.0 ),
84 tailwheel_lock( false ),
89 battery_switch( true ),
90 external_power( false ),
91 APU_generator( false ),
102 instruments_norm( 0.0 ),
106 release_ALL( false ),
107 vertical_adjust( 0.0 ),
108 fore_aft_adjust( 0.0 ),
110 APU_fire_switch( false ),
111 autothrottle_arm( false ),
112 autothrottle_engage( false ),
113 heading_select( 0.0 ),
114 altitude_select( 50000.0 ),
115 bank_angle_select( 30.0 ),
116 vertical_speed_select( 0.0 ),
125 void FGControls::reset_all()
128 set_aileron_trim( 0.0 );
130 set_elevator_trim( 0.0 );
132 set_rudder_trim( 0.0 );
135 set_speedbrake( 0.0 );
136 set_wing_sweep( 0.0 );
139 set_throttle( ALL_ENGINES, 0.0 );
140 set_starter( ALL_ENGINES, false );
141 set_magnetos( ALL_ENGINES, 0 );
142 set_fuel_pump( ALL_ENGINES, false );
143 set_fire_switch( ALL_ENGINES, false );
144 set_fire_bottle_discharge( ALL_ENGINES, false );
145 set_cutoff( ALL_ENGINES, true );
146 set_nitrous_injection( ALL_ENGINES, false );
147 set_cowl_flaps_norm( ALL_ENGINES, 1.0 );
148 set_feather( ALL_ENGINES, false );
149 set_ignition( ALL_ENGINES, false );
150 set_augmentation( ALL_ENGINES, false );
151 set_reverser( ALL_ENGINES, false );
152 set_water_injection( ALL_ENGINES, false );
153 set_condition( ALL_ENGINES, 1.0 );
154 throttle_idle = true;
155 set_fuel_selector( ALL_TANKS, true );
160 tailwheel_lock = false;
161 set_carb_heat( ALL_ENGINES, false );
162 set_inlet_heat( ALL_ENGINES, false );
167 set_engine_pump( ALL_HYD_SYSTEMS, true );
168 set_electric_pump( ALL_HYD_SYSTEMS, true );
169 landing_lights = false;
170 turn_off_lights = false;
172 set_ejection_seat( ALL_EJECTION_SEATS, false );
173 set_eseat_status( ALL_EJECTION_SEATS, SEAT_SAFED );
174 set_cmd_selector_valve( CMD_SEL_NORM );
175 APU_fire_switch = false;
176 autothrottle_arm = false;
177 autothrottle_engage = false;
178 set_autopilot_engage( ALL_AUTOPILOTS, false );
183 FGControls::~FGControls() {
190 throttle_idle = true;
191 for ( int engine = 0; engine < MAX_ENGINES; engine++ ) {
192 throttle[engine] = 0.0;
193 mixture[engine] = 1.0;
194 fuel_pump[engine] = false;
195 prop_advance[engine] = 1.0;
196 magnetos[engine] = 0;
197 starter[engine] = false;
198 ignition[engine] = false;
199 fire_switch[engine] = false;
200 cutoff[engine] = true;
201 augmentation[engine] = false;
202 reverser[engine] = false;
203 water_injection[engine] = false;
204 nitrous_injection[engine] = false;
205 cowl_flaps_norm[engine] = 0.0;
206 condition[engine] = 1.0;
209 brake_left = brake_right
210 = copilot_brake_left = copilot_brake_right
211 = brake_parking = 0.0;
212 for ( int wheel = 0; wheel < MAX_WHEELS; wheel++ ) {
213 alternate_extension[wheel] = false;
216 auto_coordination = fgGetNode("/sim/auto-coordination", true);
226 fgTie("/controls/flight/aileron", this,
227 &FGControls::get_aileron, &FGControls::set_aileron);
228 fgSetArchivable("/controls/flight/aileron");
230 fgTie("/controls/flight/aileron-trim", this,
231 &FGControls::get_aileron_trim, &FGControls::set_aileron_trim);
232 fgSetArchivable("/controls/flight/aileron-trim");
234 fgTie("/controls/flight/elevator", this,
235 &FGControls::get_elevator, &FGControls::set_elevator);
236 fgSetArchivable("/controls/flight/elevator");
238 fgTie("/controls/flight/elevator-trim", this,
239 &FGControls::get_elevator_trim, &FGControls::set_elevator_trim);
240 fgSetArchivable("/controls/flight/elevator-trim");
242 fgTie("/controls/flight/rudder", this,
243 &FGControls::get_rudder, &FGControls::set_rudder);
244 fgSetArchivable("/controls/flight/rudder");
246 fgTie("/controls/flight/rudder-trim", this,
247 &FGControls::get_rudder_trim, &FGControls::set_rudder_trim);
248 fgSetArchivable("/controls/flight/rudder-trim");
250 fgTie("/controls/flight/flaps", this,
251 &FGControls::get_flaps, &FGControls::set_flaps);
252 fgSetArchivable("/controls/flight/flaps");
254 fgTie("/controls/flight/slats", this,
255 &FGControls::get_slats, &FGControls::set_slats);
256 fgSetArchivable("/controls/flight/slats");
258 fgTie("/controls/flight/BLC", this,
259 &FGControls::get_BLC, &FGControls::set_BLC);
260 fgSetArchivable("/controls/flight/BLC");
262 fgTie("/controls/flight/spoilers", this,
263 &FGControls::get_spoilers, &FGControls::set_spoilers);
264 fgSetArchivable("/controls/flight/spoilers");
266 fgTie("/controls/flight/speedbrake", this,
267 &FGControls::get_speedbrake, &FGControls::set_speedbrake);
268 fgSetArchivable("/controls/flight/speedbrake");
270 fgTie("/controls/flight/wing-sweep", this,
271 &FGControls::get_wing_sweep, &FGControls::set_wing_sweep);
272 fgSetArchivable("/controls/flight/wing-sweep");
274 fgTie("/controls/flight/wing-fold", this,
275 &FGControls::get_wing_fold, &FGControls::set_wing_fold);
276 fgSetArchivable("/controls/flight/wing-fold");
278 fgTie("/controls/flight/drag-chute", this,
279 &FGControls::get_drag_chute, &FGControls::set_drag_chute);
280 fgSetArchivable("/controls/flight/drag-chute");
283 fgTie("/controls/engines/throttle_idle", this,
284 &FGControls::get_throttle_idle, &FGControls::set_throttle_idle);
285 fgSetArchivable("/controls/engines/throttle_idle");
287 for (index = 0; index < MAX_ENGINES; index++) {
288 char name[MAX_NAME_LEN];
289 snprintf(name, MAX_NAME_LEN,
290 "/controls/engines/engine[%d]/throttle", index);
291 fgTie(name, this, index,
292 &FGControls::get_throttle, &FGControls::set_throttle);
293 fgSetArchivable(name);
295 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/starter", index);
296 fgTie(name, this, index,
297 &FGControls::get_starter, &FGControls::set_starter);
298 fgSetArchivable(name);
300 snprintf(name, MAX_NAME_LEN,
301 "/controls/engines/engine[%d]/fuel-pump", index);
302 fgTie(name, this, index,
303 &FGControls::get_fuel_pump, &FGControls::set_fuel_pump);
304 fgSetArchivable(name);
306 snprintf(name, MAX_NAME_LEN,
307 "/controls/engines/engine[%d]/fire-switch", index);
308 fgTie(name, this, index,
309 &FGControls::get_fire_switch, &FGControls::set_fire_switch);
310 fgSetArchivable(name);
312 snprintf(name, MAX_NAME_LEN,
313 "/controls/engines/engine[%d]/fire-bottle-discharge", index);
314 fgTie(name, this, index,
315 &FGControls::get_fire_bottle_discharge,
316 &FGControls::set_fire_bottle_discharge);
317 fgSetArchivable(name);
319 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/cutoff", index);
320 fgTie(name, this, index,
321 &FGControls::get_cutoff, &FGControls::set_cutoff);
322 fgSetArchivable(name);
324 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/mixture", index);
325 fgTie(name, this, index,
326 &FGControls::get_mixture, &FGControls::set_mixture);
327 fgSetArchivable(name);
329 snprintf(name, MAX_NAME_LEN,
330 "/controls/engines/engine[%d]/propeller-pitch", index);
331 fgTie(name, this, index,
332 &FGControls::get_prop_advance,
333 &FGControls::set_prop_advance);
334 fgSetArchivable(name);
336 snprintf(name, MAX_NAME_LEN,
337 "/controls/engines/engine[%d]/magnetos", index);
338 fgTie(name, this, index,
339 &FGControls::get_magnetos, &FGControls::set_magnetos);
340 fgSetArchivable(name);
342 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/WEP", index);
343 fgTie(name, this, index,
344 &FGControls::get_nitrous_injection,
345 &FGControls::set_nitrous_injection);
346 fgSetArchivable(name);
348 snprintf(name, MAX_NAME_LEN,
349 "/controls/engines/engine[%d]/cowl-flaps-norm", index);
350 fgTie(name, this, index,
351 &FGControls::get_cowl_flaps_norm,
352 &FGControls::set_cowl_flaps_norm);
353 fgSetArchivable(name);
355 snprintf(name, MAX_NAME_LEN,
356 "/controls/engines/engine[%d]/propeller-feather", index);
357 fgTie(name, this, index,
358 &FGControls::get_feather, &FGControls::set_feather);
359 fgSetArchivable(name);
361 snprintf(name, MAX_NAME_LEN,
362 "/controls/engines/engine[%d]/ignition", index);
363 fgTie(name, this, index,
364 &FGControls::get_ignition, &FGControls::set_ignition);
365 fgSetArchivable(name);
367 snprintf(name, MAX_NAME_LEN,
368 "/controls/engines/engine[%d]/augmentation", index);
369 fgTie(name, this, index,
370 &FGControls::get_augmentation,
371 &FGControls::set_augmentation);
372 fgSetArchivable(name);
374 snprintf(name, MAX_NAME_LEN,
375 "/controls/engines/engine[%d]/reverser", index);
376 fgTie(name, this, index,
377 &FGControls::get_reverser, &FGControls::set_reverser);
378 fgSetArchivable(name);
380 snprintf(name, MAX_NAME_LEN,
381 "/controls/engines/engine[%d]/water-injection", index);
382 fgTie(name, this, index,
383 &FGControls::get_water_injection,
384 &FGControls::set_water_injection);
385 fgSetArchivable(name);
387 snprintf(name, MAX_NAME_LEN,
388 "/controls/engines/engine[%d]/condition", index);
389 fgTie(name, this, index,
390 &FGControls::get_condition, &FGControls::set_condition);
391 fgSetArchivable(name);
395 fgTie("/controls/fuel/dump-valve", this,
396 &FGControls::get_dump_valve, &FGControls::set_dump_valve);
397 fgSetArchivable("/controls/fuel/dump-valve");
399 for (index = 0; index < MAX_TANKS; index++) {
400 char name[MAX_NAME_LEN];
401 snprintf(name, MAX_NAME_LEN,
402 "/controls/fuel/tank[%d]/fuel_selector", index);
403 fgTie(name, this, index,
404 &FGControls::get_fuel_selector,
405 &FGControls::set_fuel_selector);
406 fgSetArchivable(name);
408 snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_engine", index);
409 fgTie(name, this, index,
410 &FGControls::get_to_engine, &FGControls::set_to_engine);
411 fgSetArchivable(name);
413 snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_tank", index);
414 fgTie(name, this, index,
415 &FGControls::get_to_tank, &FGControls::set_to_tank);
416 fgSetArchivable(name);
418 for (i = 0; i < MAX_BOOSTPUMPS; i++) {
419 char name[MAX_NAME_LEN];
420 snprintf(name, MAX_NAME_LEN,
421 "/controls/fuel/tank[%d]/boost-pump[%d]", index, i);
422 fgTie(name, this, index * 2 + i,
423 &FGControls::get_boost_pump,
424 &FGControls::set_boost_pump);
425 fgSetArchivable(name);
430 fgTie("/controls/gear/brake-left", this,
431 &FGControls::get_brake_left,
432 &FGControls::set_brake_left);
433 fgSetArchivable("/controls/gear/brake-left");
435 fgTie("/controls/gear/brake-right", this,
436 &FGControls::get_brake_right,
437 &FGControls::set_brake_right);
438 fgSetArchivable("/controls/gear/brake-right");
440 fgTie("/controls/gear/copilot-brake-left", this,
441 &FGControls::get_copilot_brake_left,
442 &FGControls::set_copilot_brake_left);
443 fgSetArchivable("/controls/gear/copilot-brake-left");
445 fgTie("/controls/gear/copilot-brake-right", this,
446 &FGControls::get_copilot_brake_right,
447 &FGControls::set_copilot_brake_right);
448 fgSetArchivable("/controls/gear/copilot-brake-right");
450 fgTie("/controls/gear/brake-parking", this,
451 &FGControls::get_brake_parking,
452 &FGControls::set_brake_parking);
453 fgSetArchivable("/controls/gear/brake-parking");
455 fgTie("/controls/gear/steering", this,
456 &FGControls::get_steering, &FGControls::set_steering);
457 fgSetArchivable("/controls/gear/steering");
459 fgTie("/controls/gear/gear-down", this,
460 &FGControls::get_gear_down, &FGControls::set_gear_down);
461 fgSetArchivable("/controls/gear/gear-down");
463 fgTie("/controls/gear/antiskid", this,
464 &FGControls::get_antiskid, &FGControls::set_antiskid);
465 fgSetArchivable("/controls/gear/antiskid");
467 fgTie("/controls/gear/tailhook", this,
468 &FGControls::get_tailhook, &FGControls::set_tailhook);
469 fgSetArchivable("/controls/gear/tailhook");
471 fgTie("/controls/gear/tailwheel-lock", this,
472 &FGControls::get_tailwheel_lock,
473 &FGControls::set_tailwheel_lock);
474 fgSetArchivable("/controls/gear/tailwheel-lock");
476 for (index = 0; index < MAX_WHEELS; index++) {
477 char name[MAX_NAME_LEN];
478 snprintf(name, MAX_NAME_LEN,
479 "/controls/gear/wheel[%d]/alternate-extension", index);
480 fgTie(name, this, index,
481 &FGControls::get_alternate_extension,
482 &FGControls::set_alternate_extension);
483 fgSetArchivable(name);
487 fgTie("/controls/anti-ice/wing-heat", this,
488 &FGControls::get_wing_heat, &FGControls::set_wing_heat);
489 fgSetArchivable("/controls/anti-ice/wing-heat");
491 fgTie("/controls/anti-ice/pitot-heat", this,
492 &FGControls::get_pitot_heat, &FGControls::set_pitot_heat);
493 fgSetArchivable("/controls/anti-ice/pitot-heat");
495 fgTie("/controls/anti-ice/wiper", this,
496 &FGControls::get_wiper, &FGControls::set_wiper);
497 fgSetArchivable("/controls/anti-ice/wiper");
499 fgTie("/controls/anti-ice/window-heat", this,
500 &FGControls::get_window_heat, &FGControls::set_window_heat);
501 fgSetArchivable("/controls/anti-ice/window-heat");
503 for (index = 0; index < MAX_ENGINES; index++) {
504 char name[MAX_NAME_LEN];
505 snprintf(name, MAX_NAME_LEN,
506 "/controls/anti-ice/engine[%d]/carb-heat", index);
507 fgTie(name, this, index,
508 &FGControls::get_carb_heat, &FGControls::set_carb_heat);
509 fgSetArchivable(name);
511 snprintf(name, MAX_NAME_LEN,
512 "/controls/anti-ice/engine[%d]/inlet-heat", index);
513 fgTie(name, this, index,
514 &FGControls::get_inlet_heat, &FGControls::set_inlet_heat);
515 fgSetArchivable(name);
519 for (index = 0; index < MAX_HYD_SYSTEMS; index++) {
520 char name[MAX_NAME_LEN];
521 snprintf(name, MAX_NAME_LEN,
522 "/controls/hydraulic/system[%d]/engine-pump", index);
523 fgTie(name, this, index,
524 &FGControls::get_engine_pump, &FGControls::set_engine_pump);
525 fgSetArchivable(name);
527 snprintf(name, MAX_NAME_LEN,
528 "/controls/hydraulic/system[%d]/electric-pump", index);
529 fgTie(name, this, index,
530 &FGControls::get_electric_pump,
531 &FGControls::set_electric_pump);
532 fgSetArchivable(name);
536 fgTie("/controls/electric/battery-switch", this,
537 &FGControls::get_battery_switch,
538 &FGControls::set_battery_switch);
539 fgSetArchivable("/controls/electric/battery-switch");
541 fgTie("/controls/electric/external-power", this,
542 &FGControls::get_external_power,
543 &FGControls::set_external_power);
544 fgSetArchivable("/controls/electric/external-power");
546 fgTie("/controls/electric/APU-generator", this,
547 &FGControls::get_APU_generator,
548 &FGControls::set_APU_generator);
549 fgSetArchivable("/controls/electric/APU-generator");
551 for (index = 0; index < MAX_ENGINES; index++) {
552 char name[MAX_NAME_LEN];
553 snprintf(name, MAX_NAME_LEN,
554 "/controls/electric/engine[%d]/generator", index);
555 fgTie(name, this, index,
556 &FGControls::get_generator_breaker,
557 &FGControls::set_generator_breaker);
558 fgSetArchivable(name);
560 snprintf(name, MAX_NAME_LEN,
561 "/controls/electric/engine[%d]/bus-tie", index);
562 fgTie(name, this, index,
563 &FGControls::get_bus_tie,
564 &FGControls::set_bus_tie);
565 fgSetArchivable(name);
569 fgTie("/controls/pneumatic/APU-bleed", this,
570 &FGControls::get_APU_bleed,
571 &FGControls::set_APU_bleed);
572 fgSetArchivable("/controls/pneumatic/APU-bleed");
574 for (index = 0; index < MAX_ENGINES; index++) {
575 char name[MAX_NAME_LEN];
576 snprintf(name, MAX_NAME_LEN,
577 "/controls/pneumatic/engine[%d]/bleed", index);
578 fgTie(name, this, index,
579 &FGControls::get_engine_bleed,
580 &FGControls::set_engine_bleed);
581 fgSetArchivable(name);
585 fgTie("/controls/pressurization/mode", this,
586 &FGControls::get_mode, &FGControls::set_mode);
587 fgSetArchivable("/controls/pressurization/mode");
589 fgTie("/controls/pressurization/dump", this,
590 &FGControls::get_dump, &FGControls::set_dump);
591 fgSetArchivable("/controls/pressurization/dump");
593 fgTie("/controls/pressurization/outflow-valve", this,
594 &FGControls::get_outflow_valve,
595 &FGControls::set_outflow_valve);
596 fgSetArchivable("/controls/pressurization/outflow-valve");
598 for (index = 0; index < MAX_PACKS; index++) {
599 char name[MAX_NAME_LEN];
600 snprintf(name, MAX_NAME_LEN,
601 "/controls/pressurization/pack[%d]/pack-on", index);
602 fgTie(name, this, index,
603 &FGControls::get_pack_on, &FGControls::set_pack_on);
604 fgSetArchivable(name);
608 fgTie("/controls/lighting/landing-lights", this,
609 &FGControls::get_landing_lights,
610 &FGControls::set_landing_lights);
611 fgSetArchivable("/controls/lighting/landing-lights");
613 fgTie("/controls/lighting/turn-off-lights", this,
614 &FGControls::get_turn_off_lights,
615 &FGControls::set_turn_off_lights);
616 fgSetArchivable("/controls/lighting/turn-off-lights");
618 fgTie("/controls/lighting/taxi-light", this,
619 &FGControls::get_taxi_light, &FGControls::set_taxi_light);
620 fgSetArchivable("/controls/lighting/taxi-light");
622 fgTie("/controls/lighting/logo-lights", this,
623 &FGControls::get_logo_lights, &FGControls::set_logo_lights);
624 fgSetArchivable("/controls/lighting/logo-lights");
626 fgTie("/controls/lighting/nav-lights", this,
627 &FGControls::get_nav_lights, &FGControls::set_nav_lights);
628 fgSetArchivable("/controls/lighting/nav-lights");
630 fgTie("/controls/lighting/beacon", this,
631 &FGControls::get_beacon, &FGControls::set_beacon);
632 fgSetArchivable("/controls/lighting/beacon");
634 fgTie("/controls/lighting/strobe", this,
635 &FGControls::get_strobe, &FGControls::set_strobe);
636 fgSetArchivable("/controls/lighting/strobe");
638 fgTie("/controls/lighting/panel-norm", this,
639 &FGControls::get_panel_norm, &FGControls::set_panel_norm);
640 fgSetArchivable("/controls/lighting/panel-norm");
642 fgTie("/controls/lighting/instruments-norm", this,
643 &FGControls::get_instruments_norm,
644 &FGControls::set_instruments_norm);
645 fgSetArchivable("/controls/lighting/instruments-norm");
647 fgTie("/controls/lighting/dome-norm", this,
648 &FGControls::get_dome_norm, &FGControls::set_dome_norm);
649 fgSetArchivable("/controls/lighting/dome-norm");
651 #ifdef FG_HAVE_ARMAMENT
653 fgTie("/controls/armament/master-arm", this,
654 &FGControls::get_master_arm, &FGControls::set_master_arm);
655 fgSetArchivable("/controls/armament/master-arm");
657 fgTie("/controls/armament/station-select", this,
658 &FGControls::get_station_select,
659 &FGControls::set_station_select);
660 fgSetArchivable("/controls/armament/station-select");
662 fgTie("/controls/armament/release-all", this,
663 &FGControls::get_release_ALL,
664 &FGControls::set_release_ALL);
665 fgSetArchivable("/controls/armament/release-all");
667 for (index = 0; index < MAX_STATIONS; index++) {
668 char name[MAX_NAME_LEN];
669 snprintf(name, MAX_NAME_LEN,
670 "/controls/armament/station[%d]/stick-size", index);
671 fgTie(name, this, index,
672 &FGControls::get_stick_size, &FGControls::set_stick_size);
673 fgSetArchivable(name);
675 snprintf(name, MAX_NAME_LEN,
676 "/controls/armament/station[%d]/release-stick", index);
677 fgTie(name, this, index,
678 &FGControls::get_release_stick, &FGControls::set_release_stick);
679 fgSetArchivable(name);
681 snprintf(name, MAX_NAME_LEN,
682 "/controls/armament/station[%d]/release-all", index);
683 fgTie(name, this, index,
684 &FGControls::get_release_all, &FGControls::set_release_all);
685 fgSetArchivable(name);
687 snprintf(name, MAX_NAME_LEN,
688 "/controls/armament/station[%d]/jettison-all", index);
689 fgTie(name, this, index,
690 &FGControls::get_jettison_all, &FGControls::set_jettison_all);
691 fgSetArchivable(name);
697 fgTie("/controls/seat/vertical-adjust", this,
698 &FGControls::get_vertical_adjust,
699 &FGControls::set_vertical_adjust);
700 fgSetArchivable("/controls/seat/vertical-adjust");
702 fgTie("/controls/seat/fore-aft-adjust", this,
703 &FGControls::get_fore_aft_adjust,
704 &FGControls::set_fore_aft_adjust);
705 fgSetArchivable("/controls/seat/fore-aft-adjust");
707 for (index = 0; index < MAX_EJECTION_SEATS; index++) {
708 char name[MAX_NAME_LEN];
709 snprintf(name, MAX_NAME_LEN,
710 "/controls/seat/eject[%d]/initiate", index);
711 fgTie(name, this, index,
712 &FGControls::get_ejection_seat,
713 &FGControls::set_ejection_seat);
714 fgSetArchivable(name);
716 snprintf(name, MAX_NAME_LEN,
717 "/controls/seat/eject[%d]/status", index);
719 fgTie(name, this, index,
720 &FGControls::get_eseat_status,
721 &FGControls::set_eseat_status);
723 fgSetArchivable(name);
726 fgTie("/controls/seat/cmd_selector_valve", this,
727 &FGControls::get_cmd_selector_valve,
728 &FGControls::set_cmd_selector_valve);
729 fgSetArchivable("/controls/seat/eject/cmd_selector_valve");
733 fgTie("/controls/APU/off-start-run", this,
734 &FGControls::get_off_start_run,
735 &FGControls::set_off_start_run);
736 fgSetArchivable("/controls/APU/off-start-run");
738 fgTie("/controls/APU/fire-switch", this,
739 &FGControls::get_APU_fire_switch,
740 &FGControls::set_APU_fire_switch);
741 fgSetArchivable("/controls/APU/fire-switch");
744 for (index = 0; index < MAX_AUTOPILOTS; index++) {
745 char name[MAX_NAME_LEN];
746 snprintf(name, MAX_NAME_LEN,
747 "/controls/autoflight/autopilot[%d]/engage", index);
748 fgTie(name, this, index,
749 &FGControls::get_autopilot_engage,
750 &FGControls::set_autopilot_engage);
751 fgSetArchivable(name);
754 fgTie("/controls/autoflight/autothrottle-arm", this,
755 &FGControls::get_autothrottle_arm,
756 &FGControls::set_autothrottle_arm);
757 fgSetArchivable("/controls/autoflight/autothrottle-arm");
759 fgTie("/controls/autoflight/autothrottle-engage", this,
760 &FGControls::get_autothrottle_engage,
761 &FGControls::set_autothrottle_engage);
762 fgSetArchivable("/controls/autoflight/autothrottle-engage");
764 fgTie("/controls/autoflight/heading-select", this,
765 &FGControls::get_heading_select,
766 &FGControls::set_heading_select);
767 fgSetArchivable("/controls/autoflight/heading-select");
769 fgTie("/controls/autoflight/altitude-select", this,
770 &FGControls::get_altitude_select,
771 &FGControls::set_altitude_select);
772 fgSetArchivable("/controls/autoflight/altitude-select");
774 fgTie("/controls/autoflight/bank-angle-select", this,
775 &FGControls::get_bank_angle_select,
776 &FGControls::set_bank_angle_select);
777 fgSetArchivable("/controls/autoflight/bank-angle-select");
779 fgTie("/controls/autoflight/vertical-speed-select", this,
780 &FGControls::get_vertical_speed_select,
781 &FGControls::set_vertical_speed_select);
782 fgSetArchivable("/controls/autoflight/vertical-speed-select");
784 fgTie("/controls/autoflight/speed-select", this,
785 &FGControls::get_speed_select,
786 &FGControls::set_speed_select);
787 fgSetArchivable("/controls/autoflight/speed-select");
789 fgTie("/controls/autoflight/mach-select", this,
790 &FGControls::get_mach_select,
791 &FGControls::set_mach_select);
792 fgSetArchivable("/controls/autoflight/mach-select");
794 fgTie("/controls/autoflight/vertical-mode", this,
795 &FGControls::get_vertical_mode,
796 &FGControls::set_vertical_mode);
797 fgSetArchivable("/controls/autoflight/vertical-mode");
799 fgTie("/controls/autoflight/lateral-mode", this,
800 &FGControls::get_lateral_mode,
801 &FGControls::set_lateral_mode);
802 fgSetArchivable("/controls/autoflight/lateral-mode");
806 void FGControls::unbind ()
809 //Tie control properties.
810 fgUntie("/controls/flight/aileron");
811 fgUntie("/controls/flight/aileron-trim");
812 fgUntie("/controls/flight/elevator");
813 fgUntie("/controls/flight/elevator-trim");
814 fgUntie("/controls/flight/rudder");
815 fgUntie("/controls/flight/rudder-trim");
816 fgUntie("/controls/flight/flaps");
817 fgUntie("/controls/flight/slats");
818 fgUntie("/controls/flight/BLC");
819 fgUntie("/controls/flight/spoilers");
820 fgUntie("/controls/flight/speedbrake");
821 fgUntie("/controls/flight/wing-sweep");
822 fgUntie("/controls/flight/wing-fold");
823 fgUntie("/controls/flight/drag-chute");
824 for (index = 0; index < MAX_ENGINES; index++) {
825 char name[MAX_NAME_LEN];
826 snprintf(name, MAX_NAME_LEN,
827 "/controls/engines/engine[%d]/throttle", index);
829 snprintf(name, MAX_NAME_LEN,
830 "/controls/engines/engine[%d]/starter", index);
832 snprintf(name, MAX_NAME_LEN,
833 "/controls/engines/engine[%d]/fuel_pump", index);
835 snprintf(name, MAX_NAME_LEN,
836 "/controls/engines/engine[%d]/fire-switch", index);
838 snprintf(name, MAX_NAME_LEN,
839 "/controls/engines/engine[%d]/fire-bottle-discharge", index);
841 snprintf(name, MAX_NAME_LEN,
842 "/controls/engines/engine[%d]/throttle_idle", index);
844 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/cutoff", index);
846 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/mixture", index);
848 snprintf(name, MAX_NAME_LEN,
849 "/controls/engines/engine[%d]/propeller-pitch", index);
851 snprintf(name, MAX_NAME_LEN,
852 "/controls/engines/engine[%d]/magnetos", index);
854 snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/WEP", index);
856 snprintf(name, MAX_NAME_LEN,
857 "/controls/engines/engine[%d]/cowl-flaps-norm", index);
859 snprintf(name, MAX_NAME_LEN,
860 "/controls/engines/engine[%d]/propeller-feather", index);
862 snprintf(name, MAX_NAME_LEN,
863 "/controls/engines/engine[%d]/ignition", index);
865 snprintf(name, MAX_NAME_LEN,
866 "/controls/engines/engine[%d]/augmentation", index);
868 snprintf(name, MAX_NAME_LEN,
869 "/controls/engines/engine[%d]/reverser", index);
871 snprintf(name, MAX_NAME_LEN,
872 "/controls/engines/engine[%d]/water-injection", index);
874 snprintf(name, MAX_NAME_LEN,
875 "/controls/engines/engine[%d]/condition", index);
878 fgUntie("/controls/fuel/dump-valve");
879 for (index = 0; index < MAX_TANKS; index++) {
880 char name[MAX_NAME_LEN];
881 snprintf(name, MAX_NAME_LEN,
882 "/controls/fuel/tank[%d]/fuel_selector", index);
884 snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_engine", index);
886 snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_tank", index);
888 for (i = 0; index < MAX_BOOSTPUMPS; i++) {
889 snprintf(name, MAX_NAME_LEN,
890 "/controls/fuel/tank[%d]/boost-pump[%d]", index, i);
894 fgUntie("/controls/gear/brake-left");
895 fgUntie("/controls/gear/brake-right");
896 fgUntie("/controls/gear/brake-parking");
897 fgUntie("/controls/gear/steering");
898 fgUntie("/controls/gear/gear_down");
899 fgUntie("/controls/gear/antiskid");
900 fgUntie("/controls/gear/tailhook");
901 fgUntie("/controls/gear/tailwheel-lock");
902 for (index = 0; index < MAX_WHEELS; index++) {
903 char name[MAX_NAME_LEN];
904 snprintf(name, MAX_NAME_LEN,
905 "/controls/gear/wheel[%d]/alternate-extension", index);
908 fgUntie("/controls/anti-ice/wing-heat");
909 fgUntie("/controls/anti-ice/pitot-heat");
910 fgUntie("/controls/anti-ice/wiper");
911 fgUntie("/controls/anti-ice/window-heat");
912 for (index = 0; index < MAX_ENGINES; index++) {
913 char name[MAX_NAME_LEN];
914 snprintf(name, MAX_NAME_LEN,
915 "/controls/anti-ice/engine[%d]/carb-heat", index);
917 snprintf(name, MAX_NAME_LEN,
918 "/controls/anti-ice/engine[%d]/inlet-heat", index);
921 for (index = 0; index < MAX_HYD_SYSTEMS; index++) {
922 char name[MAX_NAME_LEN];
923 snprintf(name, MAX_NAME_LEN,
924 "/controls/hydraulic/system[%d]/engine-pump", index);
926 snprintf(name, MAX_NAME_LEN,
927 "/controls/hydraulic/system[%d]/electric-pump", index);
930 fgUntie("/controls/electric/battery-switch");
931 fgUntie("/controls/electric/external-power");
932 fgUntie("/controls/electric/APU-generator");
933 for (index = 0; index < MAX_ENGINES; index++) {
934 char name[MAX_NAME_LEN];
935 snprintf(name, MAX_NAME_LEN,
936 "/controls/electric/engine[%d]/generator", index);
938 snprintf(name, MAX_NAME_LEN,
939 "/controls/electric/engine[%d]/bus-tie", index);
942 fgUntie("/controls/pneumatic/APU-bleed");
943 for (index = 0; index < MAX_ENGINES; index++) {
944 char name[MAX_NAME_LEN];
945 snprintf(name, MAX_NAME_LEN,
946 "/controls/pneumatic/engine[%d]/bleed", index);
949 fgUntie("/controls/pressurization/mode");
950 fgUntie("/controls/pressurization/dump");
951 for (index = 0; index < MAX_PACKS; index++) {
952 char name[MAX_NAME_LEN];
953 snprintf(name, MAX_NAME_LEN,
954 "/controls/pressurization/pack[%d]/pack-on", index);
957 fgUntie("/controls/lighting/landing-lights");
958 fgUntie("/controls/lighting/turn-off-lights");
959 fgUntie("/controls/lighting/taxi-light");
960 fgUntie("/controls/lighting/logo-lights");
961 fgUntie("/controls/lighting/nav-lights");
962 fgUntie("/controls/lighting/beacon");
963 fgUntie("/controls/lighting/strobe");
964 fgUntie("/controls/lighting/panel-norm");
965 fgUntie("/controls/lighting/instruments-norm");
966 fgUntie("/controls/lighting/dome-norm");
968 #ifdef FG_HAVE_ARMAMENT
969 fgUntie("/controls/armament/master-arm");
970 fgUntie("/controls/armament/station-select");
971 fgUntie("/controls/armament/release-all");
972 for (index = 0; index < MAX_STATIONS; index++) {
973 char name[MAX_NAME_LEN];
974 snprintf(name, MAX_NAME_LEN,
975 "/controls/armament/station[%d]/stick-size", index);
977 snprintf(name, MAX_NAME_LEN,
978 "/controls/armament/station[%d]/release-stick", index);
980 snprintf(name, MAX_NAME_LEN,
981 "/controls/armament/station[%d]/release-all", index);
983 snprintf(name, MAX_NAME_LEN,
984 "/controls/armament/station[%d]/jettison-all", index);
988 fgUntie("/controls/seat/vertical-adjust");
989 fgUntie("/controls/seat/fore-aft-adjust");
990 for (index = 0; index < MAX_EJECTION_SEATS; index++) {
991 char name[MAX_NAME_LEN];
992 snprintf(name, MAX_NAME_LEN,
993 "/controls/seat/eject[%d]/initiate", index);
995 snprintf(name, MAX_NAME_LEN,
996 "/controls/seat/eject[%d]/status", index);
999 fgUntie("/controls/seat/cmd_selector_valve");
1001 fgUntie("/controls/APU/off-start-run");
1002 fgUntie("/controls/APU/fire-switch");
1003 for (index = 0; index < MAX_AUTOPILOTS; index++) {
1004 char name[MAX_NAME_LEN];
1005 snprintf(name, MAX_NAME_LEN,
1006 "/controls/autoflight/autopilot[%d]/engage", index);
1009 fgUntie("/controls/autoflight/autothrottle-arm");
1010 fgUntie("/controls/autoflight/autothrottle-engage");
1011 fgUntie("/controls/autoflight/heading-select");
1012 fgUntie("/controls/autoflight/altitude-select");
1013 fgUntie("/controls/autoflight/bank-angle-select");
1014 fgUntie("/controls/autoflight/vertical-speed-select");
1015 fgUntie("/controls/autoflight/speed-select");
1016 fgUntie("/controls/autoflight/mach-select");
1017 fgUntie("/controls/autoflight/vertical-mode");
1018 fgUntie("/controls/autoflight/lateral-mode");
1023 FGControls::update (double dt)
1029 ////////////////////////////////////////////////////////////////////////
1030 // Setters and adjusters.
1031 ////////////////////////////////////////////////////////////////////////
1034 FGControls::set_aileron (double pos)
1037 CLAMP( &aileron, -1.0, 1.0 );
1039 // check for autocoordination
1040 if ( auto_coordination->getBoolValue() ) {
1041 set_rudder( aileron / 2.0 );
1046 FGControls::move_aileron (double amt)
1049 CLAMP( &aileron, -1.0, 1.0 );
1051 // check for autocoordination
1052 if ( auto_coordination->getBoolValue() ) {
1053 set_rudder( aileron / 2.0 );
1058 FGControls::set_aileron_trim( double pos )
1061 CLAMP( &aileron_trim, -1.0, 1.0 );
1065 FGControls::move_aileron_trim( double amt )
1067 aileron_trim += amt;
1068 CLAMP( &aileron_trim, -1.0, 1.0 );
1072 FGControls::set_elevator( double pos )
1075 CLAMP( &elevator, -1.0, 1.0 );
1079 FGControls::move_elevator( double amt )
1082 CLAMP( &elevator, -1.0, 1.0 );
1086 FGControls::set_elevator_trim( double pos )
1088 elevator_trim = pos;
1089 CLAMP( &elevator_trim, -1.0, 1.0 );
1093 FGControls::move_elevator_trim( double amt )
1095 elevator_trim += amt;
1096 CLAMP( &elevator_trim, -1.0, 1.0 );
1100 FGControls::set_rudder( double pos )
1103 CLAMP( &rudder, -1.0, 1.0 );
1107 FGControls::move_rudder( double amt )
1110 CLAMP( &rudder, -1.0, 1.0 );
1114 FGControls::set_rudder_trim( double pos )
1117 CLAMP( &rudder_trim, -1.0, 1.0 );
1121 FGControls::move_rudder_trim( double amt )
1124 CLAMP( &rudder_trim, -1.0, 1.0 );
1128 FGControls::set_flaps( double pos )
1131 CLAMP( &flaps, 0.0, 1.0 );
1135 FGControls::move_flaps( double amt )
1138 CLAMP( &flaps, 0.0, 1.0 );
1142 FGControls::set_slats( double pos )
1145 CLAMP( &slats, 0.0, 1.0 );
1149 FGControls::move_slats( double amt )
1152 CLAMP( &slats, 0.0, 1.0 );
1156 FGControls::set_BLC( bool val )
1162 FGControls::set_spoilers( double pos )
1165 CLAMP( &spoilers, 0.0, 1.0 );
1169 FGControls::move_spoilers( double amt )
1172 CLAMP( &spoilers, 0.0, 1.0 );
1176 FGControls::set_speedbrake( double pos )
1179 CLAMP( &speedbrake, 0.0, 1.0 );
1183 FGControls::move_speedbrake( double amt )
1186 CLAMP( &speedbrake, 0.0, 1.0 );
1190 FGControls::set_wing_sweep( double pos )
1193 CLAMP( &wing_sweep, 0.0, 1.0 );
1197 FGControls::move_wing_sweep( double amt )
1200 CLAMP( &wing_sweep, 0.0, 1.0 );
1204 FGControls::set_wing_fold( bool val )
1210 FGControls::set_drag_chute( bool val )
1216 FGControls::set_throttle_idle( bool val )
1218 throttle_idle = val;
1222 FGControls::set_throttle( int engine, double pos )
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] = pos;
1232 CLAMP( &throttle[engine], 0.0, 1.0 );
1238 FGControls::move_throttle( int engine, double amt )
1240 if ( engine == ALL_ENGINES ) {
1241 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1243 CLAMP( &throttle[i], 0.0, 1.0 );
1246 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1247 throttle[engine] += amt;
1248 CLAMP( &throttle[engine], 0.0, 1.0 );
1254 FGControls::set_starter( int engine, bool flag )
1256 if ( engine == ALL_ENGINES ) {
1257 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1261 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1262 starter[engine] = flag;
1268 FGControls::set_fuel_pump( int engine, bool val )
1270 if ( engine == ALL_ENGINES ) {
1271 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1275 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1276 fuel_pump[engine] = val;
1282 FGControls::set_fire_switch( int engine, bool val )
1284 if ( engine == ALL_ENGINES ) {
1285 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1286 fire_switch[i] = val;
1289 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1290 fire_switch[engine] = val;
1296 FGControls::set_fire_bottle_discharge( int engine, bool val )
1298 if ( engine == ALL_ENGINES ) {
1299 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1300 fire_bottle_discharge[i] = val;
1303 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1304 fire_bottle_discharge[engine] = val;
1310 FGControls::set_cutoff( int engine, bool val )
1312 if ( engine == ALL_ENGINES ) {
1313 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1317 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1318 cutoff[engine] = val;
1325 FGControls::set_mixture( int engine, double pos )
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] = pos;
1335 CLAMP( &mixture[engine], 0.0, 1.0 );
1341 FGControls::move_mixture( int engine, double amt )
1343 if ( engine == ALL_ENGINES ) {
1344 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1346 CLAMP( &mixture[i], 0.0, 1.0 );
1349 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1350 mixture[engine] += amt;
1351 CLAMP( &mixture[engine], 0.0, 1.0 );
1357 FGControls::set_prop_advance( int engine, double pos )
1359 if ( engine == ALL_ENGINES ) {
1360 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1361 prop_advance[i] = pos;
1362 CLAMP( &prop_advance[i], 0.0, 1.0 );
1365 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1366 prop_advance[engine] = pos;
1367 CLAMP( &prop_advance[engine], 0.0, 1.0 );
1373 FGControls::move_prop_advance( int engine, double amt )
1375 if ( engine == ALL_ENGINES ) {
1376 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1377 prop_advance[i] += amt;
1378 CLAMP( &prop_advance[i], 0.0, 1.0 );
1381 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1382 prop_advance[engine] += amt;
1383 CLAMP( &prop_advance[engine], 0.0, 1.0 );
1389 FGControls::set_magnetos( int engine, int pos )
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] = pos;
1399 CLAMP( &magnetos[engine], 0, 3 );
1405 FGControls::move_magnetos( int engine, int amt )
1407 if ( engine == ALL_ENGINES ) {
1408 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1410 CLAMP( &magnetos[i], 0, 3 );
1413 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1414 magnetos[engine] += amt;
1415 CLAMP( &magnetos[engine], 0, 3 );
1421 FGControls::set_nitrous_injection( int engine, bool val )
1423 if ( engine == ALL_ENGINES ) {
1424 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1425 nitrous_injection[i] = val;
1428 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1429 nitrous_injection[engine] = val;
1436 FGControls::set_cowl_flaps_norm( int engine, double pos )
1438 if ( engine == ALL_ENGINES ) {
1439 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1440 cowl_flaps_norm[i] = pos;
1441 CLAMP( &cowl_flaps_norm[i], 0.0, 1.0 );
1444 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1445 cowl_flaps_norm[engine] = pos;
1446 CLAMP( &cowl_flaps_norm[engine], 0.0, 1.0 );
1452 FGControls::move_cowl_flaps_norm( int engine, double amt )
1454 if ( engine == ALL_ENGINES ) {
1455 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1456 cowl_flaps_norm[i] += amt;
1457 CLAMP( &cowl_flaps_norm[i], 0.0, 1.0 );
1460 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1461 cowl_flaps_norm[engine] += amt;
1462 CLAMP( &cowl_flaps_norm[engine], 0.0, 1.0 );
1468 FGControls::set_feather( int engine, bool val )
1470 if ( engine == ALL_ENGINES ) {
1471 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1475 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1476 feather[engine] = val;
1482 FGControls::set_ignition( int engine, int pos )
1484 if ( engine == ALL_ENGINES ) {
1485 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1487 CLAMP( &ignition[i], 0, 3 );
1490 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1491 ignition[engine] = pos;
1492 CLAMP( &ignition[engine], 0, 3 );
1498 FGControls::set_augmentation( int engine, bool val )
1500 if ( engine == ALL_ENGINES ) {
1501 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1502 augmentation[i] = val;
1505 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1506 augmentation[engine] = val;
1512 FGControls::set_reverser( int engine, bool val )
1514 if ( engine == ALL_ENGINES ) {
1515 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1519 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1520 reverser[engine] = val;
1526 FGControls::set_water_injection( int engine, bool val )
1528 if ( engine == ALL_ENGINES ) {
1529 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1530 water_injection[i] = val;
1533 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1534 water_injection[engine] = val;
1540 FGControls::set_condition( int engine, double val )
1542 if ( engine == ALL_ENGINES ) {
1543 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1547 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1548 condition[engine] = val;
1554 FGControls::set_dump_valve( bool val )
1561 FGControls::set_fuel_selector( int tank, bool pos )
1563 if ( tank == ALL_TANKS ) {
1564 for ( int i = 0; i < MAX_TANKS; i++ ) {
1565 fuel_selector[i] = pos;
1568 if ( (tank >= 0) && (tank < MAX_TANKS) ) {
1569 fuel_selector[tank] = pos;
1575 FGControls::set_to_engine( int tank, int engine )
1577 if ( tank == ALL_TANKS ) {
1578 for ( int i = 0; i < MAX_TANKS; i++ ) {
1579 to_engine[i] = engine;
1582 if ( (tank >= 0) && (tank < MAX_TANKS) ) {
1583 to_engine[tank] = engine;
1589 FGControls::set_to_tank( int tank, int dest_tank )
1591 if ( tank == ALL_TANKS ) {
1592 for ( int i = 0; i < MAX_TANKS; i++ ) {
1593 to_tank[i] = dest_tank;
1596 if ( (tank >= 0) && (tank < MAX_TANKS) ) {
1597 to_tank[tank] = dest_tank;
1603 FGControls::set_boost_pump( int index, bool val )
1605 if ( index == -1 ) {
1606 for ( int i = 0; i < (MAX_TANKS * MAX_BOOSTPUMPS); i++ ) {
1607 boost_pump[i] = val;
1610 if ( (index >= 0) && (index < (MAX_TANKS * MAX_BOOSTPUMPS)) ) {
1611 boost_pump[index] = val;
1618 FGControls::set_brake_left( double pos )
1621 CLAMP(&brake_left, 0.0, 1.0);
1625 FGControls::move_brake_left( double amt )
1628 CLAMP( &brake_left, 0.0, 1.0 );
1632 FGControls::set_brake_right( double pos )
1635 CLAMP(&brake_right, 0.0, 1.0);
1639 FGControls::move_brake_right( double amt )
1642 CLAMP( &brake_right, 0.0, 1.0 );
1646 FGControls::set_copilot_brake_left( double pos )
1648 copilot_brake_left = pos;
1649 CLAMP(&brake_left, 0.0, 1.0);
1653 FGControls::set_copilot_brake_right( double pos )
1655 copilot_brake_right = pos;
1656 CLAMP(&brake_right, 0.0, 1.0);
1660 FGControls::set_brake_parking( double pos )
1662 brake_parking = pos;
1663 CLAMP(&brake_parking, 0.0, 1.0);
1667 FGControls::set_steering( double angle )
1670 CLAMP(&steering, -80.0, 80.0);
1674 FGControls::move_steering( double angle )
1677 CLAMP(&steering, -80.0, 80.0);
1681 FGControls::set_gear_down( bool gear )
1687 FGControls::set_antiskid( bool state )
1693 FGControls::set_tailhook( bool state )
1699 FGControls::set_tailwheel_lock( bool state )
1701 tailwheel_lock = state;
1706 FGControls::set_alternate_extension( int wheel, bool val )
1708 if ( wheel == ALL_WHEELS ) {
1709 for ( int i = 0; i < MAX_WHEELS; i++ ) {
1710 alternate_extension[i] = val;
1713 if ( (wheel >= 0) && (wheel < MAX_WHEELS) ) {
1714 alternate_extension[wheel] = val;
1720 FGControls::set_wing_heat( bool state )
1726 FGControls::set_pitot_heat( bool state )
1732 FGControls::set_wiper( int state )
1738 FGControls::set_window_heat( bool state )
1740 window_heat = state;
1744 FGControls::set_carb_heat( int engine, bool val )
1746 if ( engine == ALL_ENGINES ) {
1747 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1751 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1752 carb_heat[engine] = val;
1758 FGControls::set_inlet_heat( int engine, bool val )
1760 if ( engine == ALL_ENGINES ) {
1761 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1762 inlet_heat[i] = val;
1765 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1766 inlet_heat[engine] = val;
1772 FGControls::set_engine_pump( int system, bool val )
1774 if ( system == ALL_HYD_SYSTEMS ) {
1775 for ( int i = 0; i < MAX_HYD_SYSTEMS; i++ ) {
1776 engine_pump[i] = val;
1779 if ( (system >= 0) && (system < MAX_HYD_SYSTEMS) ) {
1780 engine_pump[system] = val;
1786 FGControls::set_electric_pump( int system, bool val )
1788 if ( system == ALL_HYD_SYSTEMS ) {
1789 for ( int i = 0; i < MAX_HYD_SYSTEMS; i++ ) {
1790 electric_pump[i] = val;
1793 if ( (system >= 0) && (system < MAX_HYD_SYSTEMS) ) {
1794 electric_pump[system] = val;
1800 FGControls::set_battery_switch( bool state )
1802 battery_switch = state;
1806 FGControls::set_external_power( bool state )
1808 external_power = state;
1812 FGControls::set_APU_generator( bool state )
1814 APU_generator = state;
1818 FGControls::set_generator_breaker( int engine, bool val )
1820 if ( engine == ALL_ENGINES ) {
1821 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1822 generator_breaker[i] = val;
1825 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1826 generator_breaker[engine] = val;
1832 FGControls::set_bus_tie( int engine, bool val )
1834 if ( engine == ALL_ENGINES ) {
1835 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1839 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1840 bus_tie[engine] = val;
1846 FGControls::set_APU_bleed( bool state )
1852 FGControls::set_engine_bleed( int engine, bool val )
1854 if ( engine == ALL_ENGINES ) {
1855 for ( int i = 0; i < MAX_ENGINES; i++ ) {
1856 engine_bleed[i] = val;
1859 if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1860 engine_bleed[engine] = val;
1866 FGControls::set_mode( int new_mode )
1872 FGControls::set_outflow_valve( double pos )
1874 outflow_valve = pos;
1875 CLAMP( &outflow_valve, 0.0, 1.0 );
1879 FGControls::move_outflow_valve( double amt )
1881 outflow_valve += amt;
1882 CLAMP( &outflow_valve, 0.0, 1.0 );
1886 FGControls::set_dump( bool state )
1892 FGControls::set_pack_on( int pack, bool val )
1894 if ( pack == ALL_PACKS ) {
1895 for ( int i = 0; i < MAX_PACKS; i++ ) {
1899 if ( (pack >= 0) && (pack < MAX_PACKS) ) {
1900 pack_on[pack] = val;
1906 FGControls::set_landing_lights( bool state )
1908 landing_lights = state;
1912 FGControls::set_turn_off_lights( bool state )
1914 turn_off_lights = state;
1918 FGControls::set_taxi_light( bool state )
1924 FGControls::set_logo_lights( bool state )
1926 logo_lights = state;
1930 FGControls::set_nav_lights( bool state )
1936 FGControls::set_beacon( bool state )
1942 FGControls::set_strobe( bool state )
1948 FGControls::set_panel_norm( double intensity )
1950 panel_norm = intensity;
1951 CLAMP( &panel_norm, 0.0, 1.0 );
1955 FGControls::move_panel_norm( double amt )
1958 CLAMP( &panel_norm, 0.0, 1.0 );
1962 FGControls::set_instruments_norm( double intensity )
1964 instruments_norm = intensity;
1965 CLAMP( &instruments_norm, 0.0, 1.0 );
1969 FGControls::move_instruments_norm( double amt )
1971 instruments_norm += amt;
1972 CLAMP( &instruments_norm, 0.0, 1.0 );
1976 FGControls::set_dome_norm( double intensity )
1978 dome_norm = intensity;
1979 CLAMP( &dome_norm, 0.0, 1.0 );
1983 FGControls::move_dome_norm( double amt )
1986 CLAMP( &dome_norm, 0.0, 1.0 );
1989 #ifdef FG_HAVE_ARMAMENT
1992 FGControls::set_master_arm( bool val )
1998 FGControls::set_station_select( int station )
2000 station_select = station;
2001 CLAMP( &station_select, 0, MAX_STATIONS );
2005 FGControls::set_release_ALL( bool val )
2011 FGControls::set_stick_size( int station, int size )
2013 if ( station == ALL_STATIONS ) {
2014 for ( int i = 0; i < MAX_STATIONS; i++ ) {
2015 stick_size[i] = size;
2016 CLAMP( &stick_size[i], 1, 20 );
2019 if ( (station >= 0) && (station < MAX_STATIONS) ) {
2020 stick_size[station] = size;
2021 CLAMP( &stick_size[station], 1, 20 );
2027 FGControls::set_release_stick( int station, bool val )
2029 if ( station == ALL_STATIONS ) {
2030 for ( int i = 0; i < MAX_STATIONS; i++ ) {
2031 release_stick[i] = val;
2034 if ( (station >= 0) && (station < MAX_STATIONS) ) {
2035 release_stick[station] = val;
2041 FGControls::set_release_all( int station, bool val )
2043 if ( station == ALL_STATIONS ) {
2044 for ( int i = 0; i < MAX_STATIONS; i++ ) {
2045 release_all[i] = val;
2048 if ( (station >= 0) && (station < MAX_STATIONS) ) {
2049 release_all[station] = val;
2055 FGControls::set_jettison_all( int station, bool val )
2057 if ( station == ALL_STATIONS ) {
2058 for ( int i = 0; i < MAX_STATIONS; i++ ) {
2059 jettison_all[i] = val;
2062 if ( (station >= 0) && (station < MAX_STATIONS) ) {
2063 jettison_all[station] = val;
2071 FGControls::set_vertical_adjust( double pos )
2073 vertical_adjust = pos;
2074 CLAMP( &vertical_adjust, -1.0, 1.0 );
2078 FGControls::move_vertical_adjust( double amt )
2080 vertical_adjust += amt;
2081 CLAMP( &vertical_adjust, -1.0, 1.0 );
2085 FGControls::set_fore_aft_adjust( double pos )
2087 fore_aft_adjust = pos;
2088 CLAMP( &fore_aft_adjust, -1.0, 1.0 );
2092 FGControls::move_fore_aft_adjust( double amt )
2094 fore_aft_adjust += amt;
2095 CLAMP( &fore_aft_adjust, -1.0, 1.0 );
2099 FGControls::set_ejection_seat( int which_seat, bool val )
2101 if ( which_seat == ALL_EJECTION_SEATS ) {
2102 for ( int i = 0; i < MAX_EJECTION_SEATS; i++ ) {
2106 if ( (which_seat >= 0) && (which_seat <= MAX_EJECTION_SEATS) ) {
2107 if ( eseat_status[which_seat] == SEAT_SAFED ||
2108 eseat_status[which_seat] == SEAT_FAIL )
2110 // we can never eject if SEAT_SAFED or SEAT_FAIL
2114 eject[which_seat] = val;
2120 FGControls::set_eseat_status( int which_seat, int val )
2122 if ( which_seat == ALL_EJECTION_SEATS ) {
2123 for ( int i = 0; i < MAX_EJECTION_SEATS; i++ ) {
2124 eseat_status[i] = val;
2127 if ( (which_seat >=0) && (which_seat <= MAX_EJECTION_SEATS) ) {
2128 eseat_status[which_seat] = val;
2134 FGControls::set_cmd_selector_valve( int val )
2136 cmd_selector_valve = val;
2141 FGControls::set_off_start_run( int pos )
2143 off_start_run = pos;
2144 CLAMP( &off_start_run, 0, 3 );
2148 FGControls::set_APU_fire_switch( bool val )
2150 APU_fire_switch = val;
2154 FGControls::set_autothrottle_arm( bool val )
2156 autothrottle_arm = val;
2160 FGControls::set_autothrottle_engage( bool val )
2162 autothrottle_engage = val;
2166 FGControls::set_heading_select( double heading )
2168 heading_select = heading;
2169 CLAMP( &heading_select, 0.0, 360.0 );
2173 FGControls::move_heading_select( double amt )
2175 heading_select += amt;
2176 CLAMP( &heading_select, 0.0, 360.0 );
2180 FGControls::set_altitude_select( double altitude )
2182 altitude_select = altitude;
2183 CLAMP( &altitude_select, -1000.0, 100000.0 );
2187 FGControls::move_altitude_select( double amt )
2189 altitude_select += amt;
2190 CLAMP( &altitude_select, -1000.0, 100000.0 );
2194 FGControls::set_bank_angle_select( double angle )
2196 bank_angle_select = angle;
2197 CLAMP( &bank_angle_select, 10.0, 30.0 );
2201 FGControls::move_bank_angle_select( double amt )
2203 bank_angle_select += amt;
2204 CLAMP( &bank_angle_select, 10.0, 30.0 );
2208 FGControls::set_vertical_speed_select( double speed )
2210 vertical_speed_select = speed;
2211 CLAMP( &vertical_speed_select, -3000.0, 4000.0 );
2215 FGControls::move_vertical_speed_select( double amt )
2217 vertical_speed_select += amt;
2218 CLAMP( &vertical_speed_select, -3000.0, 4000.0 );
2222 FGControls::set_speed_select( double speed )
2224 speed_select = speed;
2225 CLAMP( &speed_select, 60.0, 400.0 );
2229 FGControls::move_speed_select( double amt )
2231 speed_select += amt;
2232 CLAMP( &speed_select, 60.0, 400.0 );
2236 FGControls::set_mach_select( double mach )
2239 CLAMP( &mach_select, 0.4, 4.0 );
2243 FGControls::move_mach_select( double amt )
2246 CLAMP( &mach_select, 0.4, 4.0 );
2250 FGControls::set_vertical_mode( int mode )
2252 vertical_mode = mode;
2253 CLAMP( &vertical_mode, 0, 4 );
2257 FGControls::set_lateral_mode( int mode )
2259 lateral_mode = mode;
2260 CLAMP( &lateral_mode, 0, 4 );
2264 FGControls::set_autopilot_engage( int ap, bool val )
2266 if ( ap == ALL_AUTOPILOTS ) {
2267 for ( int i = 0; i < MAX_AUTOPILOTS; i++ ) {
2268 autopilot_engage[i] = val;
2271 if ( (ap >= 0) && (ap < MAX_AUTOPILOTS) ) {
2272 autopilot_engage[ap] = val;