<# .SYNOPSIS Trust the test cert, enable test signing, stage and install the RioGamepad driver. REQUIRES AN ELEVATED (admin) shell. .DESCRIPTION Two phases, because enabling test signing needs a reboot: install.ps1 (phase 1, pre-reboot) - import RIOJoyTest.cer into LocalMachine Root + TrustedPublisher - stage the signed package into the driver store (pnputil /add-driver) - bcdedit /set testsigning on - THEN REBOOT install.ps1 -CreateDevice (phase 2, after the reboot) - create the root-enumerated device with devgen, which makes PnP install the staged driver. Then check joy.cpl. Run driver\sign.ps1 first to produce the signed package + RIOJoyTest.cer. .PARAMETER Ewdk Drive or root where the EWDK is mounted (default: E:). .PARAMETER CreateDevice Run phase 2 (create the device); use after the reboot. #> param( [string]$Ewdk = "E:", [switch]$CreateDevice ) $ErrorActionPreference = "Stop" $scriptDir = $PSScriptRoot $pkg = Join-Path $scriptDir "package" $inf = Join-Path $pkg "RioGamepad.inf" $cer = Join-Path $scriptDir "RIOJoyTest.cer" $devgen = Join-Path $Ewdk "Program Files\Windows Kits\10\Tools\10.0.28000.0\x64\devgen.exe" $hardwareId = "root\RioGamepad" 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." } if ($CreateDevice) { if (-not (Test-Path $devgen)) { throw "devgen not found: $devgen" } Write-Host "Creating device node ($hardwareId)..." & $devgen /add /instanceid "RIOJOY01" /hardwareid $hardwareId Write-Host "" Write-Host "Done. Open 'joy.cpl' and look for 'RIOJoy Virtual Gamepad'." -ForegroundColor Green Write-Host "If it shows a problem, check Device Manager and 'pnputil /enum-drivers'." return } if (-not (Test-Path $inf)) { throw "Signed package not found ($inf). Run driver\sign.ps1 first." } if (-not (Test-Path $cer)) { throw "Certificate not found ($cer). Run driver\sign.ps1 first." } Write-Host "Trusting test certificate (LocalMachine Root + TrustedPublisher)..." Import-Certificate -FilePath $cer -CertStoreLocation Cert:\LocalMachine\Root | Out-Null Import-Certificate -FilePath $cer -CertStoreLocation Cert:\LocalMachine\TrustedPublisher | Out-Null Write-Host "Staging driver into the driver store..." pnputil /add-driver $inf Write-Host "Enabling test signing..." bcdedit /set testsigning on | Out-Null Write-Host "" Write-Host "Phase 1 complete. REBOOT, then run: install.ps1 -CreateDevice" -ForegroundColor Yellow