Hallo,
ich versuche meinen Controller auzulesen, dafür gibt es ja reichlich Beispiele. Hier nur ein paar:
https://www.autoitscript.com/forum/topic/10953-joystick-udf/
https://www.autoitscript.com/forum/topic/34…ntroller-input/
Das Beispiel aus dem ersten Link (joystick-udf) läuft bei mir wunderbar (Post 4). Wenn ich mir den Code allerdings für meine Bedürfnisse umbaue geht nichts mehr. Ich benötige nämlich kein GUI. Wenn ich das aber weglasse funktioniert es nicht. Ist das nur bei mir so?
Zum testen bitte mal Zeile 1 und 2 ein bzw auskommentieren und mich erleuchten
Danke
Code
;GUICreate("",1,1,-1,-1)
;GUISetState()
Global $myGamePadHandle = GPExInitialize()
While 1
Sleep(10)
$testrawdata = GPExGetRawData($myGamePadHandle, 0) ; Get almost every data possible from the gamepad. Returns in an array with 8 elements.
;
; Display the RAW output.
; --->
; ---> Resize the console area so that you can have all the outputs and then move the gamepad. <---
; --->
ConsoleWrite(@CRLF & "==========================================================")
ConsoleWrite(@CRLF & "[0]" & $testrawdata[0]) ; X Axis
ConsoleWrite(@CRLF & "[1]" & $testrawdata[1]) ; Y Axis
ConsoleWrite(@CRLF & "[2]" & $testrawdata[2]) ; Z Axis
ConsoleWrite(@CRLF & "[3]" & $testrawdata[3]) ; R Axis
ConsoleWrite(@CRLF & "[4]" & $testrawdata[4]) ; U Axis
ConsoleWrite(@CRLF & "[5]" & $testrawdata[5]) ; V Axis
ConsoleWrite(@CRLF & "[6]" & $testrawdata[6]) ; Point of View
ConsoleWrite(@CRLF & "[7]" & $testrawdata[7]) ; Buttons
ConsoleWrite(@CRLF & "==========================================================")
WEnd
Func GPExInitialize()
Local $joy
Local $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 ;==>GPExInitialize
Func GPExGetRawData($tempHandle, $tempID)
Local $coor
Dim $coor[8]
DllCall("Winmm.dll", "int", "joyGetPosEx", _
"int", $tempID, "ptr", DllStructGetPtr($tempHandle))
If Not @error Then
$coor[0] = DllStructGetData($tempHandle, 1, 3) ; X Axis
$coor[1] = DllStructGetData($tempHandle, 1, 4) ; Y Axis
$coor[2] = DllStructGetData($tempHandle, 1, 5) ; Z Axis
$coor[3] = DllStructGetData($tempHandle, 1, 6) ; R Axis
$coor[4] = DllStructGetData($tempHandle, 1, 7) ; U Axis
$coor[5] = DllStructGetData($tempHandle, 1, 8) ; V Axis
$coor[6] = DllStructGetData($tempHandle, 1, 11) ; POV Value
$coor[7] = DllStructGetData($tempHandle, 1, 9) ; Buttons Mask
EndIf
Return $coor
EndFunc ;==>GPExGetRawData
Alles anzeigen