forked from Aussiedroid/AD-EDWarthogEnhancedScript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAD_EDHardware_v4.3.0.tmh
168 lines (132 loc) · 12.2 KB
/
AD_EDHardware_v4.3.0.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
//--------------------------------------------------------------------------------------------------------------------------------------------------------------//
// HARDWARE: JOYSTICK AXIS CURVES //
//--------------------------------------------------------------------------------------------------------------------------------------------------------------//
// Up,MVR,DN
short JS_CURVE[] = {0, 1, 2}; // Set via the Autopilot Switch (UP is most aggresive, DOWN is least aggressive)
short JS_ZOOM[] = {0, 0,-1};
short YAW_CURVE[] = {0, 2, 3};
//--------------------------------------------------------------------------------------------------------------------------------------------------------------//
// HARDWARE: JOYSTICK AXIS MAPPINGS // // Define All Axis Curves/Trim/Deadzones for Device
//--------------------------------------------------------------------------------------------------------------------------------------------------------------//
// SET DEFAULT JOYSTICK AXIS //
int initSetJoystickCurves() { // Autopilot Select Switch position sets Joystick Curve Profile
profile = 1; // [APAH] // Three different presets are selectable On-The-Fly
if(Throttle[APPAT]) profile = 0;
if(Throttle[APALT]) profile = 2;
SetSCurve(&Joystick, JOYX, 0, JS_DEADZONE, 0, JS_CURVE[profile], JS_ZOOM[profile]);
SetSCurve(&Joystick, JOYY, 0, JS_DEADZONE, 0, JS_CURVE[profile], JS_ZOOM[profile]);
if(UseRuddersT16000 & UseRudderAxisCurves) SetSCurve(&TFRPRudder, TRUDDER, 0, TR_DEADZONE, 0, YAW_CURVE[profile], JS_ZOOM[profile]);
else if(UseRuddersTPR & UseRudderAxisCurves)SetSCurve(&TFRPHARudder, TFRPHA_RUDDER, 0, TR_DEADZONE, 0, YAW_CURVE[profile], JS_ZOOM[profile]);
if(!FAOFFToggle) {
if(UseRudderAxisCurves & VerboseOutput) printf("Joystick Profile[%d]: Yaw=%d, Curve=%d, Zoom=%d\x0a", profile, YAW_CURVE[profile], JS_CURVE[profile], JS_ZOOM[profile]);
else if(VerboseOutput) printf("Joystick Profile[%d]: Curve=%d, Zoom=%d\x0a", profile, JS_CURVE[profile], JS_ZOOM[profile]); } }
int initJoystickAxis() { // Set Default Joystick Axis
if(VerboseOutput) printf("Initialising Joystick Axis... ");
MapAxis(&Joystick, JOYX, DX_X_AXIS, AXIS_NORMAL, MAP_ABSOLUTE); // JOY-X Axis
SetSCurve(&Joystick, JOYX, 0, JS_DEADZONE, 0, 0, 0);
MapAxis(&Joystick, JOYY, DX_Y_AXIS, AXIS_NORMAL, MAP_ABSOLUTE); // JOY-Y Axis
SetSCurve(&Joystick, JOYY, 0, JS_DEADZONE, 0, 0, 0); }
//--------------------------------------------------------------------------------------------------------------------------------------------------------------//
// HARDWARE: THROTTLE AXIS MAPPINGS // // Define All Axis Curves/Trim/Deadzones for Device
//--------------------------------------------------------------------------------------------------------------------------------------------------------------//
// THROTTLE UTILITY FUNCTIONS //
int _trimThrottleAxes(int value) { // *TrimDXAxis(axis, +/-1024) trim is additive, SET forces trim value, CURRENT reads axis.pos
TrimDXAxis(DX_Z_AXIS, SET(value));
if(SyncLEFTTHRAxis) { TrimDXAxis(DX_ZROT_AXIS, SET(value)); } }
int _setThrottleSCurve(int lower=0, int center=0, int upper=0, int curve=0, float zoom=0) { // *SetSCurve(&Device, axis, left_deadzone%, center_deadzone%, right_deadzone%, curve(-20...20), scale)
SetSCurve(&Throttle, THR_RIGHT, lower, center, upper, curve, zoom);
if(SyncLEFTTHRAxis) { SetSCurve(&Throttle, THR_LEFT, lower, center, upper, curve, zoom); } }
int _setThrottleJCurve(float in, float out) { // *SetJCurve(&device, axis, physical axis value%, DirectX output value%)
SetJCurve(&Throttle, THR_RIGHT, in, out);
if(SyncLEFTTHRAxis) { SetJCurve(&Throttle, THR_LEFT, in, out); } }
int _setThrottleCustomCurve(int list) { // *SetCustomCurve(&device, axis name, LIST(Axis physical position 1, Axis output Value 1, Axis physical position 2, Axis output value 2, …)
SetCustomCurve(&Throttle, THR_RIGHT, list);
if(SyncLEFTTHRAxis) { SetCustomCurve(&Throttle, THR_LEFT, list); } }
// FLAP position sets Throttle Curve Profile
// MAP THROTTLE AXIS PRESETS // // Three different presets are selectable On-The-Fly
int _doThrottleFwdOnly() { // FWD ONLY : Initialising Throttle Forward Only Preset (SRV etc)
_trimThrottleAxes(-1024);
if(CruiseOnThrottle) { _setThrottleSCurve(0, -95, 0, 0); } // Trims Axis 5% when Supercruise On Throttle Active
else { _setThrottleSCurve(0, -100, 0, 0); }
if(VerboseOutput) printf("Throttle Profile: FORWARD ONLY [0 -> 100]\x0a");
SetThrottle(); }
int _doThrottleFwdNonLinear() { // FWD ONLY NL : Initialising Throttle Forward Only Non-Linear Preset (SRV etc)
_trimThrottleAxes(-1024); // <Unmapped by Default> (See User Preferences to Set)
_setThrottleCustomCurve(AxisCurveMod); // DX-SLIDER Non-Linear progression Curve
if(VerboseOutput) printf("Throttle Profile: NON-LINEAR FORWARD ONLY [0 ~> 100]\x0a");
SetThrottle(); }
int _doThrottleFullScale() { // FULL SCALE : Initialising Throttle Full Range & Make Throttle Linear (Default)
_trimThrottleAxes(0); // Initialising Throttle Full Scale Preset
if(CruiseOnThrottle) { _setThrottleSCurve(0, TFULL_DEADZONE, 5, 0); } // Trims Axis 5% when Supercruise On Throttle Active
else { _setThrottleSCurve(0, TFULL_DEADZONE, 0, 0); } // ..(Alternative= "_setThrottleJCurve(50, 50);")
if(VerboseOutput) printf("Throttle Profile: FULL SCALE [-100 -> 100]\x0a");
SetThrottle(); }
int _doThrottleFullNonLinear() { // FULL SCALE NL : Initialising Throttle Full Range & Make Throttle Non-Linear
_trimThrottleAxes(0); // <Unmapped by Default> (See User Preferences to Set)
_setThrottleCustomCurve(AxisCurveMod); // DX-SLIDER Non-Linear progression Curve
if(VerboseOutput) printf("Throttle Profile: NON-LINEAR [-100 ~> 100]\x0a");
SetThrottle(); }
int _doThrottleFullScaleCustom() { // FULL SCALE CUST : Initialising Throttle Full Range & Max Shorter @ 80% Preset (ALTERNATIVE)
_trimThrottleAxes(0); // Slightly Shorter Forward travel distance for my RSeat RS1 Cockpit setup. :)
_setThrottleJCurve(80, 100); // <Unmapped by Default> (See User Preferences to Set)
if(VerboseOutput) printf("Throttle Profile: FULL SCALE CUSTOM [-100 -> 80]\x0a");
SetThrottle(); }
int _doThrottleTrimmed() { // TRIMMED : Initialising Throttle Trimmed 25% @ Beginning/End Preset (ALTERNATIVE)
_trimThrottleAxes(0); // <Unmapped by Default> (See User Preferences to Set)
_setThrottleSCurve(-25, 0, -25, 0);
if(VerboseOutput) printf("Throttle Profile: TRIMMED [-75 -> 75]\x0a");
SetThrottle(); }
int _doThrottlePrecision() { // PRECISION : Initialising Throttle Precision Preset (Docking etc)
_trimThrottleAxes(0); // Allows Throttle Movement ONLY to the middle of blue zone
_setThrottleSCurve(0, 2, 0, 2, -2);
if(VerboseOutput) printf("Throttle Profile: PRECISION [-50 -> 50]\x0a");
SetThrottle(); }
// SET THROTTLE CURVES // // FLAP position sets Throttle Curve Profile
int initSetThrottleCurves() { // Three different presets are selectable On-The-Fly
mThrottleFwdOnly = EXEC("_doThrottleFwdOnly();"); // Initialising Throttle Forward Only Preset (SRV etc)
mThrottleFwdNonLinear = EXEC("_doThrottleFwdNonLinear();"); // Initialising Throttle Forward Only Non-Linear Preset (SRV etc)
mThrottleFullScale = EXEC("_doThrottleFullScale();"); // Initialising Throttle Full Range & Make Throttle Linear (Default)
mThrottleFullNonLinear = EXEC("_doThrottleFullNonLinear();"); // Initialising Throttle Full Range & Make Throttle Non-Linear
mThrottleFullScaleCustom = EXEC("_doThrottleFullScaleCustom();"); // Initialising Throttle Full Range & Max Shorter @ 80% Preset (ALTERNATIVE)
mThrottleTrimmed = EXEC("_doThrottleTrimmed();"); // Initialising Throttle Trimmed 25% @ Beginning/End Preset (ALTERNATIVE)
mThrottlePrecision = EXEC("_doThrottlePrecision();"); } // Initialising Throttle Precision Preset (Docking etc)
// SET DEFAULT THROTTLE AXIS //
int initThrottleAxis() { // Set Default Throttle Axis
if(VerboseOutput) printf("Initialising Throttle Axis..\x0a");
MapAxis(&Throttle, THR_RIGHT, DX_Z_AXIS, AXIS_NORMAL, MAP_ABSOLUTE); // Set Right Throttle
SetJCurve(&Throttle, THR_RIGHT, 50, 50);
if(VerboseOutput) printf("Setting ");
if(ThrottleOverride == 0) {
if (Throttle[FLAPU]) ActKey(KEYON+PULSE+ThrottlePresetUP); // Configure Throttle FLAP Switch Position on Script Run
else if (Throttle[FLAPM]) ActKey(KEYON+PULSE+ThrottlePresetMID);
else ActKey(KEYON+PULSE+ThrottlePresetDOWN); }
if(ThrottleOverride == 1) ActKey(KEYON+PULSE+ThrottlePresetDEF); // Configure Throttle Axis Default When FLAP Switch is Customised in User Preferences.
if(!DisableLEFTTHRAxis) {
MapAxis(&Throttle, THR_LEFT, DX_ZROT_AXIS, AXIS_NORMAL, MAP_ABSOLUTE); // Set Left Throttle
SetSCurve(&Throttle, THR_LEFT, 0, 0, 0, 0, 0); }
MapAxis(&Throttle, SCX, DX_XROT_AXIS, AXIS_NORMAL, MAP_ABSOLUTE); // Set Slew Control X Axis
SetSCurve(&Throttle, SCX, 0, SLEW_DEADZONE, 0, 2, -1);
MapAxis(&Throttle, SCY, DX_YROT_AXIS, AXIS_NORMAL, MAP_ABSOLUTE); // Set Slew Control Y Axis
SetSCurve(&Throttle, SCY, 0, SLEW_DEADZONE, 0, 2, -1);
MapAxis(&Throttle, THR_FC, DX_SLIDER_AXIS, AXIS_NORMAL, MAP_ABSOLUTE); // Set Friction Control Axis Curve (Sensor Range Zoom Scaling)
if(CustomDXSliderCurve == 0) SetSCurve(&Throttle, THR_FC, 0, 0, 0, 0, 0); // (DEFAULT)
if(CustomDXSliderCurve == 1) SetCustomCurve(&Throttle, THR_FC, AxisCurveMod); // (OPTIONAL OVERRIDE) (Linear Recommended in ED) *LIST(Axis physical position, Axis output Value)
if(VerboseOutput & JoystickOverride) printf("Setting Joystick Profile: Curve=%d, Zoom=%d\x0a", JS_CURVE[JoystickPresetDEF], JS_ZOOM[JoystickPresetDEF]); // NOTE: For print out positioning/order (On Startup), this Joystick Axis Preset output text is in the Throttle Axis Preset function.
if(VerboseOutput) printf("-----------------------------------------------------------------------------------------------------------------------------------------------\x0a"); }
int SetThrottle() { // Prevents Throttle jumping around on mode changes
DXAxis(DX_Z_AXIS, -AxisVal(Throttle[THR_RIGHT], &axdata));
if(!DisableLEFTTHRAxis & SyncLEFTTHRAxis) {
DXAxis(DX_ZROT_AXIS, -AxisVal(Throttle[THR_LEFT], &axdata)); } }
//--------------------------------------------------------------------------------------------------------------------------------------------------------------//
// HARDWARE: RUDDER AXIS MAPPINGS // // Define All Axis Curves/Trim/Deadzones for Device
//--------------------------------------------------------------------------------------------------------------------------------------------------------------//
// SET DEFAULT RUDDER AXES //
int initTFRPRudder() { // Initialise Thrustmaster TFRP (T.Flight T16000) Toe Pedal Axes (When enabled in AD_EDSettings)
SetSCurve(&TFRPRudder, TRUDDER, 0, TR_DEADZONE, 0, 0, 0); // Rudder Axis
SetSCurve(&TFRPRudder, TRPRIGHT, 0, TOE_DEADZONE, 0, 0, 0); // Right Toe Brake
SetSCurve(&TFRPRudder, TRPLEFT, 0, TOE_DEADZONE, 0, 0, 0); } // Left Toe Brake
int initTFRPHARudder() { // Initialise Thrustmaster TFRPHA (T.Flight TPR) Toe Pedal Axes (When enabled in AD_EDSettings)
SetSCurve(&TFRPHARudder, TFRPHA_RUDDER, 0, TR_DEADZONE, 0, 0, 0); // Rudder Axis
SetSCurve(&TFRPHARudder, TFRPHA_RIGHT, 0, TOE_DEADZONE, 0, 0, 0); // Right Toe Brake
SetSCurve(&TFRPHARudder, TFRPHA_LEFT, 0, TOE_DEADZONE, 0, 0, 0); } // Left Toe Brake
//--------------------------------------------------------------------------------------------------------------------------------------------------------------//