Jump to content

Scripting Is it possible to hold a "shift" for a delay then release?


Weegie

Recommended Posts

So I'm new to scripting and pretty green at it, so go easy on me.

 

TARGET gives you the Upper,Middle,Down & Shift Commands to set up to 6 functions onto one button.

 

I was thinking that what I'd like to be able to do is rather than have the "Shift" Toggle or Pulse it would be great if I could hold it down for a set delay, maybe 3-5 seconds then release.

 

This way I could hit the button I have allocated to "Shift" then the button I want to operate when shifted. After that the "Shift" would then switch itself off.

 

However as of now I can see ways to easily do that with Dx buttons or Keyboard comands but not with the physical buttons on the throttle.

 

I do not even know if it's possible but thought I'd ask

Link to comment
Share on other sites

This way I could hit the button I have allocated to "Shift" then the button I want to operate when shifted. After that the "Shift" would then switch itself off.

 

 

Can you be more specific? What do you want to do? What buttons do you have in mind?

 

 

I have a couple of thoughts, but I have to look at some scripts before I go any further.

Night Ops in the Harrier

IYAOYAS


 
Link to comment
Share on other sites

Hi SGT Coyle

 

I'm struggling to think how I could better explain what I want to do.

I use the APDIS swtich to activate the "SHIFT" mode

 

When referring to "SHIFT" I mean this command

 

SetShiftButton(&Throttle, APDIS, &Throttle, APPAT, APALT, IOTOGGLE);

 

So the SHIFT key is operated by APDIS and toggles at the moment.

 

What I was wanting was a way to enable the SHIFT function for a fixed time (say 3 seconds) then it would toggle itself off automatically, as opposed to having to give it another press to disable the SHIFT function

Link to comment
Share on other sites

OK.

 

First things first. Everything in the code section is credited to Drakoz.

Particularly the code below, that was originally posted in 3984086.

 

 

Copy-n-Paste the code below into a NEW .tmc in the editor. It will do as you ask. A 3 sec toggle attached to the APDIS button on the throttle base.

Test it with the Event Tester and first stage trigger [TG1].

Out state = 1

In state = 2 for 3 secs

 

 

Good Hunting!

 

 

 

include "target.tmh"

// Define virtual buttons for IO Shift and UMD mode for Warthog JoystickF18
define VBI    40    // Mode I virtual button
define VBU    41    // Mode U virtual button
define VBD    42    // Mode D virtual button

int main()
{
   if(Init(&EventHandle)) return 1;
   
   SetShiftButton(&Throttle, VBI, &JoystickF18, VBU, VBD, 0);        // IO Shift and UMD Setup (%DEV1, I button, $DEV, U, D, Toggle settings)
   //    The line directly below is an edit to original code to provide a 3 sec delay to the Middle In Shift State.
   MapKey(&Throttle, APDIS, CHAIN(
                                   EXEC("Throttle[VBI]=1; DefEventHandler(EV_HID_INPUT_DATA, &Throttle, VBI);"),
                                   D(3000),
                                   EXEC("Throttle[VBI]=0; DefEventHandler(EV_HID_INPUT_DATA, &Throttle, VBI);")
       )                                    
   );
   
   //MapKey(&Throttle, APDIS, EXEC("Throttle[VBI]=1; DefEventHandler(EV_HID_INPUT_DATA, &Throttle, VBI);"));
   //MapKey(&Throttle, S2, EXEC("Throttle[VBI]=0; DefEventHandler(EV_HID_INPUT_DATA, &Throttle, VBI);"));
   
   //MapKey(&JoystickF18, H1U, EXEC("JoystickF18[VBU]=1; DefEventHandler(EV_HID_INPUT_DATA, &JoystickF18, VBU);"));
   //MapKey(&JoystickF18, H1D, EXEC("JoystickF18[VBU]=0; DefEventHandler(EV_HID_INPUT_DATA, &JoystickF18, VBU);")); 
   //MapKey(&JoystickF18, H1L, EXEC("JoystickF18[VBD]=0; DefEventHandler(EV_HID_INPUT_DATA, &JoystickF18, VBD);")); 
   //MapKey(&JoystickF18, H1R, EXEC("JoystickF18[VBD]=1; DefEventHandler(EV_HID_INPUT_DATA, &JoystickF18, VBD);")); 
   
   
   MapKey(&Throttle, APDIS, CHAIN(
                                   EXEC("Throttle[VBI]=1; DefEventHandler(EV_HID_INPUT_DATA, &Throttle, VBI);"),
                                   D(3000),
                                   EXEC("Throttle[VBI]=0; DefEventHandler(EV_HID_INPUT_DATA, &Throttle, VBI);")
       )                                    
   );

   // Test the result
   MapKeyIOUMD(&JoystickF18, TG1, 
       '4',        // IU
       '3',        // OU
       '2',        // IM
       '1',        // OM
       '6',        // ID
       '5'        // OD
   );        
}

int EventHandle(int type, alias o, int x)
{
   DefaultMapping(&o, x);
}

Night Ops in the Harrier

IYAOYAS


 
Link to comment
Share on other sites

So just to close this out.

I copied the code and originally it wasn't working until I noticed it was configured for an F-18 Stick.

After deleting the references to the F-18, it works a treat.

 

Thanks again to Sgt Coyle for altering the script and to Drakoz for for his original code, I would never have managed this myself and its opened a whole new set of commands that I can use with the DefEventHandler

Link to comment
Share on other sites

Thanks again to Sgt Coyle for altering the script and to Drakoz for for his original code, I would never have managed this myself and its opened a whole new set of commands that I can use with the DefEventHandler

 

 

No problem. It makes my day when people use TARGET to solve interesting problems.

Night Ops in the Harrier

IYAOYAS


 
Link to comment
Share on other sites

I thought I'd try to be clever with the code but failed.

 

 

 

I was thinking that I could introduce a TEMPO command so that a short press would give me a pulse on for 3 seconds then a long press would toggle the function (1st long press would turn on the "SHIFT" 2nd long press switch it off)

 

When I tried that the first time run the code for a short press will give me the 3 second pulsed shift but subsequent short presses don't.

 

If I map of each of the functions to separate buttons I can have a delayed pulse and a toggle but can't get it to work with the TEMPO.

 

 

The second long line is the CHAINed 3 second delay, the bottom 2 are the the CHAINed commands I sequence with a long press.

 

 

TARGET Scripting is fun but frustrating at the same time

 

 

 

MapKey (&Throttle, APDIS, 
   TEMPO(CHAIN(EXEC("Throttle[VBI]=1; DefEventHandler(EV_HID_INPUT_DATA, &Throttle, VBI);"), LED(&Throttle,LED_ONOFF, LED_CURRENT+LED2),D(3000),EXEC("Throttle[VBI]=0; DefEventHandler(EV_HID_INPUT_DATA, &Throttle, VBI);"),LED(&Throttle, LED_ONOFF, LED_CURRENT-LED2)),
   SEQ(CHAIN(EXEC("Throttle[VBI]=1; DefEventHandler(EV_HID_INPUT_DATA, &Throttle, VBI);"),LED(&Throttle, LED_ONOFF, LED_CURRENT+LED2)),
   CHAIN(EXEC("Throttle[VBI]=0; DefEventHandler(EV_HID_INPUT_DATA, &Throttle, VBI);"),LED(&Throttle, LED_ONOFF, LED_CURRENT-LED2))),500));

Link to comment
Share on other sites

Try this:

