Last active
January 3, 2025 23:22
-
-
Save MoreOrLessSoftware/fbc757075a08b30d1fc64206d9a572af to your computer and use it in GitHub Desktop.
Helper script for changing the controller ID (for player 1) in the Yuzu configuration file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Usage with Sunshine (for example): | |
| # Do command: | |
| # powershell -File "F:\Scripts\Yuzu-Configure-Controller.ps1" Xbox360 | |
| # Undo command: | |
| # powershell -File "F:\Scripts\Yuzu-Configure-Controller.ps1" XboxOne | |
| # | |
| # You MUST first configure the iniFilePaths and controllerIds below for your specific system! | |
| # Highly recommend to backup your Yuzu configuration files first! | |
| param( | |
| [Parameter(Mandatory=$true)] | |
| [string]$controllerName # Whatever name you want that matches a key in the $controllerIds dictionary defined below | |
| ) | |
| # Paths to the Yuzu config files to be updated (we update the Default input config in case a game profile uses it specifically) | |
| $iniFilePaths = @("F:\Emulation\Emulators\yuzu\user\config\qt-config.ini", "F:\Emulation\Emulators\yuzu\user\config\input\Default.ini") | |
| # Controller IDs which can be found by checking in the qt-config file after configuring the controller in Yuzu | |
| # The names are arbitrary, but in this example "XboxOne" is my controller attached directly to the host, and Xbox360 is the Sunshine virtual gamepad | |
| $controllerIds = @{ | |
| XboxOne = '030000005e040000e002000000007801' | |
| Xbox360 = '030000005e0400008e02000000007801' | |
| } | |
| # --- End configuration section --- | |
| # Ensure that the provided controllerName is configured | |
| $controllerId = $controllerIds[$controllerName]; | |
| if ($null -eq $controllerId) { | |
| Write-Host "No controller ID found for name: $controllerName"; | |
| Break | |
| } | |
| # Replace the controller ID for player_0 in all the ini files | |
| For ($i = 0; $i -lt $iniFilePaths.Length; $i++) { | |
| $iniFilePath = $iniFilePaths[$i] | |
| $content = [System.IO.File]::ReadAllText($iniFilePath) | |
| $content = [System.Text.RegularExpressions.Regex]::Replace($content, "(player_0.+guid:)([\w\d]+)(.*)", '$1{ControllerIdPlaceholder}$3'); | |
| $content = $content.Replace("{ControllerIdPlaceholder}", $controllerId); | |
| [System.IO.File]::WriteAllText($iniFilePath, $content) | |
| } | |
| Write-Host "Configured Yuzu for controller: $controllerName" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment