PDA

View Full Version : joystick input



jcgam
Oct 31 2011, 14:58
How do I read a joystick button in a script? I've done a lot of research to try to find the answer myself and I think I'm close. Here's what I added to a helicopter initialization script:

while{true}do{
if(inputAction "fire" != 0)then{hint "fire button pressed!"};
};

Nothing happens when I press the fire button. Is inputAction the correct function to use? Where should I put the script?

blakeace
Oct 31 2011, 21:31
I had a quick look, and couldn't get any response for the label "fire"
Tried and couple of other names like "helifire" but got nothing there either.

I know they changed a couple of the names like heliforward and heliback to helicyclicforward and helicyclicback. So they may have changed others as well?

Here is the code I drop into the initialization area when I want to test inputaction results. I believe you would need to use the spawn command to make your code work.
Here is what I use for testing.


sh = [] spawn
{
while{true}do
{
hintsilent format ["%1",(inputaction "helicyclicleft")];
sleep 0.1;
};
};

jcgam
Nov 1 2011, 01:50
Thanks that was helpful. I tried a lot of the actions listed here but so far nothing works:

http://community.bistudio.com/wiki/ArmA:_CfgDefaultKeysMapping

blakeace
Nov 6 2011, 01:40
Thanks that was helpful. I tried a lot of the actions listed here but so far nothing works:

http://community.bistudio.com/wiki/ArmA:_CfgDefaultKeysMapping

I'm not sure what you are trying to do. Maybe as a work around or as an alternative to get things working could you set a custom control to the same button/key you have set to fire?

In your controls setup dialog select Custom controls.
For example set use action 1 to be the same button/key.

In your code use "User1" to check for that custom control?
http://community.bistudio.com/wiki/ArmA_2:_CfgDefaultKeysMapping
This link is to the Arma 2 keys, might be closer to what is found in TOH?

I did this for a hotkey option on a menu item to use for quick releasing loads using the fire button on my joystick.

I have had mixed results with inputaction, sometimes depending on what and where I get no response. Using a menu hotkey option is more consistent I have found especially when using the custom controls.

Hope this helps
Blake