Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #SingleInstance force
- ;autor: Fragoon aka Summoner, LunatiX (Piotr Bugaj)
- ;------------Edit to change Joy Number ( 0 = Auto Detect) ---------------
- JoyNo = -1
- JoyNo2 = 0
- ;------------------------------------------------------------------------
- ;--- Constants Depend on USB Adapter, Calibration ---
- J1None = 49.609
- J1Both = 49.999
- J2None = 49.609
- J2Both = 49.999
- ;------------------------------------------------------------------------
- #Persistent
- ;Run, StepMania, ,
- SetFormat, float, 2.3
- SetKeyDelay -1
- SetTimer, Detect
- SetTimer, WatchKeys, 1
- SetTimer, WatchKeys_2, 1
- ;SetTimer, GameCheck, 10000
- Detect: ;---------------------------------------------------------------------------
- if JoyNo <= -1
- {
- Loop 4
- {
- GetKeyState, JoyName, %A_Index%JoyName
- if JoyName <>
- {
- if JoyNo <= -1
- {
- JoyNo = %A_Index%
- ;MsgBox JoyNo %JoyNo%
- }
- else
- {
- JoyNo2 = %A_Index%
- ;MsgBox JoyNo2 %JoyNo2%
- break
- }
- }
- }
- if JoyNo <= -1
- {
- MsgBox No joysticks detected
- ExitApp
- }
- TrayTip, Joystick Detected, %JoyName% `nJoyNo: %JoyNo% `nJoy2No: %JoyNo2% , 3
- }
- SetTimer, Detect, Off
- return
- WatchKeys: ;-----------------------------------------------------------------------
- GetKeyState, joyx, %JoyNo%JoyX
- GetKeyState, joyy, %JoyNo%JoyY
- ;ToolTip, %JoyNo% `n %joyx% `n %joyy% 'n
- ;axis x
- if joyxP != %joyx%
- {
- if joyx >= 0
- {
- if joyx<%J1None%
- {
- SR =
- SL = 1
- Send, {Right up}
- }
- if joyx>%J1Both%
- {
- SR = 1
- SL =
- Send, {Left up}
- }
- if joyx=%J1Both%
- {
- SR = 1
- SL = 1
- }
- if joyx=%J1None%
- {
- SR =
- SL =
- Send, {Right up}
- Send, {Left up}
- }
- }
- }
- ;axis y
- if joyyP != %joyy%
- {
- if joyy >= 0
- {
- if joyy<%J1None%
- {
- SD =
- SU = 1
- Send, {Down up}
- }
- if joyy>%J1Both%
- {
- SD = 1
- SU =
- Send, {Up up}
- }
- if joyy=%J1Both%
- {
- SD = 1
- SU = 1
- }
- if joyy=%J1None%
- {
- SD =
- SU =
- Send, {Down up}
- Send, {Up up}
- }
- }
- }
- joyxP = %joyx%
- joyyP = %joyy%
- if SR
- Send, {Right down}
- if SL
- Send, {Left down}
- if SD
- Send, {Down down}
- if SU
- Send, {Up down}
- return
- WatchKeys_2: ;-----------------------------------------------------------------------
- GetKeyState, joy2x, %JoyNo2%JoyX
- GetKeyState, joy2y, %JoyNo2%JoyY
- ;ToolTip, %JoyNo2% `n %joy2x% `n %joy2y%
- ;axis x
- if joy2xP != %joy2x%
- {
- if joy2x >= 0
- {
- if joy2x<%J2None%
- {
- SR2 =
- SL2 = 1
- Send, {d up}
- }
- if joy2x>%J2Both%
- {
- SR2 = 1
- SL2 =
- Send, {a up}
- }
- if joy2x=%J2Both%
- {
- SR2 = 1
- SL2 = 1
- }
- if joy2x=%J2None%
- {
- SR2 =
- SL2 =
- Send, {d up}
- Send, {a up}
- }
- }
- }
- ;axis y
- if joy2yP != %joy2y%
- {
- if joy2y >= 0
- {
- if joy2y<%J2None%
- {
- SD2 =
- SU2 = 1
- Send, {s up}
- }
- if joy2y>%J2Both%
- {
- SD2 = 1
- SU2 =
- Send, {w up}
- }
- if joy2y=%J2Both%
- {
- SD2 = 1
- SU2 = 1
- }
- if joy2y=%J2None%
- {
- SD2 =
- SU2 =
- Send, {s up}
- Send, {w up}
- }
- }
- }
- joy2xP = %joy2x%
- joy2yP = %joy2y%
- if SR2
- Send, {d down}
- if SL2
- Send, {a down}
- if SD2
- Send, {s down}
- if SU2
- Send, {w down}
- return
- ;GameCheck: ;------------------------------------------------------------------------
- ;IfWinNotExist, StepMania
- ; {
- ; IfWinNotExist, ahk_class SDL_app
- ; ExitApp
- ; }
- ;return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement