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/misc/props.hxx>
29 #include <Main/fgfs.hxx>
30 #include <Main/globals.hxx>
33 # error This library requires C++
37 // Define a structure containing the control parameters
39 class FGControls : public FGSubsystem
99 bool BLC; // Boundary Layer Control
109 // controls/engines/engine[n]/
110 double throttle[MAX_ENGINES];
111 bool starter[MAX_ENGINES];
112 bool fuel_pump[MAX_ENGINES];
113 bool fire_switch[MAX_ENGINES];
114 bool fire_bottle_discharge[MAX_ENGINES];
115 bool cutoff[MAX_ENGINES];
116 double mixture[MAX_ENGINES];
117 double prop_advance[MAX_ENGINES];
118 int magnetos[MAX_ENGINES];
119 bool nitrous_injection[MAX_ENGINES]; // War Emergency Power
120 double cowl_flaps_norm[MAX_ENGINES];
121 bool feather[MAX_ENGINES];
122 int ignition[MAX_ENGINES];
123 bool augmentation[MAX_ENGINES];
124 bool reverser[MAX_ENGINES];
125 bool water_injection[MAX_ENGINES];
126 int condition[MAX_ENGINES]; // turboprop speed select
131 // controls/fuel/tank[n]/
132 bool fuel_selector[MAX_TANKS];
133 int to_engine[MAX_TANKS];
134 int to_tank[MAX_TANKS];
136 // controls/fuel/tank[n]/pump[p]/
137 bool boost_pump[MAX_TANKS * MAX_BOOSTPUMPS];
140 double parking_brake;
147 // controls/gear/wheel[n]/
148 double brake[MAX_WHEELS];
149 bool alternate_extension[MAX_WHEELS];
151 // controls/anti-ice/
157 // controls/anti-ice/engine[n]/
158 bool carb_heat[MAX_ENGINES];
159 bool inlet_heat[MAX_ENGINES];
161 // controls/hydraulic/system[n]/
162 bool engine_pump[MAX_HYD_SYSTEMS];
163 bool electric_pump[MAX_HYD_SYSTEMS];
165 // controls/electric/
170 // controls/electric/engine[n]/
171 bool generator_breaker[MAX_ENGINES];
172 bool bus_tie[MAX_ENGINES];
174 // controls/pneumatic/
177 // controls/pneumatic/engine[n]/
178 bool engine_bleed[MAX_ENGINES];
180 // controls/pressurization/
183 double outflow_valve;
185 // controls/pressurization/pack[n]/
186 bool pack_on[MAX_PACKS];
188 // controls/lighting/
190 bool turn_off_lights;
197 double instruments_norm;
200 // controls/armament/
205 // controls/armament/station[n]/
206 int stick_size[MAX_STATIONS];
207 bool release_stick[MAX_STATIONS];
208 bool release_all[MAX_STATIONS];
209 bool jettison_all[MAX_STATIONS];
212 double vertical_adjust;
213 double fore_aft_adjust;
218 bool APU_fire_switch;
220 // controls/autoflight/autopilot[n]/
221 bool autopilot_engage[MAX_AUTOPILOTS];
223 // controls/autoflight/
224 bool autothrottle_arm;
225 bool autothrottle_engage;
226 double heading_select;
227 double altitude_select;
228 double bank_angle_select;
229 double vertical_speed_select;
236 SGPropertyNode * auto_coordination;
243 // Implementation of FGSubsystem.
247 void update (double dt);
250 void reset_all(void);
254 inline double get_aileron() const { return aileron; }
255 inline double get_aileron_trim() const { return aileron_trim; }
256 inline double get_elevator() const { return elevator; }
257 inline double get_elevator_trim() const { return elevator_trim; }
258 inline double get_rudder() const { return rudder; }
259 inline double get_rudder_trim() const { return rudder_trim; }
260 inline double get_flaps() const { return flaps; }
261 inline double get_slats() const { return slats; }
262 inline bool get_BLC() const { return BLC; }
263 inline double get_spoilers() const { return spoilers; }
264 inline double get_speedbrake() const { return speedbrake; }
265 inline double get_wing_sweep() const { return wing_sweep; }
266 inline bool get_wing_fold() const { return wing_fold; }
267 inline bool get_drag_chute() const { return drag_chute; }
270 inline bool get_throttle_idle() const { return throttle_idle; }
272 // controls/engines/engine[n]/
273 inline double get_throttle(int engine) const { return throttle[engine]; }
274 inline bool get_starter(int engine) const { return starter[engine]; }
275 inline bool get_fuel_pump(int engine) const { return fuel_pump[engine]; }
276 inline bool get_fire_switch(int engine) const { return fire_switch[engine]; }
277 inline bool get_fire_bottle_discharge(int engine) const {
278 return fire_bottle_discharge[engine];
280 inline bool get_cutoff(int engine) const { return cutoff[engine]; }
281 inline double get_mixture(int engine) const { return mixture[engine]; }
282 inline double get_prop_advance(int engine) const {
283 return prop_advance[engine];
285 inline int get_magnetos(int engine) const { return magnetos[engine]; }
286 inline bool get_nitrous_injection(int engine) const {
287 return nitrous_injection[engine];
289 inline double get_cowl_flaps_norm(int engine) const {
290 return cowl_flaps_norm[engine];
292 inline bool get_feather(int engine) const { return feather[engine]; }
293 inline int get_ignition(int engine) const { return ignition[engine]; }
294 inline bool get_augmentation(int engine) const { return augmentation[engine]; }
295 inline bool get_reverser(int engine) const { return reverser[engine]; }
296 inline bool get_water_injection(int engine) const {
297 return water_injection[engine];
299 inline int get_condition(int engine) const { return condition[engine]; }
302 inline bool get_dump_valve() const { return dump_valve; }
304 // controls/fuel/tank[n]/
305 inline bool get_fuel_selector(int tank) const {
306 return fuel_selector[tank];
308 inline int get_to_engine(int tank) const { return to_engine[tank]; }
309 inline int get_to_tank(int tank) const { return to_tank[tank]; }
311 // controls/fuel/tank[n]/pump[p]/
312 inline bool get_boost_pump(int index) const {
313 return boost_pump[index];
317 inline double get_parking_brake() const { return parking_brake; }
318 inline double get_steering() const { return steering; }
319 inline bool get_gear_down() const { return gear_down; }
320 inline bool get_antiskid() const { return antiskid; }
321 inline bool get_tailhook() const { return tailhook; }
322 inline bool get_tailwheel_lock() const { return tailwheel_lock; }
324 // controls/gear/wheel[n]/
325 inline double get_brake(int wheel) const { return brake[wheel]; }
326 inline bool get_alternate_extension(int wheel) const {
327 return alternate_extension[wheel];
330 // controls/anti-ice/
331 inline bool get_wing_heat() const { return wing_heat; }
332 inline bool get_pitot_heat() const { return pitot_heat; }
333 inline int get_wiper() const { return wiper; }
334 inline bool get_window_heat() const { return window_heat; }
336 // controls/anti-ice/engine[n]/
337 inline bool get_carb_heat(int engine) const { return carb_heat[engine]; }
338 inline bool get_inlet_heat(int engine) const { return inlet_heat[engine]; }
340 // controls/hydraulic/system[n]/
341 inline bool get_engine_pump(int system) const { return engine_pump[system]; }
342 inline bool get_electric_pump(int system) const { return electric_pump[system]; }
344 // controls/electric/
345 inline bool get_battery_switch() const { return battery_switch; }
346 inline bool get_external_power() const { return external_power; }
347 inline bool get_APU_generator() const { return APU_generator; }
349 // controls/electric/engine[n]/
350 inline bool get_generator_breaker(int engine) const {
351 return generator_breaker[engine];
353 inline bool get_bus_tie(int engine) const { return bus_tie[engine]; }
355 // controls/pneumatic/
356 inline bool get_APU_bleed() const { return APU_bleed; }
358 // controls/pneumatic/engine[n]/
359 inline bool get_engine_bleed(int engine) const { return engine_bleed[engine]; }
361 // controls/pressurization/
362 inline int get_mode() const { return mode; }
363 inline double get_outflow_valve() const { return outflow_valve; }
364 inline bool get_dump() const { return dump; }
366 // controls/pressurization/pack[n]/
367 inline bool get_pack_on(int pack) const { return pack_on[pack]; }
369 // controls/lighting/
370 inline bool get_landing_lights() const { return landing_lights; }
371 inline bool get_turn_off_lights() const { return turn_off_lights; }
372 inline bool get_taxi_light() const { return taxi_light; }
373 inline bool get_logo_lights() const { return logo_lights; }
374 inline bool get_nav_lights() const { return nav_lights; }
375 inline bool get_beacon() const { return beacon; }
376 inline bool get_strobe() const { return strobe; }
377 inline double get_panel_norm() const { return panel_norm; }
378 inline double get_instruments_norm() const { return instruments_norm; }
379 inline double get_dome_norm() const { return dome_norm; }
381 #ifdef FG_HAVE_ARMAMENT
382 // controls/armament/
383 inline bool get_master_arm() const { return master_arm; }
384 inline int get_station_select() const { return station_select; }
385 inline bool get_release_ALL() const { return release_ALL; }
387 // controls/armament/station[n]/
388 inline int get_stick_size(int station) const { return stick_size[station]; }
389 inline bool get_release_stick(int station) const { return release_stick[station]; }
390 inline bool get_release_all(int station) const { return release_all[station]; }
391 inline bool get_jettison_all(int station) const { return jettison_all[station]; }
395 inline double get_vertical_adjust() const { return vertical_adjust; }
396 inline double get_fore_aft_adjust() const { return fore_aft_adjust; }
397 inline bool get_eject() const { return eject; }
400 inline int get_off_start_run() const { return off_start_run; }
401 inline bool get_APU_fire_switch() const { return APU_fire_switch; }
403 // controls/autoflight/
404 inline bool get_autothrottle_arm() const { return autothrottle_arm; }
405 inline bool get_autothrottle_engage() const { return autothrottle_engage; }
406 inline double get_heading_select() const { return heading_select; }
407 inline double get_altitude_select() const { return altitude_select; }
408 inline double get_bank_angle_select() const { return bank_angle_select; }
409 inline double get_vertical_speed_select() const {
410 return vertical_speed_select;
412 inline double get_speed_select() const { return speed_select; }
413 inline double get_mach_select() const { return mach_select; }
414 inline int get_vertical_mode() const { return vertical_mode; }
415 inline int get_lateral_mode() const { return lateral_mode; }
417 // controls/autoflight/autopilot[n]/
418 inline bool get_autopilot_engage(int ap) const {
419 return autopilot_engage[ap];
425 void set_aileron( double pos );
426 void move_aileron( double amt );
427 void set_aileron_trim( double pos );
428 void move_aileron_trim( double amt );
429 void set_elevator( double pos );
430 void move_elevator( double amt );
431 void set_elevator_trim( double pos );
432 void move_elevator_trim( double amt );
433 void set_rudder( double pos );
434 void move_rudder( double amt );
435 void set_rudder_trim( double pos );
436 void move_rudder_trim( double amt );
437 void set_flaps( double pos );
438 void move_flaps( double amt );
439 void set_slats( double pos );
440 void move_slats( double amt );
441 void set_BLC( bool val );
442 void set_spoilers( double pos );
443 void move_spoilers( double amt );
444 void set_speedbrake( double pos );
445 void move_speedbrake( double amt );
446 void set_wing_sweep( double pos );
447 void move_wing_sweep( double amt );
448 void set_wing_fold( bool val );
449 void set_drag_chute( bool val );
452 void set_throttle_idle( bool val );
454 // controls/engines/engine[n]/
455 void set_throttle( int engine, double pos );
456 void move_throttle( int engine, double amt );
457 void set_starter( int engine, bool flag );
458 void set_fuel_pump( int engine, bool val );
459 void set_fire_switch( int engine, bool val );
460 void set_fire_bottle_discharge( int engine, bool val );
461 void set_cutoff( int engine, bool val );
462 void set_mixture( int engine, double pos );
463 void move_mixture( int engine, double amt );
464 void set_prop_advance( int engine, double pos );
465 void move_prop_advance( int engine, double amt );
466 void set_magnetos( int engine, int pos );
467 void move_magnetos( int engine, int amt );
468 void set_nitrous_injection( int engine, bool val );
469 void set_cowl_flaps_norm( int engine, double pos );
470 void move_cowl_flaps_norm( int engine, double amt );
471 void set_feather( int engine, bool val );
472 void set_ignition( int engine, int val );
473 void set_augmentation( int engine, bool val );
474 void set_reverser( int engine, bool val );
475 void set_water_injection( int engine, bool val );
476 void set_condition( int engine, int val );
479 void set_dump_valve( bool val );
481 // controls/fuel/tank[n]/
482 void set_fuel_selector( int tank, bool pos );
483 void set_to_engine( int tank, int engine );
484 void set_to_tank( int tank, int dest_tank );
486 // controls/fuel/tank[n]/pump[p]
487 void set_boost_pump( int index, bool val );
490 void set_parking_brake( double pos );
491 void set_steering( double pos );
492 void move_steering( double amt );
493 void set_gear_down( bool gear );
494 void set_antiskid( bool val );
495 void set_tailhook( bool val );
496 void set_tailwheel_lock( bool val );
498 // controls/gear/wheel[n]/
499 void set_brake( int wheel, double pos );
500 void move_brake( int wheel, double amt );
501 void set_alternate_extension( int wheel, bool val );
503 // controls/anti-ice/
504 void set_wing_heat( bool val );
505 void set_pitot_heat( bool val );
506 void set_wiper( int speed );
507 void set_window_heat( bool val );
509 // controls/anti-ice/engine[n]/
510 void set_carb_heat( int engine, bool val );
511 void set_inlet_heat( int engine, bool val );
513 // controls/hydraulic/system[n]/
514 void set_engine_pump( int system, bool val );
515 void set_electric_pump( int system, bool val );
517 // controls/electric/
518 void set_battery_switch( bool val );
519 void set_external_power( bool val );
520 void set_APU_generator( bool val );
522 // controls/electric/engine[n]/
523 void set_generator_breaker( int engine, bool val );
524 void set_bus_tie( int engine, bool val );
526 // controls/pneumatic/
527 void set_APU_bleed( bool val );
529 // controls/pneumatic/engine[n]/
530 void set_engine_bleed( int engine, bool val );
532 // controls/pressurization/
533 void set_mode( int mode );
534 void set_outflow_valve( double pos );
535 void move_outflow_valve( double amt );
536 void set_dump( bool val );
538 // controls/pressurization/pack[n]/
539 void set_pack_on( int pack, bool val );
541 // controls/lighting/
542 void set_landing_lights( bool val );
543 void set_turn_off_lights( bool val );
544 void set_taxi_light( bool val );
545 void set_logo_lights( bool val );
546 void set_nav_lights( bool val );
547 void set_beacon( bool val );
548 void set_strobe( bool val );
549 void set_panel_norm( double intensity );
550 void move_panel_norm( double amt );
551 void set_instruments_norm( double intensity );
552 void move_instruments_norm( double amt );
553 void set_dome_norm( double intensity );
554 void move_dome_norm( double amt );
556 #ifdef FG_HAVE_ARMAMENT
557 // controls/armament/
558 void set_master_arm( bool val );
559 void set_station_select( int station );
560 void set_release_ALL( bool val );
562 // controls/armament/station[n]/
563 void set_stick_size( int station, int size );
564 void set_release_stick( int station, bool val );
565 void set_release_all( int station, bool val );
566 void set_jettison_all( int station, bool val );
570 void set_vertical_adjust( double pos );
571 void move_vertical_adjust( double amt );
572 void set_fore_aft_adjust( double pos );
573 void move_fore_aft_adjust( double amt );
574 void set_eject( bool val );
577 void set_off_start_run( int pos );
578 void set_APU_fire_switch( bool val );
580 // controls/autoflight/
581 void set_autothrottle_arm( bool val );
582 void set_autothrottle_engage( bool val );
583 void set_heading_select( double heading );
584 void move_heading_select( double amt );
585 void set_altitude_select( double altitude );
586 void move_altitude_select( double amt );
587 void set_bank_angle_select( double angle );
588 void move_bank_angle_select( double amt );
589 void set_vertical_speed_select( double vs );
590 void move_vertical_speed_select( double amt );
591 void set_speed_select( double speed );
592 void move_speed_select( double amt );
593 void set_mach_select( double mach );
594 void move_mach_select( double amt );
595 void set_vertical_mode( int mode );
596 void set_lateral_mode( int mode );
598 // controls/autoflight/autopilot[n]/
599 void set_autopilot_engage( int ap, bool val );
604 #endif // _CONTROLS_HXX