Thrustmaster HOTAS Warthog Key Mapping - Potential T.A.R.G.E.T Script.
Here is a potential script that implements the mappings defined in the table above. I am hoping that it might help further.
include “target.tmh”
int main()
{
if(Init(&EventHandle)) return 1; // declare the event handler, return on error
Copy code
// Joystick mappings
MapKey(&Joystick, TG1, PULSE+USB[0x2C]); // Wheel Brake
MapKey(&Joystick, H2U, 0);
MapKey(&Joystick, H2D, 0);
MapKey(&Joystick, H2L, PULSE+USB[0x50]); // Look Left
MapKey(&Joystick, H2R, PULSE+USB[0x4F]); // Look Right
MapKey(&Joystick, H3U, PULSE+USB[0x52]); // Look Up
MapKey(&Joystick, H3D, PULSE+USB[0x51]); // Look Down
MapKey(&Joystick, H4U, PULSE+‘x’); //Zoom In
MapKey(&Joystick, H4D, PULSE+‘z’); //Zoom Out
MapKey(&Joystick, S2, 0);
MapKey(&Joystick, S3, PULSE+USB[0x3A]); //Reset Cockpit View
MapKey(&Joystick, S4, CHAIN(
EXEC(“ActKey(PULSE+KEYON+USB[0x07]);”), // Flaps Up
D(200),
EXEC(“ActKey(PULSE+KEYON+USB[0x07]);”) // Flaps Down
));
// Throttle mappings
MapKey(&Throttle, APENG, PULSE+‘a’); // Toggle Autopilot Master
MapKey(&Throttle, APPAT, EXEC(“MapKey(&Throttle, APENG, PULSE+L_ALT+USB[0x23]);”)); // Route Following
MapKey(&Throttle, APAH, EXEC(“MapKey(&Throttle, APENG, PULSE+L_ALT+USB[0x1E]);”)); // Heading Hold
MapKey(&Throttle, APALT, EXEC(“MapKey(&Throttle, APENG, PULSE+L_ALT+USB[0x21]);”)); // Altitude Hold
MapKey(&Throttle, PBON, PULSE+USB[0x14]); // Parking Brake On
MapKey(&Throttle, EACON, CHAIN(
EXEC(“ActKey(KEYON+PULSE+USB[0x09]);”), // Landing Lights On
EXEC(“ActKey(KEYON+PULSE+USB[0x0B]);”) // Taxi Lights On
));
MapKey(&Throttle, EACOFF, CHAIN(
EXEC(“ActKey(KEYON+PULSE+USB[0x38]);”), // Landing Lights Off
EXEC(“ActKey(KEYON+PULSE+USB[0x38]);”) // Taxi Lights Off
));
MapKey(&Throttle, RDRNRM, PULSE+USB[0x1A]); // Turn On Strobes
MapKey(&Throttle, RDRDIS, PULSE+USB[0x38]); // Turn Off Strobes
MapKey(&Throttle, APUON, EXEC(“ActKey(PULSE+KEYON+USB[0x1E]);”)); // Engine 1 Start
MapKey(&Throttle, APUOFF, EXEC(“ActKey(PULSE+KEYON+USB[0x1F]);”)); // Engine 2 Start
MapKeyR(&Throttle, APUOFF, EXEC(“ActKey(PULSE+KEYON+USB[0x1E]);”)); // Engine 1 Stop
MapKeyR(&Throttle, APUOFF, EXEC(“ActKey(PULSE+KEYON+USB[0x1F]);”)); // Engine 2 Stop
MapKey(&Throttle, LDGH, PULSE+‘g’); //Landing Gear Up/Down
MapKey(&Throttle, CRUISE, EXEC(“ActKey(KEYON+PULSE+L_ALT+USB[0x02]);”)); // Set Airspeed Hold
MapKey(&Throttle, CSU, L_SHIFT+USB[0x23]); // Trim Up
MapKey(&Throttle, CSD, L_SHIFT+USB[0x1B]); // Trim Down
//Axis Mappings
MapAxis(&Joystick, JOYX, DX_X_AXIS);
MapAxis(&Joystick, JOYY, DX_Y_AXIS);
MapAxis(&Throttle, THR_LEFT, DX_ZROT_AXIS);
MapAxis(&Throttle, THR_RIGHT, DX_Z_AXIS);
MapAxis(&Throttle, SCX, DX_XROT_AXIS, AXIS_NORMAL, MAP_RELATIVE);
MapAxis(&Throttle, SCY, DX_YROT_AXIS, AXIS_NORMAL, MAP_RELATIVE);
MapAxis(&Throttle, THR_FC, DX_SLIDER_AXIS);
//Throttle Slew Control Axes
SetSCurve(&Throttle, SCX, 0, 10, 0, 0, -4); // Make slew control less sensitive
SetSCurve(&Throttle, SCY, 0, 10, 0, 0, -4);
}
int EventHandle(int type, alias o, int x)
{
DefaultMapping(&o, x);
}
This script maps the buttons, switches and axes of the HOTAS Warthog throttle and joystick according to the keybindings defined in the CSV file. It uses the USB code format for the keybindings.
Some key points:
It maps the joystick and throttle axes to the standard DirectX axes
For the slew control axes, it uses MAP_RELATIVE mode and adjusts the curves to make them less sensitive
It uses EXEC commands to dynamically remap certain autopilot buttons depending on the position of the LASTE switch
It uses PULSE for most key presses to prevent keys getting stuck on
It uses CHAIN to send multiple keystrokes for things like turning on/off lights
It uses MapKeyR to map key releases for the APU switches to stop the engines
Let me know if you have any other questions! I tried to follow the bindings from the CSV as closely as possible while organizing the script in a logical way with comments.