Hacking [WIP] Nintendont HID Config Wizard - Create controller ini files effortlessly

  • Thread starter Thread starter Corgano
  • Start date Start date
  • Views Views 63,788
  • Replies Replies 48
  • Likes Likes 8
I got this error with a PS2 controller:

"Error", "Error creating baseline! Make sure controller is on and plugged in"
 
I'm pretty sure "RumbleDataLen" is the amount of bytes that the controller needs to send a vibration command to the controller.

RumbleTransferLen would either be how long it takes between each rumble packet (in milliseconds) or the amount of actual data to send, like padding?


also Im pretty sure the "power" is what button you want to turn on/off the controller with
 
BIG UNOFFICIAL UPDATE TIME!

I have this thing spitting out a config that works for my controller. IDK if that means it's done or not, but HIDTest should no longer yell at me.

I replaced ALL the uses of eval and assign, as those are a PAIN in the A!@.

P.S. forgot to mention last time that I added tooltips.

TODO:
Wait for bugs.
Maybe port to Java for cross platform? Would need to replace HIDTrace then.
Thanks to @Corgano and @Funtime60 for this useful tool.

I've made a tiny update for some text that was hidden, typos, and links for the automatic download:
Code:
#include <Array.au3>
#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
;By Corgano
;Updated by Funtime60


; Script Start - Add your code below here
Global $usbIDs = ""
If not FileExists("usb.ids") Then InetGet("http://www.linux-usb.org/usb.ids", "usb.ids")
$usbIDs = FileRead("usb.ids")
If not FileExists("hidtrace.exe") Then InetGet("http://www.virtualdj.com/download/hidtrace.exe", "hidtrace.exe")
If not FileExists("hidtrace.exe") Then
    MsgBox(0, "ERROR", "This program acts as a wrapper for and requires hidtrace.exe to work."&@CRLF&"Attempts to automatically download it have failed. Please download hidtrace.exe from"&@CRLF&"http://www.virtualdj.com/download/hidtrace.exe"&@CRLF&", place it in the same folder as this program, and run again."&@CRLF&@CRLF&"(The link has been copied to clipboard)")
    Exit
EndIf



OnAutoItExitRegister("onExit")



Global $aButtons[0][5]
Global $swvButton = 0, $swvAxis = 1, $swvCombo = 2
Func AddButton($bHandle, $lHandle, $sINIname, $swType = $swvButton, $defaultVal = -1)
   Local $aTmpIns = [$bHandle,$lHandle,$sINIname,$defaultVal,$swType]
   _ArrayTranspose($aTmpIns)
   _ArrayAdd($aButtons, $aTmpIns)
EndFunc
#Region ### START Koda GUI section ### Form=
$sAxisTip = "If you're having trouble only moving the stick on one axis, you might try pushing it out all the way and releasing."&@CRLF&"In some cases the return to center will trigger just as well as moving outwards."
$Form1 = GUICreate("Nintendont HID Config Wizard", 720, 433)

$Group1  = GUICtrlCreateGroup("Triggers and Z Button", 310, 40, 400, 100)
;~ $Label19 = GUICtrlCreateLabel("Left Z"    , 315, 60, 50, 25, $SS_RIGHT + $SS_CENTERIMAGE)
$Label18 = GUICtrlCreateLabel("Z"   , 655, 60, 50, 25, $SS_LEFT  + $SS_CENTERIMAGE)
$Label16 = GUICtrlCreateLabel("Left Trig" , 315, 90, 50, 40, $SS_RIGHT + $SS_CENTERIMAGE)
$Label17 = GUICtrlCreateLabel("Right Trig", 655, 90, 50, 40, $SS_LEFT  + $SS_CENTERIMAGE)
;~ $bZL       = GUICtrlCreateButton("", 370, 60, 50, 25)
$bZ        = GUICtrlCreateButton("", 600, 60, 50, 25)
$bLAnalog  = GUICtrlCreateButton("", 370, 90, 50, 40)
$bRAnalog  = GUICtrlCreateButton("", 600, 90, 50, 40)
;~ GUICtrlSetBkColor($bZL, 0x3399FF)
GUICtrlSetBkColor($bZ , 0x3399FF)
$sMissingZ = "It seems not every GCN controller has a left Z button"
;~ GUICtrlSetTip($bZL    , $sMissingZ)
;~ GUICtrlSetTip($Label19, $sMissingZ)
;~ _ArrayAdd($aButtons, [$bZL,$Label19,"ZL_NA"])
AddButton($bZ, $Label18, "Z")
AddButton($bLAnalog, $Label16, "L")
AddButton($bRAnalog, $Label17, "R")
GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group

$Group2  = GUICtrlCreateGroup("Stick", 310, 145, 150, 95)
;~ $Label8  = GUICtrlCreateLabel("Stick", 384, 112, 28, 17)
$Label10 = GUICtrlCreateLabel("Stick V. Axis", 320, 165, 75, 30, $SS_RIGHT + $SS_CENTERIMAGE)
$Label9  = GUICtrlCreateLabel("Stick H. Axis", 320, 200, 75, 30, $SS_RIGHT + $SS_CENTERIMAGE)
$bStickY = GUICtrlCreateButton("", 400, 165, 50, 30)
$bStickX = GUICtrlCreateButton("", 400, 200, 50, 30)
GUICtrlSetTip($Label10, $sAxisTip)
GUICtrlSetTip($Label9 , $sAxisTip)
GUICtrlSetTip($bStickY, $sAxisTip)
GUICtrlSetTip($bStickX, $sAxisTip)
AddButton($bStickY, $Label10, "StickY", $swvAxis)
AddButton($bStickX, $Label9 , "StickX", $swvAxis)
GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group

$Label11 = GUICtrlCreateLabel("Start", 485, 175, 50, 20, $SS_CENTER + $SS_CENTERIMAGE)
$Label20 = GUICtrlCreateLabel("Power", 485, 195, 50, 20, $SS_CENTER + $SS_CENTERIMAGE)
$bStart = GUICtrlCreateButton("", 485, 150, 50, 25)
$bPower = GUICtrlCreateButton("", 485, 215, 50, 25)
GUICtrlSetTip($Label11, "Start")
GUICtrlSetTip($Label20, "Power")
AddButton($bStart, $Label11, "S" )
AddButton($bPower, $Label20, "Power" )

$Group3  = GUICtrlCreateGroup("Buttons", 560, 145, 150, 95)
$Label3  = GUICtrlCreateLabel("Y"    , 660, 160, 40, 25, $SS_LEFT   + $SS_CENTERIMAGE)
$Label2  = GUICtrlCreateLabel("B"    , 570, 185, 40, 20, $SS_CENTER + $SS_CENTERIMAGE)
$Label1  = GUICtrlCreateLabel("A"    , 615, 185, 40, 20, $SS_CENTER + $SS_CENTERIMAGE)
$Label4  = GUICtrlCreateLabel("X"    , 660, 185, 40, 20, $SS_CENTER + $SS_CENTERIMAGE)
$bY = GUICtrlCreateButton("", 615, 160, 40, 25)
$bB = GUICtrlCreateButton("", 570, 205, 40, 25)
$bA = GUICtrlCreateButton("", 615, 205, 40, 25)
$bX = GUICtrlCreateButton("", 660, 205, 40, 25)
GUICtrlSetTip($bY, "Y")
GUICtrlSetTip($bB, "B")
GUICtrlSetTip($bA, "A")
GUICtrlSetTip($bX, "X")
AddButton($bY, $Label3, "Y")
AddButton($bB, $Label2, "B")
AddButton($bA, $Label1, "A")
AddButton($bX, $Label4, "X")
GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group

$Group4  = GUICtrlCreateGroup("D-Pad", 310, 245, 195, 95)
$Label14 = GUICtrlCreateLabel("Left" , 320, 265, 35, 30, $SS_RIGHT + $SS_CENTERIMAGE)
$Label12 = GUICtrlCreateLabel("Up"   , 460, 265, 35, 30, $SS_LEFT  + $SS_CENTERIMAGE)
$Label15 = GUICtrlCreateLabel("Down" , 320, 300, 35, 30, $SS_RIGHT + $SS_CENTERIMAGE)
$Label13 = GUICtrlCreateLabel("Right", 460, 300, 35, 30, $SS_LEFT  + $SS_CENTERIMAGE)
$bLeft  = GUICtrlCreateButton("", 360, 265, 45, 30)
$bUp    = GUICtrlCreateButton("", 410, 265, 45, 30)
$bDown  = GUICtrlCreateButton("", 360, 300, 45, 30)
$bRight = GUICtrlCreateButton("", 410, 300, 45, 30)
GUICtrlSetTip($bLeft , "D-Pad Left" )
GUICtrlSetTip($bUp   , "D-Pad Up"   )
GUICtrlSetTip($bDown , "D-Pad Down" )
GUICtrlSetTip($bRight, "D-Pad Right")
AddButton($bLeft , $Label14, "Left" )
AddButton($bUp   , $Label12, "Up"   )
AddButton($bDown , $Label15, "Down" )
AddButton($bRight, $Label13, "Right")
GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group

