Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- include "target.tmh"
- int EngageAP; //AutoPilot On/Off
- int APType; //AutoPilot Type
- //program startup
- int main()
- {
- if(Init(&EventHandle)) return 1; // declare the event handler, return on error
- //add initialization code here
- EngageAP=0;
- APType=0;
- // Falcon BMS 4.33 TARGET Script for Thrustmaster HOTAS Warthog
- // Version 3.05 by Mud - Last update: April 29th, 2016
- //
- // NOTES:
- // ------
- // Readme
- // ------
- // If you start BMS without loading the script, you may lose your axis settings in BMS.
- // At least this happens to me.
- // Make sure to use and load the supplied keyfile: BMS 4.33 - Mud.key in combination with this script.
- // Start Falcon BMS Automatically on script execution:
- // Edit the line near the end of this file to the location of where you have installed Falcon BMS.
- // Remove the part (or comment it out by using //) if you don't want Falcon BMS to start automatically.
- // LED's and Throttle Backlight:
- // All LED's and the throttle backlight will be turned off on starting the script.
- // The backlight will go on when the Autopilot is engaged.
- // The backlight will go off when the Autopilot is disengaged.
- // Feedback/suggestions welcome as PM on the BMS (Mud) or the DCS (Bonso) forums.
- // Changelog:
- //-----------
- //Version 1.1
- //Added code for Right Throttle but commented it out because it's not used (yet?) in Falcon BMS
- //Added EAC Switch to Parking Brake
- //Added RDR ALTM Switch to to control Taxi / Landing Lights
- //Added APENG to toggle FPS
- //Version 1.2
- //Added code for IDLE Detent
- //Version 1.3
- //Changed Throttle pinky switch back to include strobes on as well
- //Changed Mic Switch forward to SimRangeKnobUp (CTRL+F4)
- //Changed Mic Switch backward to SimRangeKnobDown (CTRL+F3)
- //Version 1.4
- //Added the MFD's for the TM Cougar MFD Set
- //Version 1.5
- //Fixed some minor bugs
- //Version 1.6
- //Added AA / AG ICP to SYM button of MFDs
- //Version 1.7
- //Added Master arm switch and fuel door open switch to ENG FUEL FLOW switches
- //Version 1.8
- //Fixed Landing lights to properly work with on and off, rather than toggle
- //Added TGP zoom in and out on MIC Switch
- //Version 1.9
- //Mic Switch Up = AWACS Declare
- //Mic Switch Down = Wingman Attack My Target
- //Changed L ENG OPER IGN from JFS2 Start to Open/Close Canopy
- //Slew control press is now Radarcursorreset - long Cursor enable
- //Version 2.0
- //Added proper comments to autopilot controls
- //Version 2.01
- //Fixed Datalink keybinding
- //Changed MIC forward and backward to IVC (use slider for TGP zoom now)
- //Removed MIC down to free a spot for Teamspeak
- //Version 2.1
- //Changed ENG FUEL FLOW Left to Cat I / Cat III switch instead of Fuel Door switch
- //Changed Autopilor Engage/Disengage to Emergency Jettison
- //Fixed IVC mapping error
- //Version 2.2
- //Changed CMS Press to Missile Cage / Uncage instead of Toggle Jammer
- //Version 2.3
- //Swapped Coolie hat left and right for radar distance
- //Version 2.4
- //Fixed emergency jettison getting stuck after jettison
- //Version 2.5
- //Switched to USB HID codes to be compatible with all keyboard layouts
- //Version 2.6
- //Minor fix to a line that was commented out for the not-used right throttle
- //Version 3.0
- //Script and keyfile edited to be BMS 4.33 compatible
- //Version 3.01
- //Fixed Comm 1 & 2 transmit
- //Fixed Master arm on switch
- //Version 3.02
- //Support for twin-engines
- //Version 3.03
- //Fixed missile cage / uncage in keyfile
- //Version 3.04
- //Fixed missile step not switching between missile types
- //Version 3.05
- //Added callbacks for F-18 FLAPS (bound do the flaps switch together with gear up / down
- // Changes to BMS - Full.key
- // -------------------------
- //DX Assignments
- //AFGearToggle removed G
- //AFGearUp set to G
- //AFGearDown set to SHIFT+CRTL+ALT+G
- //SimExtlAntiColl removed SHIFT+CTRL+U
- //SimAntiCollOn set to SHIFT+CTRL+U
- //SimAntiCollOff set to SHIFT+U
- //SimExtlPower removed CTRL+M
- //SimExtlMasterNorm set to CTRL+M
- //SimExtlMasterOff set to ALT+M
- //SimExtlSteady removed SHIFT+CTRL+I
- //SimLightsFlash set to SHIFT+CTRL+I
- //SimLightsSteady set to SHIFT+I
- //SimExtlWing removed CTRL+SHIFT+O
- //SimWingLightBrt set to CTRL+SHIFT+O
- //SimLandingLightToggle removed SHIFT+L
- //SimLandingLightOn set to SHIFT+L
- //SimLandingLightOff set to ALT+L
- //SimParkingBrakeToggle removed ALT+P
- //SimParkingBrakeOn set to ALT+P
- //SimParkingBrakeOff set to CTRL+P
- //SimCATSwitch removed SHIFT+C
- //SimCATI set to SHIFT+C
- //SimCATIII set to CTRL+ALT+SHIFT+C
- //SimLeftAPSwitch removed SHIFT+A
- //SimLeftAPUp set to SHIFT+A
- //SimLeftAPMid set to SHIFT+CTRL+ALT+A
- //SimLeftAPDown set to SHIFT+N
- //SimRightAPSwitch removed A
- //SimRightAPUp set to A
- //SimRightAPMid set to CTRL+N
- //SimRightAPDown set to ALT+N
- //Swapped SimICPCLEAR with SimICPLIST (NUM . and F4)
- //Swapped SimDriftCO with SimICPCom1 (NUM / and F1)
- //SimStepMasterArm removed SHIFT + M
- //SimArmMasterArm set to SHIFT + M
- //SimSafeMasterArm set to SHIFT+ALT+CTRL + M
- // To Do
- // -----
- //
- //
- Configure(&TFRPRudder, MODE_EXCLUDED) ;
- SetKBRate(25, 50);
- SetKBLayout(KB_ENG);
- //Joystick Axis Modes
- MapAxis(&Joystick, JOYX, DX_X_AXIS, AXIS_NORMAL, MAP_ABSOLUTE);
- SetSCurve(&Joystick, JOYX, 0, 0, 0, 0, 0);
- MapAxis(&Joystick, JOYY, DX_Y_AXIS, AXIS_NORMAL, MAP_ABSOLUTE);
- SetSCurve(&Joystick, JOYY, 0, 0, 0, 0, 0);
- //Throttle Axis Setups
- MapAxis(&Throttle, THR_LEFT, DX_ZROT_AXIS, AXIS_NORMAL, MAP_ABSOLUTE);
- SetSCurve(&Throttle, THR_LEFT, 0, 0, 0, 0, 0);
- MapAxis(&Throttle, THR_RIGHT, DX_Z_AXIS, AXIS_NORMAL, MAP_ABSOLUTE);
- SetSCurve(&Throttle, THR_RIGHT, 0, 0, 0, 0, 0);
- MapKey(&Throttle, IDLELOFF, CHAIN(D(1000), PULSE+L_ALT+USB[0x0C])); //Idle Detent ** USB I **
- MapKey(&Throttle, IDLELON, PULSE+L_ALT+USB[0x0C]); //Idle Detent ** USB I **
- //Throttle Slider Axis
- MapAxis(&Throttle, THR_FC, DX_SLIDER_AXIS, AXIS_NORMAL, MAP_ABSOLUTE);
- SetSCurve(&Throttle, THR_FC, 0, 0, 0, 0, 0);
- //Throttle Slew Axis
- MapAxis(&Throttle, SCX, DX_XROT_AXIS, AXIS_NORMAL, MAP_ABSOLUTE);
- SetSCurve(&Throttle, SCX, 0, 15, 0, 0, 0);
- MapAxis(&Throttle, SCY, DX_YROT_AXIS, AXIS_REVERSED, MAP_ABSOLUTE);
- SetSCurve(&Throttle, SCY, 0, 15, 0, 0, 0);
- //**************************
- //*** TM Warthog Stick ***
- //**************************
- //Master mode Button: Cycle FOV
- MapKey(&Joystick, S1, PULSE+DX3);
- //Pickle Button
- MapKey(&Joystick, S2, DX2);
- //Pinky Button: Missile Step / NWS / AA Disconnect
- MapKey(&Joystick, S3, DX5);
- //Paddle Switch: Look Closer (subject to change)
- MapKey(&Joystick, S4, PULSE+USB[0x0F]); // ** USB L **
- //Trigger - First Stage
- MapKey(&Joystick, TG1, DX1);
- //Trigger - Second Stage
- MapKey(&Joystick, TG2, DX6);
- //DMS
- MapKey(&Joystick, H3U, DX11);
- MapKey(&Joystick, H3D, DX13);
- MapKey(&Joystick, H3R, DX12);
- MapKey(&Joystick, H3L, DX14);
- //TMS
- MapKey(&Joystick, H2U, DX7);
- MapKey(&Joystick, H2R, DX8);
- MapKey(&Joystick, H2D, DX9);
- MapKey(&Joystick, H2L, DX10);
- //CMS
- MapKey(&Joystick, H4P, DX24); // Missile Cage / Uncage
- MapKey(&Joystick, H4U, DX15);
- MapKey(&Joystick, H4R, DX16);
- MapKey(&Joystick, H4D, DX17);
- MapKey(&Joystick, H4L, DX18);
- //*****************************
- //*** TM Warthog Throttle ***
- //*****************************
- // Pinky Switch - External Lights
- //Forward = Navigation Lights: Steady - Anti-Collision: On
- MapKey(&Throttle, PSF, CHAIN(
- LOCK+PULSE+L_SHIFT+USB[0x0C],LOCK, //Steady ** USB I **
- D(),
- LOCK+PULSE+L_SHIFT+L_CTL+USB[0x12],LOCK, //Bright ** USB O **
- D(),
- LOCK+PULSE+L_CTL+L_SHIFT+USB[0x18],LOCK, //Anticollision On ** USB U **
- D(),
- LOCK+PULSE+L_CTL+USB[0x10],LOCK //Master On ** USB M **
- ));
- //Center = All Lights Off
- MapKey(&Throttle, PSM, LOCK+PULSE+L_ALT+USB[0x10],LOCK ); //Master Off ** USB M **
- //Backward = Navigation Light: Flash - Anti-Collision: Off
- MapKey(&Throttle, PSB, CHAIN(
- LOCK+PULSE+L_SHIFT+L_CTL+USB[0x0C],LOCK, //Flash ** USB I **
- D(),
- LOCK+PULSE+L_SHIFT+L_CTL+USB[0x12],LOCK, //Bright ** USB O **
- D(),
- LOCK+PULSE+L_CTL+L_SHIFT+USB[0x18],LOCK, //Anticollision On ** USB U **
- D(),
- LOCK+PULSE+L_CTL+USB[0x10],LOCK //Master On ** USB M **
- ));
- //Left Throttle Button (Also See Below: Autopilot Switch)
- MapKey(&Throttle, LTB, TEMPO(EXEC("EngageAPSL(1);"), EXEC("EngageAPSL(2);"), 400)); // Short: Alt & Off - Long: for Att
- //Slew Control Push
- MapKey(&Throttle, SC, TEMPO(LOCK+USB[0x4B], LOCK+USB[0x49], 500)); //Short = Cursor reset ** USB PAGE UP ** - Long = Cursor enable ** USB INSERT **
- //Coolie Hat
- MapKey(&Throttle, CSL, PULSE+L_CTL+USB[0x3B]); //Radar Range Up ** USB F2 **
- MapKey(&Throttle, CSR, PULSE+L_CTL+USB[0x3A]); //Radar Range Down ** USB F1 **
- MapKey(&Throttle, CSD, TEMPO(PULSE+L_CTL+USB[0x3E], PULSE+L_CTL+USB[0x3F], 500)); //Short: Radar Tilt Down - Long: Radar Antenna Center
- MapKey(&Throttle, CSU, TEMPO(PULSE+L_CTL+USB[0x40], PULSE+L_CTL+USB[0x3F], 500)); //Short: Radar Tilt Up - Long: Radar Antenna Center
- //Mic Switch
- MapKey(&Throttle, MSU,CHAIN(PULSE+USB[0x14], D(), PULSE+USB[0x1F])); //Declare ** USB Q ** USB 2 **
- MapKey(&Throttle, MSR, DX21); //Com 1 Transmit
- //MapKey(&Throttle, MSD, LOCK+USB[0x33]); // Map this key to anything you wish. I use it for Teamspeak NOT USED AT THE MOMENT
- MapKey(&Throttle, MSL, DX20); //Com 2 Transmit
- //MapKey(&Throttle, MSP, CHAIN(DOWN+L_CTL+USB[0x12], D(1500), UP+USB[0x12], UP+L_CTL)); //Datalink Up ** USB o ** NOT USED AT THE MOMENT
- //Speed Brake
- MapKey(&Throttle, SPDF, DX28);
- MapKey(&Throttle, SPDB, DX27);
- //Boat Switch: Dogfight/Missile Override
- MapKey(&Throttle, BSF, PULSE+USB[0x10]); // ** USB M **
- MapKey(&Throttle, BSM, PULSE+USB[0x06]); // ** USB C **
- MapKey(&Throttle, BSB, PULSE+USB[0x07]); // ** USB D **
- //China Hat: Waypoint Forward / Backward
- MapKey(&Throttle, CHF, PULSE+USB[0x1B]); // ** USB X **
- MapKey(&Throttle, CHB, PULSE++USB[0x1D]); // ** USB Z **
- //*** GEAR F-16 ***
- //Flaps = Gear Up / Down
- MapKey(&Throttle, FLAPU, PULSE+USB[0x0A]); //Gear Up ** USB G **
- MapKey(&Throttle, FLAPD, PULSE+L_ALT+L_SHIFT+L_CTL+USB[0x0A]); //Gear Down ** USB G **
- //*** GEAR + FLAPS F-18 ****
- // MapKey(&Throttle, FLAPU, CHAIN(PULSE+USB[0x0A], D(200), PULSE+L_SHIFT+USB[0x05])); //Gear Up ** USB G ** + Flaps Auto ** USB B **
- // MapKey(&Throttle, FLAPM, PULSE+L_CTL+USB[0x05]); //Flaps Half
- // MapKey(&Throttle, FLAPD, CHAIN(PULSE+L_ALT+L_SHIFT+L_CTL+USB[0x0A], D(200), PULSE+L_ALT+USB[0x05])); //Gear Down ** USB G ** + Flaps Down ** USB B **
- //ENG OPER IGN to Start JFS and open/close Canopy
- MapKey(&Throttle, EOLIGN, PULSE+L_CTL+USB[0x06]); //Canopy ** USB C **
- MapKey(&Throttle, EORIGN, PULSE+L_SHIFT+USB[0x0D]); //JFS ** USB J **
- //Autopilot Switch
- MapKey(&Throttle, APPAT, PULSE+L_SHIFT+USB[0x04]); // Short: Follow HSI heading - Long: Follow HSI & hold pitch ** USB A **
- MapKey(&Throttle, APAH, PULSE+L_CTL+L_SHIFT+L_ALT+USB[0x04]); // Short Hold roll angle and altitude - Long: Hold roll & pitch angle ** USB A **
- MapKey(&Throttle, APALT, PULSE+L_SHIFT+USB[0x11]); // Short: Follow Course to Next Waypoint - Long: Follow waypoint & hold pitch ** USB N **
- //RADAR ALTM Switch = Landing Lights Toggle
- MapKey(&Throttle, RDRNRM, PULSE+L_SHIFT+USB[0x0F]); //Landing Lights On ** USB L **
- MapKey(&Throttle, RDRDIS, PULSE+L_ALT+USB[0x0F]); //Landing Lights Off ** USB L **
- //APU Switch = Alternate Gear Control
- MapKey(&Throttle, APUON, PULSE+L_ALT+USB[0x0A]); //Alt Gear Down ** USB G **
- MapKey(&Throttle, APUOFF, PULSE+L_ALT+USB[0x0A]); //Alt Gear Down ** USB G **
- //Landing Gear Horn = Alternate Gear Reset
- MapKey(&Throttle, LDGH, PULSE+L_SHIFT+USB[0x0A]); //Alternate Gear Reset ** USB G **
- //EAC Switch = Parking Brake
- MapKey(&Throttle, EACOFF, PULSE+L_CTL+USB[0x13]); //Brake Off ** USB P **
- MapKey(&Throttle, EACON, PULSE+L_ALT+USB[0x13]); //Brake On ** USB P **
- //AP Engage / Disengage
- MapKey(&Throttle, APENG, CHAIN(DOWN+L_CTL+USB[0x0D], D(1500), UP+USB[0x0D], D(100), UP+L_CTL)); //Emergency Jettison ** USB J ** USB J **
- //ENG FUEL FLOW L
- MapKey(&Throttle, EFLNORM, PULSE+L_SHIFT+USB[0x06]); //Cat I ** USB C **
- MapKey(&Throttle, EFLOVER, PULSE+L_CTL+L_ALT+L_SHIFT+USB[0x06]); //Cat III ** USB C **
- //ENG FUEL FLOW L
- MapKey(&Throttle, EFRNORM, PULSE+L_SHIFT+USB[0x10]); //Master Arm On ** USB M **
- MapKey(&Throttle, EFROVER, PULSE+L_CTL+L_ALT+L_SHIFT+USB[0x10]); //Master Arm Safe ** USB M **
- //Turn All LED's Off
- ActKey(PULSE+KEYON+LED(&Throttle, LED_ONOFF, LED_CURRENT-LED1));
- ActKey(PULSE+KEYON+LED(&Throttle, LED_ONOFF, LED_CURRENT-LED2));
- ActKey(PULSE+KEYON+LED(&Throttle, LED_ONOFF, LED_CURRENT-LED3));
- ActKey(PULSE+KEYON+LED(&Throttle, LED_ONOFF, LED_CURRENT-LED4));
- ActKey(PULSE+KEYON+LED(&Throttle, LED_ONOFF, LED_CURRENT-LED5));
- //Turn Off Throttle Backlight
- ActKey(PULSE+KEYON+LED(&Throttle, LED_INTENSITY, 0));
- //*****************************
- //*** TFRP ***
- //*****************************
- //***************************
- //*** Launch Falcon BMS ***
- //***************************
- //Launch Falcon BMS 4.33
- // system("spawn -w \"C:\\Falcon BMS 4.33\" \"C:\\Falcon BMS 4.33\\Launcher.exe\"");
- }
- //********************
- //*** Extra Code ***
- //********************
- // Autopilot Code
- int EngageAPSL(int time)
- {
- // Long press
- if (time==2)
- APAtt();
- // Short press
- else
- {
- if (EngageAP)
- APOff();
- else
- APAlt();
- }
- }
- //Disengage AP
- int APOff()
- {
- ActKey(LOCK+PULSE+L_CTL+KEYON+USB[0x11],LOCK); // ** USB N **
- EngageAP=0;
- APType=0;
- ActKey(PULSE+KEYON+LED(&Throttle, LED_INTENSITY, 0));
- }
- //Set AP to Pitch: Alt Hold
- int APAlt()
- {
- ActKey(LOCK+PULSE+KEYON+USB[0x04],LOCK); // ** USB A **
- EngageAP=1;
- APType=1;
- ActKey(PULSE+KEYON+LED(&Throttle, LED_INTENSITY, 50));
- }
- //Set AP to Pitch: Att Hold
- int APAtt()
- {
- ActKey(LOCK+PULSE+L_ALT+KEYON+USB[0x11],LOCK); // ** USB N **
- EngageAP=1;
- APType=0;
- ActKey(PULSE+KEYON+LED(&Throttle, LED_INTENSITY, 50));
- }
- //event handler
- int EventHandle(int type, alias o, int x)
- {
- DefaultMapping(&o, x);
- //add event handling code here
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement