This does diagonals. (I added variable declarations so I could test it)
Code:
#Persistent
riButton = right
ltButton = left
dnButton = down
upButton = up
SetTimer, WatchAxis, 5
return
WatchAxis:
GetKeyState, JoyX, JoyX
GetKeyState, JoyY, JoyY
KeyToHoldDownPrevX = %KeyToHoldDownX%
KeyToHoldDownPrevY = %KeyToHoldDownY%
if JoyX > 70
KeyToHoldDownX = %riButton%
else if JoyX < 30
KeyToHoldDownX = %ltButton%
else
KeyToHoldDownX =
if JoyY > 70
KeyToHoldDownY = %dnButton%
else if JoyY < 30
KeyToHoldDownY = %upButton%
else
KeyToHoldDownY =
if KeyToHoldDownX = %KeyToHoldDownPrevX%
{
if KeyToHoldDownX
Send, {%KeyToHoldDownX% down}
} else {
if KeyToHoldDownPrevX
Send, {%KeyToHoldDownPrevX% up}
if KeyToHoldDownX
Send, {%KeyToHoldDownX% down}
}
if KeyToHoldDownY = %KeyToHoldDownPrevY%
{
if KeyToHoldDownY
Send, {%KeyToHoldDownY% down}
} else {
if KeyToHoldDownPrevY
Send, {%KeyToHoldDownPrevY% up}
if KeyToHoldDownY
Send, {%KeyToHoldDownY% down}
}
SetKeyDelay -1
return
You have to completely separate handling of the x and y axes. I basically copied the code you had, making one version for x and one for y. Also, because we have more stuff to take care of, I had to replace your use of "return" with "else". It's the exact same logic, though.