$Group5  = GUICtrlCreateGroup("C-Stick", 515, 245, 195, 95)
;~ $Label5  = GUICtrlCreateLabel("Stick", 384, 112, 28, 17)
$Label6  = GUICtrlCreateLabel("C-Stick V. Axis", 525, 265, 80, 30, $SS_RIGHT + $SS_CENTERIMAGE)
$Label7  = GUICtrlCreateLabel("C-Stick H. Axis", 525, 300, 80, 30, $SS_RIGHT + $SS_CENTERIMAGE)
$bCStickY = GUICtrlCreateButton("", 610, 265, 80, 30)
$bCStickX = GUICtrlCreateButton("", 610, 300, 80, 30)
GUICtrlSetBkColor($bCStickY, 0xFFFF00)
GUICtrlSetBkColor($bCStickX, 0xFFFF00)
GUICtrlSetTip($Label6  , $sAxisTip)
GUICtrlSetTip($Label7  , $sAxisTip)
GUICtrlSetTip($bCStickY, $sAxisTip)
GUICtrlSetTip($bCStickX, $sAxisTip)
AddButton($bCStickY, $Label6, "CStickY", $swvAxis)
AddButton($bCStickX, $Label7, "CStickX", $swvAxis)
GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group

$cJoy  =  GUICtrlCreateCombo(""               , 10 , 10 , 235, 21, $CBS_DROPDOWN +$CBS_AUTOHSCROLL)
$bJoy  = GUICtrlCreateButton("Refresh"        , 250, 9  , 50 , 23)
$eRaw  =   GUICtrlCreateEdit(""               , 10 , 42 , 289, 75)
$eIni  =   GUICtrlCreateEdit(""               , 10 , 127, 289, 296)
$iName =  GUICtrlCreateInput("Controller Name", 310, 10 , 400, 21)
GUICtrlSetData($eRaw, "")
GUICtrlSetFont($eRaw, 10, 400, 0, "Lucida Console")
GUICtrlSetFont($eIni, 10, 400, 0, "Lucida Console")

GUICtrlSetBkColor($bA, 0x00FF00)
GUICtrlSetBkColor($bB, 0xFF0000)

$Group6    =  GUICtrlCreateGroup("Misc", 310, 345, 400, 79)
$bWizzard  = GUICtrlCreateButton("Set All", 320, 365, 120, 48)
;~ $bZmod     = GUICtrlCreateButton("bZmod"  , 632, 392, 51, 25)
$bSave     = GUICtrlCreateButton("Save"   , 580, 390, 120, 23)
;Combos are vertically auto-sized based on fontsize, in this case they are 21px high. Thier surrounding are sized to match
$cDPAD     =  GUICtrlCreateCombo(""       , 450, 366, 118, 21, $CBS_DROPDOWN + $CBS_AUTOHSCROLL)
$cPollType =  GUICtrlCreateCombo(""       , 450, 391, 118, 21, $CBS_DROPDOWN + $CBS_AUTOHSCROLL)
$cTrigType =  GUICtrlCreateCombo(""       , 580, 366, 118, 21, $CBS_DROPDOWN + $CBS_AUTOHSCROLL)
GUICtrlSetFont($bWizzard, 18, 400, 0, "MS Sans Serif")
GUICtrlSetData($cDPAD    , "DPAD = 0|DPAD = 1", "DPAD = 1"               )
GUICtrlSetData($cPollType, "PollType = 0|PollType = 1", "PollType = 1"   )
GUICtrlSetData($cTrigType, "DigitalLR = 0|DigitalLR = 1", "DigitalLR = 1")
GUICtrlSetTip($bWizzard , "Begin a sequence to set each button."                                )
GUICtrlSetTip($cDPAD    , "1 if it uses a full byte, 0 if it uses only 4 bits")
GUICtrlSetTip($cPollType, "The only known case of this needing to be 0 is the PS3 Controller, or my GC style Switch one, it seems.")
GUICtrlSetTip($cTrigType, "Set this to 1 if your trigger can't tell how far you've pulled them. BTW, this program doesn't support 0, so you'd need to do some manual tweaks.")
AddButton($cDPAD    , $Group6, "DPAD", $swvCombo, 1)
AddButton($cPollType, $Group6, "Polltype", $swvCombo, 1)
AddButton($cTrigType, $Group6, "DigitalLR", $swvCombo, 1)
GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group

#EndRegion ### END Koda GUI section ###

For $i = 0 to UBound($aButtons) - 1
        $temp = $aButtons[$i][3]
        ConsoleWrite("> "&$aButtons[$i][2]&" = "&$temp&"    "&($temp <> -1)&@CRLF)
Next
Global $VID, $PID, $JoyName, $WaitForButton = 0
Global $hWin, $hEdit1, $hEdit2, $hCombo
Global $IniPath = @ScriptDir&"\controllers"
DirCreate($IniPath)
ReloadJoyList()
UpdateIni()
HotKeySet("{esc}", "ExitProgram")

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $bJoy
            ProcessClose("hidTrace.exe")
            ProcessClose("hidTrace.exe")
            sleep(200)
            ReloadJoyList()
            ; runs LoadJoy after

        Case $cJoy
            LoadJoy(GUICtrlRead($cJoy))

        Case $bWizzard
            dowizzard()

        Case $iName
            $JoyName = GUICtrlRead($iName)
            UpdateIni()

        Case $bSave
            SaveIni()

    EndSwitch

   For $iButton = 0 to UBound($aButtons) - 1
        If $nMsg = $aButtons[$iButton][0] Then
            If SetButton($iButton) Then
                UpdateIni()
            EndIf
        EndIf
    Next



    If StringTrimLeft(ControlGetText($hWin, "", $hEdit2), 10) <> GUICtrlRead($eRaw) Then
        GUICtrlSetData($eRaw, StringTrimLeft(ControlGetText($hWin, "", $hEdit2), 10))
    EndIf
WEnd

Func SetButton($iButton, $aBaseline = "")
    ControlFocus($Form1, "", $iName)
    Local $i, $timer = TimerInit()
   If $aButtons[$iButton][4] = $swvCombo Then
       If $aBaseline = "" or Not IsArray($aBaseline) Then
           Local $aTmp[1] = [GUICtrlRead($aButtons[$iButton][0])]
           $aBaseline = $aTmp
       EndIf
   Else
       If $aBaseline = "" or Not IsArray($aBaseline) Then

   ;~         MsgBox(0, "Setup Wizzard", "Release all buttons / sticks and click ok to continue")
           $aBaseline = StringRegExp(StringTrimLeft(ControlGetText($hWin, "", $hEdit2), 10), " ([0-9a-fA-F]{2})(?= )", 3)
           If Not IsArray($aBaseline) Then
               SplashOff()
               MsgBox(0, "Error", "Error creating baseline! Make sure controller is on and plugged in"&@CRLF&"E:1")
               Return -1
           EndIf
       EndIf
   EndIf

    Local $aCurrentState
;~     _ArrayDisplay($aBaseline)
   If $aButtons[$iButton][4] <> $swvCombo Then
       SplashTextOn("", "Press "&GUICtrlRead($aButtons[$iButton][1])&" to set, SPACE to skip, or ESC to cancel", 200, 150)
   EndIf

    $WaitForButton = 1
    While $WaitForButton
;~         If TimerDiff($timer) > 5000 Then ExitLoop
        If StringTrimLeft(ControlGetText($hWin, "", $hEdit2), 10) <> GUICtrlRead($eRaw) Then
            GUICtrlSetData($eRaw, StringTrimLeft(ControlGetText($hWin, "", $hEdit2), 10))
        EndIf
       If $aButtons[$iButton][4] = $swvCombo Then
           Local $aTmp[1] = [GUICtrlRead($aButtons[$iButton][0])]
           $aCurrentState = $aTmp
       Else
           $aCurrentState = StringRegExp(StringTrimLeft(ControlGetText($hWin, "", $hEdit2), 10), " ([0-9a-fA-F]{2})(?= )", 3)
       EndIf
        If Not IsArray($aCurrentState) Then
            SplashOff()
            MsgBox(0, "Error", "Error creating baseline! Make sure controller is on and plugged in"&@CRLF&"E:1")
            Return -1
        EndIf
        For $i = 0 to UBound($aBaseline) - 1
            ;$temp will store the difference of the two hex bytes being examined
           If $aButtons[$iButton][4] = $swvCombo Then
               $temp = True
           Else
               $temp = Dec($aCurrentState[$i])-Dec($aBaseline[$i])
           EndIf
            ;seperate handleing for combos and for sticks. Make sure the difference is more than an amount, to help prevent accidental buttons
           Switch $aButtons[$iButton][4]
               Case $swvButton
                   If $temp > 0 Then
                       ConsoleWrite("2> Change at index "&$i&" from "&$aBaseline[$i]&" to "&$aCurrentState[$i]&@CRLF)
                       ConsoleWrite($aButtons[$iButton][2]&"="&$i&","&hex($temp, 2)  &@CRLF)
                       $WaitForButton = 0
                       SplashOff()

                       GUICtrlSetData($aButtons[$iButton][0], $i&","&hex($temp, 2))
                       $aButtons[$iButton][3] = $i&","&hex($temp, 2)
                       Return 1
                   ElseIf $temp < 0 Then ; Special handleing: IF the difference is negitive, then chances are you need the absolute
                       ConsoleWrite("3> Change at index "&$i&" from "&$aBaseline[$i]&" to "&$aCurrentState[$i]&@CRLF)
                       ConsoleWrite($aButtons[$iButton][2]&"="&$i&","&  $aCurrentState[$i]  &@CRLF)
                       $WaitForButton = 0
                       SplashOff()

                       GUICtrlSetData($aButtons[$iButton][0], $i&","&$aCurrentState[$i])
                       $aButtons[$iButton][3] = $i&","&$aCurrentState[$i]
                       Return 1
                   EndIf
               Case $swvAxis
                   If Abs($temp) > 20 Then
                       ConsoleWrite("1> Change at index "&$i&" from "&$aBaseline[$i]&" to "&$aCurrentState[$i]&@CRLF)
                       ConsoleWrite($aButtons[$iButton][2]&"="&$i  &@CRLF)
                       $WaitForButton = 0
                       SplashOff()

                       GUICtrlSetData($aButtons[$iButton][0], $i)
                       $aButtons[$iButton][3] = $i
                       Return 1
                   EndIf
               Case $swvCombo
                   If $temp Then
                       ConsoleWrite("4> Change at index "&$i&" to "&$aCurrentState[$i]&@CRLF)
                       $WaitForButton = 0
                       SplashOff()

                       If StringInStr(GUICtrlRead($aButtons[$iButton][0]),"1") Then
                           $aButtons[$iButton][3] = 1
                       Else
                           $aButtons[$iButton][3] = 0
                       EndIf
                       Return 1
                   EndIf
            EndSwitch
        Next
    WEnd
    $WaitForButton = 0
    SplashOff()
    Return -1

