View Full Version : Nav lights keypresses
LonelyJoe
23rd October 2009, 06:39 PM
I would like to create a script for IL2 that flashes my nav lights on in a strobe like pattern. I have not idea how to do this yet... I'll figure that out as I have never done that before. But do you forsee any issues with the program sending so many keypresses in period of time interfering with other inputs from my HOTAS?
Bob Church
23rd October 2009, 07:18 PM
Hi LonelyJoe,
It's not hard, but it kind of depend on how the lights work and which button on which control you want to activate them.
First the lights. Is it a toggle key or button, e.g. you press it once and they come on, press it again and they go off, or is there a separate off key or button.
For the button, you need to know the ID for it. The devices in the map are referenced as js1 through js16. The js1 control is the one immediately to the right of the "Program Settings" tab, the one to the right of js1 is js2, then js3, etc. You also need the button number on the control. For example, the red button at the top/back of the FighterStick is button 2. If the FighterStick was on the first tab, the reference would be "js1.b2".
The script itself will depend on whether the lights are on a toggle or on separate keys in the sim. If you can let me know how the lights work and which button you want to use to control it, I can set it up for you.
Let me know!
Best regards,
- Bob
The StickWorks
http://www.stickworks.com
LonelyJoe
23rd October 2009, 11:29 PM
Bob - that is very gracious of you. Thanks so much. The keypress is:
Toggle-Nav-Lights - CTL n
Ctl n to turn em on.. Ctl n to turn em off...
I am still going to learn how to use the scripting portion of the CM. This will make my life easy and quick right now.
Bob Church
24th October 2009, 08:09 AM
Hi LonelyJoe,
Glad to help! You didn't name the button and controller, so I'm going to write this as if you have a FighterStick on the first tab to the right of "Program Settings" tab. That makes the button js1.b2 in the script. If it's somewhere else you'll need to change the js1.b2 references. If you have problems there, let me know the line up of controllers on the tabs, count "Program Settings" as "Tab 0", then "Tab 1" is the first to the right of that, "Tab 2" the second, etc. If you can let me know the tab number, what type of device it is (FighterStick, Pro Throttle), etc. and the button number you need to use I can tell you what the reference needs to be.
The script itself is simple enough to set up. Click the "Add" button on the tool bar like you were going to add another controller to the map. At the very bottom are the "CMS Controls". Add those to the map. You'll get another tab marked "CMS Controls" which carries the virtual buttons and axes that script deals with.
When you Add the CMS Controls, the CM Editor will become available. Click on that and it will show you an empty script file. There are some comment lines at the to, and then "script" and "endScript". You just need to use the editor so it reads:
script
toggle( d1 ) = js1.b2 AND NOT cms.b1;
timer( d2, INTERVAL, 10, 10 ) = d1;
cms.b1 = d2;
endScript
The Toggle changes state whenever you click the button. The first click should start the flash, the next click should shut them off, and so on. I've got both the on time and off time set to about half a second. The two "10" values. The first defines the on time, the second the off time, so you might need to play with those values to get it working like you want it to.
One thing you might find useful. If you assign Button 1 on the CMS Controls tab to, say, CM Device 1 and Button 17, some unused button anyway, you can see the flash and play with the relative on and off times in the CM GUI. Just start the map and go to the Test/Calibrate button. Once you've got it running, switch cms.b1 to send the CTL n. You could also use the Keytester to monitor the CTL n characters, but with it on a button in the test screen, it's a little easier to see what's going on. Either way you avoid running the sim each time.
That's about it. Save the map, then download it, and see how it goes. Let me know how it works out!
Best regards,
- Bob
The StickWorks
http://www.stickworks.com
LonelyJoe
24th October 2009, 03:29 PM
I seem to be getting an error when after I save and when I go to load the profile.
http://i293.photobucket.com/albums/mm68/loyalnine/10-24-200910-18-30AM.jpg
http://i293.photobucket.com/albums/mm68/loyalnine/SNAG_Program-0001.jpg
Now if I want to assign it to this button:
http://i293.photobucket.com/albums/mm68/loyalnine/10-24-200910-25-54AM.jpg
will the script look like this? (I highlighted change in red)
script
toggle( d1 ) = js2.b11 AND NOT cms.b1;
timer( d2, INTERVAL, 10, 10 ) = d1;
cms.b1 = d2;
endScript
Bob Church
24th October 2009, 07:33 PM
Hi LonelyJoe,
It's my fault. In the timer statement, INTERVAL needs to come before d2:
timer( INTERVAL, d2, 10, 10 ) = d1;
Is the addition of the AND NOT cms.b1 to stop it from stopping while the light is on? If it is, you might try putting a CTL n in the "Release" box as well as in the "Press" box. Then the On command would be sent when the timer turned on, an Off command when it timer turned off. It would avoid the "AND NOT cms.b1" if it would do the trick.
Anyway, my apologies for the error. I wrote it that way at first, then when I tried it I got the same error. It worked here, but I never went back and corrected it in the message.
One other note. That error isn't very informative. You get a better idea if you open the script in the CM editor and click that button with the red check mark on it. It does the same thing the the downloader will do, but it will place the cursor on the line where it realized there was an error and give you a message of some sort, usually telling you what it was expecting. It makes it much easier to find.
Edit: You may also need to add a NULL to the end of the Press string, it depends on how the sim picks up keys. Just set the "Press Box" to:
CTL n NULL
You don't need that on release, so just:
CTL n
is okay there.
Best regards,
- Bob
The StickWorks
http://www.stickworks.com
ABEA
26th November 2009, 09:54 PM
Bob, I would like this script to turn on the flashing nav lights when I press and release the button (js2.b3), and continue the flashing sequence until I press the button again to turn them off.
Can the above script be modified to do that?
Capt_Crunch
27th November 2009, 06:04 AM
I have a side question as well please. While a script like this is running, would not the keypresses the script is invoking (control key in this example) interfere with other key presses you might use? while the script is running? Thanks
abe456
27th November 2009, 09:07 PM
Well, you have a point there. I have a logitech G-15 keyboard with a macro that does the flashing light bit, and it does interfere. I was hoping the flashing light loop in the CH control program would not prevent other commands from executing.
Am I SOL on this one?
Wolverine
13th December 2009, 01:52 PM
If you map the command to a DirectX button in the game, it should not interfere.
Bob Church
14th December 2009, 01:41 AM
Hi Capt. Crunch et al,
The Control Manager looks like another keyboard to Windows, so it's as if you're typing on two at once. The individual characters won't actually collide, they get buffered by Windows, but they can interfere. A SHF key from the stick could conceivably get interleaved with another key from the keyboard and you'd get an upper-cased character, not what you were expecting.
The CM won't interfere with itself, so if you can move the commands to the controllers, there's not a problem. The real keyboard won't send anything so the problem doesn't exist.
Wolverine is right about the characters. In FS and sims that provide DX Inputs for their function, the interference won't occur if you program everything to the controllers. You're not sending any characters at all, presumably the sim can sort it out, and you should be in good shape. It's also a bit quicker to respond.
Abe, if the characters are being controlled by a loop in a CMS script, then it's the same as pressing and releasing a key. Nothing happens between the character clicks so unless that periodic character doesn't interfere, you should be good to go. There's nothing going on "continuously".
OTOH, if you're programming it up in the GUI using CHARDLY statements to set the timing, they controllers can essentially lock up until the loop stops. It depends on how it's set up. If it's a problem, going to a DX button should work there (assuming one is available that controls the function you need).
Best regards,
- Bob
The StickWorks
http://www.stickworks.com
Powered by vBulletin® Version 4.1.4 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.