Config Script for the Thrustmaster TARGET Software for Star Citizien
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

282 lines
13 KiB

// Copyright (c) 2015-2018 Derek Douville ("solarfly")
// commit by Tholo
// Version 3.10
// Nov 11, 2020
//
// You may freely distribute or modify this profile to as you see fit,
// so long as this copyright stays intact.
/// commits from Tholo are printed with ///
include "target.tmh"
include "solarfly.tmh"
include "solarfly_mfd.tmh"
int main()
{
Configure(&HCougar, MODE_EXCLUDED);
Configure(&T16000, MODE_EXCLUDED);
Configure(&T16000L, MODE_EXCLUDED);
Configure(&TWCSThrottle, MODE_EXCLUDED);
if (USEMFD == 0) {
Configure(&LMFD, MODE_EXCLUDED);
Configure(&RMFD, MODE_EXCLUDED);
}
if (RUDDERS < 2) {
Configure(&TFRPRudder, MODE_EXCLUDED);
} else {
Configure(&TFRPRudder, MODE_FILTERED);
}
if(Init(&EventHandle)) return 1;
if (RUDDERS == 2) {
MapAxis(&TFRPRudder, TRUDDER, DX_Z_AXIS, AXIS_NORMAL, MAP_ABSOLUTE);
MapAxis(&TFRPRudder, TRPLEFT, DX_XROT_AXIS, AXIS_REVERSED, MAP_ABSOLUTE);
MapAxis(&TFRPRudder, TRPRIGHT, DX_YROT_AXIS, AXIS_REVERSED, MAP_ABSOLUTE);
}
SetKBRate(40, 35);
/// add Keyboard Layouts
if (KBLAYOUT == 1) {
SetKBLayout(KB_GER);
} else if (KBLAYOUT == 2) {
SetKBLayout(KB_FR);
} else {
SetKBLayout(KB_ENG);
}
// =======================================================================================
// Initialize MFD Assignments
if (USEMFD > 0)
init_mfd_left();
if (USEMFD > 1)
init_mfd_right();
// =======================================================================================
// Initialize GameGlass
if (GAMEGLASS == 1) {
printf("GameGlass is running"); // Todo: start GameGlass Software
}
// =======================================================================================
// Initialize the Joystick & Throttle AXIS Assignments
// ---------------------------------------------------------------------------------------
// (Curve/Zoom can be chosen by using the FLAPS switch).
MapAxis(&Joystick, JOYX, DX_X_AXIS, AXIS_NORMAL, MAP_ABSOLUTE);
MapAxis(&Joystick, JOYY, DX_Y_AXIS, AXIS_NORMAL, MAP_ABSOLUTE);
MapAxis(&Throttle, THR_FC, DX_SLIDER_AXIS, AXIS_REVERSED, MAP_ABSOLUTE); // vertical; js1_slider1
MapAxis(&Joystick, 0, MOUSE_X_AXIS, AXIS_NORMAL, MAP_RELATIVE);
MapAxis(&Joystick, 0, MOUSE_Y_AXIS, AXIS_NORMAL, MAP_RELATIVE);
MapAxis(&Joystick, 0, MOUSE_Z_AXIS, AXIS_NORMAL, MAP_RELATIVE);
sc_set_axis(&Throttle, THR_LEFT, sc_get_axis_zero(&Throttle, THR_LEFT));
sc_set_axis(&Throttle, THR_RIGHT, sc_get_axis_zero(&Throttle, THR_RIGHT));
MapAxis(&Throttle, SCX, 0, AXIS_NORMAL, MAP_RELATIVE);
MapAxis(&Throttle, SCY, 0, AXIS_NORMAL, MAP_ABSOLUTE);
// =======================================================================================
// ---------------------------------------------------------------------------------------
// JOYSTICK FUNCTION ASSIGNMENTS
// ---------------------------------------------------------------------------------------
// -- Shift States --
// PSM: Defensive (Shield Control)
// PSF: Offensive (Power & Weapon Control) Todo: Check this
// PSB: Interact
SetShiftButton(&Throttle, 0, &Throttle, PSF, PSB); // InnerThought Control Switch, Offense/Defense/View Mode
// -- FIRE CONTROL -----------------------------------------------------------------------
MapKey(&Joystick, TG1, DX1); // Group 0
MapKey(&Joystick, TG2, DX5); // Group 0 and Group 1
MapKey(&Joystick, H4P, DX5); // Group 1
MapKey(&Joystick, S1, EXEC("sc_master_mode(0);")); // S1
MapKeyR(&Joystick, S1, EXEC("sc_master_mode(AP_RELEASE);")); // S1
MapKey(&Joystick, S2, DX2); // BSF: Quantum Drive, BSM: Lead/Lag Ret., BSB: Scanning see master_mode
MapKey(&Joystick, S3, PULSE+v_ifcs_toggle_vector_decoupling); // Fire Countermeasures 3.0, 2.4 bug which required keyboard
MapKey(&Joystick, S4, PULSE+v_strafe_longitudinal_invert);
MapKey(&Throttle, CHB, PULSE+v_weapon_launch_countermeasure);
MapKey(&Throttle, CHF, PULSE+v_weapon_cycle_countermeasure_fwd);
// View Mangagement
MapKey(&Throttle, SC, TEMPO(v_view_cycle_fwd, PULSE+TRACKIR_CENTER, 300)); // Look Camera
MapKey(&Joystick, H1U, v_view_pitch_up); // Note now the stick X axis also functions
MapKey(&Joystick, H1D, v_view_pitch_down);
MapKey(&Joystick, H1L, v_view_yaw_left);
MapKey(&Joystick, H1R, v_view_yaw_right);
MapKey(&Throttle, PSB, DOWN+pc_interaction_mode);
MapKeyR(&Throttle, PSB, UP+pc_interaction_mode);
// -- TARGET MANAGEMENT --------------------------------------------------
// H2
MapKey(&Joystick, H2U, TEMPO(PULSE+v_target_nearest_hostile, // short: target
PULSE+v_target_toggle_pinned_focused, 300)); // long: pin the target
MapKey(&Joystick, H2D, TEMPO(PULSE+v_target_reticle_focus, // short: target
PULSE+v_target_toggle_pinned_focused, 300)); // long: pin the target
MapKey(&Joystick, H2R, TEMPO(PULSE+v_target_cycle_hostile_fwd, // Short: Cycle Hostile fwd
PULSE+v_target_cycle_hostile_back, 300)); // Long: Cycle hostile Back
MapKey(&Joystick, H2L, TEMPO(PULSE+v_target_cycle_friendly_fwd, // Short: Cycle Friendly Fwd
PULSE+v_target_cycle_friendly_back, 300)); // Long: cycle Friendly Back
// ** H4 SHIELD / POWER MANAGEMENT / HUD CONTROL**
// PSM, H4 controls shields Fwd, Back, Left, Right; MSU/D on throttle controls top/bot
// PSF: H4 controls Power distribution to G1, G2, G3, Normalize; MSU/D controls power throttle
// PSF, PSM, PSD
MapKeyUMD(&Throttle, MSU, v_power_throttle_up, v_shield_up, 0); // Increase Power / Shield Top
MapKeyUMD(&Throttle, MSD, v_power_throttle_down, v_shield_down, 0); // Decrease Power / Shield Bot
// -------- POWER MANAGEMENT -----------------------------------------------
// U/M/D = PSF PSM PSF
// XXX CIG BUG - POWER DISTRIBUTION IS BROKEN
MapKeyUMD(&Joystick, H3U, TEMPO(PULSE+v_target_cycle_nearest_friendly, PULSE+v_target_deselect, 300),
TEMPO(PULSE+v_target_cycle_nearest_friendly, PULSE+v_target_deselect, 300),
pc_interaction_focus); // S: Nearest Friendly L:
MapKey(&Joystick, H3D, TEMPO(PULSE+v_target_cycle_pinned_fwd,
PULSE+v_target_cycle_pinned_back, 300));
MapKey(&Joystick, H3R, TEMPO(PULSE+v_target_cycle_all_fwd,
PULSE+v_target_cycle_all_back, 300)); // Power G2 / Shield Down / HUD Down
MapKey(&Joystick, H3L, TEMPO(PULSE+v_target_cycle_subsystem_fwd,
PULSE+v_target_reset_subsystem, 300)); // Power G1 / Shield Left / HUD Left
// -------- SHIELD/POWER MANAGEMENT -----------------
MapKeyUMD(&Joystick, H4U, PULSE+v_power_reset_focus, v_shield_forward, v_shield_forward); // Shield Top / Shield Fwd
MapKeyUMD(&Joystick, H4D, PULSE+v_power_focus_group_3, v_shield_back, v_shield_back); // Shield Bot / Shield Back
MapKeyUMD(&Joystick, H4R, PULSE+v_power_focus_group_2, v_shield_right, v_shield_right); // Shield Reset / Shield Right
MapKeyUMD(&Joystick, H4L, PULSE+v_power_focus_group_1, v_shield_left, v_shield_left); // Shield Reset/ Shield Left
// =======================================================================================
// ---------------------------------------------------------------------------------------
// THROTTLE ENGINE MANAGEMENT
// ---------------------------------------------------------------------------------------
MapKey(&Throttle, BSB, 0); // Scanning Master Mode
MapKeyR(&Throttle, BSB, 0); // Lead/Lag master mode
MapKey(&Throttle, BSF, 0); // Quantum Drive Master Mode (See S1)
MapKeyR(&Throttle, BSF, 0);
MapKey(&Throttle, EFRNORM, EXEC("sc_disable_axis(&Throttle, THR_RIGHT); pickup_thr_right=1;")); // Center Throttle Mode
MapKeyR(&Throttle, EFRNORM, EXEC("sc_disable_axis(&Throttle, THR_RIGHT); pickup_thr_right=1;")); // Normal Throttle Mode
MapKey(&Throttle, EFLNORM, EXEC("sc_disable_axis(&Throttle, THR_LEFT); pickup_thr_left=0;"));
MapKeyR(&Throttle, EFLNORM, EXEC("sc_disable_axis(&Throttle, THR_LEFT); pickup_thr_left=1;"));
MapKey(&Throttle, LTB, PULSE+v_toggle_vtol);
// -- Brake / Afterburners / Flight Control ------------------------------
MapKey(&Throttle, SPDB, KEYON+DOWN+v_afterburner);
MapKeyR(&Throttle, SPDB, KEYON+UP+v_afterburner);
MapKey(&Throttle, SPDF, v_brake);
MapKey(&Throttle, APUON, PULSE+v_toggle_yaw_roll_swap);
// -- RUDDER / STRAFE SETUP --------------------------------------------------------------
// Combat Strafe Up/Down is mapped to CSU/CSU in all configurations.
//
// If RUDDER is 1, roll and strafe lateral will be assigned to the rudders and pedals.
// If RUDDER is 0:
// - Roll will be assigned to CSL/CSR.
// - Strafe L/R will be mapped to SCX Axis
if (!RUDDERS) {
printf("No rudders\x0a");
printf("Roll on CS, Strafe\x0a");
// Add Roll somewhere for non-rudder users
}
MapKey(&Throttle, CSU, v_strafe_up);
MapKey(&Throttle, CSD, v_strafe_down);
MapKey(&Throttle, CSL, v_strafe_left);
MapKey(&Throttle, CSR, v_strafe_right);
// MapKey(&Throttle, MSR, 0);
// MapKey(&Throttle, MSL, 0);
// Countermeasures Cycling / PIP Mode / Gimbals / Look Ahead modes
// -- Engine Power Off (Pull back on throttle)
printf(" * * * NOTE! If throttle Idle pulled back to detent, use ENGLOVER to override and fix throttle position\x0a");
MapKey(&Throttle, IDLERON, PULSE+v_power_toggle_group_3); // Right throttle [6]
MapKey(&Throttle, IDLEROFF, PULSE+v_power_toggle_group_3); // Right throttle [6]
MapKey(&Throttle, IDLELON, 0); // Reserved for future
MapKey(&Throttle, IDLELOFF, 0);
// -- Push to Talk & Comms -----------------------------------------------
MapKey(&Throttle, MSP, MIC_PTT); // Match teamspeak or whatever key to the pilot_settings
// -- EJECT EJECT EJECT --------------------------------------------------
// ------------- ENGINE THROTTLE MANAGEMENT --------
// MapKey(&Throttle, FLAPU, EXEC("sc_set_joystick_curves();")); // This is also awesome voodoo magic
// MapKeyR(&Throttle, FLAPU, EXEC("sc_set_joystick_curves();"));
MapKey(&Throttle, FLAPU, v_accel_range_increase);
MapKey(&Throttle, FLAPM, 0);
MapKey(&Throttle, FLAPD, v_accel_range_decrease);
// MapKey(&Throttle, FLAPD, EXEC("sc_set_joystick_curves();"));
// MapKeyR(&Throttle, FLAPD, EXEC("sc_set_joystick_curves();"));
MapKey(&Throttle, EOLNORM, 0);
MapKeyR(&Throttle, EOLMOTOR, 0); // Swap TG1 and TG2 group assignments
MapKeyR(&Throttle, EOLMOTOR, PULSE+v_flightready);
MapKey(&Throttle, EOLIGN, PULSE+v_power_toggle);
MapKey(&Throttle, LDGH, TEMPO(PULSE+v_weapon_cycle_aimmode, PULSE+v_look_ahead_enable, 300));
MapKey(&Throttle, RDRNRM, PULSE+scan_toggle_mode);
MapKey(&Throttle, RDRDIS, PULSE+scan_toggle_mode);
MapKey(&Throttle, EORNORM, 0);
MapKey(&Throttle, EORMOTOR, DOWN+mobiglass_scoreboard); // Seems more like a Thrustmaster MFD thing/keyboard though
MapKeyR(&Throttle, EORMOTOR, UP+mobiglass_scoreboard);
MapKey(&Throttle, EORIGN, PULSE+v_starmap); // Toggle the Starmap
//printf(" * * * NOTE: If Trigger fires Group 2 and you wanted Group 1, flip RDR ALTM switch to NRM.\x0a");
MapKey(&Throttle, APAH, 0); // Flight Modes
// =============== NAVIGATION, QDRIVE, CRUISE MANAGEMENT ========================================================
MapKey(&Throttle, APPAT, 0); // S: Mining Mode when Engage Pressed
MapKeyR(&Throttle, APPAT, 0); // S: Cruise Mode L: Disable/Enable when Engage pressed
MapKey(&Throttle, APALT, 0); // S: Landing Mode L: autoland, when Engage pressed
MapKey(&Throttle, APENG, TEMPO(EXEC("sc_set_ap_mode_engage(AP_SHORT);"), EXEC("sc_set_ap_mode_engage(AP_LONG);"), 300));
MapKeyR(&Throttle, APENG, EXEC("sc_set_ap_mode_engage(AP_RELEASE);"));
MapKey(&Throttle, APDIS, 0);
}
int pickup_thr_right = 0;
int pickup_thr_left = 0;
int EventHandle(int type, alias o, int x)
{
int dev = x;
int rc;
int zero;
int thr_r_pos;
if(&o == &TFRPRudder) {
// T.Flight rudders accessed by direct hardware. Swap them to match profile.
// Huge thanks to @samneric from the RSI forums for helping me debug this all day!
GetAxisData(&o, x);
if (axdata.dxmap == DX_XROT_AXIS) dev = TRPRIGHT;
else if (axdata.dxmap == DX_YROT_AXIS) dev = TRPLEFT;
axdata.val = AxisVal(o[x], &axdata);
GameOutput(&o, dev, AxisVal(o[x], &axdata));
return 0;
}
// Smooth throttle axes pickup for when throttle modes are switched
if(&o == &Throttle & ((x == THR_RIGHT & pickup_thr_right) | (x == THR_LEFT & pickup_thr_left))) {
zero = sc_get_axis_zero(&o, x);
rc = sc_throttle_pickup_zero(&o, x, zero, 1000);
if (rc != -1) {
sc_set_axis(&o, x, rc);
if (x == THR_RIGHT) pickup_thr_right = 0;
else pickup_thr_left = 0;
}
}
DefaultMapping(&o, x);
}