Jump to content

TARGET - Advanced programming


ivanwfr

Recommended Posts

Thanks,

 

This seems to be the information I was missing. The documentation does not say you cannot declare it twice. Is it just me but I think the Fast Script guide is very light on detail.

 

Is there a more detailed script guide ?

 

So just to confirm, I will have to use the IO layer plus one of either U or D layers to have two shift buttons.

 

Hi speedbird5,

The SetShiftButton function defines all the IO and UMD modifiers keys all at once

You should call it only when you want to change something.

Try this modified version from my description in the first post and tell us if you get what you need.

SetShiftButton(
     &Joystick,  S4        // [i .. Paddle Switch]
   , &Throttle , MSL , MSD // [u .. MIC Switch Aft] , [D .. MIC Switch Down]
   , 0);

 

You could think about it as if you were defining which will be the Shift, Control and Alt keys of a keyboard allowing for 6 different combinations for each of the other 30 + 18 other switches.

 

 

The best place for more details is in the include/target.tmh file where you can see this:

   1 define IOTOGGLE     1
   2 define UDTOGGLE     2
   3 int SetShiftButton( int devI=0       , int indexI=0
   4                           , int devUMD=0 , int indexU=0 , int indexD=0
   5                           , int flag=0)
   6 {
   7     alias io = devI, umd = devUMD;
   8     layer_sw = 0;
   9     if(devI) layer_sw[0] = &&io + (indexI << 1);
  10     layer_sw[1] = flag & 1;
  11     if(devUMD) layer_sw[3] = &&umd + (indexU << 1);
  12     layer_sw[4] = flag >> 1;
  13     if(devUMD) layer_sw[6] = &&umd + (indexD << 1);
  14     layer_sw[7] = layer_sw[4];
  15 }

Link to comment
Share on other sites

Hi speedbird5,

The SetShiftButton function defines all the IO and UMD modifiers keys all at once

You should call it only when you want to change something.

Try this modified version from my description in the first post and tell us if you get what you need.

SetShiftButton(
     &Joystick,  S4        // [i .. Paddle Switch]
   , &Throttle , MSL , MSD // [u .. MIC Switch Aft] , [D .. MIC Switch Down]
   , 0);

 

You could think about it as if you were defining which will be the Shift, Control and Alt keys of a keyboard allowing for 6 different combinations for each of the other 30 + 18 other switches.

 

 

The best place for more details is in the include/target.tmh file where you can see this:

   1 define IOTOGGLE     1
   2 define UDTOGGLE     2
   3 int SetShiftButton( int devI=0       , int indexI=0
   4                           , int devUMD=0 , int indexU=0 , int indexD=0
   5                           , int flag=0)
   6 {
   7     alias io = devI, umd = devUMD;
   8     layer_sw = 0;
   9     if(devI) layer_sw[0] = &&io + (indexI << 1);
  10     layer_sw[1] = flag & 1;
  11     if(devUMD) layer_sw[3] = &&umd + (indexU << 1);
  12     layer_sw[4] = flag >> 1;
  13     if(devUMD) layer_sw[6] = &&umd + (indexD << 1);
  14     layer_sw[7] = layer_sw[4];
  15 }

 

Thanks ivanwfr, I suspect it will give me what I want which is two shift buttons one being IO and one being the U layer.

Link to comment
Share on other sites

  • 4 weeks later...

Hi,

 

I have used a script to combine my Virpil joystick and Thrustmaster throttle into one Thrustmaster Combined device.

 

It used to show up with all buttons and axes in the Device Analyser within the Target script editor.

 

Now it doesn’t.

 

My Xwind rudder pedals show up as does my EDTracker wireless, but the combined device doesn’t show.

 

All buttons and axes show in DCS.

 

I have uninstalled and reinstalled the latest version of the Target software but the problem remains.

 

The individual devices do show up in the Device Analyser.

 

Ironically, the combined device shows up in the DIview which comes with the Virpil software.

 

Any ideas.


Edited by speedbird5
Link to comment
Share on other sites

Hi,

 

FWIW I had issues with Device Analyzer with just my Warthog.

 

