我必须为 200 个游戏配置按钮!!按钮映射是通过 XML 完成的。它看起来像这样:
<GameProfile xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<ProfileName>NAME</ProfileName>
<GameNameInternal>GAME NAME HERE</GameNameInternal>
<GameGenreInternal>Fighting</GameGenreInternal>
<GamePath>PATH GOES HERE</GamePath>
<TestMenuParameter/>
<TestMenuIsExecutable>false</TestMenuIsExecutable>
<ExtraParameters/>
<TestMenuExtraParameters/>
<IconName>Icons/TITLE.png</IconName>
<ResetHint>false</ResetHint>
<ConfigValues>
...
</ConfigValues>
<JoystickButtons>
<JoystickButtons>
<ButtonName>Test</ButtonName>
<XInputButton>
...
</XInputButton>
<InputMapping>Test</InputMapping>
<AnalogType>None</AnalogType>
<BindNameXi>Input Device 0 RightThumb</BindNameXi>
<HideWithDirectInput>false</HideWithDirectInput>
<HideWithXInput>false</HideWithXInput>
<HideWithRawInput>false</HideWithRawInput>
<HideWithKeyboardForAxis>false</HideWithKeyboardForAxis>
<HideWithoutKeyboardForAxis>false</HideWithoutKeyboardForAxis>
<HideWithRelativeAxis>false</HideWithRelativeAxis>
<HideWithoutRelativeAxis>false</HideWithoutRelativeAxis>
<HideWithUseDPadForGUN1Stick>false</HideWithUseDPadForGUN1Stick>
<HideWithoutUseDPadForGUN1Stick>false</HideWithoutUseDPadForGUN1Stick>
<HideWithUseDPadForGUN2Stick>false</HideWithUseDPadForGUN2Stick>
<HideWithoutUseDPadForGUN2Stick>false</HideWithoutUseDPadForGUN2Stick>
<HideWithUseAnalogAxisToAimGUN1>false</HideWithUseAnalogAxisToAimGUN1>
<HideWithoutUseAnalogAxisToAimGUN1>false</HideWithoutUseAnalogAxisToAimGUN1>
<HideWithUseAnalogAxisToAimGUN2>false</HideWithUseAnalogAxisToAimGUN2>
<HideWithoutUseAnalogAxisToAimGUN2>false</HideWithoutUseAnalogAxisToAimGUN2>
<HideWithoutProMode>false</HideWithoutProMode>
<HideWithProMode>false</HideWithProMode>
</JoystickButtons>
我根据上一篇文章中收到的信息编写了这个脚本。它会抓取所有游戏 XML 文件,然后循环浏览每个文件并提示我输入找到的每个按钮。除了它接受我的输入“$Key”并更改“”(如果有)的值的部分外,其他一切都正常。
$games = Get-ChildItem C:\PATH\UserProfiles -Filter "*.xml"
$notMatch = "fly","drive","gun","shooter","Racing", "axis" #ignore these types of games
foreach($game in $games){
[xml]$gameInfo = Get-Content $game.fullname
if(($gameInfo.GameProfile.GameGenreInternal -notmatch ($notMatch -join '|')) -and ($gameInfo.GameProfile.GameNameInternal)){
$xml = New-Object XML
$xml.Load("C:\PATH\$game")
$gameName = $xml.GameProfile.GameNameInternal
$buttons = $xml.GameProfile.JoystickButtons.JoystickButtons
Write-Host -ForegroundColor Yellow $gameName
Write-Host -ForegroundColor Yellow "----------------------------------------"
foreach($button in $buttons){
$key = Read-Host "Map button" '"'$button.ButtonName'"'
$key = $host.ui.rawui.readkey()
$button.InputMapping = $key
}
write-host ""
}
}