MapKey (&Throttle, APDIS, TEMPO(
                                   CHAIN(
                                       EXEC("Throttle[VBI]=1; DefEventHandler(EV_HID_INPUT_DATA, &Throttle, VBI);"), 
                                       D(3000), 
                                       EXEC("Throttle[VBI]=0; DefEventHandler(EV_HID_INPUT_DATA, &Throttle, VBI);")
                                       ),
                                   SEQ(
                                       EXEC("Throttle[VBI]=1; DefEventHandler(EV_HID_INPUT_DATA, &Throttle, VBI);"),
                                       EXEC("Throttle[VBI]=0; DefEventHandler(EV_HID_INPUT_DATA, &Throttle, VBI);"),
                                       500)
                                   )
                                );

 

 

It helps to format your code. Easier to see mistakes and keeps it readable.

 

 

Did your code give an error or just not work?

Night Ops in the Harrier

IYAOYAS


 
Link to comment
Share on other sites

Will do & thanks again

 

 

Well like I said the code compiled and the first short press would give me a 3 second shift actuation, after that it would just toggle.

 

 

The sequenced long press worked fine, I'm not sure if it has something to do with the LED commands. I tried omitting the virtual shift code but even just trying to get the LEDs to sequence would not work. Exactly the same result, the short shift function would work first try (holding the shift for 3 seconds and then releasing) but subsequent presses just seemed to randomly light the LEDs.

 

 

Ok just tried your code and it's doing something similar if not the same, I don't doubt you and I'm grateful for the assistance. I'm starting to think there is something else in the program code that's throwing it out and stopping it from working correctly.

 

 

Later I'll try the code on it's own in a simple profile and see if it works there

 

 

Once again many thanks for the help

Link to comment
Share on other sites

Try this:

Paste this into your script. It is just the APDIS command.

MapKey(&Throttle, APDIS, TEMPO(

                               CHAIN(    
                                   EXEC("Throttle[VBI]=1; DefEventHandler(EV_HID_INPUT_DATA, &Throttle, VBI);"),
                                   LED(&Throttle,LED_ONOFF,LED_CURRENT+LED1),
                                   D(3000),
                                   EXEC("Throttle[VBI]=0; DefEventHandler(EV_HID_INPUT_DATA, &Throttle, VBI);"),
                                   LED(&Throttle,LED_ONOFF,LED_CURRENT-LED1)
                                   ),    
                                   
                               SEQ(
                                       CHAIN(
                                           EXEC("Throttle[VBI]=1; DefEventHandler(EV_HID_INPUT_DATA, &Throttle, VBI);"),
                                           LED(&Throttle,LED_ONOFF,LED_CURRENT+LED1)
                                           ),
                                       CHAIN(
                                           EXEC("Throttle[VBI]=0; DefEventHandler(EV_HID_INPUT_DATA, &Throttle, VBI);"),
                                           LED(&Throttle,LED_ONOFF,LED_CURRENT-LED1)
                                           )
                                   ),
                               500)
                       );

Night Ops in the Harrier

IYAOYAS


 
Link to comment
Share on other sites

Thank You Sir

 

I tried your code on the APDIS same result, extremely flaky

 

However I copied the original code I wrote for the APDIS to the joystick S3 button and it worked perfectly, so then tried the code on LDGH, worked as well.

 

Then the Lightbulb glowed dimly into life

 

Rather than use APDIS I'd try APENG............VOILA!!! All working exactly the way I wanted.

 

Thank you so much for all the assistance, you've helped me enormously, very grateful for the advice and for opening my eyes into even more advanced coding

Link to comment
Share on other sites

just define a flag instead, and use EXEC to trig it.

 

Ill name it 'shift'

 

char shift;

 

code for activate: CHAIN( EXEC(" shift=1;"), D(3000), EXEC(" shift=0;"));

 

code for shifted action: EXEC(" if (shift) actkey(KEYON+ 'a'); else actkey( KEYON+ 'b');");

 

It's not copy paste, but written from memory. This way you can make an unlimited shift keys and combine them if you need to.

Advanced is not always the way to go. :)

[sIGPIC][/sIGPIC]

Win10 64, Asus Maximus VIII Formula, i5 6600K, Geforce 980 GTX Ti, 32 GB Ram, Samsung EVO SSD.

