PDA

View Full Version : Trying to select diagonal from POV?



SmuvMoney
14th March 2004, 02:26 AM
I've been trying to use the POV on my Fighterstick USB as an 8-way hat to select weapons and send preformatted messages in FPS games. However, trying to select the diagonals of the POV inputs (js1.b26/b28/b30/b32) can be an adventure to put it nicely. :D I'll select a diagonal POV input but then usually hit an orthogonal (left, right, up, down) input when centering the POV. Because of this, I tried writing a script to only allow a diagonal input to be enabled if I touch a diagonal. The actual CMS value is sent when the hat is centered. It is a little long - I was hoping someone could condense this into something smaller or may make some improvements:



// a1 = analog value that is set when a js1.bxx is accessed by the POV Hat (values 25-32 matching js1.bxx)

// b1 = bit/boolean value set to 1 only when a diagonal POV input is registered - it is also reset to false at the end of the script

// if a diagonal input is entered followed by an orthogonal one, b1 is kept true so the orthogonal input is not saved or passed when the hat is centereed

// If an orthogonal input is hit after b1 is set to true, a1 does not change to an orthogonal value

// Once hat is centered, the a1 value is read and the appropriate input is set sent to the appropriate CMS button

// Unfortunately, this limits the POV so you can't use all eight inputs; in return, you can get a specific diagonal with much greater precision

script

// POV Hat Setup - set a1 based on value of POV when not centered - if a diagonal is set, no orthogonal values will be passed to a1

if (js1.b25 and not b1) then
Â*Â*Â*Â*a1 = 25;
Â*Â*Â*Â*cms.b25 = false;
endif

if (js1.b26) then
Â*Â*Â*Â*a1 = 26;
Â*Â*Â*Â*cms.b26 = false;
Â*Â*Â*Â*b1 = true;
endif

if (js1.b27 and not b1) then
Â*Â*Â*Â*a1 = 27;
Â*Â*Â*Â*cms.b27 = false;
endif

if (js1.b28) then
Â*Â*Â*Â*a1 = 28;
Â*Â*Â*Â*cms.b28 = false;
Â*Â*Â*Â*b1 = true;
endif

if (js1.b29 and not b1) then
Â*Â*Â*Â*a1 = 29;
Â*Â*Â*Â*cms.b29 = false;
endif

if (js1.b30) then
Â*Â*Â*Â*a1 = 30;
Â*Â*Â*Â*cms.b30 = false;
Â*Â*Â*Â*b1 = true;
endif

if (js1.b31 and not b1) then
Â*Â*Â*Â*a1 = 31;
Â*Â*Â*Â*cms.b31 = false;
endif

if (js1.b32) then
Â*Â*Â*Â*a1 = 32;
Â*Â*Â*Â*cms.b32 = false;
Â*Â*Â*Â*b1 = true;
endif

// Determine what cms button to set once hat is centered

if (js1.b24) then
Â*Â*Â*Â*if ([a1 == 25] and NOT b1) then
Â*cms.b25 = true;
Â*Â*Â*Â*endif
Â*Â*Â*Â*
Â*Â*Â*Â*if ([a1 == 26]) then
Â*cms.b26 = true;
Â*Â*Â*Â*endif
Â*Â*Â*Â*
Â*Â*Â*Â*if ([a1 == 27] and not b1) then
Â*cms.b27 = true;
Â*Â*Â*Â*endif

Â*Â*Â*Â*if ([a1 == 28]) then
Â*cms.b28 = true;
Â*Â*Â*Â*endif
Â*Â*Â*Â*
Â*Â*Â*Â*if ([a1 == 29] and not b1) then
Â*cms.b29 = true;
Â*Â*Â*Â*endif
Â*Â*Â*Â*
Â*Â*Â*Â*if ([a1 == 30]) then
Â*cms.b30 = true;
Â*Â*Â*Â*endif
Â*Â*Â*Â*
Â*Â*Â*Â*if ([a1 == 31] and not b1) then
Â*cms.b31 = true;
Â*Â*Â*Â*endif

Â*Â*Â*Â*if ([a1 == 32]) then
Â*cms.b32 = true;
Â*Â*Â*Â*endif

b1 = false;
endif

endscript

Bob Church
14th March 2004, 02:57 AM
My guess is (though I'm not absolutely sure) that the POVs are in fact 4-way hats and that the corners are generated by the two adjacent side positions closing simultaneously, e.g. if Left and Up are closed at the same time, you get Up/Left. If that's the case, it's nearly impossible to hit the corner directly. You will almost invariably hit one side or the other and then slide into the corner (even if it's only a few thousandths of a second until the second contact closes).

There are probably lots of ways it could be fixed, what you did being one of them. A couple of other methods that come to mind would be to not actually change weapons on the hat, but hold the hat into the position you want as a selector and then use a second button to actually select the weapon after you positioned the hat.

Another method might be to set it up so it had to be held in position for a bit before it registered. The hit against the side is going to be very brief, so maybe something like:

script
timer( ONDELAY, d1, 2 ) = not js1.b24;
cms.b1 = js1.b25 and d1;
cms.b2 = js1.b26 and d1;
cms.b3 = js1.b27 and d1;
cms.b4 = js1.b28 and d1;
cms.b5 = js1.b29 and d1;
cms.b6 = js1.b30 and d1;
cms.b7 = js1.b31 and d1;
cms.b8 = js1.b32 and d1;
endScript

which is simply going to delay the switch response for about 1/10th of a second which should let you get the hat into position before it actually issues a command. You'd have to assign the CMS.Bx buttons in the GUI to do the actual selection of course.

Anyway, there's other ways, too, but that's a little shorter and maybe it'll get you around the problem. If not, come on back and we'll see if we can come up with something that will.

- Bob

The StickWorks
http://www.stickworks.com

MichaelCHProd
14th March 2004, 07:44 AM
You are right Bob, the eight ways are four micro switches with contact on two adjacent giving you the diagonals.

Bob Church
14th March 2004, 04:57 PM
Thanks, Michael. Yeah, I figured that was the case. It's usually how it's done, I don't think I've ever seen an actual 8-way hat.

- Bob

The StickWorks
http://www.stickworks.com

SmuvMoney
14th March 2004, 07:02 PM
Bob Church, thanks for the script idea. I messed with my script and found it to be closer to what I needed. I had it set the POV input on release so I didn't have to be precise timewise. However, your idea would be much better and shorter should I go the "input on press" with the POV. Thanks again for the good ideas. :D