Author Topic: script wait until joy8 is pressed  (Read 14682 times)

Aeliss

  • Hero Member
  • *****
  • Posts: 900
Re: script wait until joy8 is pressed
« Reply #4 on: March 20, 2014, 01:32:28 PM »
What do you want to do with this script ?

h3xl3y

  • Newbie
  • *
  • Posts: 40
Re: script wait until joy8 is pressed
« Reply #3 on: March 19, 2014, 12:52:52 PM »
I tried several variants of that code but didn't work
maybe you can give a more specific example
i never made scripts with joy keys so maybe i missed something

Is there an easy way to do it like edit something from mGalaxy ?
from Xpadder is not working because mGalaxy recognizes my controller now
so it does not work anymore with a mGalaxy profile from Xpadder

Aeliss

  • Hero Member
  • *****
  • Posts: 900
Re: script wait until joy8 is pressed
« Reply #2 on: March 17, 2014, 12:15:13 PM »
Code: (autoit) [Select]
    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.

h3xl3y

  • Newbie
  • *
  • Posts: 40
script wait until joy8 is pressed
« Reply #1 on: March 16, 2014, 02:22:36 PM »
Hi
Who knows a easy way to detect when a button is pressed on the XBox360 controller in Autoit ?
the button i am interested to detect is Start (joy8 as detected in Windows)
i had this code previously to press Space on keyboard but now i need the Start button from Xbox360 controller
Code: [Select]
Run( $app1 )
Do
  Sleep(1)
Until _IsPressed( "20" )      ;Space
ProcessClose( $app1 )
Any ideea ?