It was when I was using Windows 10 1803 and 1809.

Since upgrading to 1903 it's working again.

 

The Game Controller control panel applet did show the combination working fine and , of course, everything worked fine in game.

 

I know not everyone had the same issue, so, YMMV if you happen to be on Win10 and using v 180x.

 

On another topic, I'd be keen to know how you got the Virpil stick working as a combined Thrustmaster device in the first place.

 

Hope this helps

dmonds

Link to comment
Share on other sites

FWIW I had issues with Device Analyzer with just my Warthog.

 

It was when I was using Windows 10 1803 and 1809.

Since upgrading to 1903 it's working again.

 

The Game Controller control panel applet did show the combination working fine and , of course, everything worked fine in game.

 

I know not everyone had the same issue, so, YMMV if you happen to be on Win10 and using v 180x.

 

 

I am on Win 10 Pro x64 version 1909. I suspect the problem may be 1909 as I have only recently updated and this problem just occurred. It was definitely working on 1903.

 

On another topic, I'd be keen to know how you got the Virpil stick working as a combined Thrustmaster device in the first place.

 

To clarify, I am using a Virpil Mongoose T-50 base and a TM Warthog Flight Stick.

 

To get TARGET to recognize the base, in the VPC Software Suite, you have to change the VID/PID of the device to VID = 044F, PID = 0402 as shown in the image attached.

 

From memory, you first have to load the VPC device then enter the VID/PID then Reset Windows name then save the VPC device then load it again.

 

After that, TARGET thiinks the Virpil base is a Thrustmaster Stick.

 

Here is a post which may help you....

 

https://forum.virpil.com/index.php?/topic/220-hybrid-t-50-base-with-warthog-stick/&do=findComment&comment=1965

 

If you use a different stick to the Warthog one, like the Virpil Mongoose Flight Stick or Warbrd, I am not sure what would happen to the mapping as the buttons are different to the Warthog flight stick.

857666947_Annotation2019-12-09204507.thumb.jpg.aeda893dc5177b6949a5eee5bf0e8332.jpg


Edited by speedbird5
Link to comment
Share on other sites

  • 1 month later...

After building a new system AMD X570 system, I was having issues getting the TARGET Device Analyzer to enumerate my Combined Controller. I updated my chipset drivers and all my USB issues resolved, but still no DA. Uninstalled and reinstalled TARGET and I'm back in business. All works as advertised.

Just thought that might be helpful.

Night Ops in the Harrier

IYAOYAS


 
Link to comment
Share on other sites

Just repaired my TARGET DA by updating my Asrock z370 Intel® Software Development Emulator Software

| VR goggles | Autopilot panel | Headtracker | TM HOTAS | G920 HOTAS | MS FFB 2 | Throttle Quadrants | 8600K | GTX 1080 | 64GB RAM| Win 10 x64 | Voicerecognition | 50" UHD TV monitor | 40" 1080p TV monitor | 2x 24" 1080p side monitors | 24" 1080p touchscreen |

Link to comment
Share on other sites

Hi All,

not really advanced programming per-say, but a semi neat way of resolving the VR zoom problem:

 

KeyAxis(&Throttle, THR_FC, 0 , AXMAP2 (3, DX77, DX76, PULSE+DX75))

 

then map DX77 to spyglass, and 76 to VR zoom...

 

the result is you get a reall nice progression on the Friction control lever from normal to full zoom :)

SYSTEM SPECS: Hardware Intel Corei7-12700KF @ 5.1/5.3p & 3.8e GHz, 64Gb RAM, 4090 FE, Dell S2716DG, Virpil T50CM3 Throttle, WinWIng Orion 2 & F-16EX + MFG Crosswinds V2, Varjo Aero
SOFTWARE: Microsoft Windows 11, VoiceAttack & VAICOM PRO

1569924735_WildcardsBadgerFAASig.jpg.dbb8c2a337e37c2bfb12855f86d70fd5.jpg

Link to comment
Share on other sites

KeyAxis(&Throttle, THR_FC, 0 , AXMAP2 (3, DX77, DX76, PULSE+DX75))

 

