#3427036 - 11/06/11 01:39 AM
Doing something based on current mode
|
Joined: Jan 2011
Posts: 1,527
WileECoyote
Member
|
Member
Joined: Jan 2011
Posts: 1,527
Argentina
|
Hello gentlemen. I'm trying to do something pretty easy... but I don't seem to be able to. What I want is combine the mode switch (button 3) with a keypress, so I can send a keystroke to the sim and at the same time switch to another mode on the stick. So, for example: I´m in mode 1 (NAV), and then press button3, to go to my AG mode, then stick not only switches to mode 2, but also sends Shift-6 to my sim. Obviously, to be able to know what key to send, I first need to know what mode I'm in. I would think that I can query the CURRENTMODE variable, something like this: if (JS1.b3) then
if (CURRENTMODE == MODE1) then
SendKey('Shift-6') <--- No idea how to do that.
CURRENTMODE= MODE2
else if (CURRENTMODE == MODE2) then... But I'm getting the error: "Bit value expected but CURRENTMODE found"... Any idea about how to accomplish this? Thanks.
When you're feeling sad, just remember that somewhere in the world, there's someone pushing a door that says "pull".
|
|
#3427056 - 11/06/11 02:10 AM
Re: Doing something based on current mode
[Re: WileECoyote]
|
Joined: Sep 2002
Posts: 11,273
531 Ghost
USMC
|
USMC
Veteran
Joined: Sep 2002
Posts: 11,273
Elizabeth City NC
|
Sounds like you may be looking for a IF/THEN/ELSE ?
America will never be destroyed from the outside. If we falter and lose our freedoms, it will be because we destroyed ourselves.
|
|
#3427063 - 11/06/11 02:16 AM
Re: Doing something based on current mode
[Re: WileECoyote]
|
Joined: Jan 2011
Posts: 1,527
WileECoyote
Member
|
Member
Joined: Jan 2011
Posts: 1,527
Argentina
|
Thanks Ghost, but nope.
The problem is the evaluation per se, the if (CURRENTMODE == MODE1) part. I played around with the if statement and have no problems with it. The problem comes when trying to evaluate the CURRENTMODE variable.
When you're feeling sad, just remember that somewhere in the world, there's someone pushing a door that says "pull".
|
|
#3427424 - 11/06/11 04:23 PM
Re: Doing something based on current mode
[Re: WileECoyote]
|
Joined: Jan 2011
Posts: 1,527
WileECoyote
Member
|
Member
Joined: Jan 2011
Posts: 1,527
Argentina
|
Ah, thank you very much mister Ghost. But still... yeah, I know... I´m still getting headaches with this. The problem now is that I can't seem to get a proper sequence out of this.
I followed your mini tut, and asigned the keys 4, 5 and 6 to each mode. Now when I press then, I get kind of random failures, for instance, 456456446564564565456. Any idea what could cause it. My first thought was that I was pressing the keys to quickly when testing them, but nope, even if I press them with enough between each other, the problem persists.
When you're feeling sad, just remember that somewhere in the world, there's someone pushing a door that says "pull".
|
|
#3427753 - 11/06/11 10:14 PM
Re: Doing something based on current mode
[Re: WileECoyote]
|
Joined: Aug 2000
Posts: 306
Bob Church
Member
|
Member
Joined: Aug 2000
Posts: 306
USA
|
Hi WileECoyote, I'm assuming you've moved to Ghost's method, just programming the character to the Mode button (3) directly. It creates some timing problems, there are just too many "clocks" running asynchronously and it's easy to pick up a repeating character or a character coming for the wrong mode. It's not usually a problem because when it's a separate button the mode change is usually complete before the character gets sent. You might still get a duplicate now and then, but there's no more risk than with a normal press. It's actually an easy thing to fix. You need to force the character to not repeat and you need to force it after the mode change is completed. Program it as Ghost says, but for Button 3 put: NULL in for the Normal "Press" character on all three Modes, and then put the character(s) you want to send in the Normal "Release" box. The mode changes on the press, so it's always complete when you release the button (if it registers at all), and seems to clear things up when I run it here. Give it a try and see if it will work for you! Best regards, - Bob The StickWorks http://www.stickworks.com
Last edited by Bob Church; 11/06/11 10:14 PM.
|
|
#3428165 - 11/07/11 12:49 PM
Re: Doing something based on current mode
[Re: WileECoyote]
|
Joined: Sep 2002
Posts: 11,273
531 Ghost
USMC
|
USMC
Veteran
Joined: Sep 2002
Posts: 11,273
Elizabeth City NC
|
It's actually an easy thing to fix. You need to force the character to not repeat and you need to force it after the mode change is completed. Program it as Ghost says, but for Button 3 put:
NULL
in for the Normal "Press" character on all three Modes, and then put the character(s) you want to send in the Normal "Release" box. The mode changes on the press, so it's always complete when you release the button (if it registers at all), and seems to clear things up when I run it here.
Should've tested in my test.map, thanks Bob!
America will never be destroyed from the outside. If we falter and lose our freedoms, it will be because we destroyed ourselves.
|
|
#3428441 - 11/07/11 07:28 PM
Re: Doing something based on current mode
[Re: WileECoyote]
|
Joined: Aug 2000
Posts: 306
Bob Church
Member
|
Member
Joined: Aug 2000
Posts: 306
USA
|
Hi Ghost, Yer welcome! It's just a little tricky, things can get out of order pretty easily. When I ran the map, I saw just what he described, but looking at it I could see that it was just not switching modes in time or getting a duplicate and I guessed the characters weren't blocked from repeating on the press side. I played around a bit and it was just an easy way to handle both. The press side always switched the mode first and the release side always acts like there's a NULL after it to stop the repeat, so it just all fit together. The only way I've been able to get a glitch out of it was working button 3 very rapidly. Sometimes that can cause it to skip, I think you end up just changing modes before it has time to react, but so long as the button gets a solid click it seems to be unbreakable. You could probably work around even that with a little CMS file and flag or two, but I don't think it's really a problem in any case. Anyway, a handy trick for the few times you want to send something and change modes at the same time. Best regards, - Bob The StickWorks http://www.stickworks.com
|
|
#3433875 - 11/14/11 07:10 PM
Re: Doing something based on current mode
[Re: WileECoyote]
|
Joined: Dec 2010
Posts: 161
OlafM
Member
|
Member
Joined: Dec 2010
Posts: 161
|
Hi WileECoyote, Concerning But I'm getting the error: "Bit value expected but CURRENTMODE found"... The error appears because you forgot to wrap the numeric comparison with brackets. Like this: if ( [ CURRENTMODE == MODE1 ] ) then
...
endif
CMS just works a little different than "normal" programming languages.
|
|
#3434185 - 11/15/11 01:53 AM
Re: Doing something based on current mode
[Re: WileECoyote]
|
Joined: Jan 2011
Posts: 1,527
WileECoyote
Member
|
Member
Joined: Jan 2011
Posts: 1,527
Argentina
|
Oh, that's great. Thanks OlafM!
When you're feeling sad, just remember that somewhere in the world, there's someone pushing a door that says "pull".
|
|
|
|
|
|
|
Exodus
by RedOneAlpha. 04/18/24 05:46 PM
|
|
|
|
|
|
|