Merge pull request #172 from h4570/support-new-pcsx2

Add support for new PCSX2
This commit is contained in:
Sandro Sobczyński
2023-11-25 16:55:36 +01:00
committed by GitHub
3 changed files with 141 additions and 13 deletions
+1 -1
View File
@@ -42,7 +42,7 @@
"options": { "options": {
"cwd": "${config:buildDirectory}" "cwd": "${config:buildDirectory}"
}, },
"command": "./run.ps1" "command": "Start-Job { ./run.ps1 } | Receive-Job -Wait"
}, },
{ {
"type": "shell", "type": "shell",
+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