then map DX77 to spyglass, and 76 to VR zoom...

 

and DX75 is?

| VR goggles | Autopilot panel | Headtracker | TM HOTAS | G920 HOTAS | MS FFB 2 | Throttle Quadrants | 8600K | GTX 1080 | 64GB RAM| Win 10 x64 | Voicerecognition | 50" UHD TV monitor | 40" 1080p TV monitor | 2x 24" 1080p side monitors | 24" 1080p touchscreen |

Link to comment
Share on other sites

Hi All,

Semi neat way of resolving the VR zoom problem:

 

KeyAxis(&Throttle, THR_FC, 0 , AXMAP2 (3, DX77, DX76, PULSE+DX75))

 

then map DX77 to spyglass, and 76 to VR zoom...

 

the result is you get a reall nice progression on the Friction control lever from normal to full zoom :)

 

 

Very nice.

Although I use my FL for thrust nozzles and landing gear ...

I never thought of combining the two zooms on one button/switch. I suppose you could get the same effect with the TEMPO command.

 

 

Thanks, I'll try that tonight.

Night Ops in the Harrier

IYAOYAS


 
Link to comment
Share on other sites

Hi guys,

 

Has anyone had experience with the TARGET system() function on Windows 10?

 

I've used this method to grab the Time of Day and add to console or log file messages as follows...

int TOD;
system("time /T > c:\\tod.txt");
fp = fopen("c:\\tod.txt", "r");
if (fp) {
 fread(TOD, 1, 5, fp);
 fclose(fp);
}

 

I'm really just interested in any examples of working script code which uses system() under Win10.

 

Cheers

dmonds


Edited by dmonds
Link to comment
Share on other sites

  • 2 weeks later...

TARGET Script not Hiding Individual Controllers

 

Hi all,

 

I have a TARGET script which used to combine both my TM Throttle and Joystick into one device and used to hide the individual controllers.

 

Now, the script creates the Thrustmaster combined device but does not hide the individual controllers which causes havoc with controller mapping in many games.

 

I am on windows 10 x64 version 1909 with everything up to date using the latest versions of TM driver software and TARGET script.

 

I have tried the following to no avail :

 

Updated motherboard chipset drivers.

 

In device manager on both USB devices and Human Interface Device controllers unchecked the "Allow the computer to turn off this device"

 

Uninstalled and reinstalled the driver and target software numerous times.

 

The only fix seems to be reboot or unplug and replug the controllers but this is a PITA.

 

Any help greatly appreciated.

 

EDIT: I think I may have found the solution...full credit to Clorydric at this post https://forums.eagle.ru/showpost.php?p=4050109&postcount=15

 

Kill the Windows Store app.

 

You can do this through task manager directly or by creating shortcut to:

 

taskkill.exe /f /im winstore.app.exe

 

 

For the mods, perhaps make this a sticky in the input output forums ?


Edited by speedbird5
Link to comment
Share on other sites

Hi all,

 

I have a TARGET script which used to combine both my TM Throttle and Joystick into one device and used to hide the individual controllers.

 

Now, the script creates the Thrustmaster combined device but does not hide the individual controllers which causes havoc with controller mapping in many games.

 

I am on windows 10 x64 version 1909 with everything up to date using the latest versions of TM driver software and TARGET script.

 

I have tried the following to no avail :

 

Updated motherboard chipset drivers.

 

In device manager on both USB devices and Human Interface Device controllers unchecked the "Allow the computer to turn off this device"

 

Uninstalled and reinstalled the driver and target software numerous times.

 

The only fix seems to be reboot or unplug and replug the controllers but this is a PITA.

 

Any help greatly appreciated.

 

EDIT: I think I may have found the solution...full credit to Clorydric at this post https://forums.eagle.ru/showpost.php?p=4050109&postcount=15

 

Kill the Windows Store app.

 

You can do this through task manager directly or by creating shortcut to:

 

taskkill.exe /f /im winstore.app.exe

 

 

For the mods, perhaps make this a sticky in the input output forums ?

 

 

