Files
riojoy/driver/uninstall.ps1
T
CydandClaude Opus 4.8 38ffb27458 Fix RioGamepad Code 31: add VHF lower filter + joy.cpl friendly name
The driver installed but the device failed with Code 31
(CM_PROB_FAILED_ADD): VhfCreate returned STATUS_INVALID_DEVICE_REQUEST
(0xC0000010) because vhf.sys was never attached beneath the FDO. Add the
required LowerFilters=vhf AddReg to the INF so VHF loads as a lower
filter; the device now starts clean and enumerates in joy.cpl.

A VHF virtual HID device cannot supply a HID product string (VHF_CONFIG
has no string field and VHF owns IOCTL_HID_GET_STRING), so register the
DirectInput OEMName (VID_1209&PID_5249 -> RIOJoy Virtual Gamepad) in
install.ps1 -CreateDevice and remove it in uninstall.ps1, giving the
controller a proper name instead of the generic VHF default.

Also fix a non-ASCII em-dash in sign.ps1 that broke parsing under
Windows PowerShell 5.1 (UTF-8 without BOM), and document the Code 52 /
Code 31 / friendly-name troubleshooting in driver/README.md.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-26 23:39:55 -05:00

72 lines
2.5 KiB
PowerShell

<#
.SYNOPSIS
Remove the RioGamepad device and driver. REQUIRES AN ELEVATED shell.
.DESCRIPTION
Removes the device node, deletes the driver package from the store, and
(optionally) turns test signing back off and removes the trusted test cert.
.PARAMETER DisableTestSigning
Also run 'bcdedit /set testsigning off' (needs a reboot to take effect).
.PARAMETER RemoveCert
Also remove the RIOJoy test certificate from the machine trust stores.
#>
param(
[switch]$DisableTestSigning,
[switch]$RemoveCert
)
$ErrorActionPreference = "Continue"
if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(
[Security.Principal.WindowsBuiltInRole]::Administrator)) {
throw "This script must be run from an elevated (Administrator) shell."
}
# 1. Remove the device instance(s) matching our hardware id.
Write-Host "Removing RioGamepad device node(s)..."
$instances = (pnputil /enum-devices /connected /class System) 2>$null
& pnputil /remove-device /deviceid "root\RioGamepad" 2>$null
# 2. Delete the driver package(s) from the store (oem*.inf published from RioGamepad.inf).
Write-Host "Locating staged driver package..."
$drivers = pnputil /enum-drivers
$published = $null
for ($i = 0; $i -lt $drivers.Count; $i++) {
if ($drivers[$i] -match 'Original Name:\s*RioGamepad\.inf') {
for ($j = $i; $j -ge 0; $j--) {
if ($drivers[$j] -match 'Published Name:\s*(oem\d+\.inf)') { $published = $Matches[1]; break }
}
}
}
if ($published) {
Write-Host "Deleting $published ..."
pnputil /delete-driver $published /uninstall /force
} else {
Write-Host "No staged RioGamepad driver package found."
}
# 3. Remove the DirectInput / joy.cpl friendly-name registration.
$joyOemRel = "SYSTEM\CurrentControlSet\Control\MediaProperties\PrivateProperties\Joystick\OEM\VID_1209&PID_5249"
foreach ($hive in @("HKLM:", "HKCU:")) {
$key = "$hive\$joyOemRel"
if (Test-Path $key) {
Write-Host "Removing joy.cpl friendly-name key: $key"
Remove-Item -Path $key -Recurse -Force -ErrorAction SilentlyContinue
}
}
if ($RemoveCert) {
Write-Host "Removing test certificate from trust stores..."
Get-ChildItem Cert:\LocalMachine\Root, Cert:\LocalMachine\TrustedPublisher |
Where-Object { $_.Subject -eq "CN=RIOJoy Test Cert" } |
ForEach-Object { Remove-Item $_.PSPath -Force }
}
if ($DisableTestSigning) {
Write-Host "Disabling test signing (reboot required)..."
bcdedit /set testsigning off | Out-Null
}
Write-Host "Done."