Link to comment
Share on other sites

What SGT posted works great if you need the IO Shift button to influence all your MapKeyIO() functions the intended way. But for "shifting" one button or a small group of buttons, I'll just use flags as Svend said. It is sometimes easier than using the sometimes complicated MapKeyIOUMD() functions which get messy due to formatting. More often, though, I use flags just for special shifted states.

 

For example, I might have a single button that I want to be multi-functional so I'll have it call a function (e.g. LTB calls LTB_Handler() and LTB_Handler may do a dozen different things depending on a bunch of other flags, or other enabled switches).

 

(this is untested and incomplete!!)

int flag1, flag2;
int main()
{
...
MapKey(&Throttle, LTB, EXEC("LTB_Handler();");
...
}

int LTB_Handler()
{				// just using psuedo code, not real C
if flag1 and flag2 {
	if FLAPU {ActKey this and that}
	else {ActKey that and this}
	// Remapping an existing key due to LTB, flags, and FLAPU state)
	MapKey(&Throttle, APENG, PULSE+MyNewMapping);  
}
if flag1 and (not flag2) {
	// Mapping back to original function perhaps...
	MapKey(&Throttle, APENG, PULSE+MyOriginalMapping);  
}
if (blah blah blah) {}  		// you get the idea
}

 

Ya, I know, duh. I'm just making the point that depending on how you want your code to look, sometimes using special functions like the above might be easier to read, or easier to edit after the fact. You could create [ANYBUTTON]_Hander() functions for every button and switch and then freely use flags and all other kinds of information to change what a button does on the fly without having to figure out multiple EXEC("....") functions inline of a MapKey() function. In fact, you could set up an entire template of using the [ANYBUTTON]_Handler() functions and all the MapKey() functions already configured to call the Handlers, and then all your programming could be done using C in the Handler functions without having to type all those MapKey() and EXEC() commands again. Yes, it defeats the purpose of all the TARGET MapKey commands, but has other powerful uses.

 

It's TARGET! There are several ways to do everything.

 

Using EventHandle() for all functions

 

You could even put all this in EventHandle() using 100% pure C code and no MapKey() functions at all. For example, for a long time I used the following to activate PTT in VAC (Voice Activated Control or Voice Attack) and cause a chirp like beep to tell me it happened. MSP is my IO Shift key. The Beep function calls an external CMD prompt program (c:\bin\wbeep.exe) that just causes a system beep. I or other people have posted such a program. I have a link below to download the one I created if you care to try it.

 

//tested and working, paste in your existing program and comment out 
//the Beep() lines if you don't have wbeep.exe. 

define	VAC_PTT		'a'

//******************************************************************
//	Beep function - calls wbeep.exe which must be located at the path below.
int Beep(int freq, int duration)		// Beep(frequency, duration in ms)
{
   char buffer;Dim(&buffer, 64);
   sprintf (&buffer, "spawn c:\\bin\\wbeep.exe %d %d", freq, duration);
   system(&buffer);
}

//******************************************************************
int EventHandle(int type, alias o, int x)
{

// MSP - Allow IO shift button to cause an action (PTT for VAC).
if ((&o == &Throttle) & (x == MSP)) {
	if (o[MSP]) {				// If Shift key pressed,	
		Beep(8000,30);			//     Beep for feedback
		ActKey(KEYON+VAC_PTT);	//     Press and hold VAC PTT key
	} 
	else {						// When Shift key released,
		ActKey(VAC_PTT);		//     Release VAC PTT key.
	}
}

DefaultMapping(&o, x);
}
//******************************************************************

 

In older versions of TARGET, I think it wasn't allowed to apply a MapKey() to the IO Shift button - but I was probably just confused. Anyway, this code shows an example of causing an action on a given button press without having to use a MapKey(...EXEC()) pair. You could call any function from EventHandle() like this and even program the entire set of your controllers using pure C code in this way. But make sure your code is efficient because every time an event occurs, including moving an axis which means thousands of EventHandle() calls per second, EventHandle() gets called and your code must be executed. Smart ordering of your if else statements could prevent bottlenecks. But you could use entire if else structures to do complex sets of commands. Ya, duh again. My point is, you can program your entire Thrustmaster Operation using pure C code.

 

 

Another way to do a 3 Second SHIFT key

 

Regarding wanting to have the shift key be "pressed" for 3 seconds, you might also look at REXEC(), or even better, DeferCall(). DeferCall() can be used like below. This allows us to avoid complex EXEC() commands in our MapKey() commands

 

(this is untested and incomplete!!)

//******************************************************************
// Define virtual buttons for IO Shift and UMD mode for Warthog JoystickF18
define VBI    40    // Mode I virtual button
define VBU    41    // Mode U virtual button
define VBD    42    // Mode D virtual button

int main()
{
...
MapKey(&Throttle, APENG, EXEC("APENG_Shifted(0);");
...
}

//******************************************************************
int APENG_Shifted()
{
Throttle[VBI]=1; 
DefEventHandler(EV_HID_INPUT_DATA, &Throttle, VBI);
LED(&Throttle,LED_ONOFF,LED_CURRENT+LED1);
DeferCall(3000, &APENG_UnShifted, 0);   // Calls APENG_UnShifted() in 3 seconds
}

//******************************************************************
int APENG_UnShifted(int x) {	// x is just a dummy var used to make DeferCall happy
Throttle[VBI]=0; 
DefEventHandler(EV_HID_INPUT_DATA, &Throttle, VBI);
LED(&Throttle,LED_ONOFF,LED_CURRENT-LED1);
}

 

This uses the virtual buttons like the example SGT posted, but it moves the code out of the EXEC() commands into two functions. One to enable the APENG shift mode and one to disable it again. The APENG_UnShifted() function is called 3 seconds after the APENG_Shifted() function using a DeferCall() at the end of APENG_Shifted().

 

The command line used above is:

 

DeferCall(3000, &APENG_UnShifted, 0);

which is the same as calling APENG_UnShifted as follows:

 

APENG_UnShifted(0);

Defercall must have 3 parameters (explained below).

 

3000 = 3 seconds, the length of delay before it calls APENG_UnShifted().

 

&APENG_UnShifted - This is just how we have to list the function to be called. The & means an alias for APENG_UnShifted(). It is the same as &Throttle, except that in this case, the & refers to an alias for a function, APENG_UnShifted(). In normal C, this would be a pointer to a function using * and &, but TARGET simplifies this with what they call an alias. If you know C, you know what I mean (and how I haven't totally said it right). If you don't know C very well, don't worry about it. It just works. :)

 

0 - the 0 is simply because DeferCall must have a parameter to pass into the referred function. APENG_UnShifted() doesn't need a parameter, but to appease Defercall, I gave it a single parameter (int x). Otherwise we get an error with DeferCall().

 

In the TARGET user manual, they give an example as follows:

 

MapKey(&Joystick, H4U, EXEC("ActKey(KEYON+PULSE+'a'); DeferCall(1000, &ActKey, KEYON+PULSE+'b');
DeferCall(2000, &ActKey, KEYON+PULSE+'c');));

 

In this example, they are calling ActKey() and passing the parameters KEYON+PULSE+'b' or KEYON+PULSE+'c'. This is the same as ActKey(KEYON+PULSE+'b') and ActKey(KEYON+PULSE+'c') respectively.

 

 

SHIFTING buttons wihtout using the IO or UMD Shift buttons at all

 

Or let's just forget using TARGET style IO SHIFT and UMD buttons along with MapKeyIO() or MapKeyIOUMD(), and do the following. Here, we remap a bunch of buttons just for 3 seconds due to pressing APENG, and only using MapKey() for more readable code.

 

// Tested and working - just paste and compile

//******************************************************************
include "target.tmh"

// Disable Beep() output - disabled =0, enabled =1
define	BeepEnabled		0		

// Handle for REXEC
define	REXEC_HalfSecHandler	1	

int main()
{
if(Init(&EventHandle)) return 1;

// Axis, MapKey etc. funcs here ...
// ...
APENG_UnShifted(0);	// Set default unshifted functions
MapKey(&Throttle, APENG, EXEC("APENG_Shifted();"));
}

//******************************************************************
// Unshifted commands - default MapKey() Setup
int APENG_UnShifted(int x) {	// x is just a dummy variable required by DeferCall
printf("APENG_Unshifted\xa");

ActKey(PULSE+KEYON+LED(&Throttle, LED_ONOFF, LED_CURRENT-LED3));
//MapKey(blah blah blah);		// Let's remap them back to their normal "unshifted" functions
//MapKey(blah blah blah);
//MapKey(blah blah blah);
//MapKey(blah blah blah);
//MapKey(blah blah blah);
Beep(7000,100);		// low beep
}

//******************************************************************
// Shifted commands - remap for 3 seconds when APENG is pressed
int APENG_Shifted()
{
printf("APENG_Shifted\xa");
ActKey(PULSE+KEYON+LED(&Throttle, LED_ONOFF, LED_CURRENT+LED3));
//MapKey(blah blah blah);		// Let's remap some buttons and switches to a "shifted" state
//MapKey(blah blah blah);
//MapKey(blah blah blah);
//MapKey(blah blah blah);
//MapKey(blah blah blah);
Beep(8000,100);		// high beep
DeferCall(3000, &APENG_UnShifted, 0);   // Calls APENG_UnShifted() in 3 seconds
}

//******************************************************************
// 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 (!BeepEnabled ) return 0;			// Disable beep sounds
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);
}

//******************************************************************
int EventHandle(int type, alias o, int x)
{
DefaultMapping(&o, x);
}
//******************************************************************

 

Again the point above is the concept of putting all shifted or flagged key outputs in a separate function that is called when the "shift" of flagging state occurs, and we just remap everything on the fly. I kind of hate using MapKeyIO() or MapKeyUMD)(), which isn't too bad, but I really hate using MapKeyIOUMD(). It just gets messy when I start adding complex functions for all 6 possible states, and even worse when I want some MapKeyIOUMD functions to be different depending on the state, but I want other buttons to be the same for all states. Moving some of this, for the more complex Mapping arrangements, into separate functions like above can simplify viewing and editing the code later.

 