I seem to have been able to avoid this same problem recently by disconnecting and reconnecting my WH usb plugs after PC reboot. You can usually tell if you are going to have problems when you try to run your script because it takes a while for it to compile and run the profile, when it should be almost imediate. But now I just replug run the profile, and that has been working out for me.

Link to comment
Share on other sites

Not too sure what you are trying to achieve here.

 

But, you can simply include “file.tmc” in your main script file.

 

Otherwise, if what you are looking to do is remap one or more keys, you can do this from within a function/routine, then when you want to switch , just call the function.

 

Dmonds

Link to comment
Share on other sites

Not too sure what you are trying to achieve here.

 

But, you can simply include “file.tmc” in your main script file.

 

Otherwise, if what you are looking to do is remap one or more keys, you can do this from within a function/routine, then when you want to switch , just call the function.

 

Dmonds

 

Something along those lines, but I wanted to able to switch airplane profiles, and to include remaps for all aircraft within a single file, sounds like big and messy and confusing as hell to acomplish.

Link to comment
Share on other sites

Something along those lines, but I wanted to able to switch airplane profiles, and to include remaps for all aircraft within a single file, sounds like big and messy and confusing as hell to acomplish.

 

All those things...but do-able!

Link to comment
Share on other sites

They are do able, but, I'm not sure desirable, it's going to be a bitch to maintain...

SYSTEM SPECS: Hardware Intel Corei7-12700KF @ 5.1/5.3p & 3.8e GHz, 64Gb RAM, 4090 FE, Dell S2716DG, Virpil T50CM3 Throttle, WinWIng Orion 2 & F-16EX + MFG Crosswinds V2, Varjo Aero
SOFTWARE: Microsoft Windows 11, VoiceAttack & VAICOM PRO

1569924735_WildcardsBadgerFAASig.jpg.dbb8c2a337e37c2bfb12855f86d70fd5.jpg

Link to comment
Share on other sites

Well if it can't switch profiles on the fly, I'm not gonna bother, too much assle. A few keys is one thing, the whole set for several planes is going to be a nightmare.

 

 

OK. Try this.

 

 

One make a .tmc that acts like a master. It has all the axis mapping and shift layers defined, calls the target.tmh, and includes any other includes you want.Other includes may be:

 

  • Macros files for each Module (.ttm)
  • Function files (.tmh) for doing special things like splitting the 2 stage trigger so only one stage fires at a time.
  • Control mapping files (.tmh) for each Module that you can call up at will.

I did this with the F14 Module. Wanted to be able to switch seats and control .tmc on the fly.

 

 

Darkoz got me there with a great little example. Here

But of course I made this one .tmc. I can easily divide the key mapping into 1 .tmc and 2 .tmh files. Would work the same and be easier to manage. I also believe in the use of macro files (.tmm). I have a macro file for the pilot and one for the RIO. That allows me to reuse keys and DX buttons.

 

 

I just wish I could get my sound ques to work like in CTS.

 

 

Hope this helps.

Night Ops in the Harrier

IYAOYAS


 
Link to comment
Share on other sites

Thank you SGT Coyle, I think I can definitely start doing something with that. Thank you very much!

 

I just answered this question over at SimHQ with a much more extensive example. Here's the topic:

https://simhq.com/forum/ubbthreads.php/topics/4021268/several-dcs-profiles-in-one#Post4021268

 

I have a profile for Train Sim World where I use MSP (shift button) plus LDGH on the Warthog Throttle to cycle through some 20 different locomotive profiles in a single .tmc file. I use the LEDs on the Throttle to display a binary code count of what profile I'm on, as well as make beep sounds of increasing tone so I can quickly cycle through to the correct profile and know which profile I am on without having to alt-tab out of the game. The profiles start at 1, go to 20, and then cycle back to 1. I also use printf() statements to the TARGET script editor console to say what profile I have loaded.

 

It is a lengthy example, so I won't repost any of it here. It is pretty simple and very similar to what SGT_Coyle was just talking about.

 

