Code: Select all
Local $joy,$coord,$h,$s,$msg
$joy = _JoyInit()
If $CmdLine[0] == 1 Then
Run ( '"snes9x.exe" -fullscreen "' & $CmdLine[1] & '"' )
$coord=_GetJoy($joy,0)
While $coord[7] <> 1
$coord=_GetJoy($joy,0)
Sleep(500)
WEnd
WinClose ( "Snes9X")
$lpJoy=0 ; Joyclose
EndIf
exit 0
;======================================
; _JoyInit()
;======================================
Func _JoyInit()
Local $joy
Global $JOYINFOEX_struct = "dword[13]"
$joy=DllStructCreate($JOYINFOEX_struct)
if @error Then Return 0
DllStructSetData($joy, 1, DllStructGetSize($joy), 1);dwSize = sizeof(struct)
DllStructSetData($joy, 1, 255, 2) ;dwFlags = GetAll
return $joy
EndFunc
;======================================
; _GetJoy($lpJoy,$iJoy)
; $lpJoy Return from _JoyInit()
; $iJoy Joystick # 0-15
; Return Array containing X-Pos, Y-Pos, Z-Pos, R-Pos, U-Pos, V-Pos,POV
; Buttons down
;
; *POV This is a digital game pad, not analog joystick
; 65535 = Not pressed
; 0 = U
; 4500 = UR
; 9000 = R
; Goes around clockwise increasing 4500 for each position
;======================================
Func _GetJoy($lpJoy,$iJoy)
Local $coor,$ret
Dim $coor[8]
DllCall("Winmm.dll","int","joyGetPosEx", _
"int",$iJoy, _
"ptr",DllStructGetPtr($lpJoy))
if Not @error Then
$coor[0] = DllStructGetData($lpJoy,1,3)
$coor[1] = DllStructGetData($lpJoy,1,4)
$coor[2] = DllStructGetData($lpJoy,1,5)
$coor[3] = DllStructGetData($lpJoy,1,6)
$coor[4] = DllStructGetData($lpJoy,1,7)
$coor[5] = DllStructGetData($lpJoy,1,8)
$coor[6] = DllStructGetData($lpJoy,1,11)
$coor[7] = DllStructGetData($lpJoy,1,9)
EndIf
return $coor
EndFunc
Code to exit when button 7 is pressed, Not sure It work for 360 pad.