Jump to content
LaunchBox Community Forums

[HOW TO] Automatically set correct mouse (light guns) bindings in Supermodel 3 config file


Hamburglin

Recommended Posts

I'm cross posting this here for visibility because I feel that it solves a really annoying issue that has been plaguing light gun users in supermodel 3 games for years now. The solution can be ran before games launch in additional apps if desired:

 

 

 

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 your 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 assignments are and then 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!

The trick----------
The novel part of this that I don't think people knew about until today is this:
1. You can assign unique names to your "Generic HID Comapitable" devices via the registry.
2. This lets you run "supermodel.exe print-inputs" and programmatically determine your gun's mouse indexes from that output.


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 and then run 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:

  1. Set-Location -Path... to your supermodel 3 folder
  2. The value to search for after Select-String (ex:GUN1) in the $gun1info and $gun2info lines
  3. Your supermodel3  exe location in the $inputs lines
  4. The path to your supermodel.ini file after the "#Read in Supermodel.ini" line
  5. Your supermodel.ini path again after the "#Write-Output $content" line
  6. 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 if you make a batch or cmd file to execute it. Instead of that, you can easily convert the ps1 script into an executable by installing PS2EXE via " Install-Module -Name ps2exe " in powershell and then running something like "Invoke-PS2EXE \thisscript.ps1 \newexecutable.exe"

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 realized this was possible today and figured out this process and script. Between this and issuing COM commands to gun4ir via echo, this should make supermodel 3 "just work" for light guns! I hope it helps!

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...