EndFunc

Func WaitForRelease($aBaseline)
    Local $aCurrentState, $i, $timer = TimerInit()
    sleep(200)
    while sleep(100)
        $aCurrentState = StringRegExp(StringTrimLeft(ControlGetText($hWin, "", $hEdit2), 10), " ([0-9a-fA-F]{2})(?= )", 3)
        If Not IsArray($aCurrentState) Then
            SplashOff()
            MsgBox(0, "Error", "Error getting controller state! Make sure controller is on and plugged in")
            Return -1
        EndIf
        For $i = 0 to UBound($aBaseline)-1
            ;$temp will store the difference of the two hex bytes being examined
            If $aCurrentState[$i] <> $aBaseline[$i] Then ExitLoop
            If $i = UBound($aBaseline)-1 Then Return 1
        Next
        If TimerDiff($timer) > 5000 Then ExitLoop
    WEnd
    return 0
EndFunc

Func UpdateIni()
    Local $i, $s = "", $temp
    $s = "["&$JoyName&"]"&@CRLF&"VID="&$VID&@CRLF&"PID="&$PID&@CRLF

    For $i = 0 to UBound($aButtons) - 1
        $temp = $aButtons[$i][3]
        ConsoleWrite("> "&$aButtons[$i][2]&" = "&$temp&"    "&($temp <> -1)&@CRLF)
        If $temp <> -1 Then $s &= $aButtons[$i][2]&"="&$temp&@CRLF
   Next
   $s &= "MultiIn=0"&@CRLF
   $s &= "LAnalog=0"&@CRLF
   $s &= "RAnalog=0"&@CRLF

    GUICtrlSetData($eIni, $s)
EndFunc

Func SaveIni()
    Local $temp = $IniPath&"\"&$VID&"_"&$PID&".ini"
    If Not FileExists($temp) or MsgBox(4, "File exists!",$VID&"_"&$PID&".ini already exists in the folder"&@CRLF&$IniPath&@CRLF&"Do you want to overwrite it?") = 6 Then
        FileRecycle($temp)
        FileWrite($temp, GUICtrlRead($eIni))
    EndIf
    ; clear the gui messages in case the user hit gui buttons while the msgbox was up
    While GUIGetMsg() <> 0
    WEnd
EndFunc

