Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 126 additions & 0 deletions .github/workflows/build-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
name: Build & Package BetterVR

on:
workflow_dispatch:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:
runs-on: windows-2022

defaults:
run:
shell: pwsh

steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive

- name: Set up MSVC dev environment
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x64

- name: Install Vulkan SDK (direct from LunarG)
run: |
$ErrorActionPreference = "Stop"

$latest = Invoke-RestMethod "https://vulkan.lunarg.com/sdk/latest/windows.json"
$ver = $latest.windows
if (-not $ver) { throw "Failed to determine latest Vulkan SDK version." }
Write-Host "Latest Vulkan SDK version: $ver"

$exe = "vulkansdk-windows-X64-$ver.exe"
$urlNew = "https://sdk.lunarg.com/sdk/download/$ver/windows/$exe"
$urlOld = "https://sdk.lunarg.com/sdk/download/$ver/windows/VulkanSDK-$ver-Installer.exe"

try {
Write-Host "Downloading: $urlNew"
Invoke-WebRequest $urlNew -OutFile $exe
} catch {
Write-Host "New-name download failed; trying legacy filename..."
Write-Host "Downloading: $urlOld"
Invoke-WebRequest $urlOld -OutFile $exe
}

$installRoot = "C:\VulkanSDK\$ver"
New-Item -ItemType Directory -Force -Path $installRoot | Out-Null

& ".\$exe" --root $installRoot --accept-licenses --default-answer --confirm-command install com.lunarg.vulkan.debug copy_only=1

"VULKAN_SDK=$installRoot" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
"VK_SDK_PATH=$installRoot" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
"$installRoot\Bin" | Out-File -FilePath $env:GITHUB_PATH -Append -Encoding utf8

Write-Host "Installed Vulkan SDK to $installRoot"

- name: Clone vcpkg
run: |
git clone https://github.com/microsoft/vcpkg "$env:GITHUB_WORKSPACE\vcpkg"

- name: Bootstrap vcpkg
run: |
& "$env:GITHUB_WORKSPACE\vcpkg\bootstrap-vcpkg.bat" -disableMetrics

- name: Export vcpkg environment for scripts
run: |
"VCPKG_ROOT=$env:GITHUB_WORKSPACE\vcpkg" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
"VCPKG_DEFAULT_TRIPLET=x64-windows-static-md" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8

- name: Install vcpkg dependencies (manifest mode)
run: |
$ErrorActionPreference = "Stop"
$vcpkg = "$env:GITHUB_WORKSPACE\vcpkg\vcpkg.exe"

if (!(Test-Path "$env:GITHUB_WORKSPACE\vcpkg.json")) {
throw "vcpkg.json not found at repo root (expected manifest mode)."
}

& $vcpkg install `
--x-manifest-root "$env:GITHUB_WORKSPACE" `
--triplet "x64-windows-static-md"

- name: Patch CMakeUserPresets.json (set VCPKG_ROOT for all presets)
run: |
$presetPath = Join-Path $env:GITHUB_WORKSPACE "CMakeUserPresets.json"
if (!(Test-Path $presetPath)) { throw "CMakeUserPresets.json not found at repo root." }

$vcpkgRoot = Join-Path $env:GITHUB_WORKSPACE "vcpkg"
$json = Get-Content $presetPath -Raw | ConvertFrom-Json

if ($null -eq $json.configurePresets) { throw "configurePresets missing in CMakeUserPresets.json" }

foreach ($p in $json.configurePresets) {
if ($null -eq $p.environment) { $p | Add-Member -NotePropertyName environment -NotePropertyValue (@{}) }
$p.environment.VCPKG_ROOT = $vcpkgRoot
}

$json | ConvertTo-Json -Depth 50 | Set-Content $presetPath -Encoding UTF8
Write-Host "Patched VCPKG_ROOT to: $vcpkgRoot"

- name: Build (build_mod.bat)
run: |
if (!(Test-Path "$env:GITHUB_WORKSPACE\build_mod.bat")) {
throw "build_mod.bat not found at repo root."
}
cmd /c build_mod.bat RelWithDebInfo

- name: Package (package_mod.bat)
run: |
if (!(Test-Path "$env:GITHUB_WORKSPACE\package_mod.bat")) {
throw "package_mod.bat not found at repo root."
}
cmd /c package_mod.bat

- name: Upload package zip (no extra repackaging step)
uses: actions/upload-artifact@v4
with:
name: BetterVR-package
path: |
*.zip
if-no-files-found: error
17 changes: 14 additions & 3 deletions build_mod.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
REM rmdir /Q /S build
cmake -G "Visual Studio 17 2022" -A x64 --preset default -B ./build
cmake --build ./build --config Debug --target ALL_BUILD
@echo off
setlocal

