Tim Phillips
asked on
AutoHotKey programming a Joystick
I'm working on a project that sends txt via serial to an Arduino. The Arduino interprets the txt and parses it to get instructions for motors. Problem is that repeating keystrokes aren't working right with my basic joystick (no potentiometers, just on/off buttons even in the stick). Here is what I'm trying to send in English:
If button 14 is pressed send, in txt, "joy14". If button 13 is pressed send, in txt, "joy13". If both button 13 and 14 are pressed send, in txt, "both".
I was finally able to code this, but I lost the repeating nature of the button. I need the button/buttons to continuously send the keystrokes if held down. Here is the code I have that DOES have diagonals:
I'm open to suggestions including other programs/languages if it makes my life easier.
If button 14 is pressed send, in txt, "joy14". If button 13 is pressed send, in txt, "joy13". If both button 13 and 14 are pressed send, in txt, "both".
I was finally able to code this, but I lost the repeating nature of the button. I need the button/buttons to continuously send the keystrokes if held down. Here is the code I have that DOES have diagonals:
Joy13::
SetTimer, WaitForJoy1, 500
return
WaitForJoy1:
if not GetKeyState("Joy14")
{
Send joy13
SetTimer, WaitForJoy1, off
return
}
if GetKeyState("Joy14")
{
Send both
SetTimer, WaitForJoy1, off
return
}
Joy14::
SetTimer, WaitForJoy2, 500
return
WaitForJoy2:
if not GetKeyState("Joy13")
{
Send joy14
SetTimer, WaitForJoy2, off
return
}
if GetKeyState("Joy13")
{
Send both
SetTimer, WaitForJoy2, off
return
}
I'm open to suggestions including other programs/languages if it makes my life easier.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Open in new window