twice arrow key by pressing once D-pad

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
leon
Posts: 3
Joined: 09 Feb 2018, 07:23

twice arrow key by pressing once D-pad

09 Feb 2018, 08:15

Hi everyone, I want to create a script that sends two times right arrow key by pressing one time right button on D-pad of gamepad
similary sends two times left arrow key by pressing one time left button on D-pad

i tried editing the script for joystick on https://autohotkey.com/docs/misc/RemapJoystick.htm but didn't work. i don't know much about the scripting in AHK

Please anyone can do this...
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: twice arrow key by pressing once D-pad

09 Feb 2018, 08:55

Code: Select all

lastValue := -1

Loop {
	povValue := GetKeyState("1JoyPOV")
	if (povValue != lastValue){
		if (povValue == 90){
			; POV is right
			Send {Right 2}
		} else if (povValue == 270){
			; POV is left
			Send {Left 2}
		}
		lastValue := povValue
	}
	Sleep 10
}
leon
Posts: 3
Joined: 09 Feb 2018, 07:23

Re: twice arrow key by pressing once D-pad

09 Feb 2018, 10:57

Thanks for your reply, i tried this code but its not working. actually i wanted this script for my game(street fighter 5), it supposed to do dash in game but nothing happened i also tried it in text files but its not working......
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: twice arrow key by pressing once D-pad

09 Feb 2018, 12:58

FYI, this code will only work if your joystick is ID 1, I have no way of knowing what ID your stick is.
You may need to replace 1JoyPOV with 2JoyPOV or another number, depending on what ID your stick is.
Use PJP JoyIDs to find the ID of your stick.
leon
Posts: 3
Joined: 09 Feb 2018, 07:23

Re: twice arrow key by pressing once D-pad

09 Feb 2018, 20:38

i used PJP JoyIDs to find out the id and it was 1 and same in the code you provided. i tried to send two times right, left arrow keys by using below simple code and it works in the game(dashes occur) for buttons those have simple names like joy11, joy2 etc but not for the d-pad button because d-pad button has no simple names in autohotkey, d-pad has very complicated names like pov9000, pov22501 to pov 4501 etc and when i use these names in below code it does not work....


#MaxThreadsPerHotkey 2
Joy11::
{
Send {right down}
Sleep 2
Send {right up}
Sleep 2
Send {right down}
Sleep 2
Send {right up}

}
return
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: twice arrow key by pressing once D-pad

10 Feb 2018, 13:25

No it is not complicated. Joystick POV reports in degrees. the same as a compass does.
It's just multiplied by 100. So 90 degrees (East) is 9000

There are no hotkeys for joystick axes or POVs, you have to continually check their state in a loop

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: filipemb, jaka1 and 172 guests