This repository has been archived by the owner on May 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththrottle.tmh
244 lines (216 loc) · 7.84 KB
/
throttle.tmh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
/*
* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42mk1):
* <bastian@codename-php.de> wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a beer in return Bastian Schwarz.
*
* If you don't want to buy me a beer, consider buying one for Poul-Henning Kamp
* for creating this licence.
* ----------------------------------------------------------------------------
*/
/*
* This file contains all functions related to the throttle. The files are split so the main
* file doesn't get too long.
*/
/*
* Calls all functions needed to setup the throttle
*/
int initThrottle() {
initLEDs();
// throttle levers
setupThrottleAxis();
setupFlaps();
setupATC();
setupSlew();
setupCoolie();
setupMIC();
setupSpeedbrake();
setupBoat();
setupChinaHat();
// panel
setupEAC();
setupRDRALTIM();
setupAutopilot();
setupLGWarn();
setupAPU();
setupFrictionLever();
setupEngine();
setupFuelFlowLeft();
setupFuelFlowRight();
}
/*
* Initializes the LEDs by setting the backlight intensitiy to a sensible level and turning off all status LEDs so they can later be set to the desired state
* by various actions
*/
int initLEDs() {
ActKey(PULSE+KEYON+LED(&Throttle, LED_INTENSITY, 214)); //set Throttle backlight power to 5/6
ActKey(PULSE+KEYON+LED(&Throttle, LED_ONOFF, LED_CURRENT-LED0)); //set backlight OFF
ActKey(PULSE+KEYON+LED(&Throttle, LED_ONOFF, LED_CURRENT-LED1)); //set LED 1 OFF
ActKey(PULSE+KEYON+LED(&Throttle, LED_ONOFF, LED_CURRENT-LED2)); //set LED 2 OFF
ActKey(PULSE+KEYON+LED(&Throttle, LED_ONOFF, LED_CURRENT-LED3)); //set LED 3 OFF
ActKey(PULSE+KEYON+LED(&Throttle, LED_ONOFF, LED_CURRENT-LED4)); //set LED 4 OFF
ActKey(PULSE+KEYON+LED(&Throttle, LED_ONOFF, LED_CURRENT-LED5)); //set LED 5 OFF
}
/*
* Sets up the throttle axis along with the idle-off key events and LED states. LEDs are off when both throttles are in off position
*
*/
int setupThrottleAxis() {
MapAxis(&Throttle, THR_LEFT, DX_ZROT_AXIS);
MapAxis(&Throttle, THR_RIGHT, DX_Z_AXIS);
MapKey(&Throttle, IDLELON, CHAIN(THROTTLE_LEFT_OFF, D(), LED(&Throttle, LED_ONOFF, LED_CURRENT - LED0)));
MapKey(&Throttle, IDLERON, CHAIN(THROTTLE_RIGHT_OFF, D(), LED(&Throttle, LED_ONOFF, LED_CURRENT - LED0)));
MapKey(&Throttle, IDLELOFF, CHAIN(THROTTLE_LEFT_IDLE, D(), LED(&Throttle, LED_ONOFF, LED_CURRENT + LED0)));
MapKey(&Throttle, IDLEROFF, CHAIN(THROTTLE_RIGHT_IDLE, D(), LED(&Throttle, LED_ONOFF, LED_CURRENT + LED0)));
}
/*
* Sets up the flap switch and the LED3 state. The LED is on when the flaps are not in AUTO position. The LED
* is also shared with the speedbreake
*/
int setupFlaps() {
MapKey(&Throttle, FLAPU, CHAIN(FLAPS_AUTO, D(), PULSE + LED(&Throttle, LED_ONOFF, LED_CURRENT - LED3)));
MapKey(&Throttle, FLAPM, CHAIN(FLAPS_HALF, D(), PULSE + LED(&Throttle, LED_ONOFF, LED_CURRENT + LED3)));
MapKey(&Throttle, FLAPD, CHAIN(FLAPS_FULL, D(), PULSE + LED(&Throttle, LED_ONOFF, LED_CURRENT + LED3)));
}
/*
* Sets up the ATC Button (the red one on the throttle) for automatic throttle controll
*/
int setupATC() {
MapKey(&Throttle, LTB, ATC);
}
/*
* Sets up the slew (microstick) as the TDC with the click as depress
*
*/
int setupSlew() {
MapAxis(&Throttle, SCX, DX_XROT_AXIS, AXIS_NORMAL, MAP_ABSOLUTE);
MapAxis(&Throttle, SCY, DX_YROT_AXIS, AXIS_REVERSED, MAP_ABSOLUTE);
MapKey(&Throttle, SC, TDC_DEPRESS);
}
/*
* Sets up the coolie as rudder (since I still can't find my pedals)
*
* Left: Rudder Left
* Right: Rudder Right
* Up: Wheelbrakes
* Down: RAID-FLIR POV Select
*/
int setupCoolie() {
MapKey(&Throttle, CSL, RUDDER_LEFT);
MapKey(&Throttle, CSR, RUDDER_RIGHT);
MapKey(&Throttle, CSU, WHEELBRAKES);
MapKey(&Throttle, CSD, RAID_FLIR_POV);
}
/*
* Sets up the MIC switch (4 way hat with press) as comms
*
* Up: COMMS1
* Down: COMMS2
* FWD: MIDDS1
* AFT: MIDDS2
* Press: TBD
*/
int setupMIC() {
MapKey(&Throttle, MSU, COMMS1);
MapKey(&Throttle, MSD, COMMS2);
MapKey(&Throttle, MSR, MIDS_A);
MapKey(&Throttle, MSL, MIDS_B);
MapKey(&Throttle, MSP, 0);
}
/*
* Sets up the speedbreak and turns LED3 on when it's not in the middle position. The LED is also shared with the flaps.
*/
int setupSpeedbrake() {
MapKey(&Throttle, SPDB, CHAIN(SPEEDBRAKE_EXTEND, LED(&Throttle, LED_ONOFF, LED_CURRENT + LED3)));
MapKey(&Throttle, SPDM, CHAIN(SPEEDBRAKE_OFF, LED(&Throttle, LED_ONOFF ,LED_CURRENT - LED3)));
MapKey(&Throttle, SPDF, CHAIN(SPEEDBRAKE_RETRACT, LED(&Throttle, LED_ONOFF, LED_CURRENT + LED3)));
}
/*
* Sets up the boat switch as ... not sure yet
*/
int setupBoat() {
}
/*
* Sets up the china hat (the red 2 direction switch at the side of the throttle) for countermeasures(ALE-47)
*/
int setupChinaHat() {
MapKey(&Throttle, CHF, CMS_FOR);
MapKey(&Throttle, CHB, CMS_AFT);
}
/*
* Sets up the EAC switch on the instrument panel as gear lever. LED2 is on when the gear is down (down or OFF position)
*/
int setupEAC() {
MapKey(&Throttle, EACON, CHAIN(GEAR_UP, D(), PULSE + LED(&Throttle, LED_ONOFF, LED_CURRENT - LED2)));
MapKey(&Throttle, EACOFF, CHAIN(GEAR_DOWN, D(), PULSE + LED(&Throttle, LED_ONOFF, LED_CURRENT + LED2)));
}
/*
* Sets up the RDR ALTIM switch on the instrument panel as hook lever. LED4 is on when the hook is down (down or DIS position)
*/
int setupRDRALTIM() {
MapKey(&Throttle, RDRNRM, CHAIN(HOOK_UP, D(), PULSE + LED(&Throttle, LED_ONOFF, LED_CURRENT - LED4)));
MapKey(&Throttle, RDRDIS, CHAIN(HOOK_DOWN, D(), PULSE + LED(&Throttle, LED_ONOFF, LED_CURRENT + LED4)));
}
/*
* Sets up the Autopilot switch (bottom right on the throttle). The switch controls the countermeaser dispenser switch:
* - Up (PATH): Bypass
* - Middle (ALT HDG): On
* - Down (ALT): Off
*
* The engage-disengage button is the master caution reset
*/
int setupAutopilot() {
MapKey(&Throttle, APPAT, DISPENSER_BYPASS);
MapKey(&Throttle, APAH, DISPENSER_ON);
MapKey(&Throttle, APALT, DISPENSER_OFF);
MapKey(&Throttle, APENG, MASTER_CAUTION);
}
/*
* Sets up the landing gear warning as FCS RESET button
*/
int setupLGWarn() {
MapKey(&Throttle, LDGH, FCS_RESET);
}
/*
* Sets up the APU switch. The APU is bound to a DX button since DCS has a special action for this
*/
int setupAPU() {
MapKey(&Throttle, APUON, APU_ON_OFF);
}
/**
* Maps the friction lever to the DX slider as axis and sets an S cruve with a negative scale since the lever is way too sensitive otherwise
*/
int setupFrictionLever() {
MapAxis(&Throttle, THR_FC, DX_SLIDER_AXIS);
}
/*
* Sets up the engine operate switches. Putting them into the norm position switches on the battery (either of them), the
* ignition position is the engine crank.
*/
int setupEngine() {
MapKey(&Throttle, EORNORM, BATTERY_ON);
MapKey(&Throttle, EOLNORM, OBOGS_ON);
MapKey(&Throttle, EORMOTOR, BATTERY_OFF);
MapKey(&Throttle, EOLMOTOR, OBOGS_OFF);
MapKey(&Throttle, EORIGN, ENGINE_CRANK_CYCLE_RIGHT);
MapKey(&Throttle, EOLIGN, ENGINE_CRANK_CYCLE_LEFT);
}
/*
* Sets up the left enginge fuel flow switch as exterior lights switch coupled with the 5th LED.
* - Up (Norm): On (LED5 On)
* - Down (OVRRD): Off (LED5 Off)
*/
int setupFuelFlowLeft() {
MapKey(&Throttle, EFLNORM, CHAIN(EXT_LIGHTS_ON, D(), PULSE + LED(&Throttle, LED_ONOFF, LED_CURRENT + LED5)));
MapKey(&Throttle, EFLOVER, CHAIN(EXT_LIGHTS_OFF, D(), PULSE + LED(&Throttle, LED_ONOFF, LED_CURRENT - LED5)));
}
/*
* Sets up the right enginge fuel flow switch as master arm coupled with the 1st LED.
* - Up (Norm): Arm (LED1 Off)
* - Down (OVRRD): Safe (LED5 On)
*/
int setupFuelFlowRight() {
MapKey(&Throttle, EFRNORM, CHAIN(MASTER_ARM_ON, D(), PULSE + LED(&Throttle, LED_ONOFF, LED_CURRENT - LED1)));
MapKey(&Throttle, EFROVER, CHAIN(MASTER_ARM_OFF, D(), PULSE + LED(&Throttle, LED_ONOFF, LED_CURRENT + LED1)));
}