add support for new pcsx2

This commit is contained in:
h4570
2023-11-25 16:12:55 +01:00
parent c40558bd54
commit 19ae6de1c7
2 changed files with 140 additions and 12 deletions
+70 -6
View File
@@ -1,12 +1,76 @@
$PCSX2_PATH = "${Env:ProgramFiles(x86)}/PCSX2" # =======================
$PCSX2_EXE = 'pcsx2.exe' $CUSTOM_PCSX2_PATH = "" # "D:/My/Path/To/PCSX2"
# =======================
function GetTargetELFName { function GetTargetELFName {
return (Select-String -Path './Makefile' -Pattern "[^ ]*.elf").Matches.Value return (Select-String -Path './Makefile' -Pattern "[^ ]*.elf").Matches.Value
} }
function RunPCSX2 { function FindPCSX2Directory {
$PCSX2_EXE_WITHOUT_EXT = (Split-Path $PCSX2_EXE -Leaf).Split('.')[0] if (-not [string]::IsNullOrEmpty($CUSTOM_PCSX2_PATH)) {
Stop-Process -Name $PCSX2_EXE_WITHOUT_EXT -ErrorAction 'SilentlyContinue' return $CUSTOM_PCSX2_PATH
Start-Process -FilePath "$PCSX2_PATH/$PCSX2_EXE" -ArgumentList "--elf=$PWD/bin/$(GetTargetELFName)"
} }
else {
# Try to find in program files
$pcsx2Path = "${Env:ProgramFiles}/PCSX2"
$pcsx2Pathx86 = "${Env:ProgramFiles(x86)}/PCSX2"
if (Test-Path -Path $pcsx2Path) {
return $pcsx2Path
}
elseif (Test-Path -Path $pcsx2Pathx86) {
return $pcsx2Pathx86
}
else {
throw "PCSX2 directory not found!"
return $null
}
}
}
function IsNewQtVersionOfPCSX2 {
param (
[string]$path
)
return Test-Path -Path "$path/qt.conf"
}
function FindPCSX2Executable {
param (
[string]$directory
)
$pcsx2ExePath = Join-Path -Path $directory -ChildPath 'pcsx2.exe'
$pcsx2QtExePath = Join-Path -Path $directory -ChildPath 'pcsx2-qt.exe'
if (Test-Path -Path $pcsx2ExePath) {
return 'pcsx2.exe'
}
elseif (Test-Path -Path $pcsx2QtExePath) {
return 'pcsx2-qt.exe'
}
else {
throw "PCSX2 executable not found in: $directory!"
return $null
}
}
function RunPCSX2 {
$dirPath = FindPCSX2Directory
$isNewVersion = IsNewQtVersionOfPCSX2 -path $dirPath
$executableName = FindPCSX2Executable -directory $dirPath
$executableNameWithoutExt = (Split-Path $executableName -Leaf).Split('.')[0]
$targetFileName = "$PWD/bin/$(GetTargetELFName)"
Stop-Process -Name $executableNameWithoutExt -ErrorAction 'SilentlyContinue'
if ($isNewVersion) {
Start-Process -FilePath "$dirPath/$executableName" -ArgumentList "-elf", $targetFileName
}
else { # Old version of PCSX2
Start-Process -FilePath "$dirPath/$executableName" -ArgumentList "--elf=$targetFileName"
}
}
RunPCSX2
+70 -6
View File
@@ -1,12 +1,76 @@
$PCSX2_PATH = "${Env:ProgramFiles(x86)}/PCSX2" # =======================
$PCSX2_EXE = 'pcsx2.exe' $CUSTOM_PCSX2_PATH = "" # "D:/My/Path/To/PCSX2"
# =======================
function GetTargetELFName { function GetTargetELFName {
return (Select-String -Path './Makefile' -Pattern "[^ ]*.elf").Matches.Value return (Select-String -Path './Makefile' -Pattern "[^ ]*.elf").Matches.Value
} }
function RunPCSX2 { function FindPCSX2Directory {
$PCSX2_EXE_WITHOUT_EXT = (Split-Path $PCSX2_EXE -Leaf).Split('.')[0] if (-not [string]::IsNullOrEmpty($CUSTOM_PCSX2_PATH)) {
Stop-Process -Name $PCSX2_EXE_WITHOUT_EXT -ErrorAction 'SilentlyContinue' return $CUSTOM_PCSX2_PATH
Start-Process -FilePath "$PCSX2_PATH/$PCSX2_EXE" -ArgumentList "--elf=$PWD/bin/$(GetTargetELFName)"
} }
else {
# Try to find in program files
$pcsx2Path = "${Env:ProgramFiles}/PCSX2"
$pcsx2Pathx86 = "${Env:ProgramFiles(x86)}/PCSX2"
if (Test-Path -Path $pcsx2Path) {
return $pcsx2Path
}
elseif (Test-Path -Path $pcsx2Pathx86) {
return $pcsx2Pathx86
}
else {
throw "PCSX2 directory not found!"
return $null
}
}
}
function IsNewQtVersionOfPCSX2 {
param (
[string]$path
)
return Test-Path -Path "$path/qt.conf"
}
function FindPCSX2Executable {
param (
[string]$directory
)
$pcsx2ExePath = Join-Path -Path $directory -ChildPath 'pcsx2.exe'
$pcsx2QtExePath = Join-Path -Path $directory -ChildPath 'pcsx2-qt.exe'
if (Test-Path -Path $pcsx2ExePath) {
return 'pcsx2.exe'
}
elseif (Test-Path -Path $pcsx2QtExePath) {
return 'pcsx2-qt.exe'
}
else {
throw "PCSX2 executable not found in: $directory!"
return $null
}
}
function RunPCSX2 {
$dirPath = FindPCSX2Directory
$isNewVersion = IsNewQtVersionOfPCSX2 -path $dirPath
$executableName = FindPCSX2Executable -directory $dirPath
$executableNameWithoutExt = (Split-Path $executableName -Leaf).Split('.')[0]
$targetFileName = "$PWD/bin/$(GetTargetELFName)"
Stop-Process -Name $executableNameWithoutExt -ErrorAction 'SilentlyContinue'
if ($isNewVersion) {
Start-Process -FilePath "$dirPath/$executableName" -ArgumentList "-elf", $targetFileName
}
else { # Old version of PCSX2
Start-Process -FilePath "$dirPath/$executableName" -ArgumentList "--elf=$targetFileName"
}
}
RunPCSX2