set PRESET=%1
if "%PRESET%"=="" set PRESET=RelWithDebInfo

if exist build rmdir /Q /S build

cmake --preset %PRESET% -B build

REM Build default target (works for Ninja and VS)
cmake --build build --config %PRESET%

endlocal
130 changes: 63 additions & 67 deletions package_mod.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@echo off
setlocal
setlocal EnableExtensions EnableDelayedExpansion

set "ZIP_NAME=BetterVR.zip"
set "TEMP_DIR=temp_package"
Expand All @@ -12,91 +12,87 @@ REM Create directory structure
mkdir "%TEMP_DIR%"
mkdir "%TEMP_DIR%\BreathOfTheWild_BetterVR"

REM Copy DLL
if exist "Cemu\BetterVR_Layer.dll" (
copy "Cemu\BetterVR_Layer.dll" "%TEMP_DIR%\" >nul
echo Copied BetterVR_Layer.dll
) else (
echo Error: Cemu\BetterVR_Layer.dll not found.
goto :error
)

REM Copy JSON
if exist "Cemu\BetterVR_Layer.json" (
copy "Cemu\BetterVR_Layer.json" "%TEMP_DIR%\" >nul
echo Copied BetterVR_Layer.json
) else (
echo Error: Cemu\BetterVR_Layer.json not found.
goto :error
)

REM Copy LIB
if exist "Cemu\BetterVR_Layer.lib" (
copy "Cemu\BetterVR_Layer.lib" "%TEMP_DIR%\" >nul
echo Copied BetterVR_Layer.lib
) else (
echo Error: Cemu\BetterVR_Layer.lib not found.
goto :error
)

REM Copy PDB
if exist "Cemu\BetterVR_Layer.pdb" (
copy "Cemu\BetterVR_Layer.pdb" "%TEMP_DIR%\" >nul
echo Copied BetterVR_Layer.pdb
) else (
echo Error: Cemu\BetterVR_Layer.pdb not found.
goto :error
)
REM -------------------------
REM Helper: locate a file
REM Usage: call :findfile VAR "filename"
REM -------------------------
call :findfile DLL_PATH "BetterVR_Layer.dll"
call :findfile JSON_PATH "BetterVR_Layer.json"
call :findfile LIB_PATH "BetterVR_Layer.lib"
call :findfile PDB_PATH "BetterVR_Layer.pdb"

REM Copy bat
if exist "resources\BetterVR LAUNCH CEMU IN VR.bat" (
copy "resources\BetterVR LAUNCH CEMU IN VR.bat" "%TEMP_DIR%\" >nul
echo Copied BetterVR LAUNCH CEMU IN VR.bat
) else (
echo Error: resources\BetterVR LAUNCH CEMU IN VR.bat not found.
goto :error
)
if not defined DLL_PATH (echo Error: BetterVR_Layer.dll not found.& goto :error)
if not defined JSON_PATH (echo Error: BetterVR_Layer.json not found.& goto :error)
if not defined LIB_PATH (echo Error: BetterVR_Layer.lib not found.& goto :error)
if not defined PDB_PATH (echo Error: BetterVR_Layer.pdb not found.& goto :error)

REM Copy compat bat
if exist "resources\BetterVR LAUNCH CEMU IN VR - COMPATIBILITY MODE.bat" (
copy "resources\BetterVR LAUNCH CEMU IN VR - COMPATIBILITY MODE.bat" "%TEMP_DIR%\" >nul
echo Copied BetterVR LAUNCH CEMU IN VR - COMPATIBILITY MODE.bat
) else (
echo Error: resources\BetterVR LAUNCH CEMU IN VR - COMPATIBILITY MODE.bat not found.
goto :error
)
echo Using:
echo DLL: "!DLL_PATH!"
echo JSON: "!JSON_PATH!"
echo LIB: "!LIB_PATH!"
echo PDB: "!PDB_PATH!"

REM Copy uninstall bat
if exist "resources\BetterVR UNINSTALL.bat" (
copy "resources\BetterVR UNINSTALL.bat" "%TEMP_DIR%\" >nul
echo Copied BetterVR UNINSTALL.bat
) else (
echo Error: resources\BetterVR UNINSTALL.bat not found.
goto :error
)
copy "!DLL_PATH!" "%TEMP_DIR%\" >nul || goto :error
copy "!JSON_PATH!" "%TEMP_DIR%\" >nul || goto :error
copy "!LIB_PATH!" "%TEMP_DIR%\" >nul || goto :error
copy "!PDB_PATH!" "%TEMP_DIR%\" >nul || goto :error

