View Full Version : Modes (ifs and else)
Smokin
28th August 2009, 09:26 AM
I just love my CH joystick and throttle, but the longer I have it, the more complicated my controls get. I use the various modes effectively, when the green light is on, I am in landing and takeoff mode and I have all the necessary buttons for that, in red mode I am in combat flight mode, and in yellow I am in bombing mode. Each mode has the buttons I need to do what I want, problem is its not uncommon to be in the wrong mode when attacking.(its very embarrassing to try and release a bomb only to turn off your engine instead!)
If there a way I can program the mode to turn on something
Like, if in green mode, then the button for cockpit light gets clicked.(this way I know I am in landing mode)
else if in red cockpit light gets clicked to turn off
else if orange, nothing happens.
Bob Church
28th August 2009, 09:52 PM
Hi Smokin,
There's not really any way to control the LEDs directly. They're part of the controller hardware and the Control Manager can't access them. You could conceivably use a few extra button outputs, they'd just be joystick buttons but they could talk to something like one of those "Phidget" modules and control external LEDs to indicate mode, that would let you jump around, but as it is you're kind of stuck with cycling through them all. Having to cycle to Take Off mode for one command and then cycle back to Combat mode again isn't much fun when they're shooting at you.
There was also some work done a few years back by one of the guys that used to hang around here, JNOV I think, where he'd managed to superimpose his own graphic on the screen over the sim cockpit picture and could put up his own readout. It was a lot of hooking of DLLs and things, I don't know what all he'd had to do exactly, but he was able to add readouts to the on-screen display for most anything he could get data for that way.
A couple of other thoughts, maybe you can find something useful in one them. One is to just ignore the LEDs entirely. Set "CMS" as the Mode Control device rather than the FighterStick or ProThrottle. The LEDs don't really mean anything when you do that, but you get four modes rather than three, and you can program them to one of the four-way hats as the Mode Selector. It gives you random access to any mode from any other mode just based on which way you move the hat. Hat Up for Take-Off, Hat Down for Landing, Hat Left for crashing with style, that sort of thing. You don't need to cycle through the intervening modes to get to where you need to be and you don't need to cycle back when you're done. Just click the hat to get back to the Mode you need, then click it again to get back where you were.
Along those same lines, you might use a four-way, maybe the shifted positions since it probably wouldn't be too heavily used, to force one of the modes while you held the hat. Go ahead and cycle it like you are now, but then set up some logic that would cause Hat 2 Up (for example) to force it into "Take Off Mode" while it's held. You could hold the hat, handle the out-of-mode command, then let go of the hat and it would fall back into whatever mode it was in. You'd still need to use CMS modes to be able to control them, but you can make them track the LEDs if you do something like "CURRENTMODE = FTRSTKMODE", the shifted hat logic would override that and force maybe "CURRENTMODE = MODE1" while you made the out-of-mode button press, and since you wouldn't be actually pressing the normal Mode button on the FighterStick, the LEDs would hold their current color and it would fall back into whatever mode you were in when the hat was released. You could just leave the MODE4 slots unprogrammed, no LED would correspond to it, or you might bury some little-used commands up there and use another button to force it to MODE4 while you did the odd command. Again, the LEDs would hold and it would just fall back to normal 3-Mode operation when you released the MODE4 button.
Anyway, maybe you could come up with some sort of workaround that way. Are you scripting now or just using the Modes in the GUI?
Best regards,
- Bob
The StickWorks
http://www.stickworks.com
Smokin
29th August 2009, 01:23 AM
Thank you great info!
I think I was a bit unclear about what Im trying to do. The problem is not cycling through modes, its forgetting to cycle through them, so thats why a readout like JNOV had would be AWESOME! I dont know if Id be able to pull something like that off so I was wondering for a easier fix, I could activate something in the cockpit to indicate what mode I am in since I rarely look at my joystick for an LED and usually just fixated on the screen.
I found this script in the help file
SCRIPT
IF( JS1.B13 ) THEN
CURRENTMODE = MODE1;
ELSE
IF( JS1.B14 ) THEN
CURRENTMODE = MODE2;
ELSE
IF( JS1.B15 ) THEN
CURRENTMODE = MODE3;
ELSE
IF( JS1.B16 ) THEN
CURRENTMODE = MODE4;
ENDIF
ENDIF
ENDIF
ENDIF
ENDSCRIPT
So I was thinking I could hopefully do something like
SCRIPT
When JS1.B3 is clicked...... //This button changes Modes and LED colors
IF( CURRENTMODE = MODE1 ) THEN //green LED is on??
JS1.B3 = CMS.B3; //turn on cockpit lights, this would tell me I am in "landing mode"
ELSE
IF( CURRENTMODE = MODE2 ) THEN //Red LED is on?
JS1.B3 = CMS.B3; //turn cockpit lights off this would tell me I am in "combat mode"
ELSE
IF( CURRENTMODE = MODE3 ) THEN //Orange LED is on?
JS1.B3 = CMS.B4; //this could turn on something like my speed bar or something I chose to make it obvious Im in Bombing mode.
ENDIF
ENDIF
ENDIF
ENDSCRIPT
Hope that makes some sense, this is what I am hoping for but obviously I dont have the skills to go about trying to figure out how exactly without getting completely frustrated.
Bob Church
29th August 2009, 08:49 AM
Hi Smokin,
>> Thank you great info! <<
You're welcome!
>> I think I was a bit unclear about what Im trying to do. The problem is not cycling through modes, its forgetting to cycle through them, so thats why a readout like JNOV had would be AWESOME! <<
I thought it was a neat idea too, but nobody ever really picked up on it much. Anyway, using the cockpit lighting, etc. is a good idea and a lot less work. :)
>> I dont know if Id be able to pull something like that off so I was wondering for a easier fix, I could activate something in the cockpit to indicate what mode I am in since I rarely look at my joystick for an LED and usually just fixated on the screen. <<
Sure. That can be done. The IF/THEN block isn't really that far off. You can't set a physical button, so statements like "js1.b3 = cms.b3" won't work, and there are a couple of other minor syntax errors, but it turns out it's easier to do with a SEQUENCE anyway.
If I break your script down, it really comes out that cms.b3 should pulse if it's in MODE1 or MODE2 and cms.b4 should pulse if it's in MODE3. I'm just going to simplify it down with the understanding that actual situations might need something more complex. If I do that, a SEQUENCE is really the easiest way to handle it because it has the instructions to wait for a button to be pressed, but not refire unless it finished, the button is released. and then gets pressed again. This seems to work (I'm using a FighterStick, if my understanding is correct js1.b2 is supposed to be the native mode-switching button for the controller, the one that cycles the LEDs, so I'm using js1.b3 instead). The script is simple enough:
script
// Start the sequence
//
sequence
// Wait for js1.b3 to be seen as released and then
// pressed. That way it doesn't just run continually
// while js1.b3 is held down, it inly works one time per
// press and it always finishes the sequence.
//
wait( js1.b3 );
// cms.b4 is ON if it's in MODE3, OFF otherwise. The comparison
// needs the square brackets to turn it back into a bit value, and
// it uses the "==" C-style equality operator, not just "=". This
// turns CMS.B4 on if it's in MODE3.
//
cms.b4 = [ CURRENTMODE == MODE3 ];
// cms.b3 is always the opposite of cms.b4 so just invert it.
//
cms.b3 = NOT cms.b4;
// This delay lets the bit (cms.b3 or cms.b4) propogate out
// into the rest of the map. It has to remain on for 1 scan,
// otherwise it won't be seen outside of the script itself.
// I've got it set to 5 because a one is fast enough that
// the CM test applet can miss it. Using 5 makes it easier to
// see, you'd probably want to set it to one in the actual
// program.
//
delay( 5 );
// The delay is finished and the outputs have gone out to the rest
// of the map logic. If either of them was ON, turn it OFF now.
//
cms.b3 = FALSE;
cms.b4 = FALSE;
// And that will do it. Close it up and quit.
//
endSequence
endScript
For testing, I had CMS.B3 assigned to CM Device 1, Button 17, and CMS.B4 assigned to CM Device 1, Button 18. With the delay of 5, you can download the map and watch CM Device 1 in the Test/Calibrate applet. You'll see JS1.B3 light up when you press button 3 and the LEDs switch, and you'll see Button 17 or Button 18 flash briefly depending on what mode you're in. In the actual map, you'd program the character or button to turn the lights off and on to CMS.B3 and CMS.B4 and you could reduce the delay to 1 or 2.
Anyway, I think it's doing what you described. You can do a similar thing with the other commands, you'd just need to modify the logic to use different CMS buttons and set up the logic to activate whatever the function actually needs to make it work, just start another sequence each time.
Best regards,
- Bob
The StickWorks
http://www.stickworks.com
Smokin
1st September 2009, 09:08 PM
Than you so much for the help. It totally worked, but I didnt think the whole idea through and am not happy with the results. If I die in "landing mode" mode 1 then when the game restarts my lights are off, so when i hit mode 2, the lights go on instead of off and I lose any visual feedback from the plane telling me what mode I'm in.
I think I would like to try what Jnov did, is there any instructions or info around, I saw a few threads, but no instructions so far. I'd hate to reprogram everything at this point since I really like having all these different modes to the joystick, but I would love something on my screen to tell me what mode Im in cause I just don't look at my joystick when playing and am too ditsy to keep track of the modes.
jayhigh
1st September 2009, 10:21 PM
im trying to understand this post...
i have one question, are you able to have the LEDs on a fighterstick or pro throttle indicate a "mode selection" i.e. red for mode 1, green for mode 2, etc...
i think bob said no, but not sure...
Bob Church
1st September 2009, 10:38 PM
Hi Jayhigh,
No. When the hardware is reset (Windows restarts, etc.) it goes initially to yellow mode and then to green mode once it's recognized. The mode means nothing at all to the stick itself. It's just designed to cycle through the LEDs green, red, yellow, green, red, yellow....) each time you click Button 3 on the FighterStick or Button 1 on the Pro Throttle.
It also sends a signal that indicates a mode switch. The CM just keeps track of what it receives, it can't force them to track it's internal state. I seems to work like you describe, but it's actually not in phase with the CMS mode until the mode gets changed after you start the map. If you leave the thing in Red Mode on one flight then restart or start another map, the CM will assume it's in Green Mode even though the LEDs are showing Red. You need to click the button one time after the map starts and it will line up, until thing it doesn't get any notification.
Best regards,
- Bob
The StickWorks
http://www.stickworks.com
Powered by vBulletin® Version 4.1.4 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.