Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //-------------------------------------------------------------------------------------------------
- // TARGET Script for playing "Elite: Dangerous" with two Thrustmaster T.16000M Joysticks
- //-------------------------------------------------------------------------------------------------
- include "target.tmh"
- alias Stick1;
- alias Stick2;
- // Script Settings --------------------------------------------------------------------------------
- // Choose whether to combine the two joysticks, or not.
- // Combining them offer more flexibility, but there is currently a bug in the TARGET
- // software, and the POV hat of the second stick won't be available.
- // If set to '0', only 'Stick1' will be defined.
- define JOYSTICKS_COMBINED 1 // '0' or '1' (default: '1')
- define JOYSTICKS_INVERTED 0
- // Which axis of which joystick to use as a throttle.
- define THROTTLE_JOYSTICK Stick2 // 'Stick1' or 'Stick2'
- define THROTTLE_AXIS JOYY // 'JOYY' or 'RUDDER'
- // Define a specific button to use as an FA Toggle; this button will automatically set
- // default speed to 0 when in FA Off. Note that in order to use this, the "Toggle Flight Assist"
- // option in the game have to be set on hold (instead of toggle).
- define FA_TOGGLE_ENABLED 0 // '0' or '1'
- define FA_TOGGLE_JOYSTICK Stick2 // 'Stick1' or 'Stick2'
- define FA_TOGGLE_BUTTON TS3 // 'TS1' .. 'TS4', 'H1L', 'H1U', 'H1R', 'H1D' or 'B5' .. 'B16'
- // Define a specific button to use as a shift mode selector. When held down, all other buttons
- // (of both joysticks) have a different binding.
- define SHIFT_ENABLED 0 // 0 or 1
- define SHIFT_JOYSTICK Stick2 // Stick1 or Stick2
- define SHIFT_BUTTON TS1 // TS1 .. TS4, H1L, H1U, H1R, H1D or B5 .. B16
- // Button Mapping ---------------------------------------------------------------------------------
- int stick1ButtonMap[] = {
- // The trigger
- TS1, DX1, DX5,
- // The 3 thumb buttons
- TS2, DX2, DX6,
- TS3, DX3, DX7,
- TS4, DX4, DX8,
- // The POV Hat
- H1L, DXHATLEFT, DX9,
- H1U, DXHATUP, DX10,
- H1R, DXHATRIGHT, DX11,
- H1D, DXHATDOWN, DX12,
- // The 12 buttons on the base
- B5, DX9, DX31,
- B6, DX10, DX31,
- B7, DX11, DX31,
- B8, DX12, DX31,
- B9, DX13, DX31,
- B10, DX14, DX31,
- B11, DX15, DX32,
- B12, DX16, DX32,
- B13, DX17, DX32,
- B14, DX18, DX32,
- B15, DX19, DX32,
- B16, DX20, DX32
- };
- int stick2ButtonMap[] = {
- // The trigger
- TS1, DX5, DX17,
- // The 3 thumb buttons
- TS2, DX6, DX18,
- TS3, DX7, DX19,
- TS4, DX8, DX20,
- // (Note: the hat on second joystick currently does not work)
- H1L, DX21, DX25,
- H1U, DX22, DX26,
- H1R, DX23, DX27,
- H1D, DX24, DX28,
- // The 12 buttons on the base
- B5, DX21, DX31,
- B6, DX22, DX31,
- B7, DX23, DX31,
- B8, DX24, DX31,
- B9, DX25, DX31,
- B10, DX26, DX31,
- B11, DX27, DX32,
- B12, DX28, DX32,
- B13, DX29, DX32,
- B14, DX30, DX32,
- B15, DX31, DX32,
- B16, DX32, DX32
- };
- // Script Implementation --------------------------------------------------------------------------
- int curve0, curve25, curve50, curve75, curve100;
- int currentCurve;
- float currentSpeed;
- int isFAOn;
- int main()
- {
- if(Init(&EventHandle)) return 1;
- if(JOYSTICKS_COMBINED){
- if(JOYSTICKS_INVERTED){
- &Stick1 = GetIndexJoy(SelectUsbDevice("VID_044F&PID_B10A"));
- &Stick2 = &T16000;
- } else {
- &Stick1 = &T16000;
- &Stick2 = GetIndexJoy(SelectUsbDevice("VID_044F&PID_B10A"));
- }
- } else {
- &Stick1 = &T16000;
- }
- // First Joystick
- MapAxis(&Stick1, JOYX, DX_X_AXIS);
- MapAxis(&Stick1, JOYY, DX_Y_AXIS);
- MapAxis(&Stick1, RUDDER, DX_Z_AXIS);
- MapAxis(&Stick1, THR, DX_THROTTLE_AXIS);
- mapButtons(&Stick1, &stick1ButtonMap);
- // Second Joystick
- if(JOYSTICKS_COMBINED){
- MapAxis(&Stick2, JOYX, DX_XROT_AXIS);
- MapAxis(&Stick2, JOYY, DX_YROT_AXIS);
- MapAxis(&Stick2, RUDDER, DX_ZROT_AXIS);
- MapAxis(&Stick2, THR, DX_SLIDER_AXIS);
- mapButtons(&Stick2, &stick2ButtonMap);
- }
- // Initialisation
- currentCurve = curve100;
- currentSpeed = 1.00;
- isFAOn = 1;
- changeSpeedCurve();
- }
- //-------------------------------------------------------------------------------------------------
- int EventHandle(int type, alias o, int x)
- {
- DefaultMapping(&o, x);
- }
- //-------------------------------------------------------------------------------------------------
- int mapButtons(alias device, alias list)
- {
- int length = elements(&list);
- int i = 0;
- while(i < length){
- if(SHIFT_ENABLED & (&device == &SHIFT_JOYSTICK) & (list[i] == SHIFT_BUTTON)){
- SetShiftButton(&SHIFT_JOYSTICK, SHIFT_BUTTON, 0, 0, 0, 0);
- MapKeyIO(&SHIFT_JOYSTICK, SHIFT_BUTTON, 0, 0);
- } else if(FA_TOGGLE_ENABLED & (&device == &FA_TOGGLE_JOYSTICK) & (list[i] == FA_TOGGLE_BUTTON)){
- MapKeyIO(&FA_TOGGLE_JOYSTICK, FA_TOGGLE_BUTTON,
- list[i+2],
- SEQ(
- CHAIN(
- DOWN+list[i+1],
- EXEC("isFAOn = 0; changeSpeedCurve();")
- ),
- CHAIN(
- UP+list[i+1],
- EXEC("isFAOn = 1; changeSpeedCurve();")
- )
- )
- );
- } else {
- MapKeyIO(&device, list[i], list[i+2], list[i+1]);
- }
- i = i + 3;
- }
- }
- //-------------------------------------------------------------------------------------------------
- int changeSpeedCurve()
- {
- if(isFAOn){
- SetCustomCurve(&THROTTLE_JOYSTICK, THROTTLE_AXIS, currentCurve);
- DXAxis(DX_THROTTLE_AXIS, -32767+65534*currentSpeed);
- } else {
- SetCustomCurve(&THROTTLE_JOYSTICK, THROTTLE_AXIS, curve100);
- DXAxis(DX_THROTTLE_AXIS, -32767+65534*1.00);
- }
- }
- //-------------------------------------------------------------------------------------------------
- // Copyright (c) 2014 - Laurent Moussault <[email protected]>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement