Jump to content
LaunchBox Community Forums

[HOW TO] Automatically update your Supermodel.ini to set correct mouse inputs for your light guns


Hamburglin

Recommended Posts

Windows does not keep or report back a consistent list of mice that are plugged in. That means that after every boot or new usb device is connected that your mouse assignments might change. In turn, you need to update you Supermodel.ini file to reference the correct number for your mice (light guns). This is super annoying.

I've automated the process of determining what your light gun's mice assignment is and auto updating the Supermodel.ini to reflect that. The powershell script is INCREDIBLY naive and needs manual editing of variable to get working on your machine. If anyone want's to generalize it make it more efficient, please do!

Requirements-----------
Here are the things you must do to prepare to run the script:

1. Ensure that you have mouse bindings in your Supermodel.ini already. The numbers can be wrong, that's alright. Just bind the buttons you want to be updated when the assignments change. If you want to have non-mouse bindings in addition to your mouse bindings, put those to the right of your mouse bindings. Example: InputCoin1 = MOUSE5_MIDDLE_BUTTON,5
2. Go to device manager and drop down the mice. You'll see a bunch of "HID compatible devices". We want to find our guns and change that description to something unique. To do this, find your gun's hardware ID (gun4ir's starts with 2341 always) by right clicking each HID device -> Details -> Hardware ID in the dropdown. Then copy its "driver key" value from the same area
3. Open up regedit and go to SYSTEM -> CurrentControlSet001 -> Enum -> HID. Now ctrl+f and find your devices. Edit their "DeviceDescr" key and add something unique to the very end, and differentiate each gun. Example for my first player's gun: @msmouse.inf,%hid.mousedevice%;HID-compliant mouseGUN1
4. While you're there, add a brand new value called "FriendlyName". Set that value to reference the same as above. This will change the name in the device manager so you can find the guns easily again if needed instead of it reading "HID compliant device"
5. Take a moment and understand what we're doing: open the command prompt, cd to your supermodel 3 directory and run "supermodel.exe -print-inputs". You MUST be IN that directory or else it will complain about not finding supermodel.ini. Ok, you ran it. Now scroll up until you see it reporting your mice. You should see the "HID compliant devices" but also your new, unique DeviceDesc values (gun1 etc). Great! Now we have a consistent way to map our lightguns!

Setting up the script------------
At this point, you can simply update your config manually using the numbers on the left for each lightgun. However, I've provided a powershell script you can manually edit to find the devices from that output and update the config for you:
 

#Set working dir to supermodel directory so that it can read Supermodel.ini and not error out
Set-Location -Path "C:\Emulation\Emulators\Supermodel 3 rawinput\"
#Get-Location

#Find gun1's mouse index
$inputs = & "C:\Emulation\Emulators\Supermodel 3 rawinput\Supermodel.exe"  -print-inputs
$gun1info = ($inputs | Select-String "GUN1").Line
$gun1index = $gun1info.Substring(1,1)
$gun1formatted = "MOUSE" + $gun1index
#Write-Output $gun1formatted

#Find gun2's mouse index
$inputs = & "C:\Emulation\Emulators\Supermodel 3 rawinput\Supermodel.exe"  -print-inputs
$gun2info = ($inputs | Select-String "GUN2").Line
$gun2index = $gun2info.Substring(1,1)
$gun2formatted = "MOUSE" + $gun2index
#Write-Output $gun2formatted

#Read in Supermodel.ini
$content = Get-Content -Path 'C:\Emulation\Emulators\Supermodel 3 rawinput\Config\Supermodel.ini'

#Edit Supermodel.ini mouse related lines
#This assumes you have one mouse assigned per bind/value already. It will not touch any bindings to the RIGHT of the mouse text
#(Need backtick in front of capture group variable in the replacement else it won't print the value)

#Update gun1
$content = $content -replace '(InputStart1.*?)(MOUSE\d)',"`$1$gun1formatted"
$content = $content -replace '(InputCoin1.*?)(MOUSE\d)',"`$1$gun1formatted"
$content = $content -replace '(InputGunX.*?)(MOUSE\d)',"`$1$gun1formatted"
$content = $content -replace '(InputGunY.*?)(MOUSE\d)',"`$1$gun1formatted"
$content = $content -replace '(InputTrigger.*?)(MOUSE\d)',"`$1$gun1formatted"
$content = $content -replace '(InputOffscreen.*?)(MOUSE\d)',"`$1$gun1formatted"
$content = $content -replace '(InputAnalogGunX.*?)(MOUSE\d)',"`$1$gun1formatted"
$content = $content -replace '(InputAnalogGunY.*?)(MOUSE\d)',"`$1$gun1formatted"
$content = $content -replace '(InputAnalogTriggerLeft.*?)(MOUSE\d)',"`$1$gun1formatted"
$content = $content -replace '(InputAnalogTriggerRight.*?)(MOUSE\d)',"`$1$gun1formatted"

#Update gun2
$content = $content -replace '(InputStart2.*?)(MOUSE\d)',"`$1$gun2formatted"
$content = $content -replace '(InputCoin2.*?)(MOUSE\d)',"`$1$gun2formatted"
$content = $content -replace '(InputGunX2.*?)(MOUSE\d)',"`$1$gun2formatted"
$content = $content -replace '(InputGunY2.*?)(MOUSE\d)',"`$1$gun2formatted"
$content = $content -replace '(InputTrigger2.*?)(MOUSE\d)',"`$1$gun2formatted"
$content = $content -replace '(InputOffscreen2.*?)(MOUSE\d)',"`$1$gun2formatted"
$content = $content -replace '(InputAnalogGunX2.*?)(MOUSE\d)',"`$1$gun2formatted"
$content = $content -replace '(InputAnalogGunY2.*?)(MOUSE\d)',"`$1$gun2formatted"
$content = $content -replace '(InputAnalogTriggerLeft2.*?)(MOUSE\d)',"`$1$gun2formatted"
$content = $content -replace '(InputAnalogTriggerRight2.*?)(MOUSE\d)',"`$1$gun2formatted"

#Write new file
#Write-Output $content
$content | Set-Content -Path "C:\Emulation\Emulators\Supermodel 3 rawinput\Config\Supermodel.ini"

#GUN4IR ONLY
#Make guns rumble once so we know this all occurred
#Uncomment the next two lines and replace the COM ports with your gun's ports. Set them in device manager -> COM ports first
#cmd.exe /c "echo F.1.2.1 > \\.\COM11"
#cmd.exe /c "echo F.1.2.1 > \\.\COM12"



The script is very primitive and requires you to change these variables or lines:
- Set-Location -Path... to your supermodel 3 folder
- The value to search for after Select-String (ex:GUN1) in the $gun1info and $gun2info lines
- The path to your supermodel.ini file after the "#Read in Supermodel.ini" line
- Your supermodel.ini path again after the "#Write-Output $content" line
- The most complicated part: adding or removing buttons you want bound in the big chunks under the "#Update gunX" lines. SImply copy and paste one of the lines and put in extra button you want bound. Please recall that you need the mouse's already bound to all of these in the supermodel.ini else the script can't match on them to update the numbers. Simply delete specific lines if you dont want some bound (like coin and start for example).

Auto running the script---------
You can now set the script to run at startup or launchbox game start. You can install PS2EXE via " Install-Module -Name ps2exe " in powershell and run Invoke-PS2EXE \thisscript.ps1 \newexecutable.exe to create an exe version of the script.

Dump a shortcut to that exe in your windows startup folder, or point to it with additional apps in launchbox

 



Sorry if this is confusing. I just realize this was possible today and figured out this process and script. I hope it helps! Please ask questions if you need clarification.

Edited by Hamburglin
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...