Sadly, there is no way to tell TARGET to load and run a different script. But as others mentioned, you can certainly break things down into as many different files to keep things organized as you like, just "including" those files in the main .tmc.

 

It isn't too difficult to maintain either. Just be structured in how you lay out your functions, or you can even use separate files for each aircraft. Many ways to do it. Once you have the organization figured out, it is easy from then on.

Link to comment
Share on other sites

Hi guys,

 

Has anyone had experience with the TARGET system() function on Windows 10?

...

I'm really just interested in any examples of working script code which uses system() under Win10

 

Here is an example I use to call an external program called wbeep.exe to give me audible feedback in my TARGET Scripts.

 

//******************************************************************
// Beep()
//	Beep function - calls wbeep.exe which must be located at the path below.
int Beep(int freq, int duration)		// Beep(frequency, duration in ms)
{
   if (!freq | !duration) return 0;		// Ignore beep - 0 given as freq or duration

   char buffer;Dim(&buffer, 64);
   sprintf (&buffer, "spawn c:\\bin\\wbeep.exe %d %d", freq, duration);
   system(&buffer);
}

 

Nothing amazing except to point out, this shows how to send parameters to the external program. I'm pretty sure this example has been given in this thread a long time ago.

 

One thing to remember about using system() is the external program is run by the TARGET Windows service, not by the TARGET Script editor. So permissions are determined by the TARGET Service's permissions. Also, the TARGET Service does not have a console or any method to display information or ask for a response from the user. Some external programs will not run properly because of this. Like I have tried to use a program to play a .WAV file (better than a beep, right?), but it didn't work. I forget why, but it had something to do with the idea that my wbeep.exe program is using very simple low level function calls, but the program that tried to play the .WAV file needed a user console or access to higher level functions that the TARGET Service did not have access to. It's been years since I tried, so I forget the exact issues. Others (probably on this fourm topic) have discussed this.

 

Also, I have seen when I try to make a beep longer than 1 second, it gets truncated to 1 second, as if the TARGET Service kills off the external process at 1 second. Perhaps to prevent a run away program (??).

Link to comment
Share on other sites

Hello @Drakoz, I have been able to put something together that is working very much like you describe after SGT Coyle pointed me in the right direction. I still haven't looked at your code to see what else I can learn, but I'll do it later.

I am very much implementing it the way you are, down to the Binary code to display aircraft, and the print to Script editor window. A bit redundant now that I had the idea after helping SGT coyle in another thread, of having spoken wave files with the aircraft's designation being played when switching profiles. I used an online site to generate the wav files from text to speech.

I am also using separate files for each aircraft to keep things simple, I have one main file and then secondary .tmc's that get called from the main one.

 

What I'm having difficulty now is adjusting the backlight intensity on the Fly, this is what I'm doing so far:

 

include "targetdx128.tmh"

 

 

int count=127;

//program startup

int main()

{

 

if(Init(&EventHandle)) return 1; // declare the event handler, return on error

 

//add initialization code here

SetKBRate(32, 50);

SetKBLayout(KB_ENG);

SetShiftButton(&Joystick, S3, &Joystick, H4U, H4D); // IO Shift and UMD Setup

 

 

ActKey(PULSE+KEYON+LED(&Throttle, LED_INTENSITY, count)); //set Backlight Intensity

 

printf("Running Profile: DCS Default \xa");

 

//Throttle

//Throttle Buttons

 

MapKeyIOUMD(&Throttle, CHF, EXEC("ProfileA10C();"), DX36,

DX36,

CHAIN(EXEC("count = count + 50;"), D(5), LED(&Throttle, LED_INTENSITY, count)), DX36,0);

 

MapKeyIOUMD(&Throttle, CHB, 0, DX37,

DX37,

CHAIN(EXEC("count = count - 50;"), D(5), LED(&Throttle, LED_INTENSITY, count)), DX37,0);

 

 

printf("----------------------------------\xa");

 

 

 

 

} // end main()

 

 

 

//event handler

int EventHandle(int type, alias o, int x)

{

DefaultMapping(&o, x);

 

//add event handling code here

}

 

 

I only pasted here the relevant lines.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...