View Full Version : Reverse Axis when Button Held
Capt_Crunch
29th July 2009, 08:24 AM
Hello Guys,
Can someone please help me. I am trying to make so that if I press b1 on my throttle, then the mini-stick's Y axis is reversed. I prefer to make it reversed as long as the button is held but a toggle would work if that isn't possible.
Here is what I can think of to toggle it, but it doesn't work. Again, I would rather make it active as long as b1 is held .Thanks
script
// Toggle Normal / reverse mouse y axis
toggle( d1 ) = js1.b1;
// It's normal (default state)
cms.a1 = js1.a2;
//reversed
if( d1 ) then
cms.a1 = 255 - (js1.a3 / 2);
endIf
Bob Church
29th July 2009, 10:27 AM
Hi Capt_Crunch,
>> Can someone please help me. I am trying to make so that if I press b1 on my throttle, then the mini-stick's Y axis is reversed. I prefer to make it reversed as long as the button is held but a toggle would work if that isn't possible.
Here is what I can think of to toggle it, but it doesn't work. Again, I would rather make it active as long as b1 is held. <<
You can just reference the button itself rather than d1 if you'd rather hold it down. Either way. You'd need to not assign the js1.a2 axis to the mouse, you'd assign the cms.a1 axis to the mouse instead and unassign js1.a2 itself (use DX Mode and set the normal device and control to "None" on the right), but I think it's the calculation that's giving you problems. Axes will range from 0 to 255, so the usual way I do it is just to subtract the value you've got from 255. If js1.a2 is 0, cms.a1 will be 255. If js1.a2 is 255, then cms.a1 will be 0. That being the case, I'd think something like:
script
// Assume it will go directly through
//
cms.a1 = js1.a2;
// Reverse it if the button is down
//
if( js1.b1 ) then
cms.a1 = 255 - js1.a2;
endIf
endScript
That should reverse the direction of the Mouse Y so long as the button was down. I didn't run it, but that's what I'd try.
I'm not sure what the reference to js1.a3 at the end is about though. That's the throttle handle itself. Am I missing something?
Best regards,
- Bob
The StickWorks
http://www.stickworks.com
Capt_Crunch
29th July 2009, 11:12 AM
Hi Bob,
The reference of js1.a3 was an error on my part and should have read js1.a2.
It doesn't seem to work. When js1.b1 is held there is no reversal of the axis.
I tried just adding the line:
cms.a1 = 255 - js1.a2;
and sure enough the axis is reversed, but with the additional lines for the held function, the axis never gets reversed. Any more ideas would be greatly appreciated.
Thanks again!
Bob Church
29th July 2009, 12:43 PM
Hi Capt_Crunch,
Well, I tried it verbatim and it did seem to work here. I used a FighterStick, it looks electrically about the same as the Pro Throttle. The FighterStick X, Y, and Trigger were set to None and None so they wouldn't interfere with anything, cms.a1 was assigned to Mouse and Y axis and the Centered box was checked.
Could you post the script you've got now so I can see what you're using? Just cut it out of the CMS file and paste it, maybe I can sort out what it's doing to you. The only other thing that I can think of would be that you had the Pro Throttle set as the Mode Control device and a map using Modes, button 1 cycles the LEDs on the PT.
Anyway, sounds like you made some progress. There can't be too much wrong.
Best regards,
- Bob
The StickWorks
http://www.stickworks.com
Capt_Crunch
29th July 2009, 10:20 PM
Problem solved. I was using the pinky button on the throttle and that is button 4 and not button 1 lol. I feel a little embarrassed. My excuse is that I was working on this at 6 am my time :)
Thanks again Bob. it works perfectly.
Bob Church
29th July 2009, 11:35 PM
Hi Capt_Crunch,
Great! I know how it is. You look at it long enough and you just get blind to some little error or typo. I've done the same thing a hundred times. In the end, you wonder how you ever could have missed it in the first place. Comes with the territory I guess. :)
Anyway, I'm glad you got it sorted out! Have fun with it!
Best regards,
- Bob
The StickWorks
http://www.stickworks.com
Rangoon
26th October 2009, 12:59 AM
Hi -
I have a very similar question except I *do* want it to toggle. I'm very new to scripting, but found this to be almost exactly what I need so figured I'd ask here first.
I am using Fighterstick, Throttle, and Pedals in one mapped profile. Throttle is CM Device 2. So here is what I've tried. I think it should work if I test it in "Test/Calibrate" but I don't see the desired effect.
script
// Toggle normal/reverse throttle axis
toggle( d1 ) = js2.b1;
cms.a1 = js2.a3;
// Reverse if toggled
//
if( d1 ) then
cms.a1 = 255 - js2.a3;
endIf
endScript
Sorry if I'm way off base here, but I'm combining your two scripts. I'm assuming js2.b1 would be the button on the mouse stick, and that js2.a3 would be the throttle axis. Not sure about the "d1" signifier for the toggle but hoping it applies here.
I'd greatly appreciate any help here.
Thanks!
Bob Church
26th October 2009, 01:46 AM
Hi Rangoon,
Looks fine to me, I'm not sure why it doesn't for you. Couple of thoughts. It won't reverse unless you've downloaded the map and are in Mapped Mode. Also, the actual throttle comes from cms.a1 (Axis 1 on the CMS Controls tab) after the script processes it. You need to clear the assignments from the actual throttle entirely, then make whatever DX Device and DX Control settings the throttle held originally to the CMS axis.
Would either of those explain it?
Best regards,
- Bob
The StickWorks
http://www.stickworks.com
Rangoon
26th October 2009, 02:36 AM
It worked! :)
Indeed I had failed to clear out the throttle axis and actually assign it to cms.a1. What I did is use the js2 for throttle ID, and told cms.a1 to be CM Device 1, Axis Z. Now I can hit the button and the throttle reverses - back and forth to suit my needs.
Edit: I should mention that in a post I have since deleted above this one, I explained that I moved everything to CM Device 1 because ArmA 2 doesn't seem to allow other devices even though it recognizes them by name in its controller list. Also the reason for this issue is that ArmA 2 has no function to reverse the throttle for helicopter vs. fixed-wing. I otherwise have to do this manually in the control options each time I go from one to the other.
Thanks for the help!
Bob Church
26th October 2009, 05:50 AM
Hi Rangoon,
Great! I kind of thought that might be the case, it's an easy thing to forget sometimes.
Anyway, I'm glad it's working for you. Have fun!
Best regards,
- Bob
The StickWorks
http://www.stickworks.com
Powered by vBulletin® Version 4.1.4 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.