Previous Thread
Next Thread
Print Thread
Rate This Thread
Hop To
#3427036 - 11/06/11 01:39 AM Doing something based on current mode  
Joined: Jan 2011
Posts: 1,527
WileECoyote Offline
Member
WileECoyote  Offline
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:

Code:
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".
Inline advert (2nd and 3rd post)

#3427056 - 11/06/11 02:10 AM Re: Doing something based on current mode [Re: WileECoyote]  
Joined: Sep 2002
Posts: 11,273
531 Ghost Offline
USMC
531 Ghost  Offline
USMC
Veteran

Joined: Sep 2002
Posts: 11,273
Elizabeth City NC
Sounds like you may be looking for a IF/THEN/ELSE ?


Originally Posted by Abraham Lincoln
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 Offline
Member
WileECoyote  Offline
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".
#3427386 - 11/06/11 03:46 PM Re: Doing something based on current mode [Re: WileECoyote]  
Joined: Sep 2002
Posts: 11,273
531 Ghost Offline
USMC
531 Ghost  Offline
USMC
Veteran

Joined: Sep 2002
Posts: 11,273
Elizabeth City NC
banghead That'll teach me to skim over the obvious!

Sorry

Yes, it is easy and no need for scripting actually. Follow along...



"gove" fat fingerd that one... biggrin







Now, simply do the same for modes 2 and 3 with the desired keys/macros and you'll be set with NAV/AA/AG modes. All you'll have to do is look at the LED on the base of the FighterStick. For me, I use Green = NAV, Red = AA and Amber = AG

Last edited by 531 Ghost; 11/06/11 03:52 PM. Reason: "gove"

Originally Posted by Abraham Lincoln
America will never be destroyed from the outside. If we falter and lose our freedoms, it will be because we destroyed ourselves.


#3427424 - 11/06/11 04:23 PM Re: Doing something based on current mode [Re: WileECoyote]  
Joined: Jan 2011
Posts: 1,527
WileECoyote Offline
Member
WileECoyote  Offline
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 Offline
Member
Bob Church  Offline
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.
#3427870 - 11/07/11 12:50 AM Re: Doing something based on current mode [Re: WileECoyote]  
Joined: Jan 2011
Posts: 1,527
WileECoyote Offline
Member
WileECoyote  Offline
Member

Joined: Jan 2011
Posts: 1,527
Argentina
Absolutely perfect. Thank you for the help. bananadance


When you're feeling sad, just remember that somewhere in the world, there's someone pushing a door that says "pull".
#3427913 - 11/07/11 01:56 AM Re: Doing something based on current mode [Re: WileECoyote]  
Joined: Aug 2000
Posts: 306
Bob Church Offline
Member
Bob Church  Offline
Member

Joined: Aug 2000
Posts: 306
USA
Hi WileECoyote,

You're quite welcome! I'm glad it was some help!

Have fun!

Best regards,

- Bob

The StickWorks
http://www.stickworks.com

#3428165 - 11/07/11 12:49 PM Re: Doing something based on current mode [Re: WileECoyote]  
Joined: Sep 2002
Posts: 11,273
531 Ghost Offline
USMC
531 Ghost  Offline
USMC
Veteran

Joined: Sep 2002
Posts: 11,273
Elizabeth City NC
Originally Posted By: Bob Church
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!


Originally Posted by Abraham Lincoln
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 Offline
Member
Bob Church  Offline
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 Offline
Member
OlafM  Offline
Member

Joined: Dec 2010
Posts: 161
Hi WileECoyote,

Concerning
Originally Posted By: WileECoyote
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:
Code:
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 Offline
Member
WileECoyote  Offline
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".

Moderated by  RacerGT 

Quick Search
Recent Articles
Support SimHQ

If you shop on Amazon use this Amazon link to support SimHQ
.
Social


Recent Topics
Carnival Cruise Ship Fire....... Again
by F4UDash4. 03/26/24 05:58 PM
Baltimore Bridge Collapse
by F4UDash4. 03/26/24 05:51 PM
The Oldest WWII Veterans
by F4UDash4. 03/24/24 09:21 PM
They got fired after this.
by Wigean. 03/20/24 08:19 PM
Grown ups joke time
by NoFlyBoy. 03/18/24 10:34 PM
Anyone Heard from Nimits?
by F4UDash4. 03/18/24 10:01 PM
RIP Gemini/Apollo astronaut Tom Stafford
by semmern. 03/18/24 02:14 PM
10 years after 3/8/2014
by NoFlyBoy. 03/17/24 10:25 AM
Copyright 1997-2016, SimHQ Inc. All Rights Reserved.

Powered by UBB.threads™ PHP Forum Software 7.6.0