]> git.mxchange.org Git - flightgear.git/blob - src/Aircraft/controls.hxx
allow to trigger widgets via accelerator key, which is defined via "keynum"
[flightgear.git] / src / Aircraft / controls.hxx
1 // controls.hxx -- defines a standard interface to all flight sim controls
2 //
3 // Written by Curtis Olson, started May 1997.
4 //
5 // Copyright (C) 1997  Curtis L. Olson  - http://www.flightgear.org/~curt
6 //
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.
11 //
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.
16 //
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.
20 //
21 // $Id$
22
23
24 #ifndef _CONTROLS_HXX
25 #define _CONTROLS_HXX
26
27 #include <simgear/props/props.hxx>
28 #include <simgear/structure/subsystem_mgr.hxx>
29
30 #include <Main/globals.hxx>
31
32 #ifndef __cplusplus                                                          
33 # error This library requires C++
34 #endif                                   
35
36
37 // Define a structure containing the control parameters
38
39 class FGControls : public SGSubsystem
40 {
41
42 public:
43
44     enum {
45         ALL_ENGINES = -1,
46         MAX_ENGINES = 10
47     };
48
49     enum {
50         ALL_WHEELS = -1,
51         MAX_WHEELS = 3
52     };
53
54     enum {
55         ALL_TANKS = -1,
56         MAX_TANKS = 8
57     };
58
59     enum {
60         ALL_BOOSTPUMPS = -1,
61         MAX_BOOSTPUMPS = 2
62     };
63
64     enum {
65         ALL_HYD_SYSTEMS = -1,
66         MAX_HYD_SYSTEMS = 4
67     };
68
69     enum {
70         ALL_PACKS = -1,
71         MAX_PACKS = 4
72     };
73
74     enum {
75         ALL_LIGHTS = -1,
76         MAX_LIGHTS = 4
77     };
78
79     enum {
80         ALL_STATIONS = -1,
81         MAX_STATIONS = 12
82     };
83
84     enum {
85         ALL_AUTOPILOTS = -1,
86         MAX_AUTOPILOTS = 3
87     };
88
89     enum {
90         ALL_EJECTION_SEATS = -1,
91         MAX_EJECTION_SEATS = 10
92     };
93    
94     enum {
95         SEAT_SAFED = -1,
96         SEAT_ARMED = 0,
97         SEAT_FAIL = 1
98     };
99    
100     enum { 
101         CMD_SEL_NORM = -1,
102         CMD_SEL_AFT = 0,
103         CMD_SEL_SOLO = 1
104     };
105     
106 private:
107     // controls/flight/
108     double aileron;
109     double aileron_trim;
110     double elevator;
111     double elevator_trim;
112     double rudder;
113     double rudder_trim;
114     double flaps;
115     double slats;
116     bool BLC;          // Boundary Layer Control
117     double spoilers;
118     double speedbrake;
119     double wing_sweep;
120     bool wing_fold;
121     bool drag_chute;
122
123     // controls/engines/
124     bool throttle_idle;
125
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     double condition[MAX_ENGINES];           // turboprop speed select
144
145     // controls/fuel/
146     bool dump_valve;
147
148     // controls/fuel/tank[n]/
149     bool fuel_selector[MAX_TANKS];
150     int to_engine[MAX_TANKS];
151     int to_tank[MAX_TANKS];
152     
153     // controls/fuel/tank[n]/pump[p]/
154     bool boost_pump[MAX_TANKS * MAX_BOOSTPUMPS];
155
156     // controls/gear/
157     double brake_left;
158     double brake_right;
159     double copilot_brake_left;
160     double copilot_brake_right;
161     double brake_parking;
162     double steering;
163     bool gear_down;
164     bool antiskid;
165     bool tailhook;
166     bool launchbar;
167     bool catapult_launch_cmd;
168     bool tailwheel_lock;
169
170     // controls/gear/wheel[n]/
171     bool alternate_extension[MAX_WHEELS];
172
173     // controls/anti-ice/
174     bool wing_heat;
175     bool pitot_heat;
176     int wiper;
177     bool window_heat;
178
179     // controls/anti-ice/engine[n]/
180     bool carb_heat[MAX_ENGINES];
181     bool inlet_heat[MAX_ENGINES];
182     
183     // controls/hydraulic/system[n]/
184     bool engine_pump[MAX_HYD_SYSTEMS];
185     bool electric_pump[MAX_HYD_SYSTEMS];
186
187     // controls/electric/
188     bool battery_switch;
189     bool external_power;
190     bool APU_generator;
191
192     // controls/electric/engine[n]/
193     bool generator_breaker[MAX_ENGINES];
194     bool bus_tie[MAX_ENGINES];
195
196     // controls/pneumatic/
197     bool APU_bleed;
198
199     // controls/pneumatic/engine[n]/
200     bool engine_bleed[MAX_ENGINES];
201     
202     // controls/pressurization/
203     int mode;
204     bool dump;
205     double outflow_valve;
206
207     // controls/pressurization/pack[n]/
208     bool pack_on[MAX_PACKS];
209
210     // controls/lighting/
211     bool landing_lights;
212     bool turn_off_lights;
213     bool taxi_light;
214     bool logo_lights;
215     bool nav_lights;
216     bool beacon;
217     bool strobe;
218     double panel_norm;
219     double instruments_norm;
220     double dome_norm;
221
222     // controls/armament/
223     bool master_arm;
224     int station_select;
225     bool release_ALL;
226
227     // controls/armament/station[n]/
228     int stick_size[MAX_STATIONS];
229     bool release_stick[MAX_STATIONS];
230     bool release_all[MAX_STATIONS];
231     bool jettison_all[MAX_STATIONS];
232
233     // controls/seat/
234     double vertical_adjust;
235     double fore_aft_adjust;
236     bool eject[MAX_EJECTION_SEATS];
237     int eseat_status[MAX_EJECTION_SEATS];
238     int cmd_selector_valve;
239
240     // controls/APU/
241     int off_start_run;
242     bool APU_fire_switch;
243
244     // controls/autoflight/autopilot[n]/
245     bool autopilot_engage[MAX_AUTOPILOTS];
246
247     // controls/autoflight/
248     bool autothrottle_arm;
249     bool autothrottle_engage;
250     double heading_select;
251     double altitude_select;
252     double bank_angle_select;
253     double vertical_speed_select;
254     double speed_select;
255     double mach_select; 
256     int vertical_mode;
257     int lateral_mode;
258      
259
260     SGPropertyNode * auto_coordination;
261
262 public:
263
264     FGControls();
265     ~FGControls();
266
267     // Implementation of SGSubsystem.
268     void init ();
269     void bind ();
270     void unbind ();
271     void update (double dt);
272
273     // Reset function
274     void reset_all(void);
275         
276     // Query functions
277     // controls/flight/
278     inline double get_aileron() const { return aileron; }
279     inline double get_aileron_trim() const { return aileron_trim; }
280     inline double get_elevator() const { return elevator; }
281     inline double get_elevator_trim() const { return elevator_trim; }
282     inline double get_rudder() const { return rudder; }
283     inline double get_rudder_trim() const { return rudder_trim; }
284     inline double get_flaps() const { return flaps; }
285     inline double get_slats() const { return slats; }
286     inline bool get_BLC() const { return BLC; }  
287     inline double get_spoilers() const { return spoilers; }
288     inline double get_speedbrake() const { return speedbrake; }
289     inline double get_wing_sweep() const { return wing_sweep; }
290     inline bool get_wing_fold() const { return wing_fold; }
291     inline bool get_drag_chute() const { return drag_chute; }
292
293     // controls/engines/
294     inline bool get_throttle_idle() const { return throttle_idle; }
295
296     // controls/engines/engine[n]/
297     inline double get_throttle(int engine) const { return throttle[engine]; }
298     inline bool get_starter(int engine) const { return starter[engine]; }
299     inline bool get_fuel_pump(int engine) const { return fuel_pump[engine]; }
300     inline bool get_fire_switch(int engine) const { return fire_switch[engine]; }
301     inline bool get_fire_bottle_discharge(int engine) const {
302         return fire_bottle_discharge[engine];
303     }
304     inline bool get_cutoff(int engine) const { return cutoff[engine]; }
305     inline double get_mixture(int engine) const { return mixture[engine]; }
306     inline double get_prop_advance(int engine) const {
307         return prop_advance[engine];
308     }
309     inline int get_magnetos(int engine) const { return magnetos[engine]; }
310     inline bool get_nitrous_injection(int engine) const { 
311         return nitrous_injection[engine];
312     }
313     inline double get_cowl_flaps_norm(int engine) const {
314         return cowl_flaps_norm[engine];
315     }
316     inline bool get_feather(int engine) const { return feather[engine]; }
317     inline int get_ignition(int engine) const { return ignition[engine]; }
318     inline bool get_augmentation(int engine) const { return augmentation[engine]; }
319     inline bool get_reverser(int engine) const { return reverser[engine]; }
320     inline bool get_water_injection(int engine) const { 
321         return water_injection[engine]; 
322     }
323     inline double get_condition(int engine) const { return condition[engine]; }
324
325     // controls/fuel/
326     inline bool get_dump_valve() const { return dump_valve; }
327
328     // controls/fuel/tank[n]/
329     inline bool get_fuel_selector(int tank) const {
330         return fuel_selector[tank];
331     }
332     inline int get_to_engine(int tank) const { return to_engine[tank]; }
333     inline int get_to_tank(int tank) const { return to_tank[tank]; }
334
335     // controls/fuel/tank[n]/pump[p]/
336     inline bool get_boost_pump(int index) const {
337         return boost_pump[index];
338     }
339
340     // controls/gear/
341     inline double get_brake_left() const { return brake_left; }
342     inline double get_brake_right() const { return brake_right; }
343     inline double get_copilot_brake_left() const { return copilot_brake_left; }
344     inline double get_copilot_brake_right() const { return copilot_brake_right; }
345     inline double get_brake_parking() const { return brake_parking; }
346     inline double get_steering() const { return steering; }
347     inline bool get_gear_down() const { return gear_down; }
348     inline bool get_antiskid() const { return antiskid; }
349     inline bool get_tailhook() const { return tailhook; }
350     inline bool get_launchbar() const { return launchbar; }
351     inline bool get_catapult_launch_cmd() const { return catapult_launch_cmd; }
352     inline bool get_tailwheel_lock() const { return tailwheel_lock; }
353
354     // controls/gear/wheel[n]/
355     inline bool get_alternate_extension(int wheel) const {
356         return alternate_extension[wheel];
357     }
358
359     // controls/anti-ice/
360     inline bool get_wing_heat() const { return wing_heat; }
361     inline bool get_pitot_heat() const { return pitot_heat; }
362     inline int get_wiper() const { return wiper; }
363     inline bool get_window_heat() const { return window_heat; }
364
365     // controls/anti-ice/engine[n]/
366     inline bool get_carb_heat(int engine) const { return carb_heat[engine]; }
367     inline bool get_inlet_heat(int engine) const { return inlet_heat[engine]; }
368
369     // controls/hydraulic/system[n]/
370     inline bool get_engine_pump(int system) const { return engine_pump[system]; }
371     inline bool get_electric_pump(int system) const { return electric_pump[system]; }
372
373     // controls/electric/
374     inline bool get_battery_switch() const { return battery_switch; }
375     inline bool get_external_power() const { return external_power; }
376     inline bool get_APU_generator() const { return APU_generator; }
377
378     // controls/electric/engine[n]/
379     inline bool get_generator_breaker(int engine) const { 
380         return generator_breaker[engine];
381     }
382     inline bool get_bus_tie(int engine) const { return bus_tie[engine]; }
383
384     // controls/pneumatic/
385     inline bool get_APU_bleed() const { return APU_bleed; }
386
387     // controls/pneumatic/engine[n]/
388     inline bool get_engine_bleed(int engine) const { return engine_bleed[engine]; }
389     
390     // controls/pressurization/
391     inline int get_mode() const { return mode; }
392     inline double get_outflow_valve() const { return outflow_valve; }
393     inline bool get_dump() const { return dump; }
394
395     // controls/pressurization/pack[n]/
396     inline bool get_pack_on(int pack) const { return pack_on[pack]; }
397
398     // controls/lighting/
399     inline bool get_landing_lights() const { return landing_lights; }
400     inline bool get_turn_off_lights() const { return  turn_off_lights; }
401     inline bool get_taxi_light() const { return taxi_light; }
402     inline bool get_logo_lights() const { return logo_lights; }
403     inline bool get_nav_lights() const { return nav_lights; }
404     inline bool get_beacon() const { return beacon; }
405     inline bool get_strobe() const { return strobe; }
406     inline double get_panel_norm() const { return panel_norm; }
407     inline double get_instruments_norm() const { return instruments_norm; }
408     inline double get_dome_norm() const { return dome_norm; }
409
410     // controls/armament/
411     inline bool get_master_arm() const { return master_arm; }
412     inline int get_station_select() const { return station_select; }
413     inline bool get_release_ALL() const { return release_ALL; }
414
415       // controls/armament/station[n]/
416     inline int get_stick_size(int station) const { return stick_size[station]; }
417     inline bool get_release_stick(int station) const { return release_stick[station]; }
418     inline bool get_release_all(int station) const { return release_all[station]; }
419     inline bool get_jettison_all(int station) const { return jettison_all[station]; }
420
421     // controls/seat/
422     inline double get_vertical_adjust() const { return vertical_adjust; }
423     inline double get_fore_aft_adjust() const { return fore_aft_adjust; }
424     inline bool get_ejection_seat( int which_seat ) const {
425         return eject[which_seat];
426     }
427     inline int get_eseat_status( int which_seat ) const {
428         return eseat_status[which_seat];
429     }
430     inline int get_cmd_selector_valve() const { return cmd_selector_valve; }
431     
432
433     // controls/APU/
434     inline int get_off_start_run() const { return off_start_run; }
435     inline bool get_APU_fire_switch() const { return APU_fire_switch; }
436
437     // controls/autoflight/
438     inline bool get_autothrottle_arm() const { return autothrottle_arm; }
439     inline bool get_autothrottle_engage() const { return autothrottle_engage; }
440     inline double get_heading_select() const { return heading_select; }
441     inline double get_altitude_select() const { return altitude_select; }
442     inline double get_bank_angle_select() const { return bank_angle_select; }
443     inline double get_vertical_speed_select() const { 
444         return vertical_speed_select; 
445     }
446     inline double get_speed_select() const { return speed_select; }
447     inline double get_mach_select() const { return mach_select; } 
448     inline int get_vertical_mode() const { return vertical_mode; }
449     inline int get_lateral_mode() const { return lateral_mode; }
450
451     // controls/autoflight/autopilot[n]/
452     inline bool get_autopilot_engage(int ap) const { 
453         return autopilot_engage[ap];
454     }
455      
456
457     // Update functions
458     // controls/flight/
459     void set_aileron( double pos );
460     void move_aileron( double amt );
461     void set_aileron_trim( double pos );
462     void move_aileron_trim( double amt );
463     void set_elevator( double pos );
464     void move_elevator( double amt );
465     void set_elevator_trim( double pos );
466     void move_elevator_trim( double amt );
467     void set_rudder( double pos );
468     void move_rudder( double amt );
469     void set_rudder_trim( double pos );
470     void move_rudder_trim( double amt );
471     void set_flaps( double pos );
472     void move_flaps( double amt );
473     void set_slats( double pos );
474     void move_slats( double amt );
475     void set_BLC( bool val ); 
476     void set_spoilers( double pos );
477     void move_spoilers( double amt );
478     void set_speedbrake( double pos );
479     void move_speedbrake( double amt );
480     void set_wing_sweep( double pos );
481     void move_wing_sweep( double amt );
482     void set_wing_fold( bool val );   
483     void set_drag_chute( bool val );
484
485     // controls/engines/
486     void set_throttle_idle( bool val );
487
488     // controls/engines/engine[n]/
489     void set_throttle( int engine, double pos );
490     void move_throttle( int engine, double amt );
491     void set_starter( int engine, bool flag );
492     void set_fuel_pump( int engine, bool val );
493     void set_fire_switch( int engine, bool val );
494     void set_fire_bottle_discharge( int engine, bool val );
495     void set_cutoff( int engine, bool val );
496     void set_mixture( int engine, double pos );
497     void move_mixture( int engine, double amt );
498     void set_prop_advance( int engine, double pos );
499     void move_prop_advance( int engine, double amt );
500     void set_magnetos( int engine, int pos );
501     void move_magnetos( int engine, int amt );
502     void set_nitrous_injection( int engine, bool val );
503     void set_cowl_flaps_norm( int engine, double pos );
504     void move_cowl_flaps_norm( int engine, double amt );
505     void set_feather( int engine, bool val );
506     void set_ignition( int engine, int val );
507     void set_augmentation( int engine, bool val );
508     void set_reverser( int engine, bool val );
509     void set_water_injection( int engine, bool val );
510     void set_condition( int engine, double val );    
511
512     // controls/fuel
513     void set_dump_valve( bool val );
514
515     // controls/fuel/tank[n]/
516     void set_fuel_selector( int tank, bool pos );
517     void set_to_engine( int tank, int engine );
518     void set_to_tank( int tank, int dest_tank );
519
520     // controls/fuel/tank[n]/pump[p]
521     void set_boost_pump( int index, bool val );
522
523     // controls/gear/
524     void set_brake_left( double pos );
525     void move_brake_left( double amt );
526     void set_brake_right( double pos );
527     void move_brake_right( double amt );
528     void set_copilot_brake_left( double pos );
529     void set_copilot_brake_right( double pos );
530     void set_brake_parking( double pos );
531     void set_steering( double pos );
532     void move_steering( double amt );
533     void set_gear_down( bool gear );
534     void set_antiskid( bool val );
535     void set_tailhook( bool val );
536     void set_launchbar( bool val );
537     void set_catapult_launch_cmd( bool val );
538     void set_tailwheel_lock( bool val );
539
540     // controls/gear/wheel[n]/
541     void set_alternate_extension( int wheel, bool val );
542
543     // controls/anti-ice/
544     void set_wing_heat( bool val );
545     void set_pitot_heat( bool val );
546     void set_wiper( int speed );
547     void set_window_heat( bool val );
548
549     // controls/anti-ice/engine[n]/
550     void set_carb_heat( int engine, bool val );
551     void set_inlet_heat( int engine, bool val );
552
553     // controls/hydraulic/system[n]/
554     void set_engine_pump( int system, bool val );
555     void set_electric_pump( int system, bool val );
556
557     // controls/electric/
558     void set_battery_switch( bool val );
559     void set_external_power( bool val );
560     void set_APU_generator( bool val );
561
562     // controls/electric/engine[n]/
563     void set_generator_breaker( int engine, bool val );
564     void set_bus_tie( int engine, bool val );
565
566     // controls/pneumatic/
567     void set_APU_bleed( bool val );
568
569     // controls/pneumatic/engine[n]/
570     void set_engine_bleed( int engine, bool val );
571     
572     // controls/pressurization/
573     void set_mode( int mode );
574     void set_outflow_valve( double pos );
575     void move_outflow_valve( double amt );
576     void set_dump( bool val );
577
578     // controls/pressurization/pack[n]/
579     void set_pack_on( int pack, bool val );
580
581     // controls/lighting/
582     void set_landing_lights( bool val );
583     void set_turn_off_lights( bool val );
584     void set_taxi_light( bool val );
585     void set_logo_lights( bool val );
586     void set_nav_lights( bool val );
587     void set_beacon( bool val );
588     void set_strobe( bool val );
589     void set_panel_norm( double intensity );
590     void move_panel_norm( double amt );
591     void set_instruments_norm( double intensity );
592     void move_instruments_norm( double amt );
593     void set_dome_norm( double intensity );
594     void move_dome_norm( double amt );
595
596     // controls/armament/
597     void set_master_arm( bool val );
598     void set_station_select( int station );
599     void set_release_ALL( bool val );
600
601     // controls/armament/station[n]/
602     void set_stick_size( int station, int size );
603     void set_release_stick( int station, bool val );
604     void set_release_all( int station, bool val );
605     void set_jettison_all( int station, bool val );
606
607     // controls/seat/
608     void set_vertical_adjust( double pos );
609     void move_vertical_adjust( double amt );
610     void set_fore_aft_adjust( double pos );
611     void move_fore_aft_adjust( double amt );
612     void set_ejection_seat( int which_seat, bool val );
613     void set_eseat_status( int which_seat, int val );
614     void set_cmd_selector_valve( int val );
615
616     // controls/APU/
617     void set_off_start_run( int pos );
618     void set_APU_fire_switch( bool val );
619
620     // controls/autoflight/
621     void set_autothrottle_arm( bool val );
622     void set_autothrottle_engage( bool val );
623     void set_heading_select( double heading );
624     void move_heading_select( double amt );
625     void set_altitude_select( double altitude );
626     void move_altitude_select( double amt );
627     void set_bank_angle_select( double angle );
628     void move_bank_angle_select( double amt );
629     void set_vertical_speed_select( double vs );
630     void move_vertical_speed_select( double amt );
631     void set_speed_select( double speed );
632     void move_speed_select( double amt );
633     void set_mach_select( double mach ); 
634     void move_mach_select( double amt ); 
635     void set_vertical_mode( int mode );
636     void set_lateral_mode( int mode );
637
638     // controls/autoflight/autopilot[n]/
639     void set_autopilot_engage( int ap, bool val );
640
641 };
642
643
644 #endif // _CONTROLS_HXX
645
646