für alle Joypads,Lenkräder,sonstige eingabegeräte !!!
Spoiler anzeigen
#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)
$joy = _JoyInit()
[/autoit] [autoit][/autoit] [autoit]While 1
Sleep(10)
$msg = GUIGetMsg()
$j = _GetJoy($joy, 0)
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
;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
;Get buttons pressed and display
$Spressed = GetPressed($j[7])
If GUICtrlRead($XB) <> $Spressed Then GUICtrlSetData($XB, $Spressed)
;Set sliders to correct position
For $a = 0 To 4
SetSliders($j[$a], $a)
Next
WEnd
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, 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
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
;======================================
; _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
;======================================
; _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,
$coor[6] = DllStructGetData($lpJoy, 1, 11)
$coor[7] = DllStructGetData($lpJoy, 1, 9)
EndIf
Return $coor
EndFunc ;==>_GetJoy