snomhf
30th March 2009, 04:36 AM
CM provides the concept of a "Shift Key" which allows a button to produce two functions (one unshifted, one shifted). With the use of the "DELAY" command, we can generate four separate functions out of a single button (though rarely would you really want all four). However, the "delay action" function serves a very cool purpose. Here is the most common use of this feature:
All flight games provide keys to raise and lower flaps (assuming planes with flaps of course). Some games (e.g. MSFS) provide keys to raise and lower flaps all the way with just a single key press. Some, however, do not. The purpose of this script is to cover those games that do not.
Assume your flight game lowers flaps using the "f" key. To raise the flaps, you press the "F" (Shift-f) key. There are no keys to lower or raise flaps completely. In this game, if you want to lower the flaps all the way, you would have to press "f" four times (assuming the flaps were completely retracted). Now, we will also assume (and you'll have to check you game to see if this is the case) that there is no adverse effect of pressing four "f"'s when less than four are required to completely lower the flaps (i.e., the flaps were already partially lowered). Our script is going to "press" four "f"s no matter what. I have not encountered a game where this is a problem.
Here is a script to lower flaps either one notch or all the way using a single button. When you briefly push (I refer to this as "click") the "Down" Cross Hat (B3") on the FighterStick, the script will generate an "f" (flaps down one notch) command. Rather than "clicking" the button, if you hold it down for a second or longer (I call this "press") then the script will generate four "f" commands. The FighterStick is assumed to be controller 1 in this example...
%DEFINE FS_CrossDN JS1.B7
%DEFINE FlapsDn CMS.B1 // Use: "NULL f" (the NULL prevents accidental extra "f"s)
%DEFINE FlapsFullDn CMS.B2 // Use: "f f f f"
script
// Click: Flaps Down One Notch Press: Flaps Full Down
timer(period, d1, 20) = FS_CrossDN; // Hold for 1 sec
FlapsDn = d1 and not FS_CrossDN; // Click: Flaps Down
FlapsFullDn = not d1 and FS_CrossDN; // Press: Flaps Full Down
endscript
Now, to extend this idea to four separate functions is a simple matter of using the "Shifted Action" of the CMS.B1 and CMS.B2 buttons. It's a very rare situation where you would want all four but I have used three functions in several occasions. Here is how I have my "red button above the cross-hat" (B2) on my FighterStick programmed in LockOn:
Click: Cycle Weapons
Press: A-10 Master Arm
Shift-Click: A-10 Toggle Gun Rate
To accomplish this, I used code very similar to the "Flaps Down" example and added the "Toggle Gun Rate" command to the "Shifted Action" of CMS.B1. Piece of cake!
All flight games provide keys to raise and lower flaps (assuming planes with flaps of course). Some games (e.g. MSFS) provide keys to raise and lower flaps all the way with just a single key press. Some, however, do not. The purpose of this script is to cover those games that do not.
Assume your flight game lowers flaps using the "f" key. To raise the flaps, you press the "F" (Shift-f) key. There are no keys to lower or raise flaps completely. In this game, if you want to lower the flaps all the way, you would have to press "f" four times (assuming the flaps were completely retracted). Now, we will also assume (and you'll have to check you game to see if this is the case) that there is no adverse effect of pressing four "f"'s when less than four are required to completely lower the flaps (i.e., the flaps were already partially lowered). Our script is going to "press" four "f"s no matter what. I have not encountered a game where this is a problem.
Here is a script to lower flaps either one notch or all the way using a single button. When you briefly push (I refer to this as "click") the "Down" Cross Hat (B3") on the FighterStick, the script will generate an "f" (flaps down one notch) command. Rather than "clicking" the button, if you hold it down for a second or longer (I call this "press") then the script will generate four "f" commands. The FighterStick is assumed to be controller 1 in this example...
%DEFINE FS_CrossDN JS1.B7
%DEFINE FlapsDn CMS.B1 // Use: "NULL f" (the NULL prevents accidental extra "f"s)
%DEFINE FlapsFullDn CMS.B2 // Use: "f f f f"
script
// Click: Flaps Down One Notch Press: Flaps Full Down
timer(period, d1, 20) = FS_CrossDN; // Hold for 1 sec
FlapsDn = d1 and not FS_CrossDN; // Click: Flaps Down
FlapsFullDn = not d1 and FS_CrossDN; // Press: Flaps Full Down
endscript
Now, to extend this idea to four separate functions is a simple matter of using the "Shifted Action" of the CMS.B1 and CMS.B2 buttons. It's a very rare situation where you would want all four but I have used three functions in several occasions. Here is how I have my "red button above the cross-hat" (B2) on my FighterStick programmed in LockOn:
Click: Cycle Weapons
Press: A-10 Master Arm
Shift-Click: A-10 Toggle Gun Rate
To accomplish this, I used code very similar to the "Flaps Down" example and added the "Toggle Gun Rate" command to the "Shifted Action" of CMS.B1. Piece of cake!