[..] Détection boutons manette
Posté : lun. 27 avr. 2020 18:40
Bonjour à tous,
Je viens demander l'aide de ceux qui passeront par là en ayant une manette branchée à leur PC.
Pouvez-vous lancer le code suivant en m'indiquant :
1) Votre OS
2) La manette utilisée
2) Si les touches sont détectées lorsque la fenêtre est active
3) Si les touches sont détectées lorsqu'une autre fenêtre est active
Merci d'avance !
Je tiendrai un tableau des tests ici :
PS : S'il y a déjà des résultats pour les données que vous avez, mettez quand même vos réponses, cela permettra de savoir combien de personnes ont testé.
Je viens demander l'aide de ceux qui passeront par là en ayant une manette branchée à leur PC.
Pouvez-vous lancer le code suivant en m'indiquant :
1) Votre OS
2) La manette utilisée
2) Si les touches sont détectées lorsque la fenêtre est active
3) Si les touches sont détectées lorsqu'une autre fenêtre est active
Merci d'avance !
Je tiendrai un tableau des tests ici :
Code : Tout sélectionner
OS | Pad | Active | Non active | Pseudos
--------|------------------------|--------|------------|------------------
Win10 | PS2 | 1 | 1 | TommyDDR
Win10 | PS3 | 1 | 1 | TommyDDR
Win10 | PS4 | 1 | 1 | TommyDDR / Joebar
Win10 | XBOX360 | 1 | 1 | TommyDDR
Win10 | XBOXOne | 1 | 0 | TommyDDR
Win10 | Logitech ChillStream | 1 | 1 | TommyDDR
Win10 | Nacon GC | 1 | 1 | Franco
Code : Tout sélectionner
Logitech
Bouton | XBOX 360 | XBOX One | PS2 | PS3 | PS4 |ChillStream| Nacon GC |
0 | A | A | Triangle | Croix | Carre | A | 1 (vert) |
1 | B | B | Rond | Rond | Croix | B | 2 (rouge) |
2 | X | X | Croix | Carre | Rond | X | 3 (bleu) |
3 | Y | Y | Carre | Triangle | Triangle | Y | 4 (jaune) |
4 | L1 | L1 | L2 | L1 | L1 | L1 | L1 |
5 | R1 | R1 | R2 | R1 | R1 | R1 | R1 |
6 | Select | Select | L1 | Select | L2 | Select | Select |
7 | Start | Start | R1 | Start | R2 | Start | Start |
8 | L3 | L3 | Select | L3 | Select | L3 | L3 |
9 | R3 | R3 | L3 | R3 | Start | R3 | R3 |
10 | | | R3 | | L3 | | |
11 | | | Start | | R3 | | |
12 | Haut | Haut | Haut | Haut | Haut | Haut | Haut |
13 | Droite | Droite | Droite | Droite | Droite | Droite | Droite |
14 | Bas | Bas | Bas | Bas | Bas | Bas | Bas |
15 | Gauche | Gauche | Gauche | Gauche | Gauche | Gauche | Gauche |
mId | 1118 | 1118 | 3727 | 1118 | 1356 | 1133 | 1118 |
pId | 654 | 767 | 4102 | 654 | 1476 | 49730 | 654 |
caps | 55 | 55 | 51 | 55 | 63 | 55 | 55 |
maxAxes | 6 | 6 | 6 | 6 | 6 | 6 | 6 |
numAxes | 5 | 5 | 4 | 5 | 6 | 5 | 5 |
maxBut | 32 | 32 | 32 | 32 | 32 | 32 | 32 |
numBut | 10 | 10 | 12 | 10 | 14 | 10 | 10 |
#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <Math.au3>
#include <String.au3>
Opt("GUIOnEventMode", 1)
Opt("MustDeclareVars", 1)
Global $gui
Global $edit
Global $size = [600, (1 + 16 + 1 + 8 + 1 + 1)*13 + 6]
Global $oldData = ""
Global $numDevs = _GetNumDevs()
Global $capsData = [[0, "mId"], [1, "pId"], [18, "caps"], [19, "maxAxes"], [20, "numAxes"], [21, "maxBut"], [9, "numBut"]]
Global $pIDs = [[654, "XBOX360"], [767, "XBOXOne"], [4102, "PS2"], [1476, "PS4"], [49730, "Logitech"]]
$gui = GUICreate("joy", $size[0], $size[1])
GUISetOnEvent($GUI_EVENT_CLOSE, quit, $gui)
$edit = GUICtrlCreateEdit("", 0, 0, $size[0], $size[1], 0)
GUICtrlSetState($edit, $GUI_DISABLE)
GUICtrlSetFont($edit, Default, Default, Default, "Courier")
GUISetState(@SW_SHOW, $gui)
While 1
Local $space = 8
Local $txt = " Bouton |"
Local $separator = _StringRepeat("-", $space) & "|"
Local $touches[$numDevs][0]
Local $caps[$numDevs][0]
Local $padValid[$numDevs]
For $i = 0 To $numDevs - 1
Local $tches = _GetJoy($i)
$padValid[$i] = Not(@error)
If($padValid[$i]) Then
$tches = _JoyToBool($tches)
set($touches, $tches, $i)
Local $cap = _GetJoyCaps($i)
set($caps, $cap, $i)
$txt &= " " & StringFormat("%-" & $space - 1 & "s", "Pad " & $i) & "|"
$separator &= _StringRepeat("-", $space) & "|"
EndIf
Next
$txt &= @CRLF
For $i = 0 To UBound($touches, 2) - 1
$txt &= StringFormat("%" & $space - 1 & "s", $i) & " |"
For $j = 0 To UBound($touches, 1) - 1
If($padValid[$j]) Then
$txt &= _StringRepeat(" ", Ceiling(($space-1)/2)) & ($touches[$j][$i] ? "1" : " ") & _StringRepeat(" ", Floor(($space-1)/2)) & "|"
EndIf
Next
$txt &= @CRLF
Next
$txt &= $separator & @CRLF
For $i = 0 To UBound($capsData, 1) - 1
$txt &= StringFormat("%" & $space - 1 & "s", $capsData[$i][1]) & " |"
For $j = 0 To UBound($touches, 1) - 1
If($padValid[$j]) Then
$txt &= StringFormat("%" & $space - 1 & "s", $caps[$j][$capsData[$i][0]]) & " |"
EndIf
Next
$txt &= @CRLF
Next
$txt &= $separator & @CRLF
$txt &= " " & StringFormat("%-" & $space - 1& "s", "Nom") & "|"
For $j = 0 To UBound($touches, 1) - 1
If($padValid[$j]) Then
Local $index = _ArraySearch($pIDs, $caps[$j][1], 0, 0, 0, 0, 1, 0)
Local $padName = ($index < 0) ? "INCONNU" : $pIDs[$index][1]
$txt &= StringFormat("%-" & $space & "s", $padName) & "|"
EndIf
Next
$txt &= @CRLF
If($oldData <> $txt) Then
$oldData = $txt
GUICtrlSetData($edit, $txt)
EndIf
Sleep(1)
WEnd
Func _JoyToBool($array)
Local $touches[16]
$touches[0] = BitAND($array[7], 1) <> 0
$touches[1] = BitAND($array[7], 2) <> 0
$touches[2] = BitAND($array[7], 4) <> 0
$touches[3] = BitAND($array[7], 8) <> 0
$touches[4] = BitAND($array[7], 16) <> 0
$touches[5] = BitAND($array[7], 32) <> 0
$touches[6] = BitAND($array[7], 64) <> 0
$touches[7] = BitAND($array[7], 128) <> 0
$touches[8] = BitAND($array[7], 256) <> 0
$touches[9] = BitAND($array[7], 512) <> 0
$touches[10] = BitAND($array[7], 1024) <> 0
$touches[11] = BitAND($array[7], 2048) <> 0
$touches[12] = StringLen($array[6]) > 0 And ($array[6] < 9000 Or $array[6] > 27000 And $array[6] < 65535)
$touches[13] = StringLen($array[6]) > 0 And ($array[6] > 0 And $array[6] < 18000)
$touches[14] = StringLen($array[6]) > 0 And ($array[6] > 9000 And $array[6] < 27000)
$touches[15] = StringLen($array[6]) > 0 And ($array[6] > 18000 And $array[6] < 36000)
Return $touches
EndFunc
Func _GetNumDevs()
Local $ret
$ret = DllCall("Winmm.dll", "int", "joyGetNumDevs")
If(Not(@error)) Then
$ret = $ret[0]
EndIf
Return $ret
EndFunc
Func _GetJoy($iJoy)
Local $joy = _JoyInit()
Local $ret
Local $err = False
Local $coor[9]
$ret = DllCall("Winmm.dll", "int", "joyGetPosEx", "int", $iJoy, "ptr", DllStructGetPtr($joy))
If(Not(@error) And $ret[0] == 0) Then
$coor[0] = DllStructGetData($joy,1,3)
$coor[1] = DllStructGetData($joy,1,4)
$coor[2] = DllStructGetData($joy,1,5)
$coor[3] = DllStructGetData($joy,1,6)
$coor[4] = DllStructGetData($joy,1,7)
$coor[5] = DllStructGetData($joy,1,8)
$coor[6] = DllStructGetData($joy,1,11)
$coor[7] = DllStructGetData($joy,1,9)
$coor[8] = DllStructGetData($joy,1,10)
Else
$err = True
;~ ConsoleWrite($ret[0] & @CRLF)
EndIf
$joy = 0
Return SetError($err, 0, $coor)
EndFunc
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
Func _GetJoyCaps($iJoy)
Local $retour[24]
Local $err = False
Local $ret
Local $joycap = _JoyCapsWInit()
$ret = DllCall("Winmm.dll", "int", "joyGetDevCapsW", "int", $iJoy, "ptr", DllStructGetPtr($joycap), "int", DllStructGetSize($joycap))
If(Not(@error) And $ret[0] == 0) Then
For $i = 0 To UBound($retour, 1) - 1
$retour[$i] = DllStructGetData($joycap, $i+1)
Next
Else
$err = True
EndIf
$joycap = 0
Return SetError($err, 0, $retour)
EndFunc
Func _JoyCapsWInit()
local $JOYCAPS_struct = "WORD wMid;WORD wPid;WCHAR szPname[32];UINT wXmin;UINT wXmax;UINT wYmin;UINT wYmax;UINT wZmin;" & _
"UINT wZmax;UINT wNumButtons;UINT wPeriodMin;UINT wPeriodMax;UINT wRmin;UINT wRmax;UINT wUmin;" & _
"UINT wUmax;UINT wVmin;UINT wVmax;UINT wCaps;UINT wMaxAxes;UINT wNumAxes;UINT wMaxButtons;" & _
"WCHAR szRegKey[32];WCHAR szOEMVxD[260]"
Local $joycap = DllStructCreate($JOYCAPS_struct)
if @error Then Return 0
return $joycap
EndFunc
Func set(ByRef $array, $add, $indice)
If(Not(IsArray($array) And IsArray($add))) Then Return SetError(1, 0, -1)
Local $ubound = _Max(UBound($array, 2), UBound($add, 1))
ReDim $array[UBound($array, 1)][$ubound]
ReDim $add[$ubound]
For $j = 0 To UBound($array, 2)-1
$array[$indice][$j] = $add[$j]
Next
EndFunc
Func quit()
Exit
EndFunc
#include <GUIConstantsEx.au3>
#include <Math.au3>
#include <String.au3>
Opt("GUIOnEventMode", 1)
Opt("MustDeclareVars", 1)
Global $gui
Global $edit
Global $size = [600, (1 + 16 + 1 + 8 + 1 + 1)*13 + 6]
Global $oldData = ""
Global $numDevs = _GetNumDevs()
Global $capsData = [[0, "mId"], [1, "pId"], [18, "caps"], [19, "maxAxes"], [20, "numAxes"], [21, "maxBut"], [9, "numBut"]]
Global $pIDs = [[654, "XBOX360"], [767, "XBOXOne"], [4102, "PS2"], [1476, "PS4"], [49730, "Logitech"]]
$gui = GUICreate("joy", $size[0], $size[1])
GUISetOnEvent($GUI_EVENT_CLOSE, quit, $gui)
$edit = GUICtrlCreateEdit("", 0, 0, $size[0], $size[1], 0)
GUICtrlSetState($edit, $GUI_DISABLE)
GUICtrlSetFont($edit, Default, Default, Default, "Courier")
GUISetState(@SW_SHOW, $gui)
While 1
Local $space = 8
Local $txt = " Bouton |"
Local $separator = _StringRepeat("-", $space) & "|"
Local $touches[$numDevs][0]
Local $caps[$numDevs][0]
Local $padValid[$numDevs]
For $i = 0 To $numDevs - 1
Local $tches = _GetJoy($i)
$padValid[$i] = Not(@error)
If($padValid[$i]) Then
$tches = _JoyToBool($tches)
set($touches, $tches, $i)
Local $cap = _GetJoyCaps($i)
set($caps, $cap, $i)
$txt &= " " & StringFormat("%-" & $space - 1 & "s", "Pad " & $i) & "|"
$separator &= _StringRepeat("-", $space) & "|"
EndIf
Next
$txt &= @CRLF
For $i = 0 To UBound($touches, 2) - 1
$txt &= StringFormat("%" & $space - 1 & "s", $i) & " |"
For $j = 0 To UBound($touches, 1) - 1
If($padValid[$j]) Then
$txt &= _StringRepeat(" ", Ceiling(($space-1)/2)) & ($touches[$j][$i] ? "1" : " ") & _StringRepeat(" ", Floor(($space-1)/2)) & "|"
EndIf
Next
$txt &= @CRLF
Next
$txt &= $separator & @CRLF
For $i = 0 To UBound($capsData, 1) - 1
$txt &= StringFormat("%" & $space - 1 & "s", $capsData[$i][1]) & " |"
For $j = 0 To UBound($touches, 1) - 1
If($padValid[$j]) Then
$txt &= StringFormat("%" & $space - 1 & "s", $caps[$j][$capsData[$i][0]]) & " |"
EndIf
Next
$txt &= @CRLF
Next
$txt &= $separator & @CRLF
$txt &= " " & StringFormat("%-" & $space - 1& "s", "Nom") & "|"
For $j = 0 To UBound($touches, 1) - 1
If($padValid[$j]) Then
Local $index = _ArraySearch($pIDs, $caps[$j][1], 0, 0, 0, 0, 1, 0)
Local $padName = ($index < 0) ? "INCONNU" : $pIDs[$index][1]
$txt &= StringFormat("%-" & $space & "s", $padName) & "|"
EndIf
Next
$txt &= @CRLF
If($oldData <> $txt) Then
$oldData = $txt
GUICtrlSetData($edit, $txt)
EndIf
Sleep(1)
WEnd
Func _JoyToBool($array)
Local $touches[16]
$touches[0] = BitAND($array[7], 1) <> 0
$touches[1] = BitAND($array[7], 2) <> 0
$touches[2] = BitAND($array[7], 4) <> 0
$touches[3] = BitAND($array[7], 8) <> 0
$touches[4] = BitAND($array[7], 16) <> 0
$touches[5] = BitAND($array[7], 32) <> 0
$touches[6] = BitAND($array[7], 64) <> 0
$touches[7] = BitAND($array[7], 128) <> 0
$touches[8] = BitAND($array[7], 256) <> 0
$touches[9] = BitAND($array[7], 512) <> 0
$touches[10] = BitAND($array[7], 1024) <> 0
$touches[11] = BitAND($array[7], 2048) <> 0
$touches[12] = StringLen($array[6]) > 0 And ($array[6] < 9000 Or $array[6] > 27000 And $array[6] < 65535)
$touches[13] = StringLen($array[6]) > 0 And ($array[6] > 0 And $array[6] < 18000)
$touches[14] = StringLen($array[6]) > 0 And ($array[6] > 9000 And $array[6] < 27000)
$touches[15] = StringLen($array[6]) > 0 And ($array[6] > 18000 And $array[6] < 36000)
Return $touches
EndFunc
Func _GetNumDevs()
Local $ret
$ret = DllCall("Winmm.dll", "int", "joyGetNumDevs")
If(Not(@error)) Then
$ret = $ret[0]
EndIf
Return $ret
EndFunc
Func _GetJoy($iJoy)
Local $joy = _JoyInit()
Local $ret
Local $err = False
Local $coor[9]
$ret = DllCall("Winmm.dll", "int", "joyGetPosEx", "int", $iJoy, "ptr", DllStructGetPtr($joy))
If(Not(@error) And $ret[0] == 0) Then
$coor[0] = DllStructGetData($joy,1,3)
$coor[1] = DllStructGetData($joy,1,4)
$coor[2] = DllStructGetData($joy,1,5)
$coor[3] = DllStructGetData($joy,1,6)
$coor[4] = DllStructGetData($joy,1,7)
$coor[5] = DllStructGetData($joy,1,8)
$coor[6] = DllStructGetData($joy,1,11)
$coor[7] = DllStructGetData($joy,1,9)
$coor[8] = DllStructGetData($joy,1,10)
Else
$err = True
;~ ConsoleWrite($ret[0] & @CRLF)
EndIf
$joy = 0
Return SetError($err, 0, $coor)
EndFunc
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
Func _GetJoyCaps($iJoy)
Local $retour[24]
Local $err = False
Local $ret
Local $joycap = _JoyCapsWInit()
$ret = DllCall("Winmm.dll", "int", "joyGetDevCapsW", "int", $iJoy, "ptr", DllStructGetPtr($joycap), "int", DllStructGetSize($joycap))
If(Not(@error) And $ret[0] == 0) Then
For $i = 0 To UBound($retour, 1) - 1
$retour[$i] = DllStructGetData($joycap, $i+1)
Next
Else
$err = True
EndIf
$joycap = 0
Return SetError($err, 0, $retour)
EndFunc
Func _JoyCapsWInit()
local $JOYCAPS_struct = "WORD wMid;WORD wPid;WCHAR szPname[32];UINT wXmin;UINT wXmax;UINT wYmin;UINT wYmax;UINT wZmin;" & _
"UINT wZmax;UINT wNumButtons;UINT wPeriodMin;UINT wPeriodMax;UINT wRmin;UINT wRmax;UINT wUmin;" & _
"UINT wUmax;UINT wVmin;UINT wVmax;UINT wCaps;UINT wMaxAxes;UINT wNumAxes;UINT wMaxButtons;" & _
"WCHAR szRegKey[32];WCHAR szOEMVxD[260]"
Local $joycap = DllStructCreate($JOYCAPS_struct)
if @error Then Return 0
return $joycap
EndFunc
Func set(ByRef $array, $add, $indice)
If(Not(IsArray($array) And IsArray($add))) Then Return SetError(1, 0, -1)
Local $ubound = _Max(UBound($array, 2), UBound($add, 1))
ReDim $array[UBound($array, 1)][$ubound]
ReDim $add[$ubound]
For $j = 0 To UBound($array, 2)-1
$array[$indice][$j] = $add[$j]
Next
EndFunc
Func quit()
Exit
EndFunc