Gamepad Tasten einlesen

  • Hi Leute.
    Erst einmal euch allen ein frohes neues Jahr und dann meine Frage:
    Ich habe ein
    SPEED-LINK Hornet Gamepad, black (SL-6512-SBK-A)
    mit 10 Tasten und würde gerne ein AutoIT Programm schreiben, in dem man vorher in einer GUI festlegt welche Tasten gedrückt werden sollen, wenn eine Taste des Gamepads betätigt wird.
    Dann würde ich auch noch gerne Mausbewegungen mit der X und Y Achse des Gamepads möglich machen.
    Jetzt stellt sich mir nur ein Problem:
    Wie erfasse ich die Gamepad Tasten und die X und Y Achse.
    Google hat nicht viel weitergeholfen und deshalb erbitte ich eure Hilfe.
    Mit freundlichen Grüßen und danke im Vorraus
    Fliwatt

  • da fällt mir gard garnix ein das liegt wohl aber eher das sich mein gerhinr jetz mit weniger zellen zurechtfinden muss :P

    ICh würde mal auf der HP nach der Treiber Software suchen.
    Also nich nur die Treiber Datein sonder die ganze software.
    Weil wenn ich das für mein gamepad installieren simuliert der ne ganz normale maus und tastatur


  • da fällt mir gard garnix ein das liegt wohl aber eher das sich mein gerhinr jetz mit weniger zellen zurechtfinden muss :P

    ICh würde mal auf der HP nach der Treiber Software suchen.
    Also nich nur die Treiber Datein sonder die ganze software.
    Weil wenn ich das für mein gamepad installieren simuliert der ne ganz normale maus und tastatur


    Tja... Das Gampad hat nur ne lumpige Anleitung. Es ist Plug&Play und außer dem Standardfaq steht dort nichts geschrieben:
    http://www.speedlink.com/?p=3&cat=313&pid=1542&paus=1
    Trotzdem Danke
    Fliwatt

  • Sowas gab es hier schon einmal, und da hat jemand auch eine nützliche UDF gepostet.

    Ich finde diese nur gerade leider nicht mehr...

  • Ja genau. Da ist ja auch ein GUI dabei, dieses dir die Werte von deinem Gamepad gibt.

    Bei was hast du nun jetzt noch Probleme?

  • Wie benutze ich jetzt das?
    Bei mir geht der Skript prima nur ich würde jetzt gerne ein Programm machen, das Gamepad2Keyboard heißen soll. Jetzt würde ich gerne, dass er eine Gampad Taste empfängt und z.b. bei dem Button 2 auf dem Gamepad die Taste W auf der Tastatur drückt. Es wäre auch toll wenn er X und Y des Gamepads nehmen würde und die Maus daraufhin bewegen würde.
    Und noch etwas, das Skript hat einen Bug:
    Bei mir zeigt er wenn ich Button 8 drücke Button 128 an.
    Na gut, ich werde versuchen damit zu leben.
    Mfg Fliwatt

  • Jetzt startest du das Script, und schaust einfach, welche Eigenschaft die Buttons bei dir haben.

    Wegen dem W:

    Du schließt den Joy an, startest das Script.
    Drückst den Button für das "W", und dann siehst du welche Nummer er hat.

    Dann schaust du dir die Funktionsheader der Funktionen an, und merkst, dass du damit überprüfen kannst, ob die Taste gedrückt wurde auf dem Gamepad. Wenn das ist, sendest du einfach "W".

    Noch fragen? *gg*

  • [autoit]

    Func JoyPressed()
    Local $dsJoy, $iBit = 0.5, $iReturn = 0
    $dsJoy = DllStructCreate("dword[13]")
    DllStructSetData($dsJoy, 1, DllStructGetSize($dsJoy), 1)
    DllStructSetData($dsJoy, 1, 255, 2)
    DllCall("Winmm.dll", "int", "joyGetPosEx", "int", 0, "ptr", DllStructGetPtr($dsJoy))
    If DllStructGetData($dsJoy, 1, 9) = 0 Then Return 0
    Do
    $iReturn += 1
    $iBit *= 2
    Until DllStructGetData($dsJoy, 1, 9) = $iBit
    Return $iReturn
    EndFunc ;==>JoyPressed

    [/autoit]

    Einmal editiert, zuletzt von Smincke (8. Januar 2011 um 19:39)

  • für alle Joypads,Lenkräder,sonstige eingabegeräte !!!

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    ;655535

    [/autoit] [autoit][/autoit] [autoit]

    $Form1 = GUICreate("Xbox 360 Controller", 300, 400)
    $X0 = GUICtrlCreateLabel('', 10, 10, 30, 20)
    $S0 = GUICtrlCreateSlider(40, 05, 250, 20, 0x0010)
    $X1 = GUICtrlCreateLabel('', 10, 30, 30, 20)
    $S1 = GUICtrlCreateSlider(40, 25, 250, 20, 0x0010)
    $X2 = GUICtrlCreateLabel('', 10, 50, 30, 20)
    $S2 = GUICtrlCreateSlider(40, 45, 250, 20, 0x0010)
    $X3 = GUICtrlCreateLabel('', 10, 70, 30, 20)
    $S3 = GUICtrlCreateSlider(40, 65, 250, 20, 0x0010)
    $X4 = GUICtrlCreateLabel('', 10, 90, 30, 20)
    $S4 = GUICtrlCreateSlider(40, 85, 250, 20, 0x0010)
    $X5 = GUICtrlCreateLabel('', 10, 110, 30, 20)
    $X6 = GUICtrlCreateLabel('', 10, 130, 30, 20)
    $X7 = GUICtrlCreateLabel('', 10, 150, 30, 20)
    GUICtrlCreateLabel('Buttons Pressed:', 10, 170, 280, 20)
    $XB = GUICtrlCreateLabel('', 10, 190, 280, 20)
    GUISetState(@SW_SHOW)

    [/autoit] [autoit][/autoit] [autoit]

    $joy = _JoyInit()

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    Sleep(10)
    $msg = GUIGetMsg()
    $j = _GetJoy($joy, 0)
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop

    [/autoit] [autoit][/autoit] [autoit]

    ;Get Array values from _GetJoy return and display
    For $a = 0 To 7
    $control = Execute('$X' & $a)
    If GUICtrlRead($control) <> $j[$a] Then GUICtrlSetData($control, $j[$a])
    Next

    [/autoit] [autoit][/autoit] [autoit]

    ;Get buttons pressed and display
    $Spressed = GetPressed($j[7])
    If GUICtrlRead($XB) <> $Spressed Then GUICtrlSetData($XB, $Spressed)

    [/autoit] [autoit][/autoit] [autoit]

    ;Set sliders to correct position
    For $a = 0 To 4
    SetSliders($j[$a], $a)
    Next
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func GetPressed($Val)
    $SButtons = ''
    If BitAND($Val, 1) Then $SButtons &= '(A)'
    If BitAND($Val, 2) Then $SButtons &= '(B)'
    If BitAND($Val, 4) Then $SButtons &= '(X)'
    If BitAND($Val, 8) Then $SButtons &= '(Y)'
    If BitAND($Val, 16) Then $SButtons &= '(LB)'
    If BitAND($Val, 32) Then $SButtons &= '(RB)'
    If BitAND($Val, 64) Then $SButtons &= '(Back)'
    If BitAND($Val, 128) Then $SButtons &= '(Start)'
    If BitAND($Val, 256) Then $SButtons &= '(LS)'
    If BitAND($Val, 512) Then $SButtons &= '(RS)'
    Return $SButtons
    EndFunc ;==>GetPressed

    [/autoit] [autoit][/autoit] [autoit]

    Func SetSliders($Val, $Slide)
    $control = Execute('$S' & $Slide)
    If $Val = 65535 Then
    GUICtrlSetData($control, 0)
    ElseIf $Val = 0 Then
    GUICtrlSetData($control, 100)
    Else
    GUICtrlSetData($control, ((65535 - $Val) / 65535) * 100)
    EndIf
    EndFunc ;==>SetSliders

    [/autoit] [autoit][/autoit] [autoit]

    ;======================================
    ; _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 ;==>_JoyInit

    [/autoit] [autoit][/autoit] [autoit]

    ;======================================
    ; _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 ;==>_GetJoy

    [/autoit]
  • Das is Total unnütz, weil mein controler 6 tasten hat und das dann gar net mehr stimmt