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
// 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