include "target.tmh" include "StarCitizenMappings.tmh" char DECOUPLED_MODE; char FAST_DECOUPLED; char LONG_DECOUPLED; int set_throttle_to_strafe() { int ZONES = LIST(0,40,45,50,55,60,100); KeyAxis(&Throttle, THR_RIGHT, 0, AXMAP2( ZONES, Strafe_Backward, PULSE+Strafe_Backward, 0, 0, PULSE+Strafe_Forward, Strafe_Forward ) ); return 0; } int set_throttle_to_default() { KeyAxis(&Throttle, THR_RIGHT, 0, 0); return 0; } //program startup int main() { Configure(&HCougar, MODE_EXCLUDED); Configure(&T16000, MODE_EXCLUDED); Configure(&LMFD, MODE_EXCLUDED); Configure(&RMFD, MODE_EXCLUDED); if(Init(&EventHandle)) return 1; // declare the event handler, return on error ///////////////////////// // Keyboard Settings ///////////////////////// SetKBRate(32, 50); SetKBLayout(KB_ENG); ///////////////////////// // IO and UMD buttons ///////////////////////// SetShiftButton(&Joystick, INPUT_LAYER_SHIFT, &Throttle, UPPER_LAYER_SHIFT, LOWER_LAYER_SHIFT, IOTOGGLE+UDTOGGLE); ///////////////////////// ///// Init LEDS ///////////////////////// 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 ///////////////////////// /// AXIS MAPPINGS ///////////////////////// ///// X AXIS MapAxis(&Joystick, JOYX, DX_X_AXIS, AXIS_NORMAL, MAP_ABSOLUTE); SetSCurve(&Joystick, JOYX, 0, 0, 0, 0, 0); ///// Y AXIS MapAxis(&Joystick, JOYY, DX_Y_AXIS, AXIS_NORMAL, MAP_ABSOLUTE); SetSCurve(&Joystick, JOYY, 0, 0, 0, 0, 0); ////// SCX (Jostick Skew Button) //MapAxis(&Throttle, SCX, MOUSE_X_AXIS, AXIS_NORMAL, MAP_RELATIVE); //SetSCurve(&Throttle, SCX, 0, 10, 0, 0, -3); ////// SCY (Jostick Skew Button) //MapAxis(&Throttle, SCY, MOUSE_Y_AXIS, AXIS_REVERSED, MAP_RELATIVE); //SetSCurve(&Throttle, SCY, 0, 10, 0, 0, -3); ////// Throttle MapAxis(&Throttle, THR_RIGHT, DX_THROTTLE_AXIS, AXIS_NORMAL, MAP_ABSOLUTE); SetJCurve(&Throttle, THR_RIGHT, 35, 75); MapAxis(&Throttle, THR_LEFT, 0, AXIS_NORMAL, MAP_ABSOLUTE); SetSCurve(&Throttle, THR_LEFT, 0, 0, 0, 0, 0); MapAxis(&Throttle, THR_FC, DX_SLIDER_AXIS, AXIS_NORMAL, MAP_ABSOLUTE); SetSCurve(&Throttle, THR_FC, 0, 0, 0, 0, 0); /////////////////////////////////////////////////////////// // Key Mappings /////////////////////////////////////////////////////////// //////////////////////////// /// Main Layer Mappings (Dogfight Mode) //////////////////////////// MapKey(&Throttle, SPDB, SpaceBrake_Newtonian_Brake); MapKey(&Throttle, SPDF, Match_Target_Velocity_Toggle_On); MapKeyR(&Throttle, SPDF, Match_Target_Velocity_Toggle_Off); // On release button toggle break back //////////////// /// Maneuvering //////////////// /// Switch From Yaw to Roll on Input Layout MapKey(&Joystick, Roll_Switch, EXEC( "MapAxis(&Joystick, JOYX, DX_Z_AXIS, AXIS_NORMAL, MAP_ABSOLUTE);" ) ); /// Switch From Roll to Yaw on Input Layout MapKeyR(&Joystick, Roll_Switch, EXEC( "DXAxis(DX_Z_AXIS, 0);" "MapAxis(&Joystick, JOYX, DX_X_AXIS, AXIS_NORMAL, MAP_ABSOLUTE);" ) ); /////////////////////////////////////// // DECOUPLED MODE /////////////////////////////////////// DECOUPLED_MODE = 0; LONG_DECOUPLED = 0; MapKey(&Joystick, S4, TEMPO( /// On Short Press Toggle Fast Decoupled SEQ( //// Start FAST_DECOUPLED EXEC( "printf(\"Fast Decoupled Toggled\\xa\");" "DECOUPLED_MODE = 1;" "ActKey(KEYON+PULSE+Decoupled_Trigger);" "ActKey(PULSE+KEYON+LED(&Throttle, LED_ONOFF, LED_CURRENT+LED1));" "set_throttle_to_strafe();" ), //// Stop FAST_DECOUPLED EXEC( "printf(\"Fast Decoupled Release\\xa\");" "DECOUPLED_MODE = 0;" "ActKey(KEYON+PULSE+Decoupled_Trigger);" "ActKey(PULSE+KEYON+LED(&Throttle, LED_ONOFF, LED_CURRENT-LED1));" "set_throttle_to_default();" ) ), // Long Press CHAIN( EXEC("printf(\"New Long Decoupled\\xa\");"), EXEC( "DECOUPLED_MODE = 1;" "LONG_DECOUPLED = 1;" "ActKey(PULSE+KEYON+LED(&Throttle, LED_ONOFF, LED_CURRENT+LED1));" "ActKey(KEYON+Decoupled_Trigger);" //"set_throttle_to_strafe();" ), LED(&Throttle, LED_ONOFF, LED_CURRENT+LED1) ), /// Tempo time 200 ) ); MapKeyR(&Joystick, S4, /// Handle Long Decoupled EXEC( "if (LONG_DECOUPLED) printf(\"Long Decoupled Release\\xa\");" "if (LONG_DECOUPLED) DECOUPLED_MODE = 0;" "if (LONG_DECOUPLED) ActKey(Decoupled_Trigger);" "if (LONG_DECOUPLED) ActKey(PULSE+KEYON+LED(&Throttle, LED_ONOFF, LED_CURRENT-LED1));" "if (LONG_DECOUPLED) LONG_DECOUPLED = 0;" //"set_throttle_to_default();" ) ); /////////////////////////////////////// // END DECOUPLED MODE /////////////////////////////////////// } //event handler int EventHandle(int type, alias o, int x) { //printf("%d", sizeof(&o)); DefaultMapping(&o, x); //add event handling code here }