1 // controls.hxx -- 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.
27 #include <simgear/props/props.hxx>
28 #include <simgear/structure/subsystem_mgr.hxx>
30 #include <Main/globals.hxx>
33 # error This library requires C++
37 // Define a structure containing the control parameters
39 class FGControls : public SGSubsystem
90 ALL_EJECTION_SEATS = -1,
91 MAX_EJECTION_SEATS = 10
111 double elevator_trim;
116 bool BLC; // Boundary Layer Control
126 // controls/engines/engine[n]/
127 double throttle[MAX_ENGINES];
128 bool starter[MAX_ENGINES];
129 bool fuel_pump[MAX_ENGINES];
130 bool fire_switch[MAX_ENGINES];
131 bool fire_bottle_discharge[MAX_ENGINES];
132 bool cutoff[MAX_ENGINES];
133 double mixture[MAX_ENGINES];
134 double prop_advance[MAX_ENGINES];
135 int magnetos[MAX_ENGINES];
136 bool nitrous_injection[MAX_ENGINES]; // War Emergency Power
137 double cowl_flaps_norm[MAX_ENGINES];
138 bool feather[MAX_ENGINES];
139 int ignition[MAX_ENGINES];
140 bool augmentation[MAX_ENGINES];
141 bool reverser[MAX_ENGINES];
142 bool water_injection[MAX_ENGINES];
143 int condition[MAX_ENGINES]; // turboprop speed select
148 // controls/fuel/tank[n]/
149 bool fuel_selector[MAX_TANKS];
150 int to_engine[MAX_TANKS];
151 int to_tank[MAX_TANKS];
153 // controls/fuel/tank[n]/pump[p]/
154 bool boost_pump[MAX_TANKS * MAX_BOOSTPUMPS];
159 double brake_parking;
166 // controls/gear/wheel[n]/
167 bool alternate_extension[MAX_WHEELS];
169 // controls/anti-ice/
175 // controls/anti-ice/engine[n]/
176 bool carb_heat[MAX_ENGINES];
177 bool inlet_heat[MAX_ENGINES];
179 // controls/hydraulic/system[n]/
180 bool engine_pump[MAX_HYD_SYSTEMS];
181 bool electric_pump[MAX_HYD_SYSTEMS];
183 // controls/electric/
188 // controls/electric/engine[n]/
189 bool generator_breaker[MAX_ENGINES];
190 bool bus_tie[MAX_ENGINES];
192 // controls/pneumatic/
195 // controls/pneumatic/engine[n]/
196 bool engine_bleed[MAX_ENGINES];
198 // controls/pressurization/
201 double outflow_valve;
203 // controls/pressurization/pack[n]/
204 bool pack_on[MAX_PACKS];
206 // controls/lighting/
208 bool turn_off_lights;
215 double instruments_norm;
218 // controls/armament/
223 // controls/armament/station[n]/
224 int stick_size[MAX_STATIONS];
225 bool release_stick[MAX_STATIONS];
226 bool release_all[MAX_STATIONS];
227 bool jettison_all[MAX_STATIONS];
230 double vertical_adjust;
231 double fore_aft_adjust;
232 bool eject[MAX_EJECTION_SEATS];
233 int eseat_status[MAX_EJECTION_SEATS];
234 int cmd_selector_valve;
238 bool APU_fire_switch;
240 // controls/autoflight/autopilot[n]/
241 bool autopilot_engage[MAX_AUTOPILOTS];
243 // controls/autoflight/
244 bool autothrottle_arm;
245 bool autothrottle_engage;
246 double heading_select;
247 double altitude_select;
248 double bank_angle_select;
249 double vertical_speed_select;
256 SGPropertyNode * auto_coordination;
263 // Implementation of SGSubsystem.
267 void update (double dt);
270 void reset_all(void);
274 inline double get_aileron() const { return aileron; }
275 inline double get_aileron_trim() const { return aileron_trim; }
276 inline double get_elevator() const { return elevator; }
277 inline double get_elevator_trim() const { return elevator_trim; }
278 inline double get_rudder() const { return rudder; }
279 inline double get_rudder_trim() const { return rudder_trim; }
280 inline double get_flaps() const { return flaps; }
281 inline double get_slats() const { return slats; }
282 inline bool get_BLC() const { return BLC; }
283 inline double get_spoilers() const { return spoilers; }
284 inline double get_speedbrake() const { return speedbrake; }
285 inline double get_wing_sweep() const { return wing_sweep; }
286 inline bool get_wing_fold() const { return wing_fold; }
287 inline bool get_drag_chute() const { return drag_chute; }
290 inline bool get_throttle_idle() const { return throttle_idle; }
292 // controls/engines/engine[n]/
293 inline double get_throttle(int engine) const { return throttle[engine]; }
294 inline bool get_starter(int engine) const { return starter[engine]; }
295 inline bool get_fuel_pump(int engine) const { return fuel_pump[engine]; }
296 inline bool get_fire_switch(int engine) const { return fire_switch[engine]; }
297 inline bool get_fire_bottle_discharge(int engine) const {
298 return fire_bottle_discharge[engine];
300 inline bool get_cutoff(int engine) const { return cutoff[engine]; }
301 inline double get_mixture(int engine) const { return mixture[engine]; }
302 inline double get_prop_advance(int engine) const {
303 return prop_advance[engine];
305 inline int get_magnetos(int engine) const { return magnetos[engine]; }
306 inline bool get_nitrous_injection(int engine) const {
307 return nitrous_injection[engine];
309 inline double get_cowl_flaps_norm(int engine) const {
310 return cowl_flaps_norm[engine];
312 inline bool get_feather(int engine) const { return feather[engine]; }
313 inline int get_ignition(int engine) const { return ignition[engine]; }
314 inline bool get_augmentation(int engine) const { return augmentation[engine]; }
315 inline bool get_reverser(int engine) const { return reverser[engine]; }
316 inline bool get_water_injection(int engine) const {
317 return water_injection[engine];
319 inline int get_condition(int engine) const { return condition[engine]; }
322 inline bool get_dump_valve() const { return dump_valve; }
324 // controls/fuel/tank[n]/
325 inline bool get_fuel_selector(int tank) const {
326 return fuel_selector[tank];
328 inline int get_to_engine(int tank) const { return to_engine[tank]; }
329 inline int get_to_tank(int tank) const { return to_tank[tank]; }
331 // controls/fuel/tank[n]/pump[p]/
332 inline bool get_boost_pump(int index) const {
333 return boost_pump[index];
337 inline double get_brake_left() const { return brake_left; }
338 inline double get_brake_right() const { return brake_right; }
339 inline double get_brake_parking() const { return brake_parking; }
340 inline double get_steering() const { return steering; }
341 inline bool get_gear_down() const { return gear_down; }
342 inline bool get_antiskid() const { return antiskid; }
343 inline bool get_tailhook() const { return tailhook; }
344 inline bool get_tailwheel_lock() const { return tailwheel_lock; }
346 // controls/gear/wheel[n]/
347 inline bool get_alternate_extension(int wheel) const {
348 return alternate_extension[wheel];
351 // controls/anti-ice/
352 inline bool get_wing_heat() const { return wing_heat; }
353 inline bool get_pitot_heat() const { return pitot_heat; }
354 inline int get_wiper() const { return wiper; }
355 inline bool get_window_heat() const { return window_heat; }
357 // controls/anti-ice/engine[n]/
358 inline bool get_carb_heat(int engine) const { return carb_heat[engine]; }
359 inline bool get_inlet_heat(int engine) const { return inlet_heat[engine]; }
361 // controls/hydraulic/system[n]/
362 inline bool get_engine_pump(int system) const { return engine_pump[system]; }
363 inline bool get_electric_pump(int system) const { return electric_pump[system]; }
365 // controls/electric/
366 inline bool get_battery_switch() const { return battery_switch; }
367 inline bool get_external_power() const { return external_power; }
368 inline bool get_APU_generator() const { return APU_generator; }
370 // controls/electric/engine[n]/
371 inline bool get_generator_breaker(int engine) const {
372 return generator_breaker[engine];
374 inline bool get_bus_tie(int engine) const { return bus_tie[engine]; }
376 // controls/pneumatic/
377 inline bool get_APU_bleed() const { return APU_bleed; }
379 // controls/pneumatic/engine[n]/
380 inline bool get_engine_bleed(int engine) const { return engine_bleed[engine]; }
382 // controls/pressurization/
383 inline int get_mode() const { return mode; }
384 inline double get_outflow_valve() const { return outflow_valve; }
385 inline bool get_dump() const { return dump; }
387 // controls/pressurization/pack[n]/
388 inline bool get_pack_on(int pack) const { return pack_on[pack]; }
390 // controls/lighting/
391 inline bool get_landing_lights() const { return landing_lights; }
392 inline bool get_turn_off_lights() const { return turn_off_lights; }
393 inline bool get_taxi_light() const { return taxi_light; }
394 inline bool get_logo_lights() const { return logo_lights; }
395 inline bool get_nav_lights() const { return nav_lights; }
396 inline bool get_beacon() const { return beacon; }
397 inline bool get_strobe() const { return strobe; }
398 inline double get_panel_norm() const { return panel_norm; }
399 inline double get_instruments_norm() const { return instruments_norm; }
400 inline double get_dome_norm() const { return dome_norm; }
402 #ifdef FG_HAVE_ARMAMENT
403 // controls/armament/
404 inline bool get_master_arm() const { return master_arm; }
405 inline int get_station_select() const { return station_select; }
406 inline bool get_release_ALL() const { return release_ALL; }
408 // controls/armament/station[n]/
409 inline int get_stick_size(int station) const { return stick_size[station]; }
410 inline bool get_release_stick(int station) const { return release_stick[station]; }
411 inline bool get_release_all(int station) const { return release_all[station]; }
412 inline bool get_jettison_all(int station) const { return jettison_all[station]; }
416 inline double get_vertical_adjust() const { return vertical_adjust; }
417 inline double get_fore_aft_adjust() const { return fore_aft_adjust; }
418 inline bool get_ejection_seat( int which_seat ) const {
419 return eject[which_seat];
421 inline int get_eseat_status( int which_seat ) const {
422 return eseat_status[which_seat];
424 inline int get_cmd_selector_valve() const { return cmd_selector_valve; }
428 inline int get_off_start_run() const { return off_start_run; }
429 inline bool get_APU_fire_switch() const { return APU_fire_switch; }
431 // controls/autoflight/
432 inline bool get_autothrottle_arm() const { return autothrottle_arm; }
433 inline bool get_autothrottle_engage() const { return autothrottle_engage; }
434 inline double get_heading_select() const { return heading_select; }
435 inline double get_altitude_select() const { return altitude_select; }
436 inline double get_bank_angle_select() const { return bank_angle_select; }
437 inline double get_vertical_speed_select() const {
438 return vertical_speed_select;
440 inline double get_speed_select() const { return speed_select; }
441 inline double get_mach_select() const { return mach_select; }
442 inline int get_vertical_mode() const { return vertical_mode; }
443 inline int get_lateral_mode() const { return lateral_mode; }
445 // controls/autoflight/autopilot[n]/
446 inline bool get_autopilot_engage(int ap) const {
447 return autopilot_engage[ap];
453 void set_aileron( double pos );
454 void move_aileron( double amt );
455 void set_aileron_trim( double pos );
456 void move_aileron_trim( double amt );
457 void set_elevator( double pos );
458 void move_elevator( double amt );
459 void set_elevator_trim( double pos );
460 void move_elevator_trim( double amt );
461 void set_rudder( double pos );
462 void move_rudder( double amt );
463 void set_rudder_trim( double pos );
464 void move_rudder_trim( double amt );
465 void set_flaps( double pos );
466 void move_flaps( double amt );
467 void set_slats( double pos );
468 void move_slats( double amt );
469 void set_BLC( bool val );
470 void set_spoilers( double pos );
471 void move_spoilers( double amt );
472 void set_speedbrake( double pos );
473 void move_speedbrake( double amt );
474 void set_wing_sweep( double pos );
475 void move_wing_sweep( double amt );
476 void set_wing_fold( bool val );
477 void set_drag_chute( bool val );
480 void set_throttle_idle( bool val );
482 // controls/engines/engine[n]/
483 void set_throttle( int engine, double pos );
484 void move_throttle( int engine, double amt );
485 void set_starter( int engine, bool flag );
486 void set_fuel_pump( int engine, bool val );
487 void set_fire_switch( int engine, bool val );
488 void set_fire_bottle_discharge( int engine, bool val );
489 void set_cutoff( int engine, bool val );
490 void set_mixture( int engine, double pos );
491 void move_mixture( int engine, double amt );
492 void set_prop_advance( int engine, double pos );
493 void move_prop_advance( int engine, double amt );
494 void set_magnetos( int engine, int pos );
495 void move_magnetos( int engine, int amt );
496 void set_nitrous_injection( int engine, bool val );
497 void set_cowl_flaps_norm( int engine, double pos );
498 void move_cowl_flaps_norm( int engine, double amt );
499 void set_feather( int engine, bool val );
500 void set_ignition( int engine, int val );
501 void set_augmentation( int engine, bool val );
502 void set_reverser( int engine, bool val );
503 void set_water_injection( int engine, bool val );
504 void set_condition( int engine, int val );
507 void set_dump_valve( bool val );
509 // controls/fuel/tank[n]/
510 void set_fuel_selector( int tank, bool pos );
511 void set_to_engine( int tank, int engine );
512 void set_to_tank( int tank, int dest_tank );
514 // controls/fuel/tank[n]/pump[p]
515 void set_boost_pump( int index, bool val );
518 void set_brake_left( double pos );
519 void move_brake_left( double amt );
520 void set_brake_right( double pos );
521 void move_brake_right( double amt );
522 void set_brake_parking( double pos );
523 void set_steering( double pos );
524 void move_steering( double amt );
525 void set_gear_down( bool gear );
526 void set_antiskid( bool val );
527 void set_tailhook( bool val );
528 void set_tailwheel_lock( bool val );
530 // controls/gear/wheel[n]/
531 void set_alternate_extension( int wheel, bool val );
533 // controls/anti-ice/
534 void set_wing_heat( bool val );
535 void set_pitot_heat( bool val );
536 void set_wiper( int speed );
537 void set_window_heat( bool val );
539 // controls/anti-ice/engine[n]/
540 void set_carb_heat( int engine, bool val );
541 void set_inlet_heat( int engine, bool val );
543 // controls/hydraulic/system[n]/
544 void set_engine_pump( int system, bool val );
545 void set_electric_pump( int system, bool val );
547 // controls/electric/
548 void set_battery_switch( bool val );
549 void set_external_power( bool val );
550 void set_APU_generator( bool val );
552 // controls/electric/engine[n]/
553 void set_generator_breaker( int engine, bool val );
554 void set_bus_tie( int engine, bool val );
556 // controls/pneumatic/
557 void set_APU_bleed( bool val );
559 // controls/pneumatic/engine[n]/
560 void set_engine_bleed( int engine, bool val );
562 // controls/pressurization/
563 void set_mode( int mode );
564 void set_outflow_valve( double pos );
565 void move_outflow_valve( double amt );
566 void set_dump( bool val );
568 // controls/pressurization/pack[n]/
569 void set_pack_on( int pack, bool val );
571 // controls/lighting/
572 void set_landing_lights( bool val );
573 void set_turn_off_lights( bool val );
574 void set_taxi_light( bool val );
575 void set_logo_lights( bool val );
576 void set_nav_lights( bool val );
577 void set_beacon( bool val );
578 void set_strobe( bool val );
579 void set_panel_norm( double intensity );
580 void move_panel_norm( double amt );
581 void set_instruments_norm( double intensity );
582 void move_instruments_norm( double amt );
583 void set_dome_norm( double intensity );
584 void move_dome_norm( double amt );
586 #ifdef FG_HAVE_ARMAMENT
587 // controls/armament/
588 void set_master_arm( bool val );
589 void set_station_select( int station );
590 void set_release_ALL( bool val );
592 // controls/armament/station[n]/
593 void set_stick_size( int station, int size );
594 void set_release_stick( int station, bool val );
595 void set_release_all( int station, bool val );
596 void set_jettison_all( int station, bool val );
600 void set_vertical_adjust( double pos );
601 void move_vertical_adjust( double amt );
602 void set_fore_aft_adjust( double pos );
603 void move_fore_aft_adjust( double amt );
604 void set_ejection_seat( int which_seat, bool val );
605 void set_eseat_status( int which_seat, int val );
606 void set_cmd_selector_valve( int val );
609 void set_off_start_run( int pos );
610 void set_APU_fire_switch( bool val );
612 // controls/autoflight/
613 void set_autothrottle_arm( bool val );
614 void set_autothrottle_engage( bool val );
615 void set_heading_select( double heading );
616 void move_heading_select( double amt );
617 void set_altitude_select( double altitude );
618 void move_altitude_select( double amt );
619 void set_bank_angle_select( double angle );
620 void move_bank_angle_select( double amt );
621 void set_vertical_speed_select( double vs );
622 void move_vertical_speed_select( double amt );
623 void set_speed_select( double speed );
624 void move_speed_select( double amt );
625 void set_mach_select( double mach );
626 void move_mach_select( double amt );
627 void set_vertical_mode( int mode );
628 void set_lateral_mode( int mode );
630 // controls/autoflight/autopilot[n]/
631 void set_autopilot_engage( int ap, bool val );
636 #endif // _CONTROLS_HXX