; Script can be directly run by or compiled into an .exe by the open-source software AutoHotkey
; https://www.autohotkey.com

;
; Front Matter
;

; Include general library
#Include ../lib/Prelude.ahk

; Include XInput library
#Include ../thirdparty/XInput/XInput.ahk

; Only do hotkeys if relevant window is
;#If WinActive("Dark Souls III")

;
; Hotkeys
;
XInput_Init()

PrevState := 0
Loop {
    State := XInput_GetState(0)
    if ( State.wButtons & XINPUT_GAMEPAD_LEFT_THUMB ) {
        if (PrevState == 0) {
            Send {LButton down}
            Send {w down}
            PrevState := 1
        }
    } else {
        if (PrevState == 1) {
            Send {LButton up}
            Send {w up}
            PrevState := 0
        }
    }
    Sleep 50
}