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.

169 lines
5.8 KiB

// Copyright (c) 2015-2020 Derek Douville ("solarfly")
//
// Version 3.8.2_v1
// Apr 10, 2020 7:50AM CST
//
// You are free to modify or redistrubute so long as my Copyright stays intact.
define MAX_INT 32767
define MIN_INT -32767
include "pilot_settings.tmh"
//include "solarfly_mapping.tmh"
include "solarfly_gameglass_mapping.tmh"
define AP_SHORT 1
define AP_LONG 2
define AP_RELEASE 3
// Reconfigure the Master Mode button every time the Boat Switch is repositioned
int sc_master_mode(int t) {
printf("sc_master_mode(%d)\x0a", t);
if (t == AP_RELEASE) {
if (Throttle[BSF])
ActKey(KEYON+UP+v_toggle_qdrive_engagement); // Same binding for both, just hold it
} else {
if (Throttle[BSF])
ActKey(KEYON+DOWN+v_toggle_qdrive_engagement); // Same binding for both, just hold it
else if (Throttle[BSB]) {
printf("Throttle is BSB\0xa");
ActKey(KEYON+PULSE+scan_toggle_mode);
} else // BSM
ActKey(KEYON+PULSE+v_target_cycle_reticle_mode);
}
}
// Return the new position once the axis crosses the target position within a
// threshold, otherwise return -1. While -1 is a valid value, it's a
// 1/65536 chance the user lands exactly there.
int sc_throttle_pickup_zero(alias o, int axis, int pickup_target, int threshold) {
if (axis < IN_POSITION_AXES | axis > IN_POSITION_AXES+IN_MAX_AXES)
return -1;
if (threshold == 0)
threshold = 1000;
int pos = AxisVal(o[axis], &axdata);
int min = MIN_INT;
int max = MAX_INT;
if (pickup_target > MIN_INT + abs(threshold))
min = pickup_target - threshold;
if (pickup_target < MAX_INT - abs(threshold))
max = pickup_target + threshold;
if (pos > min & pos < max) {
return pos;
}
return -1;
}
// Assign the correct DX axis to physical axis and set curves depending on
// the position of the EFL and EFR switches
int sc_set_axis(alias o, int axis, int val) {
int dx_axis = 0;
if (axis < IN_POSITION_AXES | axis > IN_POSITION_AXES+IN_MAX_AXES)
return -1;
if (&o == &Throttle & (axis == THR_RIGHT | axis == THR_LEFT)) {
if (axis == THR_RIGHT) {
if (Throttle[EFRNORM]) {
dx_axis = DX_Z_AXIS;
SetSCurve(&o, axis, 0, 0, 0, 0, 0);
SetJCurve(&o, axis, 70, 50); // Nice and smooth
} else {
dx_axis = DX_THROTTLE_AXIS;
SetSCurve(&o, axis, 0, THR_STRAFE_DEADZONE, 0, THR_STRAFE_CURVE, 0);
}
} else { // THR_LEFT
if (Throttle[EFLNORM])
dx_axis = 0;
else {
dx_axis = DX_ZROT_AXIS;
SetSCurve(&o, axis, 0, THR_STRAFE_DEADZONE, 0, THR_STRAFE_CURVE, 0);
}
}
DXSetAxis(dx_axis, val);
MapAxis(&o, axis, dx_axis, AXIS_REVERSED, MAP_ABSOLUTE);
}
}
// Return the zero-value of what an axis should be given the position of EFR switches
int sc_get_axis_zero(alias o, int axis) {
if (&o == &Throttle) {
if ((axis == THR_RIGHT & Throttle[EFRNORM]) | axis == DX_Z_AXIS)
return MIN_INT;
}
return 0;
}
// Disconnect a physical axis from a DX axis until the EventLoop calls sc_set_axis
// to prevent unwanted position jumps in Star Citizen when changing behaviors
int sc_disable_axis(alias o, int axis)
{
if (axis < IN_POSITION_AXES | axis > IN_POSITION_AXES+IN_MAX_AXES)
return -1;
if (&o == &Throttle) {
if (axis == THR_LEFT)
DXSetAxis(DX_ZROT_AXIS, sc_get_axis_zero(&o, DX_ZROT_AXIS));
if (axis == THR_RIGHT) {
DXSetAxis(DX_THROTTLE_AXIS, sc_get_axis_zero(&o, DX_THROTTLE_AXIS));
DXSetAxis(DX_Z_AXIS, sc_get_axis_zero(&o, DX_Z_AXIS));
}
}
MapAxis(&o, axis, 0, AXIS_REVERSED, MAP_ABSOLUTE);
}
// Read the position of the Autopilot switch and the Engage
// button press combination and emit the correct event
int sc_set_ap_mode_engage(int t) {
// t == AP_SHORT, AP_LONG or AP_RELEASE (for MapKeyR)
if (t == AP_RELEASE) {
ActKey(KEYON+UP+v_autoland);
return 0;
}
if (Throttle[APPAT]) { // Quantum Drive
ActKey(KEYON+PULSE+v_toggle_mining_mode);
} else if (Throttle[APAH]) {
if (t == AP_SHORT)
ActKey(KEYON+PULSE+v_ifcs_toggle_cruise_control);
if (t == AP_LONG)
ActKey(KEYON+PULSE+v_ifcs_toggle_speed_limiter);
} else { // (Throttle[APALT])
if (t == AP_SHORT)
ActKey(KEYON+PULSE+v_toggle_landing_system);
if (t == AP_LONG)
ActKey(KEYON+DOWN+v_autoland); // Auto or Manual
}
}
/*
int sc_set_joystick_curves()
{
// FLAP position sets joystick curve profile defined in pilot_settings.tmh
int profile;
if (Throttle[FLAPU]) profile = 0;
if (!Throttle[FLAPU] & !Throttle[FLAPD]) profile = 1;
if (Throttle[FLAPD]) profile = 2;
SetSCurve(&Joystick, JOYX, 0, 0, 0, JS_CURVE[profile], JS_ZOOM[profile]);
SetSCurve(&Joystick, JOYY, 0, 0, 0, JS_CURVE[profile], JS_ZOOM[profile]);
printf("Profile[%d]: Curve=%d, Zoom=%d\x0a", profile, JS_CURVE[profile], JS_ZOOM[profile]);
//led2bin(profile);
}
int sc_set_tg1_h4p()
{
// If RDRALT
int secondary_fire = 0;
if (Throttle[EOLMOTOR]) { // Normal
MapKey(&Joystick, TG1, DX1); // fire group 1
MapKey(&Joystick, TG2, DX5);
secondary_fire = DX5;
printf("RDRNRM: Weapon Group 1 on TG1, Weapon Group 2 on H4P\x0a");
} else {
MapKey(&Joystick, TG1, DX5); // fire group 1
MapKey(&Joystick, TG2, DX1);
secondary_fire = DX1;
printf("RDRDIS: Weapon Group 2 on TG1, Weapon Group 1 on H4P\x0a");
}
MapKeyIO(&Joystick, H4P, PULSE+pc_select, secondary_fire); // EACARM: Inner Thought select, EACNORM: Secondary fire
}
*/