Advertisement
Guest User

Untitled

a guest
Nov 29th, 2016
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.75 KB | None | 0 0
  1. include "target.tmh"
  2.  
  3. int EngageAP; //AutoPilot On/Off
  4. int APType; //AutoPilot Type
  5.  
  6. //program startup
  7. int main()
  8. {
  9. if(Init(&EventHandle)) return 1; // declare the event handler, return on error
  10.  
  11. //add initialization code here
  12. EngageAP=0;
  13. APType=0;
  14.  
  15. // Falcon BMS 4.33 TARGET Script for Thrustmaster HOTAS Warthog
  16. // Version 3.05 by Mud - Last update: April 29th, 2016
  17. //
  18. // NOTES:
  19. // ------
  20. // Readme
  21. // ------
  22. // If you start BMS without loading the script, you may lose your axis settings in BMS.
  23. // At least this happens to me.
  24. // Make sure to use and load the supplied keyfile: BMS 4.33 - Mud.key in combination with this script.
  25. // Start Falcon BMS Automatically on script execution:
  26. // Edit the line near the end of this file to the location of where you have installed Falcon BMS.
  27. // Remove the part (or comment it out by using //) if you don't want Falcon BMS to start automatically.
  28. // LED's and Throttle Backlight:
  29. // All LED's and the throttle backlight will be turned off on starting the script.
  30. // The backlight will go on when the Autopilot is engaged.
  31. // The backlight will go off when the Autopilot is disengaged.
  32. // Feedback/suggestions welcome as PM on the BMS (Mud) or the DCS (Bonso) forums.
  33.  
  34. // Changelog:
  35. //-----------
  36. //Version 1.1
  37. //Added code for Right Throttle but commented it out because it's not used (yet?) in Falcon BMS
  38. //Added EAC Switch to Parking Brake
  39. //Added RDR ALTM Switch to to control Taxi / Landing Lights
  40. //Added APENG to toggle FPS
  41. //Version 1.2
  42. //Added code for IDLE Detent
  43. //Version 1.3
  44. //Changed Throttle pinky switch back to include strobes on as well
  45. //Changed Mic Switch forward to SimRangeKnobUp (CTRL+F4)
  46. //Changed Mic Switch backward to SimRangeKnobDown (CTRL+F3)
  47. //Version 1.4
  48. //Added the MFD's for the TM Cougar MFD Set
  49. //Version 1.5
  50. //Fixed some minor bugs
  51. //Version 1.6
  52. //Added AA / AG ICP to SYM button of MFDs
  53. //Version 1.7
  54. //Added Master arm switch and fuel door open switch to ENG FUEL FLOW switches
  55. //Version 1.8
  56. //Fixed Landing lights to properly work with on and off, rather than toggle
  57. //Added TGP zoom in and out on MIC Switch
  58. //Version 1.9
  59. //Mic Switch Up = AWACS Declare
  60. //Mic Switch Down = Wingman Attack My Target
  61. //Changed L ENG OPER IGN from JFS2 Start to Open/Close Canopy
  62. //Slew control press is now Radarcursorreset - long Cursor enable
  63. //Version 2.0
  64. //Added proper comments to autopilot controls
  65. //Version 2.01
  66. //Fixed Datalink keybinding
  67. //Changed MIC forward and backward to IVC (use slider for TGP zoom now)
  68. //Removed MIC down to free a spot for Teamspeak
  69. //Version 2.1
  70. //Changed ENG FUEL FLOW Left to Cat I / Cat III switch instead of Fuel Door switch
  71. //Changed Autopilor Engage/Disengage to Emergency Jettison
  72. //Fixed IVC mapping error
  73. //Version 2.2
  74. //Changed CMS Press to Missile Cage / Uncage instead of Toggle Jammer
  75. //Version 2.3
  76. //Swapped Coolie hat left and right for radar distance
  77. //Version 2.4
  78. //Fixed emergency jettison getting stuck after jettison
  79. //Version 2.5
  80. //Switched to USB HID codes to be compatible with all keyboard layouts
  81. //Version 2.6
  82. //Minor fix to a line that was commented out for the not-used right throttle
  83. //Version 3.0
  84. //Script and keyfile edited to be BMS 4.33 compatible
  85. //Version 3.01
  86. //Fixed Comm 1 & 2 transmit
  87. //Fixed Master arm on switch
  88. //Version 3.02
  89. //Support for twin-engines
  90. //Version 3.03
  91. //Fixed missile cage / uncage in keyfile
  92. //Version 3.04
  93. //Fixed missile step not switching between missile types
  94. //Version 3.05
  95. //Added callbacks for F-18 FLAPS (bound do the flaps switch together with gear up / down
  96.  
  97. // Changes to BMS - Full.key
  98. // -------------------------
  99. //DX Assignments
  100. //AFGearToggle removed G
  101. //AFGearUp set to G
  102. //AFGearDown set to SHIFT+CRTL+ALT+G
  103. //SimExtlAntiColl removed SHIFT+CTRL+U
  104. //SimAntiCollOn set to SHIFT+CTRL+U
  105. //SimAntiCollOff set to SHIFT+U
  106. //SimExtlPower removed CTRL+M
  107. //SimExtlMasterNorm set to CTRL+M
  108. //SimExtlMasterOff set to ALT+M
  109. //SimExtlSteady removed SHIFT+CTRL+I
  110. //SimLightsFlash set to SHIFT+CTRL+I
  111. //SimLightsSteady set to SHIFT+I
  112. //SimExtlWing removed CTRL+SHIFT+O
  113. //SimWingLightBrt set to CTRL+SHIFT+O
  114. //SimLandingLightToggle removed SHIFT+L
  115. //SimLandingLightOn set to SHIFT+L
  116. //SimLandingLightOff set to ALT+L
  117. //SimParkingBrakeToggle removed ALT+P
  118. //SimParkingBrakeOn set to ALT+P
  119. //SimParkingBrakeOff set to CTRL+P
  120. //SimCATSwitch removed SHIFT+C
  121. //SimCATI set to SHIFT+C
  122. //SimCATIII set to CTRL+ALT+SHIFT+C
  123. //SimLeftAPSwitch removed SHIFT+A
  124. //SimLeftAPUp set to SHIFT+A
  125. //SimLeftAPMid set to SHIFT+CTRL+ALT+A
  126. //SimLeftAPDown set to SHIFT+N
  127. //SimRightAPSwitch removed A
  128. //SimRightAPUp set to A
  129. //SimRightAPMid set to CTRL+N
  130. //SimRightAPDown set to ALT+N
  131. //Swapped SimICPCLEAR with SimICPLIST (NUM . and F4)
  132. //Swapped SimDriftCO with SimICPCom1 (NUM / and F1)
  133. //SimStepMasterArm removed SHIFT + M
  134. //SimArmMasterArm set to SHIFT + M
  135. //SimSafeMasterArm set to SHIFT+ALT+CTRL + M
  136.  
  137.  
  138. // To Do
  139. // -----
  140. //
  141. //
  142.  
  143. Configure(&TFRPRudder, MODE_EXCLUDED) ;
  144. SetKBRate(25, 50);
  145. SetKBLayout(KB_ENG);
  146.  
  147. //Joystick Axis Modes
  148. MapAxis(&Joystick, JOYX, DX_X_AXIS, AXIS_NORMAL, MAP_ABSOLUTE);
  149. SetSCurve(&Joystick, JOYX, 0, 0, 0, 0, 0);
  150. MapAxis(&Joystick, JOYY, DX_Y_AXIS, AXIS_NORMAL, MAP_ABSOLUTE);
  151. SetSCurve(&Joystick, JOYY, 0, 0, 0, 0, 0);
  152.  
  153. //Throttle Axis Setups
  154. MapAxis(&Throttle, THR_LEFT, DX_ZROT_AXIS, AXIS_NORMAL, MAP_ABSOLUTE);
  155. SetSCurve(&Throttle, THR_LEFT, 0, 0, 0, 0, 0);
  156. MapAxis(&Throttle, THR_RIGHT, DX_Z_AXIS, AXIS_NORMAL, MAP_ABSOLUTE);
  157. SetSCurve(&Throttle, THR_RIGHT, 0, 0, 0, 0, 0);
  158. MapKey(&Throttle, IDLELOFF, CHAIN(D(1000), PULSE+L_ALT+USB[0x0C])); //Idle Detent ** USB I **
  159. MapKey(&Throttle, IDLELON, PULSE+L_ALT+USB[0x0C]); //Idle Detent ** USB I **
  160.  
  161. //Throttle Slider Axis
  162. MapAxis(&Throttle, THR_FC, DX_SLIDER_AXIS, AXIS_NORMAL, MAP_ABSOLUTE);
  163. SetSCurve(&Throttle, THR_FC, 0, 0, 0, 0, 0);
  164.  
  165. //Throttle Slew Axis
  166. MapAxis(&Throttle, SCX, DX_XROT_AXIS, AXIS_NORMAL, MAP_ABSOLUTE);
  167. SetSCurve(&Throttle, SCX, 0, 15, 0, 0, 0);
  168. MapAxis(&Throttle, SCY, DX_YROT_AXIS, AXIS_REVERSED, MAP_ABSOLUTE);
  169. SetSCurve(&Throttle, SCY, 0, 15, 0, 0, 0);
  170.  
  171.  
  172.  
  173. //**************************
  174. //*** TM Warthog Stick ***
  175. //**************************
  176.  
  177. //Master mode Button: Cycle FOV
  178. MapKey(&Joystick, S1, PULSE+DX3);
  179.  
  180. //Pickle Button
  181. MapKey(&Joystick, S2, DX2);
  182.  
  183. //Pinky Button: Missile Step / NWS / AA Disconnect
  184. MapKey(&Joystick, S3, DX5);
  185.  
  186. //Paddle Switch: Look Closer (subject to change)
  187. MapKey(&Joystick, S4, PULSE+USB[0x0F]); // ** USB L **
  188.  
  189. //Trigger - First Stage
  190. MapKey(&Joystick, TG1, DX1);
  191.  
  192. //Trigger - Second Stage
  193. MapKey(&Joystick, TG2, DX6);
  194.  
  195. //DMS
  196. MapKey(&Joystick, H3U, DX11);
  197. MapKey(&Joystick, H3D, DX13);
  198. MapKey(&Joystick, H3R, DX12);
  199. MapKey(&Joystick, H3L, DX14);
  200.  
  201. //TMS
  202. MapKey(&Joystick, H2U, DX7);
  203. MapKey(&Joystick, H2R, DX8);
  204. MapKey(&Joystick, H2D, DX9);
  205. MapKey(&Joystick, H2L, DX10);
  206.  
  207. //CMS
  208. MapKey(&Joystick, H4P, DX24); // Missile Cage / Uncage
  209. MapKey(&Joystick, H4U, DX15);
  210. MapKey(&Joystick, H4R, DX16);
  211. MapKey(&Joystick, H4D, DX17);
  212. MapKey(&Joystick, H4L, DX18);
  213.  
  214.  
  215.  
  216. //*****************************
  217. //*** TM Warthog Throttle ***
  218. //*****************************
  219.  
  220. // Pinky Switch - External Lights
  221. //Forward = Navigation Lights: Steady - Anti-Collision: On
  222. MapKey(&Throttle, PSF, CHAIN(
  223. LOCK+PULSE+L_SHIFT+USB[0x0C],LOCK, //Steady ** USB I **
  224. D(),
  225. LOCK+PULSE+L_SHIFT+L_CTL+USB[0x12],LOCK, //Bright ** USB O **
  226. D(),
  227. LOCK+PULSE+L_CTL+L_SHIFT+USB[0x18],LOCK, //Anticollision On ** USB U **
  228. D(),
  229. LOCK+PULSE+L_CTL+USB[0x10],LOCK //Master On ** USB M **
  230. ));
  231. //Center = All Lights Off
  232. MapKey(&Throttle, PSM, LOCK+PULSE+L_ALT+USB[0x10],LOCK ); //Master Off ** USB M **
  233. //Backward = Navigation Light: Flash - Anti-Collision: Off
  234. MapKey(&Throttle, PSB, CHAIN(
  235. LOCK+PULSE+L_SHIFT+L_CTL+USB[0x0C],LOCK, //Flash ** USB I **
  236. D(),
  237. LOCK+PULSE+L_SHIFT+L_CTL+USB[0x12],LOCK, //Bright ** USB O **
  238. D(),
  239. LOCK+PULSE+L_CTL+L_SHIFT+USB[0x18],LOCK, //Anticollision On ** USB U **
  240. D(),
  241. LOCK+PULSE+L_CTL+USB[0x10],LOCK //Master On ** USB M **
  242. ));
  243.  
  244. //Left Throttle Button (Also See Below: Autopilot Switch)
  245. MapKey(&Throttle, LTB, TEMPO(EXEC("EngageAPSL(1);"), EXEC("EngageAPSL(2);"), 400)); // Short: Alt & Off - Long: for Att
  246.  
  247. //Slew Control Push
  248. MapKey(&Throttle, SC, TEMPO(LOCK+USB[0x4B], LOCK+USB[0x49], 500)); //Short = Cursor reset ** USB PAGE UP ** - Long = Cursor enable ** USB INSERT **
  249.  
  250. //Coolie Hat
  251. MapKey(&Throttle, CSL, PULSE+L_CTL+USB[0x3B]); //Radar Range Up ** USB F2 **
  252. MapKey(&Throttle, CSR, PULSE+L_CTL+USB[0x3A]); //Radar Range Down ** USB F1 **
  253. MapKey(&Throttle, CSD, TEMPO(PULSE+L_CTL+USB[0x3E], PULSE+L_CTL+USB[0x3F], 500)); //Short: Radar Tilt Down - Long: Radar Antenna Center
  254. MapKey(&Throttle, CSU, TEMPO(PULSE+L_CTL+USB[0x40], PULSE+L_CTL+USB[0x3F], 500)); //Short: Radar Tilt Up - Long: Radar Antenna Center
  255.  
  256. //Mic Switch
  257. MapKey(&Throttle, MSU,CHAIN(PULSE+USB[0x14], D(), PULSE+USB[0x1F])); //Declare ** USB Q ** USB 2 **
  258. MapKey(&Throttle, MSR, DX21); //Com 1 Transmit
  259. //MapKey(&Throttle, MSD, LOCK+USB[0x33]); // Map this key to anything you wish. I use it for Teamspeak NOT USED AT THE MOMENT
  260. MapKey(&Throttle, MSL, DX20); //Com 2 Transmit
  261. //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
  262.  
  263. //Speed Brake
  264. MapKey(&Throttle, SPDF, DX28);
  265. MapKey(&Throttle, SPDB, DX27);
  266.  
  267. //Boat Switch: Dogfight/Missile Override
  268. MapKey(&Throttle, BSF, PULSE+USB[0x10]); // ** USB M **
  269. MapKey(&Throttle, BSM, PULSE+USB[0x06]); // ** USB C **
  270. MapKey(&Throttle, BSB, PULSE+USB[0x07]); // ** USB D **
  271.  
  272. //China Hat: Waypoint Forward / Backward
  273. MapKey(&Throttle, CHF, PULSE+USB[0x1B]); // ** USB X **
  274. MapKey(&Throttle, CHB, PULSE++USB[0x1D]); // ** USB Z **
  275.  
  276. //*** GEAR F-16 ***
  277. //Flaps = Gear Up / Down
  278. MapKey(&Throttle, FLAPU, PULSE+USB[0x0A]); //Gear Up ** USB G **
  279. MapKey(&Throttle, FLAPD, PULSE+L_ALT+L_SHIFT+L_CTL+USB[0x0A]); //Gear Down ** USB G **
  280. //*** GEAR + FLAPS F-18 ****
  281. // MapKey(&Throttle, FLAPU, CHAIN(PULSE+USB[0x0A], D(200), PULSE+L_SHIFT+USB[0x05])); //Gear Up ** USB G ** + Flaps Auto ** USB B **
  282. // MapKey(&Throttle, FLAPM, PULSE+L_CTL+USB[0x05]); //Flaps Half
  283. // 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 **
  284.  
  285. //ENG OPER IGN to Start JFS and open/close Canopy
  286. MapKey(&Throttle, EOLIGN, PULSE+L_CTL+USB[0x06]); //Canopy ** USB C **
  287. MapKey(&Throttle, EORIGN, PULSE+L_SHIFT+USB[0x0D]); //JFS ** USB J **
  288.  
  289. //Autopilot Switch
  290. MapKey(&Throttle, APPAT, PULSE+L_SHIFT+USB[0x04]); // Short: Follow HSI heading - Long: Follow HSI & hold pitch ** USB A **
  291. 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 **
  292. MapKey(&Throttle, APALT, PULSE+L_SHIFT+USB[0x11]); // Short: Follow Course to Next Waypoint - Long: Follow waypoint & hold pitch ** USB N **
  293.  
  294. //RADAR ALTM Switch = Landing Lights Toggle
  295. MapKey(&Throttle, RDRNRM, PULSE+L_SHIFT+USB[0x0F]); //Landing Lights On ** USB L **
  296. MapKey(&Throttle, RDRDIS, PULSE+L_ALT+USB[0x0F]); //Landing Lights Off ** USB L **
  297.  
  298. //APU Switch = Alternate Gear Control
  299. MapKey(&Throttle, APUON, PULSE+L_ALT+USB[0x0A]); //Alt Gear Down ** USB G **
  300. MapKey(&Throttle, APUOFF, PULSE+L_ALT+USB[0x0A]); //Alt Gear Down ** USB G **
  301.  
  302. //Landing Gear Horn = Alternate Gear Reset
  303. MapKey(&Throttle, LDGH, PULSE+L_SHIFT+USB[0x0A]); //Alternate Gear Reset ** USB G **
  304.  
  305. //EAC Switch = Parking Brake
  306. MapKey(&Throttle, EACOFF, PULSE+L_CTL+USB[0x13]); //Brake Off ** USB P **
  307. MapKey(&Throttle, EACON, PULSE+L_ALT+USB[0x13]); //Brake On ** USB P **
  308.  
  309. //AP Engage / Disengage
  310. 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 **
  311.  
  312. //ENG FUEL FLOW L
  313. MapKey(&Throttle, EFLNORM, PULSE+L_SHIFT+USB[0x06]); //Cat I ** USB C **
  314. MapKey(&Throttle, EFLOVER, PULSE+L_CTL+L_ALT+L_SHIFT+USB[0x06]); //Cat III ** USB C **
  315.  
  316. //ENG FUEL FLOW L
  317. MapKey(&Throttle, EFRNORM, PULSE+L_SHIFT+USB[0x10]); //Master Arm On ** USB M **
  318. MapKey(&Throttle, EFROVER, PULSE+L_CTL+L_ALT+L_SHIFT+USB[0x10]); //Master Arm Safe ** USB M **
  319.  
  320. //Turn All LED's Off
  321. ActKey(PULSE+KEYON+LED(&Throttle, LED_ONOFF, LED_CURRENT-LED1));
  322. ActKey(PULSE+KEYON+LED(&Throttle, LED_ONOFF, LED_CURRENT-LED2));
  323. ActKey(PULSE+KEYON+LED(&Throttle, LED_ONOFF, LED_CURRENT-LED3));
  324. ActKey(PULSE+KEYON+LED(&Throttle, LED_ONOFF, LED_CURRENT-LED4));
  325. ActKey(PULSE+KEYON+LED(&Throttle, LED_ONOFF, LED_CURRENT-LED5));
  326.  
  327. //Turn Off Throttle Backlight
  328. ActKey(PULSE+KEYON+LED(&Throttle, LED_INTENSITY, 0));
  329.  
  330. //*****************************
  331. //*** TFRP ***
  332. //*****************************
  333.  
  334.  
  335.  
  336. //***************************
  337. //*** Launch Falcon BMS ***
  338. //***************************
  339.  
  340. //Launch Falcon BMS 4.33
  341. // system("spawn -w \"C:\\Falcon BMS 4.33\" \"C:\\Falcon BMS 4.33\\Launcher.exe\"");
  342.  
  343. }
  344.  
  345.  
  346. //********************
  347. //*** Extra Code ***
  348. //********************
  349.  
  350. // Autopilot Code
  351. int EngageAPSL(int time)
  352. {
  353. // Long press
  354. if (time==2)
  355. APAtt();
  356. // Short press
  357. else
  358. {
  359. if (EngageAP)
  360. APOff();
  361. else
  362. APAlt();
  363. }
  364. }
  365.  
  366. //Disengage AP
  367. int APOff()
  368. {
  369. ActKey(LOCK+PULSE+L_CTL+KEYON+USB[0x11],LOCK); // ** USB N **
  370. EngageAP=0;
  371. APType=0;
  372. ActKey(PULSE+KEYON+LED(&Throttle, LED_INTENSITY, 0));
  373. }
  374. //Set AP to Pitch: Alt Hold
  375. int APAlt()
  376. {
  377. ActKey(LOCK+PULSE+KEYON+USB[0x04],LOCK); // ** USB A **
  378. EngageAP=1;
  379. APType=1;
  380. ActKey(PULSE+KEYON+LED(&Throttle, LED_INTENSITY, 50));
  381. }
  382. //Set AP to Pitch: Att Hold
  383. int APAtt()
  384. {
  385. ActKey(LOCK+PULSE+L_ALT+KEYON+USB[0x11],LOCK); // ** USB N **
  386. EngageAP=1;
  387. APType=0;
  388. ActKey(PULSE+KEYON+LED(&Throttle, LED_INTENSITY, 50));
  389. }
  390.  
  391.  
  392. //event handler
  393. int EventHandle(int type, alias o, int x)
  394. {
  395. DefaultMapping(&o, x);
  396.  
  397. //add event handling code here
  398. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement