Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Versão 2.2 - bug no joystick 2 corrigido
- ; Versão 2.1 - bug ao ir para direita corrigido
- ; site: https://wgomessantos.blogspot.com/2020/04/autohotkey-joystick-1-e-2.html
- #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
- #Persistent ; Keep this script running until the user explicitly exits it.
- #SingleInstance force
- ; Which joystick is the configuration for? Common values 1 or 2
- ; A configuração é para qual joystick? Valores comuns 1 ou 2
- joystick := 1
- ; If true the keyboard arrows will be used
- ; Se true será usado as setas do teclado
- ; If false you will have to customize it your way, the default is wasd
- ; Se false você terá que personalizar do seu jeito, o padrão é wasd
- setas_teclado = true
- if(%setas_teclado%)
- {
- joy1up = up
- joy1left = left
- joy1down = down
- joy1right = right
- }
- else
- {
- joy1up = w
- joy1left = a
- joy1down = s
- joy1right = d
- }
- ; Opcional: Se desejar atribua as teclas para ações
- ; Optional: If desired, assign keys to actions
- jump = y ;pulo
- attack = u ;ataque
- kick = ;chute
- punch = ;soco
- special = i ;especial
- power = ;poder
- select = o
- start = p
- ; Map the joystick buttons here
- ; Mapeie os botões do joystick aqui
- ; Optional: Map an action instead of a key, see the example below
- ; Important: The action must be previously mapped
- ; Example
- ; punch = z
- ; joy1b1 = %punch%
- ; Opcional: Mapear uma ação ao invés de uma tecla, ver o exemplo abaixo
- ; Importante: A ação deve estar previamente mapeada
- ; Exemplo
- ; punch = z
- ; joy1b1 = %punch%
- joy1b1 = 1
- joy1b2 = 2
- joy1b3 = 3
- joy1b4 = 4
- joy1b5 = 5
- joy1b6 = 6
- joy1b7 = 7
- joy1b8 = 8
- joy1b9 = 9
- joy1b10 = 0
- joy1b11 = a
- joy1b12 = b
- ; turbo button (true = yes, false = no)
- ; botao turbo (true = sim, false = nao)
- joy1b1turbo = false
- joy1b2turbo = false
- joy1b3turbo = false
- joy1b4turbo = false
- joy1b5turbo = false
- joy1b6turbo = false
- joy1b7turbo = false
- joy1b8turbo = false
- joy1b9turbo = false
- joy1b10turbo = false
- joy1b11turbo = false
- joy1b12turbo = false
- ; SOMENTE ALTERE SE VOCE SOUBER O QUE ESTA FAZENDO!
- ; Only change if you are sure what you are doing.
- joy1PovIdle = -1
- joy1PovUpNumber = 0
- joy1PovLeftNumber = 27000
- joy1PovDownNumber = 18000
- joy1PovRightNumber = 9000
- ;POV (Point Of View), D-PAD or PAD
- joy1PovUpKey := joy1up
- joy1PovLeftKey := joy1left
- joy1PovDownKey := joy1down
- joy1PovRightKey := joy1right
- SetKeyDelay -1
- turboDelay = 50
- j1direction := 0
- ladoAnterior = %joy1right%
- verticalAnterior = %joy1up%
- ; To adjust the axes in an integer, as the return can be decimal with 49.6086 instead of 50
- ; Para ajuste dos eixos em um inteiro, pois o retorno pode ser decimal com 49.6086 invés de 50
- axisIdle := 50
- tolerance := 1
- axisMinor := axisIdle - tolerance
- axisMajor := axisIdle + tolerance
- ; Calling a steam game
- ;caminho = %A_ProgramFiles%\Steam\Steam.exe
- ;IfNotExist % caminho
- ;{
- ; caminho = %A_ProgramFiles% (x86)\Steam\Steam.exe
- ;}
- ;
- ;IfExist % caminho
- ;{
- ; Run %caminho% -applaunch 422810
- ;}
- Hotkey, %joystick%Joy1, button1
- Hotkey, %joystick%Joy2, button2
- Hotkey, %joystick%Joy3, button3
- Hotkey, %joystick%Joy4, button4
- Hotkey, %joystick%Joy5, button5
- Hotkey, %joystick%Joy6, button6
- Hotkey, %joystick%Joy7, button7
- Hotkey, %joystick%Joy8, button8
- Hotkey, %joystick%Joy9, button9
- Hotkey, %joystick%Joy10, button10
- Hotkey, %joystick%Joy11, button11
- Hotkey, %joystick%Joy12, button12
- SetTimer, WatchAxis, 5
- ; Quits script automatically when the game is finished
- ;Process, Wait, RCRU.exe
- ;Process, Exist, RCRU.exe
- ;PID = %ErrorLevel%
- ;Process, WaitClose, %PID%
- ;ExitApp
- stopDirection = false
- WatchAxis:
- if (%stopDirection%) {
- return
- }
- GetKeyState, joy1X, %joystick%JoyX ;posição do eixo X
- GetKeyState, joy1Y, %joystick%JoyY ;posição do eixo X
- GetKeyState, pov1, %joystick%JoyPOV ;posição Point Of View
- ;Debug
- ;ToolTip, joy1X: %joy1X% `n joy1Y: %joy1Y% `n j1direction: %j1direction% `n axisIdle: %axisIdle% `n pov1: %pov1%
- ; Para ajuste dos eixos em um inteiro, pois o retorno pode ser decimal com 49.6086 invés de 50
- if((joy1X > axisMinor) and (joy1X < axisMajor)){
- joy1X := axisIdle
- }
- if(joy1Y > axisMinor) and (joy1Y < axisMajor){
- joy1Y := axisIdle
- }
- if (pov1 <> joy1PovIdle)
- {
- ;diagonal - up + left
- if (pov1 > joy1PovLeftNumber) ; 31500
- {
- j1direction := 1
- verticalAnterior = %joy1up%
- ladoAnterior = %joy1left%
- }
- else if (pov1 = joy1PovLeftNumber) ; 27000
- {
- ;left
- j1direction := 6
- ladoAnterior = %joy1left%
- }
- else if (pov1 > joy1PovDownNumber) ; 22500
- {
- ;diagonal - down + left
- j1direction := 3
- verticalAnterior = %joy1down%
- ladoAnterior = %joy1left%
- }
- else if (pov1 = joy1PovDownNumber) ; 18000
- {
- ;down
- j1direction := 7
- verticalAnterior = %joy1down%
- }
- else if (pov1 > joy1PovRightNumber) ; 13500
- {
- ;diagonal - down + right
- j1direction := 4
- verticalAnterior = %joy1down%
- ladoAnterior = %joy1right%
- }
- else if (pov1 = joy1PovRightNumber) ; 9000
- {
- ;right
- j1direction := 5
- ladoAnterior = %joy1right%
- }
- else if (pov1 > joy1PovUpNumber) ; 4500
- {
- ;diagonal - up + right
- j1direction := 2
- verticalAnterior = %joy1up%
- ladoAnterior = %joy1right%
- }
- else if (pov1 = joy1PovUpNumber) ; 0
- {
- ;up
- j1direction := 8
- verticalAnterior = %joy1up%
- }
- else
- {
- j1direction := 0
- }
- }
- else
- {
- if ((joy1X = axisIdle) and (joy1Y = axisIdle))
- {
- j1direction := 0
- }
- else if ((joy1X < axisIdle) and (joy1Y < axisIdle))
- {
- ;diagonal - up + left
- j1direction := 1
- verticalAnterior = %joy1up%
- ladoAnterior = %joy1left%
- }
- else if ((joy1X > axisIdle) and (joy1Y < axisIdle))
- {
- ;diagonal - up + right
- j1direction := 2
- verticalAnterior = %joy1up%
- ladoAnterior = %joy1right%
- }
- else if ((joy1X < axisIdle) and (joy1Y > axisIdle))
- {
- ;diagonal - down + left
- j1direction := 3
- verticalAnterior = %joy1down%
- ladoAnterior = %joy1left%
- }
- else if ((joy1X > axisIdle) and (joy1Y > axisIdle))
- {
- ;diagonal - down + right
- j1direction := 4
- verticalAnterior = %joy1down%
- ladoAnterior = %joy1right%
- }
- else if (joy1X > axisIdle)
- {
- ;right
- j1direction := 5
- ladoAnterior = %joy1right%
- }
- else if (joy1X < axisIdle)
- {
- ;left
- j1direction := 6
- ladoAnterior = %joy1left%
- }
- else if (joy1Y > axisIdle)
- {
- ;down
- j1direction := 7
- verticalAnterior = %joy1down%
- }
- else if (joy1Y < axisIdle)
- {
- ;up
- j1direction := 8
- verticalAnterior = %joy1up%
- }
- else
- {
- j1direction := 0
- }
- }
- ;Ative esse return quando o joystick estiver
- ;funcionando ao mesmo tempo que esta macro
- ;assim o jogo não receberá 2 inputs, porém
- ;podemos chamar os golpes especiais
- ;return
- if (j1direction <> j1directionPrevious)
- {
- if(j1direction = 0){
- Send, {%joy1up% up}
- Send, {%joy1left% up}
- Send, {%joy1down% up}
- Send, {%joy1right% up}
- }else if(j1direction = 5){
- Send, {%joy1up% up}
- Send, {%joy1left% up}
- Send, {%joy1down% up}
- ;Send, {%joy1right% up}
- Send, {%joy1right% down}
- }else if(j1direction = 6){
- Send, {%joy1up% up}
- ;Send, {%joy1left% up}
- Send, {%joy1down% up}
- Send, {%joy1right% up}
- Send, {%joy1left% down}
- }else if(j1direction = 8){
- ;Send, {%joy1up% up}
- Send, {%joy1left% up}
- Send, {%joy1down% up}
- Send, {%joy1right% up}
- Send, {%joy1up% down}
- }else if(j1direction = 7){
- Send, {%joy1up% up}
- Send, {%joy1left% up}
- ;Send, {%joy1down% up}
- Send, {%joy1right% up}
- Send, {%joy1down% down}
- }else if(j1direction = 2){
- ;Send, {%joy1up% up}
- Send, {%joy1left% up}
- Send, {%joy1down% up}
- ;Send, {%joy1right% up}
- Send, {%joy1up% down}
- Send, {%joy1right% down}
- }else if(j1direction = 1){
- ;Send, {%joy1up% up}
- ;Send, {%joy1left% up}
- Send, {%joy1down% up}
- Send, {%joy1right% up}
- Send, {%joy1up% down}
- Send, {%joy1left% down}
- }else if(j1direction = 4){
- Send, {%joy1up% up}
- Send, {%joy1left% up}
- ;Send, {%joy1down% up}
- ;Send, {%joy1right% up}
- Send, {%joy1right% down}
- Send, {%joy1down% down}
- }else if(j1direction = 3){
- Send, {%joy1up% up}
- ;Send, {%joy1left% up}
- ;Send, {%joy1down% up}
- Send, {%joy1right% up}
- Send, {%joy1left% down}
- Send, {%joy1down% down}
- }
- j1directionPrevious := j1direction
- }
- return ; WatchAxis end
- button1:
- if (%joy1b1turbo%) {
- loop { ; loop the script untill broken
- GetKeyState, stateJoy1, %joystick%Joy1, P ; Get the state of button (U = Up and D = Down)
- if stateJoy1 = U
- break ; its been released so break the loop
- sleep, turboDelay
- send {%joy1b1% down}
- sleep, turboDelay ; This is the time between presses, after its slept it will return to the top of the loop and start again
- send {%joy1b1% up}
- } ;loop end
- } else {
- send {%joy1b1% down}
- KeyWait %joystick%Joy1
- send {%joy1b1% up}
- } ; if end
- return
- button2:
- if (%joy1b2turbo%) {
- loop { ; loop the script untill broken
- GetKeyState, stateJoy2, %joystick%Joy2, P ; Get the state of button (U = Up and D = Down)
- if stateJoy2 = U
- break ; its been released so break the loop
- sleep, turboDelay
- send {%joy1b2% down}
- sleep, turboDelay ; This is the time between presses, after its slept it will return to the top of the loop and start again
- send {%joy1b2% up}
- } ;loop end
- } else {
- send {%joy1b2% down}
- KeyWait %joystick%Joy2
- send {%joy1b2% up}
- } ; if end
- return
- button3:
- if (%joy1b3turbo%) {
- loop { ; loop the script untill broken
- GetKeyState, stateJoy3, %joystick%Joy3, P ; Get the state of button (U = Up and D = Down)
- if stateJoy3 = U
- break ; its been released so break the loop
- sleep, turboDelay
- send {%joy1b3% down}
- sleep, turboDelay ; This is the time between presses, after its slept it will return to the top of the loop and start again
- send {%joy1b3% up}
- } ;loop end
- } else {
- send {%joy1b3% down}
- KeyWait %joystick%Joy3
- send {%joy1b3% up}
- } ; if end
- return
- button4:
- if (%joy1b4turbo%) {
- loop { ; loop the script untill broken
- GetKeyState, stateJoy4, %joystick%Joy4, P ; Get the state of button (U = Up and D = Down)
- if stateJoy4 = U
- break ; its been released so break the loop
- sleep, turboDelay
- send {%joy1b4% down}
- sleep, turboDelay ; This is the time between presses, after its slept it will return to the top of the loop and start again
- send {%joy1b4% up}
- } ;loop end
- } else {
- send {%joy1b4% down}
- KeyWait %joystick%Joy4
- send {%joy1b4% up}
- } ; if end
- return
- button5:
- if (%joy1b5turbo%) {
- loop { ; loop the script untill broken
- GetKeyState, stateJoy5, %joystick%Joy5, P ; Get the state of button (U = Up and D = Down)
- if stateJoy5 = U
- break ; its been released so break the loop
- sleep, turboDelay
- send {%joy1b5% down}
- sleep, turboDelay ; This is the time between presses, after its slept it will return to the top of the loop and start again
- send {%joy1b5% up}
- } ;loop end
- } else {
- send {%joy1b5% down}
- KeyWait %joystick%Joy5
- send {%joy1b5% up}
- } ; if end
- return
- button6:
- if (%joy1b6turbo%) {
- loop { ; loop the script untill broken
- GetKeyState, stateJoy6, %joystick%Joy6, P ; Get the state of button (U = Up and D = Down)
- if stateJoy6 = U
- break ; its been released so break the loop
- sleep, turboDelay
- send {%joy1b6% down}
- sleep, turboDelay ; This is the time between presses, after its slept it will return to the top of the loop and start again
- send {%joy1b6% up}
- } ;loop end
- } else {
- send {%joy1b6% down}
- KeyWait %joystick%Joy6
- send {%joy1b6% up}
- } ; if end
- return
- button7:
- if (%joy1b7turbo%) {
- loop { ; loop the script untill broken
- GetKeyState, stateJoy7, %joystick%Joy7, P ; Get the state of button (U = Up and D = Down)
- if stateJoy7 = U
- break ; its been released so break the loop
- sleep, turboDelay
- send {%joy1b7% down}
- sleep, turboDelay ; This is the time between presses, after its slept it will return to the top of the loop and start again
- send {%joy1b7% up}
- } ;loop end
- } else {
- send {%joy1b7% down}
- KeyWait %joystick%Joy7
- send {%joy1b7% up}
- } ; if end
- return
- button8:
- if (%joy1b8turbo%) {
- loop { ; loop the script untill broken
- GetKeyState, stateJoy8, %joystick%Joy8, P ; Get the state of button (U = Up and D = Down)
- if stateJoy8 = U
- break ; its been released so break the loop
- sleep, turboDelay
- send {%joy1b8% down}
- sleep, turboDelay ; This is the time between presses, after its slept it will return to the top of the loop and start again
- send {%joy1b8% up}
- } ;loop end
- } else {
- send {%joy1b8% down}
- KeyWait %joystick%Joy8
- send {%joy1b8% up}
- } ; if end
- return
- button9:
- if (%joy1b9turbo%) {
- loop { ; loop the script untill broken
- GetKeyState, stateJoy9, %joystick%Joy9, P ; Get the state of button (U = Up and D = Down)
- if stateJoy9 = U
- break ; its been released so break the loop
- sleep, turboDelay
- send {%joy1b9% down}
- sleep, turboDelay ; This is the time between presses, after its slept it will return to the top of the loop and start again
- send {%joy1b9% up}
- } ;loop end
- } else {
- send {%joy1b9% down}
- KeyWait %joystick%Joy9
- send {%joy1b9% up}
- } ; if end
- return
- button10:
- if (%joy1b10turbo%) {
- loop { ; loop the script untill broken
- GetKeyState, stateJoy10, %joystick%Joy10, P ; Get the state of button (U = Up and D = Down)
- if stateJoy10 = U
- break ; its been released so break the loop
- sleep, turboDelay
- send {%joy1b10% down}
- sleep, turboDelay ; This is the time between presses, after its slept it will return to the top of the loop and start again
- send {%joy1b10% up}
- } ;loop end
- } else {
- send {%joy1b10% down}
- KeyWait %joystick%Joy10
- send {%joy1b10% up}
- } ; if end
- return
- button11:
- if (%joy1b11turbo%) {
- loop { ; loop the script untill broken
- GetKeyState, stateJoy11, %joystick%Joy11, P ; Get the state of button (U = Up and D = Down)
- if stateJoy11 = U
- break ; its been released so break the loop
- sleep, turboDelay
- send {%joy1b11% down}
- sleep, turboDelay ; This is the time between presses, after its slept it will return to the top of the loop and start again
- send {%joy1b11% up}
- } ;loop end
- } else {
- send {%joy1b11% down}
- KeyWait %joystick%Joy11
- send {%joy1b11% up}
- } ; if end
- return
- button12:
- if (%joy1b12turbo%) {
- loop { ; loop the script untill broken
- GetKeyState, stateJoy12, %joystick%Joy12, P ; Get the state of button (U = Up and D = Down)
- if stateJoy12 = U
- break ; its been released so break the loop
- sleep, turboDelay
- send {%joy1b12% down}
- sleep, turboDelay ; This is the time between presses, after its slept it will return to the top of the loop and start again
- send {%joy1b12% up}
- } ;loop end
- } else {
- send {%joy1b12% down}
- KeyWait %joystick%Joy12
- send {%joy1b12% up}
- } ; if end
- return
- ;correr atacar
- run_attack:
- if(%stopDirection%){
- return
- }
- stopDirection = true
- Send, {%joy1up% up}
- Send, {%joy1left% up}
- Send, {%joy1down% up}
- Send, {%joy1right% up}
- send, {%ladoAnterior% down}
- sleep, turboDelay
- send, {%ladoAnterior% up}
- sleep, turboDelay
- send, {%ladoAnterior% down}
- sleep, turboDelay
- send, {%attack% down}
- sleep, turboDelay ;fix
- send, {%ladoAnterior% up}
- send, {%attack% up}
- stopDirection = false
- return
- ;correr chutar
- run_kick:
- if(%stopDirection%){
- return
- }
- stopDirection = true
- Send, {%joy1up% up}
- Send, {%joy1left% up}
- Send, {%joy1down% up}
- Send, {%joy1right% up}
- send, {%ladoAnterior% down}
- sleep, turboDelay
- send, {%ladoAnterior% up}
- sleep, turboDelay
- send, {%ladoAnterior% down}
- sleep, turboDelay
- send, {%kick% down}
- send, {%ladoAnterior% up}
- send, {%kick% up}
- stopDirection = false
- return
- ;voadora
- flying_kick:
- send, {%jump% down}
- sleep, turboDelay
- send, {%jump% up}
- send {%kick%}
- return
- ;esquiva vertical (cima ou baixo)
- vertical_dogde:
- if(%stopDirection%){
- return
- }
- stopDirection = true
- Send, {%joy1up% up}
- Send, {%joy1left% up}
- Send, {%joy1down% up}
- Send, {%joy1right% up}
- send, {%verticalAnterior% down}
- sleep, turboDelay
- send, {%verticalAnterior% up}
- sleep, turboDelay
- send, {%verticalAnterior% down}
- sleep, turboDelay
- ;sleep, turboDelay
- send, {%verticalAnterior% up}
- stopDirection = false
- return
- ;esquiva para cima
- up_dogde:
- if(%stopDirection%){
- return
- }
- stopDirection = true
- Send, {%joy1up% up}
- Send, {%joy1left% up}
- Send, {%joy1down% up}
- Send, {%joy1right% up}
- send, {%joy1up% down}
- sleep, turboDelay
- send, {%joy1up% up}
- sleep, turboDelay
- send, {%joy1up% down}
- sleep, turboDelay
- ;sleep, turboDelay
- send, {%joy1up% up}
- stopDirection = false
- return
- ;esquiva para baixo
- down_dogde:
- if(%stopDirection%){
- return
- }
- stopDirection = true
- Send, {%joy1up% up}
- Send, {%joy1left% up}
- Send, {%joy1down% up}
- Send, {%joy1right% up}
- send, {%joy1down% down}
- sleep, turboDelay
- send, {%joy1down% up}
- sleep, turboDelay
- send, {%joy1down% down}
- sleep, turboDelay
- ;sleep, turboDelay
- send, {%joy1down% up}
- stopDirection = false
- return
Add Comment
Please, Sign In to add comment