REM Copy launch scripts
call :copyreq "resources\BetterVR LAUNCH CEMU IN VR.bat" "%TEMP_DIR%\BetterVR LAUNCH CEMU IN VR.bat"
call :copyreq "resources\BetterVR LAUNCH CEMU IN VR - COMPATIBILITY MODE.bat" "%TEMP_DIR%\BetterVR LAUNCH CEMU IN VR - COMPATIBILITY MODE.bat"
call :copyreq "resources\BetterVR UNINSTALL.bat" "%TEMP_DIR%\BetterVR UNINSTALL.bat"

REM Copy Graphic Packs
if exist "resources\BreathOfTheWild_BetterVR" (
xcopy /E /I /Y "resources\BreathOfTheWild_BetterVR" "%TEMP_DIR%\BreathOfTheWild_BetterVR" >nul
echo Copied BreathOfTheWild_BetterVR resources
xcopy /E /I /Y "resources\BreathOfTheWild_BetterVR" "%TEMP_DIR%\BreathOfTheWild_BetterVR" >nul || goto :error
) else (
echo Error: resources\BreathOfTheWild_BetterVR not found.
goto :error
)

REM Create Zip
echo Creating %ZIP_NAME%...
powershell -Command "Compress-Archive -Path '%TEMP_DIR%\*' -DestinationPath '%ZIP_NAME%'"
powershell -NoProfile -Command "Compress-Archive -Force -Path '%TEMP_DIR%\*' -DestinationPath '%ZIP_NAME%'" || goto :error

REM Cleanup
rmdir /S /Q "%TEMP_DIR%"
echo Package created successfully: %ZIP_NAME%
PAUSE
goto :eof
exit /b 0

:copyreq
if exist "%~1" (
copy "%~1" "%~2" >nul || exit /b 1
exit /b 0
) else (
echo Error: %~1 not found.
exit /b 1
)

:findfile
set "%~1="
set "FN=%~2"

REM Preferred locations first (fast)
for %%P in (
"Cemu\%FN%"
"bin\%FN%"
"build\bin\%FN%"
"build\%FN%"
) do (
if exist "%%~P" (
set "%~1=%%~P"
exit /b 0
)
)

REM Fallback: search repo (slower, but robust)
for /f "delims=" %%F in ('dir /b /s "%FN%" 2^>nul') do (
set "%~1=%%F"
exit /b 0
)
exit /b 0

:error
echo Failed to create package.
PAUSE
if exist "%TEMP_DIR%" rmdir /S /Q "%TEMP_DIR%"
exit /b 1
exit /b 1
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ li r3, 0
stw r3, 0x00(r7)
li r3, 1


exitHookInput:
; epilogue
lwz r7, 0x18(r1)
Expand Down
10 changes: 6 additions & 4 deletions resources/BreathOfTheWild_BetterVR/patch_Misc.asm
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ moduleMatches = 0x6267BFD0
; disable AutoExposure
; 0x039D99A4 = li r3, 0

; disable gyro controls
0x02E1905C = li r3, 0 ; always return 0 to signal disabled
; native controls toggle
; $nativeCtrlEnabled = 0 -> Use VR Controls
; $nativeCtrlEnabled = 1 -> Use Standard Controls
0x02E1905C = li r3, $nativeCtrlEnabled
0x02E19060 = blr
0x02E19064 = li r5, 0 ; always set 0
0x02E19064 = li r5, $nativeCtrlEnabled

; disable inversed button controls
0x02E199AC = li r3, 0 ; return 0 to signal disabled
Expand Down Expand Up @@ -136,4 +138,4 @@ moduleMatches = 0x6267BFD0

;0x02C196A4 = li r3, 1

;0x024B6F40 = li r12, 0
;0x024B6F40 = li r12, 0
14 changes: 13 additions & 1 deletion resources/BreathOfTheWild_BetterVR/rules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,25 @@ default = 1

[Default]
$enableDebugOverlay:int = 0
$nativeCtrlEnabled:int = 0

$accessibilityUIColor:int = 0
$accessibilityUIColor_x = 0.000
$accessibilityUIColor_y = 0.804
$accessibilityUIColor_z = 1.000
$accessibilityUIColor_w = 1.000

[Preset]
name = VR Controls
category = Input
default = 1
$nativeCtrlEnabled:int = 0

[Preset]
name = Standard Controls
category = Input
$nativeCtrlEnabled:int = 1

# Accessibility UI Color

[Preset]
Expand All @@ -39,4 +51,4 @@ $accessibilityUIColor:int = 1
$accessibilityUIColor_x = 0.6728
$accessibilityUIColor_y = 0.0
$accessibilityUIColor_z = 0.3272
$accessibilityUIColor_w = 1.000
$accessibilityUIColor_w = 1.000
Loading