Advertisement
Guest User

Dual T16000M Mapping Elite: Dangerous T.A.R.G.E.T.

a guest
Aug 30th, 2014
1,423
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.68 KB | None | 0 0
  1. //-------------------------------------------------------------------------------------------------
  2.  
  3. // TARGET Script for playing "Elite: Dangerous" with two Thrustmaster T.16000M Joysticks
  4.  
  5. //-------------------------------------------------------------------------------------------------
  6.  
  7.  
  8. include "target.tmh"
  9.  
  10. alias Stick1;
  11. alias Stick2;
  12.  
  13.  
  14. // Script Settings --------------------------------------------------------------------------------
  15.  
  16.  
  17. // Choose whether to combine the two joysticks, or not.
  18. // Combining them offer more flexibility, but there is currently a bug in the TARGET
  19. // software, and the POV hat of the second stick won't be available.
  20. // If set to '0', only 'Stick1' will be defined.
  21. define JOYSTICKS_COMBINED 1 // '0' or '1' (default: '1')
  22.  
  23. define JOYSTICKS_INVERTED 0
  24.  
  25. // Which axis of which joystick to use as a throttle.
  26. define THROTTLE_JOYSTICK Stick2 // 'Stick1' or 'Stick2'
  27. define THROTTLE_AXIS JOYY // 'JOYY' or 'RUDDER'
  28.  
  29. // Define a specific button to use as an FA Toggle; this button will automatically set
  30. // default speed to 0 when in FA Off. Note that in order to use this, the "Toggle Flight Assist"
  31. // option in the game have to be set on hold (instead of toggle).
  32. define FA_TOGGLE_ENABLED 0 // '0' or '1'
  33. define FA_TOGGLE_JOYSTICK Stick2 // 'Stick1' or 'Stick2'
  34. define FA_TOGGLE_BUTTON TS3 // 'TS1' .. 'TS4', 'H1L', 'H1U', 'H1R', 'H1D' or 'B5' .. 'B16'
  35.  
  36. // Define a specific button to use as a shift mode selector. When held down, all other buttons
  37. // (of both joysticks) have a different binding.
  38. define SHIFT_ENABLED 0 // 0 or 1
  39. define SHIFT_JOYSTICK Stick2 // Stick1 or Stick2
  40. define SHIFT_BUTTON TS1 // TS1 .. TS4, H1L, H1U, H1R, H1D or B5 .. B16
  41.  
  42.  
  43. // Button Mapping ---------------------------------------------------------------------------------
  44.  
  45.  
  46. int stick1ButtonMap[] = {
  47. // The trigger
  48. TS1, DX1, DX5,
  49. // The 3 thumb buttons
  50. TS2, DX2, DX6,
  51. TS3, DX3, DX7,
  52. TS4, DX4, DX8,
  53. // The POV Hat
  54. H1L, DXHATLEFT, DX9,
  55. H1U, DXHATUP, DX10,
  56. H1R, DXHATRIGHT, DX11,
  57. H1D, DXHATDOWN, DX12,
  58. // The 12 buttons on the base
  59. B5, DX9, DX31,
  60. B6, DX10, DX31,
  61. B7, DX11, DX31,
  62. B8, DX12, DX31,
  63. B9, DX13, DX31,
  64. B10, DX14, DX31,
  65. B11, DX15, DX32,
  66. B12, DX16, DX32,
  67. B13, DX17, DX32,
  68. B14, DX18, DX32,
  69. B15, DX19, DX32,
  70. B16, DX20, DX32
  71. };
  72.  
  73. int stick2ButtonMap[] = {
  74. // The trigger
  75. TS1, DX5, DX17,
  76. // The 3 thumb buttons
  77. TS2, DX6, DX18,
  78. TS3, DX7, DX19,
  79. TS4, DX8, DX20,
  80. // (Note: the hat on second joystick currently does not work)
  81. H1L, DX21, DX25,
  82. H1U, DX22, DX26,
  83. H1R, DX23, DX27,
  84. H1D, DX24, DX28,
  85. // The 12 buttons on the base
  86. B5, DX21, DX31,
  87. B6, DX22, DX31,
  88. B7, DX23, DX31,
  89. B8, DX24, DX31,
  90. B9, DX25, DX31,
  91. B10, DX26, DX31,
  92. B11, DX27, DX32,
  93. B12, DX28, DX32,
  94. B13, DX29, DX32,
  95. B14, DX30, DX32,
  96. B15, DX31, DX32,
  97. B16, DX32, DX32
  98. };
  99.  
  100.  
  101. // Script Implementation --------------------------------------------------------------------------
  102.  
  103.  
  104. int curve0, curve25, curve50, curve75, curve100;
  105.  
  106. int currentCurve;
  107. float currentSpeed;
  108.  
  109. int isFAOn;
  110.  
  111. int main()
  112. {
  113. if(Init(&EventHandle)) return 1;
  114.  
  115. if(JOYSTICKS_COMBINED){
  116. if(JOYSTICKS_INVERTED){
  117. &Stick1 = GetIndexJoy(SelectUsbDevice("VID_044F&PID_B10A"));
  118. &Stick2 = &T16000;
  119. } else {
  120. &Stick1 = &T16000;
  121. &Stick2 = GetIndexJoy(SelectUsbDevice("VID_044F&PID_B10A"));
  122. }
  123. } else {
  124. &Stick1 = &T16000;
  125. }
  126.  
  127.  
  128. // First Joystick
  129.  
  130. MapAxis(&Stick1, JOYX, DX_X_AXIS);
  131. MapAxis(&Stick1, JOYY, DX_Y_AXIS);
  132. MapAxis(&Stick1, RUDDER, DX_Z_AXIS);
  133. MapAxis(&Stick1, THR, DX_THROTTLE_AXIS);
  134.  
  135. mapButtons(&Stick1, &stick1ButtonMap);
  136.  
  137.  
  138. // Second Joystick
  139.  
  140. if(JOYSTICKS_COMBINED){
  141. MapAxis(&Stick2, JOYX, DX_XROT_AXIS);
  142. MapAxis(&Stick2, JOYY, DX_YROT_AXIS);
  143. MapAxis(&Stick2, RUDDER, DX_ZROT_AXIS);
  144.  
  145. MapAxis(&Stick2, THR, DX_SLIDER_AXIS);
  146.  
  147. mapButtons(&Stick2, &stick2ButtonMap);
  148. }
  149.  
  150.  
  151.  
  152.  
  153. // Initialisation
  154.  
  155. currentCurve = curve100;
  156. currentSpeed = 1.00;
  157. isFAOn = 1;
  158. changeSpeedCurve();
  159. }
  160.  
  161.  
  162. //-------------------------------------------------------------------------------------------------
  163.  
  164.  
  165. int EventHandle(int type, alias o, int x)
  166. {
  167. DefaultMapping(&o, x);
  168. }
  169.  
  170.  
  171. //-------------------------------------------------------------------------------------------------
  172.  
  173.  
  174. int mapButtons(alias device, alias list)
  175. {
  176. int length = elements(&list);
  177. int i = 0;
  178. while(i < length){
  179. if(SHIFT_ENABLED & (&device == &SHIFT_JOYSTICK) & (list[i] == SHIFT_BUTTON)){
  180. SetShiftButton(&SHIFT_JOYSTICK, SHIFT_BUTTON, 0, 0, 0, 0);
  181. MapKeyIO(&SHIFT_JOYSTICK, SHIFT_BUTTON, 0, 0);
  182. } else if(FA_TOGGLE_ENABLED & (&device == &FA_TOGGLE_JOYSTICK) & (list[i] == FA_TOGGLE_BUTTON)){
  183. MapKeyIO(&FA_TOGGLE_JOYSTICK, FA_TOGGLE_BUTTON,
  184. list[i+2],
  185. SEQ(
  186. CHAIN(
  187. DOWN+list[i+1],
  188. EXEC("isFAOn = 0; changeSpeedCurve();")
  189. ),
  190. CHAIN(
  191. UP+list[i+1],
  192. EXEC("isFAOn = 1; changeSpeedCurve();")
  193. )
  194. )
  195. );
  196. } else {
  197. MapKeyIO(&device, list[i], list[i+2], list[i+1]);
  198. }
  199. i = i + 3;
  200. }
  201. }
  202.  
  203.  
  204. //-------------------------------------------------------------------------------------------------
  205.  
  206.  
  207. int changeSpeedCurve()
  208. {
  209. if(isFAOn){
  210. SetCustomCurve(&THROTTLE_JOYSTICK, THROTTLE_AXIS, currentCurve);
  211. DXAxis(DX_THROTTLE_AXIS, -32767+65534*currentSpeed);
  212. } else {
  213. SetCustomCurve(&THROTTLE_JOYSTICK, THROTTLE_AXIS, curve100);
  214. DXAxis(DX_THROTTLE_AXIS, -32767+65534*1.00);
  215. }
  216. }
  217.  
  218.  
  219. //-------------------------------------------------------------------------------------------------
  220. // Copyright (c) 2014 - Laurent Moussault <[email protected]>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement