TARGET Script Editor quick and dirty - Page 2 - ED Forums
 


Notices

Reply
 
Thread Tools Display Modes
Old 10-21-2019, 04:11 PM   #11
SGT Coyle
Member
 
Join Date: Dec 2011
Posts: 839
Default

Let's get scripting.
A couple Rules to remember:
Code:
MapKey(&Joystick, S1, Expand_FOV_Button_Depress);
  1. "MapKey" is a function to make a button do something. There are other functions, but "MapKey" is the topic today.
  2. Every function has variables between "( )". For every one of these "(", you need one of these ")".
  3. Variables are separated by",".
  4. Every function line needs ";" at the end.
Making buttons do things on the stick.
To map keyboard presses, DirectX Commands, or other functions to the buttons on the joystick, you use the "MapKey" function.

What you need for a MapKey function:
Code:
Function Name (
Device Name,
Button Name,
Key or Command to be passed);
  • Function Name = MapKey
  • Device Name = TSE designation for the TM Device you want to map proceded by "&". i.e. &Joystick = Standard TMWH Joystick Grip.
  • Button Name = Name of the button or switch you want to map. Button names can be found on the Device diagram located in documents folder in the TMSE directory
  • Key to be mapped = keyboard key to mapped between " ' ' " (single quotes).
The template in the OP breaks down the joystick mapping options by button name (Triggers, Buttons, TMS Hat, DMS Hat, TRIM Hat, and CMS Hat).


The individual sections are further broken down into commented out MapKey functions for the each button in the section.
Example:
Code:
//TMS   // Hat Name on the Stick
//MapKey(&Joystick,H2U, 0);  // Device Name
//MapKey(&Joystick,H2D, 0);  //Actual button on the Hat to be mapped
//MapKey(&Joystick,H2R, 0);  // Zero passed w/ no quotation to produce "nothing"
 //MapKey(&Joystick,H2L, 'c'); //C in single quotes to passed to DCS as key press
This is what it looks like with my macros form the Macro.ttm
Code:
//TMS
MapKey(&Joystick,H2U, Target_Management_Switch_Up);
MapKey(&Joystick,H2D, Target_Management_Switch_Down);
MapKey(&Joystick,H2R, Target_Management_Switch_Right);
 MapKey(&Joystick,H2L, Target_Management_Switch_Left);
Macros don't need single quotes and are easier to read.


Go read pgs 15 and 16 in the manual.


Hope this helps.
__________________
Implement CW and CCW keyboard commands for the encoders!!!!!
For all that is holy and right with the world please!
SGT Coyle is offline   Reply With Quote
Old 10-21-2019, 04:35 PM   #12
Rudel_chw
Veteran
 
Join Date: Nov 2013
Location: Antofagasta, Chile
Posts: 4,846
Default

Very informative thread .. subscribed, just in case I try to learn TARGET once again
__________________
For work: iMac mid-2010 of 27" - Core i7 870 - 6 GB DDR3 1333 MHz - ATI HD5670 - SSD 256 GB - HDD 2 TB - macOS High Sierra
For Gaming: 27" Monitor - Ryzen 1500X - 32 GB DDR4 2400 - MSI GTX970 - SSD 480 GB - HDD 10 TB - Windows 8.1 Pro - Thrustmaster HOTAS Cougar - Oculus Rift CV1
Mobile: iPad Pro 12.9" of 128 GB
Rudel_chw is offline   Reply With Quote
Old 10-21-2019, 08:48 PM   #13
SGT Coyle
Member
 
Join Date: Dec 2011
Posts: 839
Default

Quote:
Originally Posted by Rudel_chw View Post
subscribed, just in case I try to learn TARGET once again

Once you learn TARGET you never go back
Thanks
__________________
Implement CW and CCW keyboard commands for the encoders!!!!!
For all that is holy and right with the world please!
SGT Coyle is offline   Reply With Quote
Old 10-24-2019, 10:58 AM   #14
SGT Coyle
Member
 
Join Date: Dec 2011
Posts: 839
Default

Layers!
WTF!


TARGET SE gives us three layers:
UP
MIDDLE
DOWN
and two sub-layers for each:
IN
OUT

You have to tell TARGET what layers/sub-layers you want to use and if the those layers are going to be momentary or toggled. You also need to tell TARGET what buttons or switch is going to activate witch layer/sub-layer. You do this with the "SetShiftButton" function.
Code:
SetShiftButton(Device for Sub-Layer, Button Name for Sub-Layer, Device for Layer, Button Name for UP, Button Name for DOWN, Toggle Indicator);
As with "MapKey", you need to tell "SetShiftButton" what device your going to map an activating button to, and what button it is going to be.
Example:
Code:
SetShiftButton(&Joystick, S4, &Throttle, PSF, PSB);
Sub-layer is Pinky Lever on the Stick.
Pinky Switch Forward is UP layer and Pinky Switch Back is the DOWN layer, on the Throttle. All the these activations are momentary since we didn't declare any Toggle instructions.
Look at pages 21 and 22 in the manual for more examples.

To make a "MapKey" assignment you need to tell "MapKey" that you want to access the Layers and/or Sub-Layers. You don't have to use layers or sub-layers in your "MapKey" if you don't need to even if assigned them with "SetShiftButton".

So here's a scenario where I use the Trim Hat to trim the A/C. I assign all six trim functions to the four way hat using the Sub-Layer of the default MIDDLE layer.
Code:
MapKey(&Joystick,H1U, Nose_Down);
MapKey(&Joystick,H1D, Nose_Up);
MapKeyIO(&Joystick,H1R, Rudder_Right, Right_Wing_Down);
MapKeyIO(&Joystick,H1L, Rudder_Left, Left_Wing_Down);
IO added to the end of the "MapKey" function tells TARGET the TRIM Hat Left/Right buttons have Sub-Layer assignments available, but the TRIM Hat Up/Down buttons do not. Furthermore the Sub-Layer functions are only active while I hold the Pinky lever on the stick in since I didn't give any toggle instructions. Momentary by default.


Now for a more complicated scenario also using the TRIM Hat button. First the example then the explanation.
Code:
MapKeyUMD(&Joystick,H1U, F1_Cockpit_view, Nose_Down, Cockpit_Camera_Move_Up);
MapKeyUMD(&Joystick, H1D, 0, Nose_Up, Cockpit_Camera_Move_Down);
MapKeyIOUMD(&Joystick,H1R, 0, F4_Chase_view, Rudder_Right, Right_Wing_Down, 0, F3_Fly_By_view);
MapKey(&Joystick,H1L, Left_Wing_Down);
First line "MapKeyUMD(&Joystick,H1U, Up layer Cockpit View, Middle layer Nose_Down, Down layer Cockpit_Camera_Move_Up);" MapKeyUMD tells the MapKey function that there is a UP, MIDDLE, and DOWN layer assignment in the function.


Second line is the same with exception of 0 in the UP layer position. A 0(zero) in a variable position will result in nothing. Nothing will be passed when in the UP layer and press H1 down.


Third line "MapKeyIOUMD(&Joystick,H1R, UP layer with sub-layer active, UP layer no sub-layer, MIDDLE layer sublayer active, Middle layer no sub-layer, DOWN layer sub-layer active, DOWN layer no sub-layer active);"
As you can probably tell. When using Layers, the code can get rather messy and hard to read. Adding a little formating to the text can make things much more clear:
Code:
MapKeyIOUMD(&Joystick,H1R,
            UP layer IN, UP layer OUT,
            MIDDLE layer IN, MIDDLE layer OUT,
            DOWN layer IN, DOWN layer OUT);
Fourth line is a standard single button assignment. No layers or sub-layers assignment in the function.



As you can see there are number of ways to interact with layers to multiple functions in a single button.


I hope this made sense.
__________________
Implement CW and CCW keyboard commands for the encoders!!!!!
For all that is holy and right with the world please!

Last edited by SGT Coyle; 10-27-2019 at 01:19 AM.
SGT Coyle is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 12:52 PM. vBulletin Skin by ForumMonkeys. Powered by vBulletin®.
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.