The above uses my Beep() function, but it is disabled in the script by setting "define BeepEnabled 0". But you may want to try the beep because it is good feedback to know if the 3 second period has ended. If you want to try the beep, you'll need the wbeep.exe program (placed in c:\bin\wbee.exe in my example below). You can download it as part of this package http://akhara.com/drop/TrainSimWorld/TSW_TARGET_Script_Drakoz_v2_1.zip which is a script I wrote for Train Sim World. Sorry I don't have a download link for just the wbeep.exe program by itself. The above includes source code for wbeep.exe as well. Look in the "wbeep" folder in the .ZIP. It just calls the Windows system function beep() - literally that is it.

 

 

In Summary

 

The key to all this is to recognize that the functions in main() get called once to setup all the Axis and MapKey... functions. Then those functions are never called again period. From then on, EventHandle() deals with all button and axis events by using a lookup table. That table was defined by the MapKey commands or Axis commands.

 

EventHandle() is our hook to do anything we want because it gets called anytime an event occurs. But note, there is no freely running code here. None of the examples above will work unless an event happens to call EventHandle(). That's fine, because through MapKey(EXEC("Handler();")); calls, we can make our own new functions to do anything we want. Or we can do it through EventHandle() directly.

 

 

Making your own Event Handler - called at a regular interval without waiting for an event

 

What if you wanted to create your own Handler that was called every half second regardless of a button press. This doesn't have much to do with the above, but just contemplating other nonstandard ways to make actions occur in TARGET. Say you wanted to check and set some LEDs based on changing events in DCS using DCS exports LUA scripting such as the led_update() function at this thread (https://forums.eagle.ru/showthread.php?t=174929). Then you would use REXEC(). It might look like the following. I didn't call the led_update() function, but instead, I show some example code that changes LED1 and LED2 every half second. I suggest putting such an REXEC at the end of main(), but main seems to execute very quickly, so it doesn't really matter where your REXEC is.

 

// Tested and working - just paste and compile

//******************************************************************
include "target.tmh"

define	REXEC_HalfSecHandler	1	// Handle for REXEC

int main()
{
if(Init(&EventHandle)) return 1;

// Axis, MapKey etc. funcs here ...
// ...

// Make sure LEDs are off
ActKey(PULSE+KEYON+LED(&Throttle, LED_ONOFF, LED_CURRENT-LED1)); 	// set LED 1 OFF
ActKey(PULSE+KEYON+LED(&Throttle, LED_ONOFF, LED_CURRENT-LED2)); 	// set LED 2 OFF

// Call HalfSecHandler every 500ms
ActKey(KEYON+REXEC(REXEC_HalfSecHandler, 500, "HalfSecHandler();", RNOSTOP));
}