Func LoadIni()
    Local $temp, $iButton, $path = $IniPath&"\"&$VID&"_"&$PID&".ini"
    ConsoleWrite("+  "&$IniPath&"\"&$VID&"_"&$PID&".ini"&@CRLF)
    If Not FileExists($path) Then return 0

    $temp = IniReadSectionNames($path)
    If not IsArray($temp) Then return -1
    $JoyName = $temp[1]
    ConsoleWrite("Loaded joystick named: "&$JoyName&@CRLF)

    For $iButton = 0 to UBound($aButtons) - 1
        $temp = IniRead($path, $JoyName, $aButtons[$iButton][2], -1)
        $aButtons[$iButton][3] = $temp
        If $temp > -1 Then GUICtrlSetData($aButtons[$iButton][0], $temp)
    Next

    ; clear the gui messages in case the user hit gui buttons while the msgbox was up
    While GUIGetMsg() <> 0
    WEnd
    UpdateIni()
EndFunc

Func dowizzard()
    MsgBox(0, "Setup Wizzard", "Release all buttons / sticks and click Ok to continue")
    Local $i, $aBaseline = StringRegExp(StringTrimLeft(ControlGetText($hWin, "", $hEdit2), 10), " ([0-9a-fA-F]{2})(?= )", 3)
    For $iButton = 0 to UBound($aButtons) - 1
       If $aButtons[$iButton][4] <> $swvCombo Then
           If SetButton($iButton) = -1 Then ExitLoop
           If WaitForRelease($aBaseline) <> 1 Then
               SplashOff()
               $WaitForButton = 0
               MsgBox(0, "Error", "Button jammed / not released after setting "&GUICtrlRead($aButtons[$iButton][1])&"!"&@CRLF&"Check controller and try again.")
               Return -1
           EndIf
       EndIf
    Next
    $WaitForButton = 0
    UpdateIni()
EndFunc

Func ExitProgram()
    If $WaitForButton = 1 Then
        $WaitForButton = 0
    Else
        Exit
    EndIf
EndFunc

Func ReloadJoyList()
    Run("hidTrace.exe", "", @SW_HIDE)
    $hWin = WinWait("HID Trace - (c) Atomix Productions 2009", "", 2)
    $hCombo = ControlGetHandle($hWin, "", "[CLASS:ComboBox; INSTANCE:1]")
    $hEdit1 = ControlGetHandle($hWin, "", "[CLASS:Edit; INSTANCE:1]")
    $hEdit2 = ControlGetHandle($hWin, "", "[CLASS:Edit; INSTANCE:2]")
    WinActivate($Form1)

    if Not $hCombo Then Exit MsgBox(0, "Error", "Could not run HidTrace (no window found!)")
    $joyList = StringRegExpReplace(_GUICtrlComboBox_GetList($hCombo), "(\d{1,5}e? \/ \d{1,5}e?\|?)", "")
    ConsoleWrite('"'&$joyList&'"'&@CRLF)
    If $joyList = "" Then
;~         MsgBox(0, "Error", "No controllers found! Check controllers and re-run this program")
        $joyList = "None found - Hit Refresh"
    EndIf
    If StringInStr($joyList, GUICtrlRead($cJoy)) Then
        $temp = GUICtrlRead($cJoy)
        GUICtrlSetData($cJoy, "")
        GUICtrlSetData($cJoy, $joyList, $temp)
    Else
        GUICtrlSetData($cJoy, "")
        Local $temp = StringSplit($joyList, "|")
        GUICtrlSetData($cJoy, $joyList, $temp[1])
    EndIf
    LoadJoy(GUICtrlRead($cJoy))
    UpdateIni()
EndFunc

func LoadJoy($sName)
    ConsoleWrite("LoadJoy("&$sName&")"&@CRLF)
    ; assign default values
    $VID = 0
    $PID = 0
    For $iButton = 0 to UBound($aButtons) - 1
       If $aButtons[$iButton][4] <> $swvCombo Then
           $aButtons[$iButton][3] = -1
       Else
           If StringInStr(GUICtrlRead($aButtons[$iButton][0]),"1") Then
               $aButtons[$iButton][3] = 1
           Else
               $aButtons[$iButton][3] = 0
           EndIf
       EndIf
    Next
    $JoyName = $sName
    ControlCommand($hWin, "", $hCombo, "SelectString", $sName)
    $a = StringRegExp(ControlGetText($hWin, "", $hEdit1), "VID=([0-9a-fA-F)]{4})\|PID=([0-9a-fA-F)]{4})", 3)
    If @error Then return -1
    $VID = $a[0]
    $PID = $a[1]

    LoadIni()

    ;attempt name lookup from ID's
    If $usbIDs <> "" Then
        Local $temp = StringRegExp($usbIDs, $VID&" [^\r\n]*[\r\n]*\s*"&$PID&"\s\s([^\r\n]*)", 3)
        If UBound($temp) = 1 Then
            $JoyName = $temp[0]
        EndIf
    EndIf

    GUICtrlSetData($iName, $JoyName)
EndFunc


Func onExit()
    ProcessClose("hidTrace.exe")
EndFunc
 
  • Like
Reactions: yinto
Ok im trying use my XBOX360Wired controller directly connected to Wii USB Ports.
Xbox360 Wired the Xbox Button is just Blinking Constantly


On the HIDTest i get the follow output on my Wii :
Nintendont: HIDTest -> Version: 1.0 [Autor: crediar]
HIDTest
Built : Apr 20 2014 00:24:40
Versopm : 0.6
Firmware : 55.22.31

Failed to open config
HIDVersion:40001
Getting list of HID compatible devices...


Searching on internet, i saw on some site i need create
"sd:/controllers.ini" and/or
"sd:/config" and/or
"sd:/controller/045e_028e.ini"


is not too much specific which thing is really need, the last line i read from -> https://github.com/revvv/Nintendont-XBOX360

i put the issue here -> https://github.com/revvv/Nintendont-XBOX360/issues/20#issuecomment-3507017816

How is the correct way of do this ?
 
Last edited by inukaze,
  • Like
Reactions: JorgeV
Ok im trying use my XBOX360Wired controller directly connected to Wii USB Ports.
Xbox360 Wired the Xbox Button is just Blinking Constantly


On the HIDTest i get the follow output on my Wii :
Nintendont: HIDTest -> Version: 1.0 [Autor: crediar]
HIDTest
Built : Apr 20 2014 00:24:40
Versopm : 0.6
Firmware : 55.22.31

Failed to open config
HIDVersion:40001
Getting list of HID compatible devices...


Searching on internet, i saw on some site i need create
"sd:/controllers.ini" and/or
"sd:/config" and/or
"sd:/controller/045e_028e.ini"


is not too much specific which thing is really need, the last line i read from -> https://github.com/revvv/Nintendont-XBOX360

i put the issue here -> https://github.com/revvv/Nintendont-XBOX360/issues/20#issuecomment-3507017816

How is the correct way of do this ?

Are you sure that are using the revive versión, it have a different loader on homebrew channel
 
Are you sure that are using the revive versión, it have a different loader on homebrew channel

i really don't know, from where i can download that version ?
i had check the HIDTest read is the file sd://controller.ini
the nintendont-xbox360 read the file sd://controllers/vid####_pid####.ini

i try to use the autoit-v3 and hidtest for make it work but something weird was happend, when i press A, trying Puyo Pop Fever, in the first screen asking for " Create " or "Do not Create " a memory card savefile, thee behaviour was if i hold up or down on stick or digital pad if i try press again a simple is not stopping.

The produced file by autoit-v3 inside the sub-folder controllers, 045e_028e.ini has the follow content :

[Controller (XBOX 360 For Windows)]
VID=045e
PID=028e
A=12,08
B=10,02
X=10,04
Y=10,08
CStickY=6
CStickX=5
StickY=2
StickX=1
Start=10,80
Up=11,04
Right=11,0C
Left=11,1C
Down=11,14
L=10,10
R=10,20
Z=8,80

i see this not produce some lines, are in the example configuration -> https://github.com/revvv/Nintendont-XBOX360/blob/master/controllerconfigs/045e_028e.ini

like :
MultiIn=0
Polltype=1
DPAD=0
DigitalLR=0

# L and R not used as modifiers, because triggers support half-/fully triggered states
#XBOX-L=3,01
#XBOX-R=3,02
#XBOX-Back=2,20

LAnalog=4
RAnalog=5

# XBOX button is power
Power=3,04

S=2,10
A=3,20

The most curious for me is when S and A are set with this last configutation, just work once time when i connect my xbox360 wired controller, for example on Luigi Mansion, but is very weird just work once but i not secure if A button working or Start button working.


you know a tool for read any thing connect to the wii usb0 port and usb1 port, to get all information without requiered you first write some file like sd://controllers/vid####_pid####.ini for get the values just for try , to make some test, and if possible change « EndpointOut=1 » on hot to see which is the right value to get the right led and make the rumble works, just if possible.



the next week i try to buy a Gamecube Controller or a DualShock 3 controller depend which i found more cheap. but i think is really possible make the xbox360 wired controller works directly connected on wii usb ports, if i want configure 2 controls can work on wii how i do set it ?
 
Are you sure that are using the revive versión, it have a different loader on homebrew channel

i really don't know, from where i can download that version ?
i had check the HIDTest read is the file sd://controller.ini
the nintendont-xbox360 read the file sd://controllers/vid####_pid####.ini

i try to use the autoit-v3 and hidtest for make it work but something weird was happend, when i press A, trying Puyo Pop Fever, in the first screen asking for " Create " or "Do not Create " a memory card savefile, thee behaviour was if i hold up or down on stick or digital pad if i try press again a simple is not stopping.

The produced file by autoit-v3 inside the sub-folder controllers, 045e_028e.ini has the follow content :

[Controller (XBOX 360 For Windows)]
VID=045e
PID=028e
A=12,08
B=10,02
X=10,04
Y=10,08
CStickY=6
CStickX=5
StickY=2
StickX=1
Start=10,80
Up=11,04
Right=11,0C
Left=11,1C
Down=11,14
L=10,10
R=10,20
Z=8,80

i see this not produce some lines, are in the example configuration -> https://github.com/revvv/Nintendont-XBOX360/blob/master/controllerconfigs/045e_028e.ini

like :
MultiIn=0
Polltype=1
DPAD=0
DigitalLR=0

# L and R not used as modifiers, because triggers support half-/fully triggered states
#XBOX-L=3,01
#XBOX-R=3,02
#XBOX-Back=2,20

LAnalog=4
RAnalog=5

# XBOX button is power
Power=3,04

S=2,10
A=3,20

The most curious for me is when S and A are set with this last configutation, just work once time when i connect my xbox360 wired controller, for example on Luigi Mansion, but is very weird just work once but i not secure if A button working or Start button working.


you know a tool for read any thing connect to the wii usb0 port and usb1 port, to get all information without requiered you first write some file like sd://controllers/vid####_pid####.ini for get the values just for try , to make some test, and if possible change « EndpointOut=1 » on hot to see which is the right value to get the right led and make the rumble works, just if possible.



the next week i try to buy a Gamecube Controller or a DualShock 3 controller depend which i found more cheap. but i think is really possible make the xbox360 wired controller works directly connected on wii usb ports, if i want configure 2 controls can work on wii how i do set it ?
Download THIS VERSION https://github.com/revvv/Nintendont-XBOX360/releases/download/1.3.2/Nintendont-XBOX360-1.3.2.zip on that the xbox 360 controller works, but just ONE CONTROLLER of xbox (the dualshock 3 its a good choice)

that info is on the fixed post of nintendont even i made a .ini for a Genius MaxFire 2 with rumble features totally working. with this you can se HID/PID/VID

Your USB-HID controller is not in the list?

If you have a specific USB controller you want to play with, you can test if it is compatible with this homebrew:

http://crediar.no-ip.com/HIDTestv4.rar
The readme in this rar-file should explain everything.
Rename to boot.dol to launch the homebrew from HBC.

new versions:
HID_Test v6
Spoiler: changelog since r4
Use this guide to create your own controller.ini file.
And place your controller.ini on the root of your Gaming device.

If your games are located on USB : USB:/controller.ini
If your games are located on USB : SD:/controller.ini

If you want to use different controllers, instead of using "controller.ini" on the root, you can place your files in a sub-folder, and using the PID_VID as filename.
/controllers/PID_VID.ini
/controllers/PID_VID.ini
/controllers/PID_VID.ini
etc.

Note: You can use only one HID-USB Compatible controller or adapter at a time. No multiplayer with HID is possible unless you are using a multi-controllers adapter.
 
Last edited by JorgeV,
Thank you very much for the answers, i wrote your comment url on the issue of proyect -> https://github.com/revvv/Nintendont-XBOX360/issues/20#issuecomment-3539468664

Because making test, values one by one i determinate with the nintendont-xbox360 version i am using the follow things works on luigi mansion (PAL - Spain) works :

Code:
S=2,10 ; Start/Pause

invert_lx=1
invert_ly=1
invert_rx=0
invert_ry=1

CStickX=8
CStickY=9

A=3,10
B=3,20

well if i remember, tomorrow i try you answer to my before questions.

Download THIS VERSION https://github.com/revvv/Nintendont-XBOX360/releases/download/1.3.2/Nintendont-XBOX360-1.3.2.zip on that the xbox 360 controller works, but just ONE CONTROLLER of xbox (the dualshock 3 its a good choice)

that info is on the fixed post of nintendont even i made a .ini for a Genius MaxFire 2 with rumble features totally working. with this you can se HID/PID/VID

Your USB-HID controller is not in the list?

If you have a specific USB controller you want to play with, you can test if it is compatible with this homebrew:

http://crediar.no-ip.com/HIDTestv4.rar
The readme in this rar-file should explain everything.
Rename to boot.dol to launch the homebrew from HBC.

new versions:
HID_Test v6
Spoiler: changelog since r4
Use this guide to create your own controller.ini file.
And place your controller.ini on the root of your Gaming device.

If your games are located on USB : USB:/controller.ini
If your games are located on USB : SD:/controller.ini

If you want to use different controllers, instead of using "controller.ini" on the root, you can place your files in a sub-folder, and using the PID_VID as filename.
/controllers/PID_VID.ini
/controllers/PID_VID.ini
/controllers/PID_VID.ini
etc.

Note: You can use only one HID-USB Compatible controller or adapter at a time. No multiplayer with HID is possible unless you are using a multi-controllers adapter.

i already test, that is the same version of nintendont i am using, and that was the configuration file i found on a youtube video called

"Jon GamezOn - Como usar Controle USB de Xbox 360 para jogar Gamecube no Wii [Nintendont 360]"

The url to the video ->


The HID Test wait the config file
sd://controller.ini

The Nintendont-XBOX360 wait the config file
sd://controllers/VID_PID.ini

On the both version of HIDTest my controllers does not gave my any result, like is not exist

i saw on the source code :
https://github.com/FIX94/Nintendont...608ae6cefc277ccfb8abe/loader/source/HID.c#L24

The weird is with my generic clone controllers: does not react equals the video i saw on youtube

i am trying editing values one by one with possible values just to get the working config with my xbox360 generic clone controllers, my files are

sd://controller.ini
sd://controllers/045e_028e.ini

both files content the sames lines right now are :

Code:
[XBOX 360 Controller]
VID=045e
PID=028e

# Endpoint configuration
EndpointOut=1            #; From 0 to 5 looks like try to works, on 6 can make nintendont-xbox360 ramdonly crash, 7 & 8 not work

# Axis Inversion
invert_lx=1
invert_ly=1
invert_rx=0
invert_ry=1

MultiIn=0            #; This value i never had change to 1
Polltype=1            #; This is mandatory value must be 1 for Xbox360 Controller
DPAD=1                #; Enable D-Pad
DigitalLR=1            #; Enable digital L/R

# Button Mapping
B=3,20                #; This is the working value for B button on my Xbox360 Controller
A=3,10                #; This is the working value for A button on my Xbox360 Controller
Y=3,40
X=3,80

# D-Pad Entries
Up=2,01
Down=2,02
Left=2,04
Right=2,08

# D-Pad Diagonal Mappings
RightUp=2,05            #; Diagonal Up Right
RightDown=2,0    7        #; Diagonal Down Right
LeftUp=2,03            #; Diagonal Up Left
LeftDown=2,06            #; Diagonal Down Left



#Power Test
#Power=3,04            #; This value make the Xbox Button return to Homebrew Channel
Power=3,05            #; Testing right now
#Power=3,06            #; This value make the Xbox Button must press first and after press any another thing on Xbox360 Controller to make it work
#Power=3,07            #; This value can make the cursor move down in Device Selection if Xbox360 is Plugged before start Nintendont-Xbox360


#;ORIGINAL#Rumble=3,05

S=2,10 ; Start/Pause

# Digital L, R, Z buttons
L=3,01
R=3,02
ZL=3,03
Z=3,02                #; Common / # Z is R


# Analog Axises
LAnalog=4
RAnalog=5
StickX=6            # This is the working Value
StickY=7            # This is the working Value
CStickX=8            # This is the working Value
CStickY=9            # This is the working Value

well during the week or during weeking i continue with my tests
 
Last edited by inukaze,
HID config wizard is a program to assist in creating controller.ini files for using HID controllers with nintendont. Just plug in a controller, click one button, and then press the controller buttons one by one while prompted. Simple!​
THINGS I NEED HELP WITH (PLEASE READ)
The following ini keys are ones that I have no idea how to use them properly. I need someone who knows to tell me what they do!​
  • Polltype=
  • DPAD=
  • DigitalLR=
  • Power=
  • Rumble=
  • RumbleType=
  • RumbleDataLen=
  • RumbleDataOn=
  • RumbleDataOff=
  • RumbleTransferLen=
  • RumbleTransfers=
  • MultiIn=
  • MultiInValue=
  • ZL=
About
ermzCWk.png
This program is a wrapper around Atomix Productions HID Trace (c) 2009. Full credit for that program goes to them. HID Config Wizard simply reads from it and provides the interface, ini generation / saving / loading, device name lookup, and other Nintendont specific features. HID Config Wizard is written in Autoit, freely available from Autoitscript.com, and is required to run it from source. Once it is more complete I'll be compiling and releasing compiled .exe's for ease of use​
Features
  • Automatic loading configs (if found)
  • Automatic controller name lookup
  • Creates and saves ini files
  • Wizard! Two clicks to set all buttons
  • Set / View individual button settings
  • Live hex readout
  • Select from multiple connected controllers (should support all HID)
  • More coming!
How to run source
To run from source code:​
  1. Download autoit from autoitscript.com, and download the script editor from their download page (SciTE with lexar and help files pre-packaged)
  2. Copy the source below and save it in a new .au3 file (right click in windows explorer -> new autoit v3 script, or save in notepad and rename .au3)
  3. Then double click the .au3 file to run (Or if selected when installing autoit it will open in SciTE, use F5 to run)
  4. more later :P
Source code:
Code:
#include <Array.au3>[/SIZE][/INDENT]
[SIZE=3][INDENT]#include <GuiComboBox.au3>[/INDENT]
[INDENT]#include <GUIConstantsEx.au3>[/INDENT]
[INDENT][/INDENT]
[INDENT]; Script Start - Add your code below here[/INDENT]
[INDENT]Global $usbIDs = ""[/INDENT]
[INDENT]If not FileExists("usb.ids") Then InetGet("http://www.linux-usb.org/usb.ids", "usb.ids")[/INDENT]
[INDENT]$usbIDs = FileRead("usb.ids")[/INDENT]
[INDENT]If not FileExists("hidtrace.exe") Then InetGet("http://www.virtualdj.com/download/hidtrace.exe", "hidtrace.exe")[/INDENT]
[INDENT]If not FileExists("hidtrace.exe") Then[/INDENT]
[INDENT]    MsgBox(0, "ERROR", "This program acts as a wrapper for and requires hidtrace.exe to work."&@CRLF&"Attempts to automaticly download it has failed. Please download hidtrace.exe from"&@CRLF&"http://www.virtualdj.com/download/hidtrace.exe"&@CRLF&" and place it in the same folder as this program and run again."&@CRLF&@CRLF&"(The link has been copied to clipboard)")[/INDENT]
[INDENT]    Exit[/INDENT]
[INDENT]EndIf[/INDENT]
[INDENT][/INDENT]
[INDENT]#include <ButtonConstants.au3>[/INDENT]
[INDENT]#include <ComboConstants.au3>[/INDENT]
[INDENT]#include <EditConstants.au3>[/INDENT]
[INDENT]#include <StaticConstants.au3>[/INDENT]
[INDENT]#include <WindowsConstants.au3>[/INDENT]
[INDENT][/INDENT]
[INDENT]OnAutoItExitRegister("onExit")[/INDENT]
[INDENT][/INDENT]
[INDENT]#Region ### START Koda GUI section ### Form=[/INDENT]
[INDENT]$Form1 = GUICreate("Form1", 706, 440)[/INDENT]
[INDENT][/INDENT]
[INDENT]$Label1 = GUICtrlCreateLabel("A", 592, 144, 11, 17)[/INDENT]
[INDENT]$Label3 = GUICtrlCreateLabel("X", 592, 96, 11, 17)[/INDENT]
[INDENT]$Label4 = GUICtrlCreateLabel("Y", 640, 120, 11, 17)[/INDENT]
[INDENT]$Label5 = GUICtrlCreateLabel("C-Stick", 608, 216, 38, 17)[/INDENT]
[INDENT]$Label6 = GUICtrlCreateLabel("UpDown", 576, 240, 46, 17)[/INDENT]
[INDENT]$Label7 = GUICtrlCreateLabel("LeftRight", 632, 240, 47, 17)[/INDENT]
[INDENT]$Label8 = GUICtrlCreateLabel("Stick", 384, 112, 28, 17)[/INDENT]
[INDENT]$Label9 = GUICtrlCreateLabel("LeftRight", 400, 136, 47, 17)[/INDENT]
[INDENT]$Label10 = GUICtrlCreateLabel("UpDown", 344, 136, 46, 17)[/INDENT]
[INDENT]$Label14 = GUICtrlCreateLabel("Left", 344, 240, 22, 17)[/INDENT]
[INDENT]$Label15 = GUICtrlCreateLabel("Down", 382, 272, 32, 17)[/INDENT]
[INDENT]$Label16 = GUICtrlCreateLabel("Left Trig.", 344, 40, 46, 17)[/INDENT]
[INDENT]$Label17 = GUICtrlCreateLabel("Right Trig", 632, 40, 50, 17)[/INDENT]
[INDENT]$Label18 = GUICtrlCreateLabel("Zed", 576, 40, 23, 17)[/INDENT]
[INDENT]$Label11 = GUICtrlCreateLabel("Start", 480, 136, 26, 17)[/INDENT]
[INDENT]$Label2 = GUICtrlCreateLabel("B", 544, 168, 11, 17)[/INDENT]
[INDENT]$Label12 = GUICtrlCreateLabel("Up", 388, 208, 18, 17)[/INDENT]
[INDENT]$Label13 = GUICtrlCreateLabel("Right", 424, 240, 29, 17)[/INDENT]
[INDENT]$Label19 = GUICtrlCreateLabel("ZedL", 640, 376, 29, 17)[/INDENT]
[INDENT][/INDENT]
[INDENT]$iStart = GUICtrlCreateDummy()[/INDENT]
[INDENT]$cJoy = GUICtrlCreateCombo("", 8, 8, 289-48, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))[/INDENT]
[INDENT]$bJoy = GUICtrlCreateButton("Refresh", 289-48+8, 7, 48,23)[/INDENT]
[INDENT]$eRaw = GUICtrlCreateEdit("", 8, 40, 289, 73)[/INDENT]
[INDENT]GUICtrlSetData(-1, "")[/INDENT]
[INDENT]GUICtrlSetFont(-1, 10, 400, 0, "Lucida Console")[/INDENT]
[INDENT]$eIni = GUICtrlCreateEdit("", 8, 120, 289, 305)[/INDENT]
[INDENT]GUICtrlSetFont(-1, 10, 400, 0, "Lucida Console")[/INDENT]
[INDENT]$iName = GUICtrlCreateInput("Controller Name", 304, 8, 393, 21)[/INDENT]
[INDENT][/INDENT]
[INDENT]$bA = GUICtrlCreateButton("", 576, 160, 43, 25)[/INDENT]
[INDENT]GUICtrlSetBkColor(-1, 0x00FF00)[/INDENT]
[INDENT]$bB = GUICtrlCreateButton("", 528, 184, 43, 25)[/INDENT]
[INDENT]GUICtrlSetBkColor(-1, 0xFF0000)[/INDENT]
[INDENT]$bX = GUICtrlCreateButton("", 576, 112, 43, 25)[/INDENT]
[INDENT]$bY = GUICtrlCreateButton("", 624, 136, 43, 25)[/INDENT]
[INDENT]$bCStickY = GUICtrlCreateButton("", 576, 256, 43, 25)[/INDENT]
[INDENT]GUICtrlSetBkColor(-1, 0xFFFF00)[/INDENT]
[INDENT]$bCStickX = GUICtrlCreateButton("", 632, 256, 43, 25)[/INDENT]
[INDENT]GUICtrlSetBkColor(-1, 0xFFFF00)[/INDENT]
[INDENT]$bStickY = GUICtrlCreateButton("", 344, 152, 43, 25)[/INDENT]
[INDENT]$bStickX = GUICtrlCreateButton("", 400, 152, 43, 25)[/INDENT]
[INDENT]$bStart = GUICtrlCreateButton("", 472, 152, 43, 25)[/INDENT]
[INDENT]$bUp = GUICtrlCreateButton("", 376, 224, 43, 25)[/INDENT]
[INDENT]$bRight = GUICtrlCreateButton("", 416, 256, 43, 25)[/INDENT]
[INDENT]$bDown = GUICtrlCreateButton("", 376, 288, 43, 25)[/INDENT]
[INDENT]$bLeft = GUICtrlCreateButton("", 336, 256, 43, 25)[/INDENT]
[INDENT]$bL = GUICtrlCreateButton("", 344, 64, 43, 25)[/INDENT]
[INDENT]$bR = GUICtrlCreateButton("", 632, 56, 43, 25)[/INDENT]
[INDENT]$bZ = GUICtrlCreateButton("", 568, 56, 43, 25)[/INDENT]
[INDENT]GUICtrlSetBkColor(-1, 0x3399FF)[/INDENT]
[INDENT][/INDENT]
[INDENT]$bWizzard = GUICtrlCreateButton("Set All", 304, 368, 115, 49)[/INDENT]
[INDENT]GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif")[/INDENT]
[INDENT]$bZmod = GUICtrlCreateButton("bZmod", 632, 392, 51, 25)[/INDENT]
[INDENT]$bSave = GUICtrlCreateButton("Save", 512, 392, 101, 25)[/INDENT]
[INDENT]$cDPAD = GUICtrlCreateCombo("", 424, 368, 81, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))[/INDENT]
[INDENT]GUICtrlSetData(-1, "DPAD = 0|DPAD = 1", "DPAD = 1")[/INDENT]
[INDENT]$cPollType = GUICtrlCreateCombo("", 424, 394, 81, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))[/INDENT]
[INDENT]GUICtrlSetData(-1, "PollType = 1|PollType = 0", "PollType = 1")[/INDENT]
[INDENT]$Combo1 = GUICtrlCreateCombo("", 512, 368, 89, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))[/INDENT]
[INDENT]GUICtrlSetData(-1, "DigitalLR = 1|DigitalLR = 0", "DigitalLR = 1")[/INDENT]
[INDENT]$iEnd = GUICtrlCreateDummy()[/INDENT]
[INDENT]#EndRegion ### END Koda GUI section ###[/INDENT]
[INDENT][/INDENT]
[INDENT]Global $aButtons[17] = [16,"A","B","X","Y","CStickY","CStickX","StickY","StickX","Start","Up","Right","Left","Down","L","R","Z"][/INDENT]
[INDENT]Global $aButtName[17] = [16,"A","B","X","Y","C Stick UP or DOWN","C Stick LEFT or RIGHT","Stick UP or DOWN","Stick LEFT or RIGHT","Start","D-Pad Up","D-Pad Right","D-Pad Left","D-Pad Down","Left Trigger","Right Trigger","Z"][/INDENT]
[INDENT]For $i = 1 to $aButtons[0][/INDENT]
[INDENT]    Assign("v"&$aButtons[$i], -1)[/INDENT]
[INDENT]Next[/INDENT]
[INDENT]Global $VID, $PID, $JoyName, $WaitForButton = 0[/INDENT]
[INDENT]Global $hWin, $hEdit1, $hEdit2, $hCombo[/INDENT]
[INDENT]Global $IniPath = @ScriptDir&"\controllers"[/INDENT]
[INDENT]DirCreate($IniPath)[/INDENT]
[INDENT]ReloadJoyList()[/INDENT]
[INDENT]UpdateIni()[/INDENT]
[INDENT]HotKeySet("{esc}", "ExitProgram")[/INDENT]
[INDENT][/INDENT]
[INDENT]GUISetState(@SW_SHOW)[/INDENT]
[INDENT][/INDENT]
[INDENT]While 1[/INDENT]
[INDENT]    $nMsg = GUIGetMsg()[/INDENT]
[INDENT]    Switch $nMsg[/INDENT]
[INDENT]        Case $GUI_EVENT_CLOSE[/INDENT]
[INDENT]            Exit[/INDENT]
[INDENT][/INDENT]
[INDENT]        Case $bJoy[/INDENT]
[INDENT]            ProcessClose("hidTrace.exe")[/INDENT]
[INDENT]            ProcessClose("hidTrace.exe")[/INDENT]
[INDENT]            sleep(200)[/INDENT]
[INDENT]            For $i = $iStart To $iEnd[/INDENT]
[INDENT]                GUICtrlSetState($i, $GUI_DISABLE)[/INDENT]
[INDENT]            Next[/INDENT]
[INDENT]            ReloadJoyList()[/INDENT]
[INDENT]            ; runs LoadJoy after[/INDENT]
[INDENT]            For $i = $iStart To $iEnd[/INDENT]
[INDENT]                GUICtrlSetState($i, $GUI_ENABLE)[/INDENT]
[INDENT]            Next[/INDENT]
[INDENT][/INDENT]
[INDENT]        Case $cJoy[/INDENT]
[INDENT]            LoadJoy(GUICtrlRead($cJoy))[/INDENT]
[INDENT][/INDENT]
[INDENT]        Case $bWizzard[/INDENT]
[INDENT]            dowizzard()[/INDENT]
[INDENT][/INDENT]
[INDENT]        Case $iName[/INDENT]
[INDENT]            $JoyName = GUICtrlRead($iName)[/INDENT]
[INDENT]            UpdateIni()[/INDENT]
[INDENT][/INDENT]
[INDENT]        Case $bSave[/INDENT]
[INDENT]            SaveIni()[/INDENT]
[INDENT][/INDENT]
[INDENT]    EndSwitch[/INDENT]
[INDENT][/INDENT]
[INDENT]    For $iButton = 1 to $aButtons[0][/INDENT]
[INDENT]        If $nMsg = Eval("b"&$aButtons[$iButton]) Then[/INDENT]
[INDENT];~             ConsoleWrite(Eval("b"&$aButtons[$iButton])&"    "&"Button "&"$b"&$aButtons[$iButton]&" pushed!"&@CRLF)[/INDENT]
[INDENT]            If SetButton($iButton) Then[/INDENT]
[INDENT]                UpdateIni()[/INDENT]
[INDENT]            EndIf[/INDENT]
[INDENT]        EndIf[/INDENT]
[INDENT]    Next[/INDENT]
[INDENT][/INDENT]
[INDENT][/INDENT]
[INDENT][/INDENT]
[INDENT]    If StringTrimLeft(ControlGetText($hWin, "", $hEdit2), 10) <> GUICtrlRead($eRaw) Then[/INDENT]
[INDENT]        GUICtrlSetData($eRaw, StringTrimLeft(ControlGetText($hWin, "", $hEdit2), 10))[/INDENT]
[INDENT]    EndIf[/INDENT]
[INDENT]WEnd[/INDENT]
[INDENT][/INDENT]
[INDENT]Func SetButton($iButton, $aBaseline = "")[/INDENT]
[INDENT]    ControlFocus($Form1, "", $iName)[/INDENT]
[INDENT]    Local $i, $timer = TimerInit()[/INDENT]
[INDENT]    If $aBaseline = "" or Not IsArray($aBaseline) Then[/INDENT]
[INDENT];~         MsgBox(0, "Setup Wizzard", "Release all buttons / sticks and click ok to continue")[/INDENT]
[INDENT]        $aBaseline = StringRegExp(StringTrimLeft(ControlGetText($hWin, "", $hEdit2), 10), " ([0-9a-fA-F]{2})(?= )", 3)[/INDENT]
[INDENT]        If Not IsArray($aBaseline) Then[/INDENT]
[INDENT]            SplashOff()[/INDENT]
[INDENT]            MsgBox(0, "Error", "Error creating baseline! Make sure controller is on and plugged in")[/INDENT]
[INDENT]            Return -1[/INDENT]
[INDENT]        EndIf[/INDENT]
[INDENT]    EndIf[/INDENT]
[INDENT]    Local $aCurrentState[/INDENT]
[INDENT];~     _ArrayDisplay($aBaseline)[/INDENT]
[INDENT]    SplashTextOn("", "Press "&$aButtName[$iButton]&" to set, SPACE to skip, or ESC to cancel", 200, 150)[/INDENT]
[INDENT][/INDENT]
[INDENT]    $WaitForButton = 1[/INDENT]
[INDENT]    While $WaitForButton[/INDENT]
[INDENT];~         If TimerDiff($timer) > 5000 Then ExitLoop[/INDENT]
[INDENT]        If StringTrimLeft(ControlGetText($hWin, "", $hEdit2), 10) <> GUICtrlRead($eRaw) Then[/INDENT]
[INDENT]            GUICtrlSetData($eRaw, StringTrimLeft(ControlGetText($hWin, "", $hEdit2), 10))[/INDENT]
[INDENT]        EndIf[/INDENT]
[INDENT]        $aCurrentState = StringRegExp(StringTrimLeft(ControlGetText($hWin, "", $hEdit2), 10), " ([0-9a-fA-F]{2})(?= )", 3)[/INDENT]
[INDENT]        If Not IsArray($aCurrentState) Then[/INDENT]
[INDENT]            SplashOff()[/INDENT]
[INDENT]            MsgBox(0, "Error", "Error creating baseline! Make sure controller is on and plugged in")[/INDENT]
[INDENT]            Return -1[/INDENT]
[INDENT]        EndIf[/INDENT]
[INDENT]        For $i = 0 to UBound($aBaseline)-1[/INDENT]
[INDENT]            ;$temp will store the difference of the two hex bytes being examined[/INDENT]
[INDENT]            $temp = Dec($aCurrentState[$i])-Dec($aBaseline[$i])[/INDENT]
[INDENT]            ;seperate handleing for sticks. Make sure the difference is more than an amount, to help prevent accidental buttons[/INDENT]
[INDENT]            If StringInStr($aButtons[$iButton], "stick") Then[/INDENT]
[INDENT]                If Abs($temp) > 20 Then[/INDENT]
[INDENT]                    ConsoleWrite("1> Change at index "&$i&" from "&$aBaseline[$i]&" to "&$aCurrentState[$i]&@CRLF)[/INDENT]
[INDENT]                    ConsoleWrite($aButtons[$iButton]&"="&$i  &@CRLF)[/INDENT]
[INDENT]                    $WaitForButton = 0[/INDENT]
[INDENT]                    SplashOff()[/INDENT]
[INDENT][/INDENT]
[INDENT]                    GUICtrlSetData(Eval("b"&$aButtons[$iButton]), $i)[/INDENT]
[INDENT]                    Assign("v"&$aButtons[$iButton], $i)[/INDENT]
[INDENT]                    Return 1[/INDENT]
[INDENT]                EndIf[/INDENT]
[INDENT][/INDENT]
[INDENT]            Else ; handleing for button, just check difference[/INDENT]
[INDENT]                If $temp > 1 Then[/INDENT]
[INDENT]                    ConsoleWrite("2> Change at index "&$i&" from "&$aBaseline[$i]&" to "&$aCurrentState[$i]&@CRLF)[/INDENT]
[INDENT]                    ConsoleWrite($aButtons[$iButton]&"="&$i&","&  hex($temp, 2)  &@CRLF)[/INDENT]
[INDENT]                    $WaitForButton = 0[/INDENT]
[INDENT]                    SplashOff()[/INDENT]
[INDENT][/INDENT]
[INDENT]                    GUICtrlSetData(Eval("b"&$aButtons[$iButton]), $i&","&  hex($temp, 2))[/INDENT]
[INDENT]                    Assign("v"&$aButtons[$iButton], $i&","&  hex($temp, 2) )[/INDENT]
[INDENT]                    Return 1[/INDENT]
[INDENT]                ElseIf $temp < 0 Then ; Special handleing: IF the difference is negitive, then chances are you need the absolute[/INDENT]
[INDENT]                    ConsoleWrite("3> Change at index "&$i&" from "&$aBaseline[$i]&" to "&$aCurrentState[$i]&@CRLF)[/INDENT]
[INDENT]                    ConsoleWrite($aButtons[$iButton]&"="&$i&","&  $aCurrentState[$i]  &@CRLF)[/INDENT]
[INDENT]                    $WaitForButton = 0[/INDENT]
[INDENT]                    SplashOff()[/INDENT]
[INDENT][/INDENT]
[INDENT]                    GUICtrlSetData(Eval("b"&$aButtons[$iButton]), $i&","&  $aCurrentState[$i])[/INDENT]
[INDENT]                    Assign("v"&$aButtons[$iButton], $i&","&  $aCurrentState[$i] )[/INDENT]
[INDENT]                    Return 1[/INDENT]
[INDENT]                EndIf[/INDENT]
[INDENT]            EndIf[/INDENT]
[INDENT]        Next[/INDENT]
[INDENT]    WEnd[/INDENT]
[INDENT]    $WaitForButton = 0[/INDENT]
[INDENT]    SplashOff()[/INDENT]
[INDENT]    Return -1[/INDENT]
[INDENT][/INDENT]
[INDENT]EndFunc[/INDENT]
[INDENT][/INDENT]
[INDENT]Func WaitForRelease($aBaseline)[/INDENT]
[INDENT]    Local $aCurrentState, $i, $timer = TimerInit()[/INDENT]
[INDENT]    sleep(200)[/INDENT]
[INDENT]    while sleep(100)[/INDENT]
[INDENT]        $aCurrentState = StringRegExp(StringTrimLeft(ControlGetText($hWin, "", $hEdit2), 10), " ([0-9a-fA-F]{2})(?= )", 3)[/INDENT]
[INDENT]        If Not IsArray($aCurrentState) Then[/INDENT]
[INDENT]            SplashOff()[/INDENT]
[INDENT]            MsgBox(0, "Error", "Error getting controller state! Make sure controller is on and plugged in")[/INDENT]
[INDENT]            Return -1[/INDENT]
[INDENT]        EndIf[/INDENT]
[INDENT]        For $i = 0 to UBound($aBaseline)-1[/INDENT]
[INDENT]            ;$temp will store the difference of the two hex bytes being examined[/INDENT]
[INDENT]            If $aCurrentState[$i] <> $aBaseline[$i] Then ExitLoop[/INDENT]
[INDENT]            If $i = UBound($aBaseline)-1 Then Return 1[/INDENT]
[INDENT]        Next[/INDENT]
[INDENT]        If TimerDiff($timer) > 5000 Then ExitLoop[/INDENT]
[INDENT]    WEnd[/INDENT]
[INDENT]    return 0[/INDENT]
[INDENT]EndFunc[/INDENT]
[INDENT][/INDENT]
[INDENT]Func UpdateIni()[/INDENT]
[INDENT]    Local $i, $s = "", $temp[/INDENT]
[INDENT]    $s = "["&$JoyName&"]"&@CRLF&"VID="&$VID&@CRLF&"PID="&$PID&@CRLF[/INDENT]
[INDENT][/INDENT]
[INDENT]    For $i = 1 to $aButtons[0][/INDENT]
[INDENT]        $temp = Eval("v"&$aButtons[$i])[/INDENT]
[INDENT];~         ConsoleWrite("> "&$aButtons[$i]&" = "&$temp&"    "&($temp <> -1)&@CRLF)[/INDENT]
[INDENT]        If $temp <> -1 Then $s &= $aButtons[$i]&"="&$temp&@CRLF[/INDENT]
[INDENT]    Next[/INDENT]
[INDENT]    GUICtrlSetData($eIni, $s)[/INDENT]
[INDENT]EndFunc[/INDENT]
[INDENT][/INDENT]
[INDENT]Func SaveIni()[/INDENT]
[INDENT]    Local $temp = $IniPath&"\"&$VID&"_"&$PID&".ini"[/INDENT]
[INDENT]    If Not FileExists($temp) or MsgBox(4, "File exists!",$VID&"_"&$PID&".ini already exists in the folder"&@CRLF&$IniPath&@CRLF&"Do you want to overwrite it?") = 6 Then[/INDENT]
[INDENT]        FileRecycle($temp)[/INDENT]
[INDENT]        FileWrite($temp, GUICtrlRead($eIni))[/INDENT]
[INDENT]    EndIf[/INDENT]
[INDENT]    ; clear the gui messages in case the user hit gui buttons while the msgbox was up[/INDENT]
[INDENT]    While GUIGetMsg() <> 0[/INDENT]
[INDENT]    WEnd[/INDENT]
[INDENT]EndFunc[/INDENT]
[INDENT][/INDENT]
[INDENT]Func LoadIni()[/INDENT]
[INDENT]    Local $temp, $iButton, $path = $IniPath&"\"&$VID&"_"&$PID&".ini"[/INDENT]
[INDENT]    ConsoleWrite("+  "&$IniPath&"\"&$VID&"_"&$PID&".ini"&@CRLF)[/INDENT]
[INDENT]    If Not FileExists($path) Then return 0[/INDENT]
[INDENT][/INDENT]
[INDENT]    $temp = IniReadSectionNames($path)[/INDENT]
[INDENT]    If not IsArray($temp) Then return -1[/INDENT]
[INDENT]    $JoyName = $temp[1][/INDENT]
[INDENT]    ConsoleWrite("Loaded joystick named: "&$JoyName&@CRLF)[/INDENT]
[INDENT][/INDENT]
[INDENT]    For $iButton = 1 to $aButtons[0][/INDENT]
[INDENT]        $temp = IniRead($path, $JoyName, $aButtons[$iButton], -1)[/INDENT]
[INDENT]        Assign("v"&$aButtons[$iButton], $temp)[/INDENT]
[INDENT]        If $temp > -1 Then GUICtrlSetData(Eval("b"&$aButtons[$iButton]), $temp)[/INDENT]
[INDENT]    Next[/INDENT]
[INDENT][/INDENT]
[INDENT]    ; clear the gui messages in case the user hit gui buttons while the msgbox was up[/INDENT]
[INDENT]    While GUIGetMsg() <> 0[/INDENT]
[INDENT]    WEnd[/INDENT]
[INDENT]    UpdateIni()[/INDENT]
[INDENT]EndFunc[/INDENT]
[INDENT][/INDENT]
[INDENT]Func dowizzard()[/INDENT]
[INDENT]    MsgBox(0, "Setup Wizzard", "Release all buttons / sticks and click ok to continue")[/INDENT]
[INDENT]    Local $i, $aBaseline = StringRegExp(StringTrimLeft(ControlGetText($hWin, "", $hEdit2), 10), " ([0-9a-fA-F]{2})(?= )", 3)[/INDENT]
[INDENT]    For $iButton = 1 to $aButtons[0][/INDENT]
[INDENT]        If SetButton($iButton) = -1 Then ExitLoop[/INDENT]
[INDENT]        If WaitForRelease($aBaseline) <> 1 Then[/INDENT]
[INDENT]            SplashOff()[/INDENT]
[INDENT]            $WaitForButton = 0[/INDENT]
[INDENT]            MsgBox(0, "Error", "Button jammed / not released after setting "&$aButtName[$iButton]&"!"&@CRLF&"Check controller and try again.")[/INDENT]
[INDENT]            Return -1[/INDENT]
[INDENT]        EndIf[/INDENT]
[INDENT]    Next[/INDENT]
[INDENT]    $WaitForButton = 0[/INDENT]
[INDENT]    UpdateIni()[/INDENT]
[INDENT]EndFunc[/INDENT]
[INDENT][/INDENT]
[INDENT]Func ExitProgram()[/INDENT]
[INDENT]    If $WaitForButton = 1 Then[/INDENT]
[INDENT]        $WaitForButton = 0[/INDENT]
[INDENT]    Else[/INDENT]
[INDENT]        Exit[/INDENT]
[INDENT]    EndIf[/INDENT]
[INDENT]EndFunc[/INDENT]
[INDENT][/INDENT]
[INDENT]Func ReloadJoyList()[/INDENT]
[INDENT]    Run("hidTrace.exe", "", @SW_HIDE)[/INDENT]
[INDENT]    $hWin = WinWait("HID Trace - (c) Atomix Productions 2009", "", 2)[/INDENT]
[INDENT]    $hCombo = ControlGetHandle($hWin, "", "[CLASS:ComboBox; INSTANCE:1]")[/INDENT]
[INDENT]    $hEdit1 = ControlGetHandle($hWin, "", "[CLASS:Edit; INSTANCE:1]")[/INDENT]
[INDENT]    $hEdit2 = ControlGetHandle($hWin, "", "[CLASS:Edit; INSTANCE:2]")[/INDENT]
[INDENT]    WinActivate($Form1)[/INDENT]
[INDENT][/INDENT]
[INDENT]    if Not $hCombo Then Exit MsgBox(0, "Error", "Could not run HidTrace (no window found!)")[/INDENT]
[INDENT]    $joyList = StringRegExpReplace(_GUICtrlComboBox_GetList($hCombo), "(\d{1,5}e? \/ \d{1,5}e?\|?)", "")[/INDENT]
[INDENT]    ConsoleWrite('"'&$joyList&'"'&@CRLF)[/INDENT]
[INDENT]    If $joyList = "" Then[/INDENT]
[INDENT];~         MsgBox(0, "Error", "No controllers found! Check controllers and re-run this program")[/INDENT]
[INDENT]        $joyList = "None found - Hit Refresh"[/INDENT]
[INDENT]    EndIf[/INDENT]
[INDENT]    If StringInStr($joyList, GUICtrlRead($cJoy)) Then[/INDENT]
[INDENT]        $temp = GUICtrlRead($cJoy)[/INDENT]
[INDENT]        GUICtrlSetData($cJoy, "")[/INDENT]
[INDENT]        GUICtrlSetData($cJoy, $joyList, $temp)[/INDENT]
[INDENT]    Else[/INDENT]
[INDENT]        GUICtrlSetData($cJoy, "")[/INDENT]
[INDENT]        Local $temp = StringSplit($joyList, "|")[/INDENT]
[INDENT]        GUICtrlSetData($cJoy, $joyList, $temp[1])[/INDENT]
[INDENT]    EndIf[/INDENT]
[INDENT]    LoadJoy(GUICtrlRead($cJoy))[/INDENT]
[INDENT]    UpdateIni()[/INDENT]
[INDENT]EndFunc[/INDENT]
[INDENT][/INDENT]
[INDENT]func LoadJoy($sName)[/INDENT]
[INDENT]    ConsoleWrite("LoadJoy("&$sName&")"&@CRLF)[/INDENT]
[INDENT]    ; assign default values[/INDENT]
[INDENT]    $VID = 0[/INDENT]
[INDENT]    $PID = 0[/INDENT]
[INDENT]    For $i = 1 to $aButtons[0][/INDENT]
[INDENT]        Assign("v"&$aButtons[$i], -1)[/INDENT]
[INDENT]    Next[/INDENT]
[INDENT]    $JoyName = $sName[/INDENT]
[INDENT]    ControlCommand($hWin, "", $hCombo, "SelectString", $sName)[/INDENT]
[INDENT]    $a = StringRegExp(ControlGetText($hWin, "", $hEdit1), "VID=([0-9a-fA-F)]{4})\|PID=([0-9a-fA-F)]{4})", 3)[/INDENT]
[INDENT]    If @error Then return -1[/INDENT]
[INDENT]    $VID = $a[0][/INDENT]
[INDENT]    $PID = $a[1][/INDENT]
[INDENT][/INDENT]
[INDENT]    LoadIni()[/INDENT]
[INDENT][/INDENT]
[INDENT]    ;attempt name lookup from ID's[/INDENT]
[INDENT]    If $usbIDs <> "" Then[/INDENT]
[INDENT]        Local $temp = StringRegExp($usbIDs, $VID&" [^\r\n]*[\r\n]*\s*"&$PID&"\s\s([^\r\n]*)", 3)[/INDENT]
[INDENT]        If UBound($temp) = 1 Then[/INDENT]
[INDENT]            $JoyName = $temp[0][/INDENT]
[INDENT]        EndIf[/INDENT]
[INDENT]    EndIf[/INDENT]
[INDENT][/INDENT]
[INDENT]    GUICtrlSetData($iName, $JoyName)[/INDENT]
[INDENT]EndFunc[/INDENT]
[INDENT][/INDENT]
[INDENT][/INDENT]
[INDENT]Func onExit()[/INDENT]
[INDENT]    ProcessClose("hidTrace.exe")[/INDENT]
[INDENT]EndFunc

ToDo:
  • Polltype, DPAD, and a few other settings aren't handled.
  • Rumble. no idea HOW it works, need help with this
  • Suggest a feature!
INI Key Documentation (so far)
VID= VID of device
PID= PID of device
A, B, X, Y= Buttons
Z= Trigger (n64) or right bumper (Gamecube
L= Left bumper/trigger
R= Right bumper/trigger
S= Start?
Up, RightUp, Right, DownRight, Down, DownLeft, Left, UpLeft= D-Pad directions.
StickX= The Grey Stick, Left/Right
StickY= The Grey Stick, Up/Down
CStickX= The Yellow Stick, Left/Right
CStickY= The Yellow Stick, Up/Down
RAnalog= Right Analog Trigger
LAnalog= Left Analog Trigger
This detects my adapter but none of the actual button inputs
 

Site & Scene News

Popular threads in this forum