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

Cube6gamer

Member
Newcomer
Joined
Jul 5, 2021
Messages
5
Trophies
0
Age
16
XP
35
Country
United States
GUID: 030000006f0e00008001000000000000
Mapping String: 030000006f0e00008001000000000000,Faceoff Wired Pro Controller for Nintendo Switch,platform:Windows,a:b1,b:b2,x:b0,y:b3,back:b8,guide:b12,start:b9,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,
what do I do with it ?????????????????????
 

Funtime60

Member
Newcomer
Joined
Jul 23, 2021
Messages
5
Trophies
0
Age
23
XP
36
Country
United States
Not to hijack this program, but I took the liberty of modding it as soon as I saw it was in Autoit. I've added support for a left Z (I think, EDIT: I probaby didn't) and I've spruced up the GUI. I also noticed that I couldn't set my Y key to be 1 and changed a line from $temp > 1 to $temp > 0 to allow that to no noticeable detriment. I also saw that the X and Y buttons were reversed from my GC controllers.

This is the source for my version.

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("I CAN'T POST LINKS YET GET THESE FROM THE ORIGINAL, SORRY", "usb.ids")
$usbIDs = FileRead("usb.ids")
If not FileExists("hidtrace.exe") Then InetGet("I CAN'T POST LINKS YET GET THESE FROM THE ORIGINAL, SORRY", "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 automaticly download it has failed. Please download hidtrace.exe from"&@CRLF&"I CAN'T POST LINKS YET GET THESE FROM THE ORIGINAL, SORRY"&@CRLF&" and place it in the same folder as this program and run again."&@CRLF&@CRLF&"(The link has been copied to clipboard)")
    Exit
EndIf

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

OnAutoItExitRegister("onExit")

#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("Tiggers and Z Buttons", 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)
$bL  = GUICtrlCreateButton("", 370, 90, 50, 40)
$bR  = GUICtrlCreateButton("", 600, 90, 50, 40)
;~ GUICtrlSetBkColor($bZL, 0x3399FF)
GUICtrlSetBkColor($bZ , 0x3399FF)
$sMissingZ = "It would seem not every GC controller had a left Z button"
;~ GUICtrlSetTip($bZL    , $sMissingZ)
;~ GUICtrlSetTip($Label19, $sMissingZ)
GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group

$Group2  = GUICtrlCreateGroup("Stick", 310, 145, 150, 95)
;~ $Label8  = GUICtrlCreateLabel("Stick", 384, 112, 28, 17)
$Label10 = GUICtrlCreateLabel("Vertical Axis"  , 320, 165, 75, 30, $SS_RIGHT + $SS_CENTERIMAGE)
$Label9  = GUICtrlCreateLabel("Horizontal 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)
GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group

$Label11 = GUICtrlCreateLabel("Start", 485, 170, 50, 20, $SS_CENTER + $SS_CENTERIMAGE)
$bStart = GUICtrlCreateButton("", 485, 190, 50, 25)

$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")
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 , "Left" )
GUICtrlSetTip($bUp   , "Up"   )
GUICtrlSetTip($bDown , "Down" )
GUICtrlSetTip($bRight, "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("Vertical Axis"  , 525, 265, 80, 30, $SS_RIGHT + $SS_CENTERIMAGE)
$Label7  = GUICtrlCreateLabel("Horizontal 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)
GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group

$iStart = GUICtrlCreateDummy()

$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 = 1|PollType = 0", "PollType = 1"   )
GUICtrlSetData($cTrigType, "DigitalLR = 1|DigitalLR = 0", "DigitalLR = 1")
GUICtrlSetTip($bWizzard , "Begin a sequence to set each button."                                )
GUICtrlSetTip($cDPAD    , "I'm not sure what this does, so I can't help you here."              )
GUICtrlSetTip($cPollType, "The only known case of this needing to be 0 is the PS3 Controller."  )
GUICtrlSetTip($cTrigType, "Set this to 1 if your trigger can't tell how far you've pulled them.")
GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group

$iEnd = GUICtrlCreateDummy()
#EndRegion ### END Koda GUI section ###

Global $aButtons[18] = [16,"A","B","X","Y","CStickY","CStickX","StickY","StickX","Start","Up","Right","Left","Down","L","R","Z","ZL"]
Global $aButtName[18] = [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","Right Z","Left Z"]
For $i = 1 to $aButtons[0]
    Assign("v"&$aButtons[$i], -1)
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)
            For $i = $iStart To $iEnd
                GUICtrlSetState($i, $GUI_DISABLE)
            Next
            ReloadJoyList()
            ; runs LoadJoy after
            For $i = $iStart To $iEnd
                GUICtrlSetState($i, $GUI_ENABLE)
            Next

        Case $cJoy
            LoadJoy(GUICtrlRead($cJoy))

        Case $bWizzard
            dowizzard()

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

        Case $bSave
            SaveIni()

    EndSwitch

    For $iButton = 1 to $aButtons[0]
        If $nMsg = Eval("b"&$aButtons[$iButton]) Then
;~             ConsoleWrite(Eval("b"&$aButtons[$iButton])&"    "&"Button "&"$b"&$aButtons[$iButton]&" pushed!"&@CRLF)
            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 $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")
            Return -1
        EndIf
    EndIf
    Local $aCurrentState
;~     _ArrayDisplay($aBaseline)
    SplashTextOn("", "Press "&$aButtName[$iButton]&" to set, SPACE to skip, or ESC to cancel", 200, 150)

    $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
        $aCurrentState = StringRegExp(StringTrimLeft(ControlGetText($hWin, "", $hEdit2), 10), " ([0-9a-fA-F]{2})(?= )", 3)
        If Not IsArray($aCurrentState) Then
            SplashOff()
            MsgBox(0, "Error", "Error creating baseline! 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
            $temp = Dec($aCurrentState[$i])-Dec($aBaseline[$i])
            ;seperate handleing for sticks. Make sure the difference is more than an amount, to help prevent accidental buttons
            If StringInStr($aButtons[$iButton], "stick") Then
                If Abs($temp) > 20 Then
                    ConsoleWrite("1> Change at index "&$i&" from "&$aBaseline[$i]&" to "&$aCurrentState[$i]&@CRLF)
                    ConsoleWrite($aButtons[$iButton]&"="&$i  &@CRLF)
                    $WaitForButton = 0
                    SplashOff()

                    GUICtrlSetData(Eval("b"&$aButtons[$iButton]), $i)
                    Assign("v"&$aButtons[$iButton], $i)
                    Return 1
                EndIf

            Else ; handleing for button, just check difference
                If $temp > 0 Then
                    ConsoleWrite("2> Change at index "&$i&" from "&$aBaseline[$i]&" to "&$aCurrentState[$i]&@CRLF)
                    ConsoleWrite($aButtons[$iButton]&"="&$i&","&  hex($temp, 2)  &@CRLF)
                    $WaitForButton = 0
                    SplashOff()

                    GUICtrlSetData(Eval("b"&$aButtons[$iButton]), $i&","&  hex($temp, 2))
                    Assign("v"&$aButtons[$iButton], $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]&"="&$i&","&  $aCurrentState[$i]  &@CRLF)
                    $WaitForButton = 0
                    SplashOff()

                    GUICtrlSetData(Eval("b"&$aButtons[$iButton]), $i&","&  $aCurrentState[$i])
                    Assign("v"&$aButtons[$iButton], $i&","&  $aCurrentState[$i] )
                    Return 1
                EndIf
            EndIf
        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 = 1 to $aButtons[0]
        $temp = Eval("v"&$aButtons[$i])
;~         ConsoleWrite("> "&$aButtons[$i]&" = "&$temp&"    "&($temp <> -1)&@CRLF)
        If $temp <> -1 Then $s &= $aButtons[$i]&"="&$temp&@CRLF
    Next
    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 = 1 to $aButtons[0]
        $temp = IniRead($path, $JoyName, $aButtons[$iButton], -1)
        Assign("v"&$aButtons[$iButton], $temp)
        If $temp > -1 Then GUICtrlSetData(Eval("b"&$aButtons[$iButton]), $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 = 1 to $aButtons[0]
        If SetButton($iButton) = -1 Then ExitLoop
        If WaitForRelease($aBaseline) <> 1 Then
            SplashOff()
            $WaitForButton = 0
            MsgBox(0, "Error", "Button jammed / not released after setting "&$aButtName[$iButton]&"!"&@CRLF&"Check controller and try again.")
            Return -1
        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 $i = 1 to $aButtons[0]
        Assign("v"&$aButtons[$i], -1)
    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
 
Last edited by Funtime60,

pedro702

Well-Known Member
Member
Joined
Mar 3, 2014
Messages
12,722
Trophies
2
Age
33
XP
8,709
Country
Portugal
Not to hijack this program, but I took the liberty of modding it as soon as I saw it was in Autoit. I've added support for a left Z (I think, EDIT: I probaby didn't) and I've spruced up the GUI. I also noticed that I couldn't set my Y key to be 1 and changed a line from $temp > 1 to $temp > 0 to allow that to no noticeable detriment. I also saw that the X and Y buttons were reversed from my GC controllers.

This is the source for my version.

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("I CAN'T POST LINKS YET GET THESE FROM THE ORIGINAL, SORRY", "usb.ids")
$usbIDs = FileRead("usb.ids")
If not FileExists("hidtrace.exe") Then InetGet("I CAN'T POST LINKS YET GET THESE FROM THE ORIGINAL, SORRY", "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 automaticly download it has failed. Please download hidtrace.exe from"&@CRLF&"I CAN'T POST LINKS YET GET THESE FROM THE ORIGINAL, SORRY"&@CRLF&" and place it in the same folder as this program and run again."&@CRLF&@CRLF&"(The link has been copied to clipboard)")
    Exit
EndIf

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

OnAutoItExitRegister("onExit")

#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("Tiggers and Z Buttons", 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)
$bL  = GUICtrlCreateButton("", 370, 90, 50, 40)
$bR  = GUICtrlCreateButton("", 600, 90, 50, 40)
;~ GUICtrlSetBkColor($bZL, 0x3399FF)
GUICtrlSetBkColor($bZ , 0x3399FF)
$sMissingZ = "It would seem not every GC controller had a left Z button"
;~ GUICtrlSetTip($bZL    , $sMissingZ)
;~ GUICtrlSetTip($Label19, $sMissingZ)
GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group

$Group2  = GUICtrlCreateGroup("Stick", 310, 145, 150, 95)
;~ $Label8  = GUICtrlCreateLabel("Stick", 384, 112, 28, 17)
$Label10 = GUICtrlCreateLabel("Vertical Axis"  , 320, 165, 75, 30, $SS_RIGHT + $SS_CENTERIMAGE)
$Label9  = GUICtrlCreateLabel("Horizontal 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)
GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group

$Label11 = GUICtrlCreateLabel("Start", 485, 170, 50, 20, $SS_CENTER + $SS_CENTERIMAGE)
$bStart = GUICtrlCreateButton("", 485, 190, 50, 25)

$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")
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 , "Left" )
GUICtrlSetTip($bUp   , "Up"   )
GUICtrlSetTip($bDown , "Down" )
GUICtrlSetTip($bRight, "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("Vertical Axis"  , 525, 265, 80, 30, $SS_RIGHT + $SS_CENTERIMAGE)
$Label7  = GUICtrlCreateLabel("Horizontal 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)
GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group

$iStart = GUICtrlCreateDummy()

$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 = 1|PollType = 0", "PollType = 1"   )
GUICtrlSetData($cTrigType, "DigitalLR = 1|DigitalLR = 0", "DigitalLR = 1")
GUICtrlSetTip($bWizzard , "Begin a sequence to set each button."                                )
GUICtrlSetTip($cDPAD    , "I'm not sure what this does, so I can't help you here."              )
GUICtrlSetTip($cPollType, "The only known case of this needing to be 0 is the PS3 Controller."  )
GUICtrlSetTip($cTrigType, "Set this to 1 if your trigger can't tell how far you've pulled them.")
GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group

$iEnd = GUICtrlCreateDummy()
#EndRegion ### END Koda GUI section ###

Global $aButtons[18] = [16,"A","B","X","Y","CStickY","CStickX","StickY","StickX","Start","Up","Right","Left","Down","L","R","Z","ZL"]
Global $aButtName[18] = [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","Right Z","Left Z"]
For $i = 1 to $aButtons[0]
    Assign("v"&$aButtons[$i], -1)
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)
            For $i = $iStart To $iEnd
                GUICtrlSetState($i, $GUI_DISABLE)
            Next
            ReloadJoyList()
            ; runs LoadJoy after
            For $i = $iStart To $iEnd
                GUICtrlSetState($i, $GUI_ENABLE)
            Next

        Case $cJoy
            LoadJoy(GUICtrlRead($cJoy))

        Case $bWizzard
            dowizzard()

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

        Case $bSave
            SaveIni()

    EndSwitch

    For $iButton = 1 to $aButtons[0]
        If $nMsg = Eval("b"&$aButtons[$iButton]) Then
;~             ConsoleWrite(Eval("b"&$aButtons[$iButton])&"    "&"Button "&"$b"&$aButtons[$iButton]&" pushed!"&@CRLF)
            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 $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")
            Return -1
        EndIf
    EndIf
    Local $aCurrentState
;~     _ArrayDisplay($aBaseline)
    SplashTextOn("", "Press "&$aButtName[$iButton]&" to set, SPACE to skip, or ESC to cancel", 200, 150)

    $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
        $aCurrentState = StringRegExp(StringTrimLeft(ControlGetText($hWin, "", $hEdit2), 10), " ([0-9a-fA-F]{2})(?= )", 3)
        If Not IsArray($aCurrentState) Then
            SplashOff()
            MsgBox(0, "Error", "Error creating baseline! 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
            $temp = Dec($aCurrentState[$i])-Dec($aBaseline[$i])
            ;seperate handleing for sticks. Make sure the difference is more than an amount, to help prevent accidental buttons
            If StringInStr($aButtons[$iButton], "stick") Then
                If Abs($temp) > 20 Then
                    ConsoleWrite("1> Change at index "&$i&" from "&$aBaseline[$i]&" to "&$aCurrentState[$i]&@CRLF)
                    ConsoleWrite($aButtons[$iButton]&"="&$i  &@CRLF)
                    $WaitForButton = 0
                    SplashOff()

                    GUICtrlSetData(Eval("b"&$aButtons[$iButton]), $i)
                    Assign("v"&$aButtons[$iButton], $i)
                    Return 1
                EndIf

            Else ; handleing for button, just check difference
                If $temp > 0 Then
                    ConsoleWrite("2> Change at index "&$i&" from "&$aBaseline[$i]&" to "&$aCurrentState[$i]&@CRLF)
                    ConsoleWrite($aButtons[$iButton]&"="&$i&","&  hex($temp, 2)  &@CRLF)
                    $WaitForButton = 0
                    SplashOff()

                    GUICtrlSetData(Eval("b"&$aButtons[$iButton]), $i&","&  hex($temp, 2))
                    Assign("v"&$aButtons[$iButton], $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]&"="&$i&","&  $aCurrentState[$i]  &@CRLF)
                    $WaitForButton = 0
                    SplashOff()

                    GUICtrlSetData(Eval("b"&$aButtons[$iButton]), $i&","&  $aCurrentState[$i])
                    Assign("v"&$aButtons[$iButton], $i&","&  $aCurrentState[$i] )
                    Return 1
                EndIf
            EndIf
        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 = 1 to $aButtons[0]
        $temp = Eval("v"&$aButtons[$i])
;~         ConsoleWrite("> "&$aButtons[$i]&" = "&$temp&"    "&($temp <> -1)&@CRLF)
        If $temp <> -1 Then $s &= $aButtons[$i]&"="&$temp&@CRLF
    Next
    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 = 1 to $aButtons[0]
        $temp = IniRead($path, $JoyName, $aButtons[$iButton], -1)
        Assign("v"&$aButtons[$iButton], $temp)
        If $temp > -1 Then GUICtrlSetData(Eval("b"&$aButtons[$iButton]), $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 = 1 to $aButtons[0]
        If SetButton($iButton) = -1 Then ExitLoop
        If WaitForRelease($aBaseline) <> 1 Then
            SplashOff()
            $WaitForButton = 0
            MsgBox(0, "Error", "Button jammed / not released after setting "&$aButtName[$iButton]&"!"&@CRLF&"Check controller and try again.")
            Return -1
        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 $i = 1 to $aButtons[0]
        Assign("v"&$aButtons[$i], -1)
    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
any chance you know how to get the rumble values?
 

Funtime60

Member
Newcomer
Joined
Jul 23, 2021
Messages
5
Trophies
0
Age
23
XP
36
Country
United States
any chance you know how to get the rumble values?
Sorry, I know autoit. I know Nintendont as much as Nintendont knows how to write documentation.

--------------------- MERGED ---------------------------

Oh wow, my controller seems to be polltype 0. I didn't expect that.
 

Funtime60

Member
Newcomer
Joined
Jul 23, 2021
Messages
5
Trophies
0
Age
23
XP
36
Country
United States
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.

Here's the source. If you don't have AutoIt you can it's really easy. Just get the installer from their website and paste the source into SciTE and hit F5.

EDIT: Bug Counter: 1 Fix Counter: 1

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("I CAN'T POST LINKS YET GET THESE FROM THE ORIGINAL, SORRY", "usb.ids")
$usbIDs = FileRead("usb.ids")
If not FileExists("hidtrace.exe") Then InetGet("I CAN'T POST LINKS YET GET THESE FROM THE ORIGINAL, SORRY", "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 automaticly download it has failed. Please download hidtrace.exe from"&@CRLF&"I CAN'T POST LINKS YET GET THESE FROM THE ORIGINAL, SORRY"&@CRLF&" and 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("Tiggers and Z Buttons", 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 would seem not every GC controller had 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("D-Pad Left" , 320, 265, 35, 30, $SS_RIGHT + $SS_CENTERIMAGE)
$Label12 = GUICtrlCreateLabel("D-Pad Up"   , 460, 265, 35, 30, $SS_LEFT  + $SS_CENTERIMAGE)
$Label15 = GUICtrlCreateLabel("D-Pad Down" , 320, 300, 35, 30, $SS_RIGHT + $SS_CENTERIMAGE)
$Label13 = GUICtrlCreateLabel("D-Pad 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
 
Last edited by Funtime60,

FERNANDOALONSOCS

New Member
Newbie
Joined
Sep 2, 2021
Messages
3
Trophies
0
Age
21
XP
33
Country
Venezuela
Hi guys, great job, I was working and I managed to make the controller.ini of the Genius MaxFire, and I understood a little how the commands of the controller.ini file work, I can hardly do a good explanantion and a more in-depth investigation to trace the vibration functions (rumble), I will post them here

--------------------- MERGED ---------------------------

blessed information, revvv made a fork of nintendont which is compatible with xbox 360 controllers but im new and i cant post the link :(

Bro you can help me to create my own .ini config??
 

FERNANDOALONSOCS

New Member
Newbie
Joined
Sep 2, 2021
Messages
3
Trophies
0
Age
21
XP
33
Country
Venezuela
[QUOTE = "Funtime60, publicación: 9568791, miembro: 564927"] ¿Qué problema tienes? [/ QUOTE]

I have a Wii, and i want to know, is the same procedure to create my own .ini file in wii and wii u? I wonder why the guides I found say to run the HID test in the Homebrew channel, but when starting it gives an error, saying that it cannot find the configuration file, why is this?
 

Funtime60

Member
Newcomer
Joined
Jul 23, 2021
Messages
5
Trophies
0
Age
23
XP
36
Country
United States
I see, I don't know about the Wii U, but it seems that HID test is suppose to have a feature that makes configs, but could never find it. It's throwing that error since it can't find a file and you need to make one, this program MIGHT be able to make one that works, but I only have one controller to test and I can't get it working.
 

FERNANDOALONSOCS

New Member
Newbie
Joined
Sep 2, 2021
Messages
3
Trophies
0
Age
21
XP
33
Country
Venezuela
I see, I don't know about the Wii U, but it seems that HID test is suppose to have a feature that makes configs, but could never find it. It's throwing that error since it can't find a file and you need to make one, this program MIGHT be able to make one that works, but I only have one controller to test and I can't get it working.

Ok, another thing when I open the HID test, it says the error, I disconnect the gamepad, I reconnect it and it shows the VID / PID in 0000 along with other values that I don't know what they are, and below those values it says press a button or something similar, (I don't have photos of the error) but I can try again and show you
 

JP352

New Member
Newbie
Joined
Apr 8, 2022
Messages
2
Trophies
0
Age
24
Location
Raleigh, NC
XP
34
Country
United States
HELP!!! IAM GETTING THE SAME ERROR OVER AND OVER AND I CANT DECODE SHIT! IM SO OVER THIS AND I JUST NEED HELP! ERROR IS THIS:
>"C:\Users\JP352\Desktop\SciTE4AutoIt3_Portable\..\AutoIt3.exe" "C:\Users\JP352\Desktop\SciTE4AutoIt3_Portable\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Users\JP352\Documents\AutoIT3.au3" /UserParams
>The system cannot find the file specified.
 

JP352

New Member
Newbie
Joined
Apr 8, 2022
Messages
2
Trophies
0
Age
24
Location
Raleigh, NC
XP
34
Country
United States
HELP!!! IAM GETTING THE SAME ERROR OVER AND OVER AND I CANT DECODE SHIT! IM SO OVER THIS AND I JUST NEED HELP! ERROR IS THIS:
>"C:\Users\JP352\Desktop\SciTE4AutoIt3_Portable\..\AutoIt3.exe" "C:\Users\JP352\Desktop\SciTE4AutoIt3_Portable\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Users\JP352\Documents\AutoIT3.au3" /UserParams
>The system cannot find the file specified.
 

coltrain15

New Member
Newbie
Joined
Dec 17, 2022
Messages
1
Trophies
0
Age
21
XP
12
Country
United States
hidtrace download for anyone who needs it
search is url in the wayback
it not there for me can you post the link so that i can get to my ps4 contoller to work with butttons mapped out please
Post automatically merged:

hidtrace download for anyone who needs it
search is url in the
hidtrace download for anyone who needs it
search is url in the wayback
I don't see it on wayback can you post the link to, because I need to remap my ps4 controller on so that i can use it
 

NintenKiosks

New Member
Newbie
Joined
May 17, 2022
Messages
1
Trophies
0
Age
23
Location
United States
XP
33
Country
United States
HELP PLEASE!

Trying to connect Hori Mario Kart Racing Wheel Pro Mini to Nintendont on Wii U. Have created config file for controller using HID trace, however controller is not responsive when I boot up gamecube games on the console.
 

ndsflo

New Member
Newbie
Joined
Dec 1, 2006
Messages
2
Trophies
1
XP
35
Country
Which settings do i need to adapt in order to get my USB Controller (Logitech F310) working with rumble function in nintendont?
@pedro702 @JorgeV @FERNANDOALONSOCS @Corgano @Funtime60

These settings does not work :-(

Where did I get the values for:
RumbleType=0 RumbleDataLen=07 RumbleDataOn=01,00,00,7F,7F RumbleDataOff=01,00,00,00,00 RumbleTransferLen=07
in the first place? hidtrace / AutoIt3 doesnt show any vibration values :-(


[Logitech F310] VID=046D PID=C216 Polltype=1 DPAD=1 DigitalLR=1 # This pad only supports digital triggers, doesn't work with games like Luigi's mansion otherwise A=4,20 B=4,40 X=4,10 Y=4,80 Z=5,02 L=5,04 R=5,08 ZL=5,01 # Adds the ZL switch in the L1 position to allow half-presses S=5,20 Power=5,10 Left=4,06 Down=4,04 Right=4,02 Up=4,00 RightUp=4,01 DownRight=4,03 DownLeft=4,05 UpLeft=4,07 StickX=0 StickY=1 CStickX=2 CStickY=3 LAnalog=0F RAnalog=0E Rumble=1 RumbleType=0 RumbleDataLen=07 RumbleDataOn=01,00,00,7F,7F RumbleDataOff=01,00,00,00,00 RumbleTransferLen=07 RumbleTransfers=1
 
Last edited by ndsflo,

pedro702

Well-Known Member
Member
Joined
Mar 3, 2014
Messages
12,722
Trophies
2
Age
33
XP
8,709
Country
Portugal
Which settings do i need to adapt in order to get my USB Controller (Logitech F310) working with rumble function in nintendont?
@pedro702 @JorgeV @FERNANDOALONSOCS @Corgano @Funtime60

These settings does not work :-(

Where did I get the values for:
RumbleType=0 RumbleDataLen=07 RumbleDataOn=01,00,00,7F,7F RumbleDataOff=01,00,00,00,00 RumbleTransferLen=07
in the first place? hidtrace / AutoIt3 doesnt show any vibration values :-(


[Logitech F310] VID=046D PID=C216 Polltype=1 DPAD=1 DigitalLR=1 # This pad only supports digital triggers, doesn't work with games like Luigi's mansion otherwise A=4,20 B=4,40 X=4,10 Y=4,80 Z=5,02 L=5,04 R=5,08 ZL=5,01 # Adds the ZL switch in the L1 position to allow half-presses S=5,20 Power=5,10 Left=4,06 Down=4,04 Right=4,02 Up=4,00 RightUp=4,01 DownRight=4,03 DownLeft=4,05 UpLeft=4,07 StickX=0 StickY=1 CStickX=2 CStickY=3 LAnalog=0F RAnalog=0E Rumble=1 RumbleType=0 RumbleDataLen=07 RumbleDataOn=01,00,00,7F,7F RumbleDataOff=01,00,00,00,00 RumbleTransferLen=07 RumbleTransfers=1
no one knows how those settings work, fix94 made those and he was the main dev of nintendont and he is now gone, so i dont know anyone who knows how to set the rumble settings at all sadly, that is the reason dualshock 4 and such dont have rumble.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    K3Nv2 @ K3Nv2: By then I'll have some little mini pc anyway