//******************************************************************
int LEDStatus = 0;
int HalfSecHandler()
{
// Toggle LED2 on/off using the ^ operator
ActKey(PULSE+KEYON+LED(&Throttle, LED_ONOFF, LED_CURRENT^LED2));

// Toggle LED1 on/off using if/else statements and the LEDStatus variable.  
if (LEDStatus == 0) {
	ActKey(PULSE+KEYON+LED(&Throttle, LED_ONOFF, LED_CURRENT+LED1));
	LEDStatus = 1;
}
else {
	ActKey(PULSE+KEYON+LED(&Throttle, LED_ONOFF, LED_CURRENT-LED1));
	LEDStatus = 0;
}
}

//******************************************************************
int EventHandle(int type, alias o, int x)
{
DefaultMapping(&o, x);
}
//******************************************************************

 

You can run the REXEC'ed handler faster than 500ms. I tried every 100ms, but it didn't look like it was working that fast.

 

If you aren't aware, you have to use ActKey(KEYON+REXEC...); because REXEC is not a normal executable function. Instead, like EXEC(), LED(), AXMAP(), LIST(), etc., these functions cannot be called without an ActKey or outside of a MapKey or KeyAxis, etc. Also, the defined value "REXEC_HalfSecHandler" is just a handle so you can differentiate different REXEC commands from each other and stop them later using StopAutoRepeat(REXEC_HalfSecHandler);. See REXEC in the manual for details.

Link to comment
Share on other sites

Drakoz

 

Wow you are on a completely different level to me.

 

Thank you so much for the thorough explanation and it will probably take me a few hours just to decipher some of this BUT I know it's going to be worth the time as I'll learn something from it and that's a lot of the fun

 

I spend more time these days inside the TARGET Editor and Voice Attack than I do flying

 

Your post is very much appreciated

Link to comment
Share on other sites

Ha, Weegie , SGT, we are all the same on this. My hobby isn't so much flight sims as it is flight sim controls. So funny to see. Part of why I help answer questions about TARGET is because it gives me an excuse to go figure new stuff out that I wouldn't have done on my own. :)

 

That whole Train Sim World script I linked above wasn't because it was worth the effort. Very few in the TSW forums seemed to care as train simmers and flight simmers don't cross pollinate. Not a lot of TARGET users playing with train simulators. No, it was just a challenge I couldn't put down. So I'm glad you found the info interesting Weegie.

 

Your question really got me thinking about custom shifted states in TARGET and completely changed my perspective how I might handle them in the future, especially the concept of a timed shift that resets. I use the MSP button on the Warthog Throttle for my shift button. But that means I can't shift the other Mic Switch buttons (MSR, MSD, MSU, and MSL). So thanks Weggie, now I can.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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