├── .clang-format ├── .clang-tidy ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md └── workflows │ ├── dev-build-pr.yml │ └── dev-release.yml ├── .gitignore ├── .gitmodules ├── CMakeLists.txt ├── CMakeSettings.json ├── COMPILING.md ├── MakeCommitHash.bat ├── README.md ├── cmake.toml ├── cmkr.cmake ├── dependencies ├── lua │ └── src │ │ ├── .gitignore │ │ ├── README.md │ │ ├── all │ │ ├── lapi.c │ │ ├── lapi.h │ │ ├── lauxlib.c │ │ ├── lauxlib.h │ │ ├── lbaselib.c │ │ ├── lcode.c │ │ ├── lcode.h │ │ ├── lcorolib.c │ │ ├── lctype.c │ │ ├── lctype.h │ │ ├── ldblib.c │ │ ├── ldebug.c │ │ ├── ldebug.h │ │ ├── ldo.c │ │ ├── ldo.h │ │ ├── ldump.c │ │ ├── lfunc.c │ │ ├── lfunc.h │ │ ├── lgc.c │ │ ├── lgc.h │ │ ├── linit.c │ │ ├── liolib.c │ │ ├── ljumptab.h │ │ ├── llex.c │ │ ├── llex.h │ │ ├── llimits.h │ │ ├── lmathlib.c │ │ ├── lmem.c │ │ ├── lmem.h │ │ ├── loadlib.c │ │ ├── lobject.c │ │ ├── lobject.h │ │ ├── lopcodes.c │ │ ├── lopcodes.h │ │ ├── lopnames.h │ │ ├── loslib.c │ │ ├── lparser.c │ │ ├── lparser.h │ │ ├── lprefix.h │ │ ├── lstate.c │ │ ├── lstate.h │ │ ├── lstring.c │ │ ├── lstring.h │ │ ├── lstrlib.c │ │ ├── ltable.c │ │ ├── ltable.h │ │ ├── ltablib.c │ │ ├── ltests.c │ │ ├── ltests.h │ │ ├── ltm.c │ │ ├── ltm.h │ │ ├── lua.c │ │ ├── lua.h │ │ ├── luaconf.h │ │ ├── lualib.h │ │ ├── lundump.c │ │ ├── lundump.h │ │ ├── lutf8lib.c │ │ ├── lvm.c │ │ ├── lvm.h │ │ ├── lzio.c │ │ ├── lzio.h │ │ └── makefile ├── openvr │ ├── .gitattributes │ ├── CMakeLists.txt │ ├── LICENSE │ ├── README.md │ ├── Toolchain-clang.cmake │ ├── codegen │ │ ├── README.md │ │ ├── api_shared.py │ │ ├── openvr_capi.cpp.py │ │ ├── openvr_capi.h.py │ │ └── openvr_interop.cs.py │ ├── controller_callouts │ │ ├── Callouts.eps │ │ └── Callouts.pdf │ ├── headers │ │ ├── openvr.h │ │ ├── openvr_api.cs │ │ ├── openvr_api.json │ │ ├── openvr_capi.h │ │ └── openvr_driver.h │ └── src │ │ ├── CMakeLists.txt │ │ ├── Info.plist │ │ ├── README │ │ ├── ivrclientcore.h │ │ ├── json │ │ ├── json-forwards.h │ │ └── json.h │ │ ├── jsoncpp.cpp │ │ ├── openvr.pc.in │ │ ├── openvr_api_public.cpp │ │ └── vrcommon │ │ ├── dirtools_public.cpp │ │ ├── dirtools_public.h │ │ ├── envvartools_public.cpp │ │ ├── envvartools_public.h │ │ ├── hmderrors_public.cpp │ │ ├── hmderrors_public.h │ │ ├── pathtools_public.cpp │ │ ├── pathtools_public.h │ │ ├── sharedlibtools_public.cpp │ │ ├── sharedlibtools_public.h │ │ ├── strtools_public.cpp │ │ ├── strtools_public.h │ │ ├── vrpathregistry_public.cpp │ │ └── vrpathregistry_public.h └── sol2 │ ├── LICENSE.txt │ ├── README.md │ └── single │ ├── CMakeLists.txt │ ├── single.py │ └── single │ └── include │ └── sol │ ├── config.hpp │ ├── forward.hpp │ └── sol.hpp ├── examples ├── LICENSE ├── example_plugin │ └── Plugin.cpp └── renderlib │ ├── imgui │ ├── font_robotomedium.hpp │ ├── imgui_impl_dx11.cpp │ ├── imgui_impl_dx11.h │ ├── imgui_impl_dx12.cpp │ ├── imgui_impl_dx12.h │ ├── imgui_impl_win32.cpp │ ├── imgui_impl_win32.h │ └── re2_imconfig.hpp │ └── rendering │ ├── d3d11.cpp │ ├── d3d11.hpp │ ├── d3d12.cpp │ ├── d3d12.hpp │ └── shared.hpp ├── include ├── LICENSE └── uevr │ ├── API.h │ ├── API.hpp │ └── Plugin.hpp ├── lua-api ├── Main.cpp ├── ScriptContext.cpp └── ScriptContext.hpp ├── nightly-body.md ├── side-projects └── sdk-test │ └── Main.cpp ├── src ├── ExceptionHandler.cpp ├── ExceptionHandler.hpp ├── Framework.cpp ├── Framework.hpp ├── LicenseStrings.hpp ├── Main.cpp ├── Mod.cpp ├── Mod.hpp ├── Mods.cpp ├── Mods.hpp ├── UILocalized.cpp ├── UILocalized.hpp ├── WindowFilter.cpp ├── WindowFilter.hpp ├── hooks │ ├── D3D11Hook.cpp │ ├── D3D11Hook.hpp │ ├── D3D12Hook.cpp │ ├── D3D12Hook.hpp │ ├── DInputHook.cpp │ ├── DInputHook.hpp │ ├── WindowsMessageHook.cpp │ ├── WindowsMessageHook.hpp │ ├── XInputHook.cpp │ └── XInputHook.hpp ├── mods │ ├── FrameworkConfig.cpp │ ├── FrameworkConfig.hpp │ ├── FrameworkConfig.hpp.orig │ ├── ImGuiThemeHelpers.cpp │ ├── ImGuiThemeHelpers.hpp │ ├── PluginLoader.cpp │ ├── PluginLoader.hpp │ ├── UObjectHook.cpp │ ├── UObjectHook.hpp │ ├── VR.cpp │ ├── VR.hpp │ ├── pluginloader │ │ ├── FFakeStereoRenderingFunctions.cpp │ │ ├── FFakeStereoRenderingFunctions.hpp │ │ ├── FRHITexture2DFunctions.cpp │ │ ├── FRHITexture2DFunctions.hpp │ │ ├── FRenderTargetPoolHook.cpp │ │ ├── FRenderTargetPoolHook.hpp │ │ ├── FUObjectArrayFunctions.cpp │ │ ├── FUObjectArrayFunctions.hpp │ │ ├── UScriptStructFunctions.cpp │ │ └── UScriptStructFunctions.hpp │ ├── uobjecthook │ │ ├── SDKDumper.cpp │ │ └── SDKDumper.hpp │ └── vr │ │ ├── Bindings.cpp │ │ ├── CVarManager.cpp │ │ ├── CVarManager.hpp │ │ ├── D3D11Component.cpp │ │ ├── D3D11Component.hpp │ │ ├── D3D12Component.cpp │ │ ├── D3D12Component.hpp │ │ ├── FFakeStereoRenderingHook.cpp │ │ ├── FFakeStereoRenderingHook.hpp │ │ ├── IXRTrackingSystemHook.cpp │ │ ├── IXRTrackingSystemHook.hpp │ │ ├── OverlayComponent.cpp │ │ ├── OverlayComponent.hpp │ │ ├── RenderTargetPoolHook.cpp │ │ ├── RenderTargetPoolHook.hpp │ │ ├── d3d12 │ │ ├── ComPtr.hpp │ │ ├── CommandContext.cpp │ │ ├── CommandContext.hpp │ │ ├── DirectXTK.cpp │ │ ├── DirectXTK.hpp │ │ ├── TextureContext.cpp │ │ └── TextureContext.hpp │ │ ├── runtimes │ │ ├── OpenVR.cpp │ │ ├── OpenVR.hpp │ │ ├── OpenXR.cpp │ │ ├── OpenXR.hpp │ │ └── VRRuntime.hpp │ │ └── shaders │ │ ├── ps.hpp │ │ └── vs.hpp ├── uevr-imgui │ ├── font_robotomedium.hpp │ ├── imgui_impl_dx11.cpp │ ├── imgui_impl_dx11.h │ ├── imgui_impl_dx12.cpp │ ├── imgui_impl_dx12.h │ ├── imgui_impl_win32.cpp │ ├── imgui_impl_win32.h │ └── uevr_imconfig.hpp └── utility │ ├── ImGui.cpp │ ├── ImGui.hpp │ └── Logging.hpp └── vr-plugin-nullifier └── Main.cpp /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | BasedOnStyle: LLVM 3 | IndentWidth: 4 4 | ColumnLimit: 140 5 | --- 6 | Language: Cpp 7 | AccessModifierOffset: -4 8 | AlignAfterOpenBracket: DontAlign 9 | AlignEscapedNewlines: Left 10 | AllowShortFunctionsOnASingleLine: InlineOnly 11 | ConstructorInitializerAllOnOneLineOrOnePerLine: false 12 | DerivePointerAlignment: false 13 | PointerAlignment: Left 14 | BreakConstructorInitializers: BeforeComma 15 | ... 16 | -------------------------------------------------------------------------------- /.clang-tidy: -------------------------------------------------------------------------------- 1 | Checks: -*,readability-identifier-naming,readability-else-after-return 2 | HeaderFilterRegex: '^.*src.*\.hpp$' 3 | CheckOptions: 4 | # Classes, structs, ... 5 | - key: readability-identifier-naming.NamespaceCase 6 | value: lower_case 7 | - key: readability-identifier-naming.ClassCase 8 | value: CamelCase 9 | - key: readability-identifier-naming.StructCase 10 | value: CamelCase 11 | - key: readability-identifier-naming.EnumCase 12 | value: CamelCase 13 | - key: readability-identifier-naming.UnionCase 14 | value: CamelCase 15 | - key: readability-identifier-naming.TypedefCase 16 | value: CamelCase 17 | 18 | # Variables, member variables, ... 19 | - key: readability-identifier-naming.ParameterCase 20 | value: lower_case 21 | - key: readability-identifier-naming.VariableCase 22 | value: lower_case 23 | - key: readability-identifier-naming.MemberCase 24 | value: lower_case 25 | - key: readability-identifier-naming.PublicMemberCase 26 | value: lower_case 27 | - key: readability-identifier-naming.ProtectedMemberCase 28 | value: lower_case 29 | - key: readability-identifier-naming.PrivateMemberCase 30 | value: lower_case 31 | - key: readability-identifier-naming.PrivateMemberSuffix 32 | value: '' 33 | 34 | # Functions, methods, ... 35 | - key: readability-identifier-naming.FunctionCase 36 | value: lower_case 37 | - key: readability-identifier-naming.MethodCase 38 | value: lower_case 39 | 40 | # Constants 41 | - key: readability-identifier-naming.ConstantPrefix 42 | value: '' 43 | - key: readability-identifier-naming.ConstantCase 44 | value: UPPER_CASE 45 | - key: readability-identifier-naming.ConstantMemberPrefix 46 | value: '' 47 | - key: readability-identifier-naming.ConstantMemberCase 48 | value: lower_case 49 | - key: readability-identifier-naming.ConstantParameterPrefix 50 | value: '' 51 | - key: readability-identifier-naming.ConstantParameterCase 52 | value: lower_case 53 | - key: readability-identifier-naming.LocalConstantParameterPrefix 54 | value: '' 55 | - key: readability-identifier-naming.LocalConstantCase 56 | value: lower_case 57 | - key: readability-identifier-naming.ConstexprVariablePrefix 58 | value: '' 59 | - key: readability-identifier-naming.ConstexprVariableCase 60 | value: lower_case 61 | 62 | # Other 63 | - key: readability-braces-around-statements.ShortStatementLines 64 | value: 0 -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | patreon: praydog 4 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: "[BUG]" 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | 12 | A clear and concise description of what the bug is. If the bug only started to happen after a certain UEVR update, let us know which version the bug appeared in. 13 | 14 | **Upload logs and any crash dumps** 15 | 16 | If this is a game crash or game bug: 17 | 18 | UEVR-specific logs and crash dumps: 19 | 20 | * Click "Open Global Dir" in the injector frontend 21 | * Navigate to the offending game folder 22 | * Zip up the folder 23 | * Upload to the issue 24 | 25 | Game-specific crash dumps: 26 | 27 | * These can usually be found in `%LOCALAPPDATA%/{the_game_name}/Saved/Crashes` 28 | * Once found, zip up the folder and upload 29 | 30 | **Identify the UEVR version** 31 | 32 | If the UEVR version or commit hash is known, submit this information. 33 | 34 | **To Reproduce** 35 | 36 | Steps to reproduce the behavior: 37 | 1. Go to '...' 38 | 2. Click on '....' 39 | 3. Scroll down to '....' 40 | 4. See error 41 | 42 | **Expected behavior** 43 | 44 | A clear and concise description of what you expected to happen. 45 | 46 | **Screenshots** 47 | 48 | If applicable, add screenshots to help explain your problem. 49 | 50 | **PC Specs (please complete the following information):** 51 | - OS (e.g. Windows 11) 52 | - Graphics card 53 | - CPU 54 | - Headset Model 55 | - OpenXR or OpenVR 56 | - Streamer if applicable (Link, Air Link, Virtual Desktop, Steam Link, ALVR, etc...) 57 | - If using OpenXR, the runtime (Oculus, SteamVR, VDXR, PimaxXR, etc...) 58 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/workflows/dev-build-pr.yml: -------------------------------------------------------------------------------- 1 | name: Dev Build PR 2 | on: [pull_request_target, workflow_dispatch] 3 | env: 4 | BUILD_TYPE: Release 5 | permissions: 6 | contents: read 7 | pull-requests: read 8 | jobs: 9 | dev-release: 10 | runs-on: windows-latest 11 | 12 | # Minimal permissions for this pull_request_target action 13 | # Because we only need to read the repository contents 14 | # By default, pull_request_target grants read/write permissions (not good) 15 | # But it also passes along repository secrets, which we need 16 | # unlike pull_request, which does not pass secrets 17 | permissions: 18 | contents: read 19 | pull-requests: read 20 | 21 | strategy: 22 | matrix: 23 | target: [uevr] 24 | steps: 25 | - name: Checkout 26 | uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 27 | with: 28 | ref: "refs/pull/${{ github.event.number }}/merge" 29 | token: ${{ secrets.UESDK_PULLER || github.token }} 30 | submodules: recursive 31 | persist-credentials: false 32 | fetch-depth: 4 33 | 34 | # Important security check: https://github.com/actions/checkout/issues/518 35 | - name: Sanity check 36 | if : ${{ github.event_name == 'pull_request_target' }} 37 | shell: pwsh 38 | run: | 39 | $commits = git log -n 4 --pretty=format:%H 40 | $previous_commit = $commits[1] 41 | echo $commits 42 | if ($previous_commit -ne "${{ github.event.pull_request.head.sha }}") { 43 | throw "The pull request head commit has changed since the event was triggered." 44 | } 45 | 46 | - name: Configure CMake 47 | run: cmake -S ${{github.workspace}} -B ${{github.workspace}}/build -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} 48 | 49 | - name: Build 50 | run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target ${{matrix.target}} 51 | 52 | - name: Upload artifacts 53 | uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 54 | with: 55 | name: ${{matrix.target}} 56 | path: ${{github.workspace}}/build/bin/${{matrix.target}}/* 57 | if-no-files-found: error 58 | -------------------------------------------------------------------------------- /.github/workflows/dev-release.yml: -------------------------------------------------------------------------------- 1 | name: Dev Release 2 | on: [push, workflow_dispatch] 3 | env: 4 | BUILD_TYPE: Release 5 | jobs: 6 | dev-release: 7 | runs-on: windows-latest 8 | strategy: 9 | matrix: 10 | target: [uevr] 11 | steps: 12 | - name: Checkout backend 13 | uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 14 | with: 15 | token: ${{ secrets.UESDK_PULLER }} 16 | submodules: recursive 17 | persist-credentials: false 18 | 19 | - name: Configure CMake 20 | run: cmake -S ${{github.workspace}} -B ${{github.workspace}}/build -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} 21 | 22 | - name: Build backend 23 | run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target ${{matrix.target}} 24 | 25 | - name: Build plugin nullifier 26 | run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target vr-plugin-nullifier 27 | 28 | - name: Checkout frontend 29 | uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 30 | with: 31 | repository: praydog/uevr-frontend 32 | path: frontend 33 | persist-credentials: false 34 | 35 | - name: Set up dotnet 36 | uses: actions/setup-dotnet@v1 37 | with: 38 | dotnet-version: 6.0.x 39 | 40 | - name: Build frontend 41 | run: dotnet publish '${{github.workspace}}/frontend' --output '${{github.workspace}}/build/bin/${{matrix.target}}' --configuration Release 42 | 43 | - name: Upload artifacts 44 | uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 45 | with: 46 | name: ${{matrix.target}} 47 | path: | 48 | ${{github.workspace}}/build/bin/${{matrix.target}}/* 49 | ${{github.workspace}}/build/bin/vr-plugin-nullifier/UEVRPluginNullifier.dll 50 | if-no-files-found: error 51 | 52 | - name: Compress artifacts 53 | run: | 54 | echo ${{github.sha}} > ${{github.workspace}}/revision.txt 55 | 7z a ${{github.workspace}}/${{matrix.target}}.zip ${{github.workspace}}/build/bin/${{matrix.target}}/* 56 | 7z a ${{github.workspace}}/${{matrix.target}}.zip ${{github.workspace}}/build/bin/vr-plugin-nullifier/UEVRPluginNullifier.dll 57 | 7z a ${{github.workspace}}/${{matrix.target}}.zip ${{github.workspace}}/revision.txt 58 | 59 | - name: Hash zip 60 | run: | 61 | $ReleaseHash = Get-FileHash -Algorithm SHA256 ${{github.workspace}}/${{matrix.target}}.zip 62 | $ReleaseHash.Hash | Out-File -FilePath ${{github.workspace}}/${{matrix.target}}.zip.sha256 63 | 64 | - name: Create Release 65 | if: github.ref == 'refs/heads/master' 66 | uses: ncipollo/release-action@6c75be85e571768fa31b40abf38de58ba0397db5 67 | with: 68 | repo: UEVR-nightly 69 | owner: praydog 70 | token: ${{ secrets.CI_NIGHTLY }} 71 | name: ${{format('UEVR Nightly {0} ({1})', github.run_number, github.sha)}} 72 | tag: ${{format('nightly-{0}-{1}', github.run_number, github.sha)}} 73 | artifacts: "${{github.workspace}}/${{matrix.target}}.zip,${{github.workspace}}/${{matrix.target}}.zip.sha256" 74 | makeLatest: true 75 | bodyFile: ${{github.workspace}}/nightly-body.md 76 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Compiled Static libraries 20 | *.lai 21 | *.la 22 | *.a 23 | *.lib 24 | 25 | # Executables 26 | *.exe 27 | *.out 28 | *.app 29 | 30 | build/* 31 | .vscode/* 32 | out/* 33 | .vs/* 34 | 35 | # Ignore autogenerated headers 36 | src/CommitHash.hpp 37 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "dependencies/submodules/glm"] 2 | path = dependencies/submodules/glm 3 | url = https://github.com/g-truc/glm 4 | [submodule "dependencies/submodules/spdlog"] 5 | path = dependencies/submodules/spdlog 6 | url = https://github.com/gabime/spdlog 7 | [submodule "dependencies/submodules/imgui"] 8 | path = dependencies/submodules/imgui 9 | url = https://github.com/zhangredli/imgui.git 10 | [submodule "dependencies/submodules/UESDK"] 11 | path = dependencies/submodules/UESDK 12 | url = git@github.com:praydog/UESDK.git 13 | -------------------------------------------------------------------------------- /CMakeSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "x64-RelWithDebInfo", 5 | "generator": "Visual Studio 17 2022 Win64", 6 | "configurationType": "RelWithDebInfo", 7 | "buildRoot": "${projectDir}\\out\\build\\${name}", 8 | "installRoot": "${projectDir}\\out\\install\\${name}", 9 | "cmakeCommandArgs": "", 10 | "buildCommandArgs": "", 11 | "ctestCommandArgs": "", 12 | "inheritEnvironments": [ "msvc_x64_x64" ] 13 | } 14 | ] 15 | } -------------------------------------------------------------------------------- /COMPILING.md: -------------------------------------------------------------------------------- 1 | # Compiling UEVR 2 | 3 | ## Necessary prerequisites 4 | 5 | Your GitHub account must have access to the [EpicGames](https://github.com/EpicGames/) GitHub organization. If you do not have access, you will not be able to compile UEVR. 6 | 7 | This is because the [UESDK](https://github.com/praydog/UESDK) submodule is a fork of the [EpicGames/UnrealEngine](https://github.com/EpicGames/UnrealEngine) repository. You must have an SSH key set up with your GitHub account and an SSH agent running in order to clone the UESDK submodule. 8 | 9 | A C++23 compatible compiler is required. Visual Studio 2022 is recommended. Compilers other than MSVC have not been tested. 10 | 11 | CMake is required. 12 | 13 | ## Compiling 14 | 15 | ### Clone the repository 16 | 17 | #### SSH 18 | ``` 19 | git clone git@github.com:praydog/UEVR.git 20 | ``` 21 | 22 | #### HTTPS 23 | ``` 24 | git clone https://github.com/praydog/UEVR 25 | ``` 26 | 27 | ### Initialize the submodules 28 | 29 | ``` 30 | git submodule update --init --recursive 31 | ``` 32 | 33 | ### Set up CMake 34 | 35 | #### Command line 36 | 37 | ``` 38 | cmake -S . -B build ./build -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=Release 39 | cmake --build ./build --config Release --target uevr 40 | ``` 41 | 42 | #### VSCode 43 | 44 | 1. Install the [CMake Tools](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cmake-tools) extension 45 | 2. Open the UEVR folder in VSCode 46 | 3. Press `Ctrl+Shift+P` and select `CMake: Configure` 47 | 4. When "Select a kit" appears, select `Visual Studio Community 2022 Release - amd64` 48 | 5. Select the desired build config (usually `Release` or `RelWithDebInfo`) 49 | 6. You should now be able to compile UEVR by pressing `Ctrl+Shift+P` and selecting `CMake: Build` or by pressing `F7` -------------------------------------------------------------------------------- /MakeCommitHash.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | FOR /F "tokens=*" %%g IN ('git rev-parse HEAD') DO (SET UEVR_COMMIT_HASH=%%g) 3 | 4 | FOR /F "tokens=2 delims==" %%a IN ('wmic OS get localdatetime /value') DO ( 5 | SET datetime=%%a 6 | ) 7 | 8 | SET year=%datetime:~0,4% 9 | SET month=%datetime:~4,2% 10 | SET day=%datetime:~6,2% 11 | SET hour=%datetime:~8,2% 12 | SET minute=%datetime:~10,2% 13 | 14 | echo #pragma once > src/CommitHash.autogenerated 15 | echo #define UEVR_COMMIT_HASH "%UEVR_COMMIT_HASH%" >> src/CommitHash.autogenerated 16 | echo #define UEVR_BUILD_DATE "%day%.%month%.%year%" >> src/CommitHash.autogenerated 17 | echo #define UEVR_BUILD_TIME "%hour%:%minute%" >> src/CommitHash.autogenerated 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # UEVR ![build](https://github.com/praydog/UEVR/actions/workflows/dev-release.yml/badge.svg) 2 | 3 | The Chinese localization branch of Universal Unreal Engine VR Mod (4/5) 4 | 5 | ## Supported Engine Versions 6 | 7 | 4.8 - 5.3 8 | 9 | ## Links 10 | 11 | - [Download (Stable release)](https://github.com/praydog/UEVR/releases) 12 | - [Download (Nightly release)](https://github.com/praydog/UEVR-nightly/releases/latest) 13 | - [Documentation](https://praydog.github.io/uevr-docs) 14 | - [Flat2VR Discord](https://flat2vr.com) 15 | 16 | ## Features 17 | 18 | - Full 6DOF support out of the box (HMD movement) 19 | - Full stereoscopic 3D out of the box 20 | - Native UE4/UE5 stereo rendering system 21 | - Frontend GUI for easy process injection 22 | - Supports OpenVR and OpenXR runtimes 23 | - 3 rendering modes: Native Stereo, Synchronized Sequential, and Alternating/AFR 24 | - Automatic handling of most in-game UI so it is projected into 3D space 25 | - Optional 3DOF motion controls out of the box in many games, essentially emulating a semi-native VR experience 26 | - Optional roomscale movement in many games, moving the player character itself in 3D space along with the headset 27 | - User-authored UI-based system for adding motion controls and first person to games that don't support them 28 | - In-game menu with shortcuts for adjusting settings 29 | - Access to various CVars for fixing broken shaders/effects/performance issues 30 | - Optional depth buffer integration for improved latency on some headsets 31 | - Per-game configurations 32 | - [C++ Plugin system](https://praydog.github.io/uevr-docs/plugins/getting_started.html) and [Blueprint support](https://praydog.github.io/uevr-docs/plugins/blueprint.html) for modders to add additional features like motion controls 33 | 34 | ## Getting Started 35 | 36 | Before launching, ensure you have installed .NET 6.0. It should tell you where to install it upon first open, but if not, you can [download it from here](https://dotnet.microsoft.com/en-us/download/dotnet/6.0) 37 | 38 | Download the latest release from the [Releases page](https://github.com/praydog/UEVR/releases) 39 | 40 | 1. Launch UEVRInjector.exe 41 | 2. Launch the target game 42 | 3. Locate the game in the process dropdown list 43 | 4. Select your desired runtime (OpenVR/OpenXR) 44 | 5. Toggle existing VR plugin nullification (if necessary) 45 | 6. Configure pre-injection settings 46 | 7. Inject 47 | 48 | ## To-dos before injection 49 | 50 | 1. Disable HDR (it will still work without it, but the game will be darker than usual if it is) 51 | 2. Start as administrator if the game is not visible in the list 52 | 3. Pass `-nohmd` to the game's command line and/or delete VR plugins from the game directory if the game contains any existing VR plugins 53 | 4. Disable any overlays that may conflict and cause crashes (Rivatuner, ASUS software, Razer software, Overwolf, etc...) 54 | 5. Disable graphical options in-game that may cause crashes or severe issues like DLSS Frame Generation 55 | 6. Consider disabling `Hardware Accelerated GPU Scheduling` in your Windows `Graphics settings` 56 | 57 | ## In-Game Menu 58 | 59 | Press the **Insert** key or **L3+R3** on an XInput based controller to access the in-game menu, which opens by default at startup. With the menu open, hold **RT** for various shortcuts: 60 | 61 | - RT + Left Stick: Move the camera left/right/forward/back 62 | - RT + Right Stick: Move the camera up/down 63 | - RT + B: Reset camera offset 64 | - RT + Y: Recenter view 65 | - RT + X: Reset standing origin 66 | 67 | ## Quick overview of rendering methods 68 | 69 | ### Native Stereo 70 | 71 | When it works, it looks the best, performs the best (usually). Can cause crashes or graphical bugs if the game does not play well with it. 72 | 73 | Temporal effects like TAA are fully intact. DLSS/FSR2 usually work completely fine with no ghosting in this mode. 74 | 75 | Fully synchronized eye rendering. Works with the majority of games. Uses the actual stereo rendering pipeline in the Unreal Engine to achieve a stereoscopic image. 76 | 77 | ### Synchronized Sequential 78 | 79 | A form of AFR. Can fix many rendering bugs that are introduced with Native Stereo. Renders two frames **sequentially** in a **synchronized** fashion on the same engine tick. 80 | 81 | Fully synchronized eye rendering. Game world does not advance time between frames. 82 | 83 | Looks normal but temporal effects like TAA will have ghosting/doubling effect. Motion blur will need to be turned off. 84 | 85 | This is the first alternative option that should be used if Native Stereo is not working as expected or you are encountering graphical bugs. 86 | 87 | **Skip Draw** skips the viewport draw on the next engine tick. Usually works the best but sometimes particle effects may not play at the correct speed. 88 | 89 | **Skip Tick** skips the next engine tick entirely. Usually buggy but does fix particle effects and sometimes brings higher performance. 90 | 91 | ### AFR 92 | 93 | Alternated Frame Rendering. Renders each eye on separate frames in an alternating fashion, with the game world advancing time in between frames. Causes eye desyncs and usually nausea along with it. 94 | 95 | Not synchronized. Generally should not be used unless the other two are unusable in some way. 96 | -------------------------------------------------------------------------------- /dependencies/lua/src/.gitignore: -------------------------------------------------------------------------------- 1 | .gitattributes 2 | 3 | *.so 4 | *.o 5 | *.a 6 | 7 | manual/manual.html 8 | 9 | testes/time.txt 10 | testes/time-debug.txt 11 | 12 | testes/libs/all 13 | 14 | temp 15 | lua 16 | -------------------------------------------------------------------------------- /dependencies/lua/src/README.md: -------------------------------------------------------------------------------- 1 | # Lua 2 | 3 | This is the repository of Lua development code, as seen by the Lua team. It contains the full history of all commits but is mirrored irregularly. For complete information about Lua, visit [Lua.org](https://www.lua.org/). 4 | 5 | Please **do not** send pull requests. To report issues, post a message to the [Lua mailing list](https://www.lua.org/lua-l.html). 6 | 7 | Download official Lua releases from [Lua.org](https://www.lua.org/download.html). 8 | -------------------------------------------------------------------------------- /dependencies/lua/src/all: -------------------------------------------------------------------------------- 1 | make -s -j 2 | cd testes/libs; make -s 3 | cd .. # back to directory 'testes' 4 | ulimit -S -s 1000 5 | if { ../lua -W all.lua; } then 6 | echo -e "\n\n final OK!!!!\n\n" 7 | else 8 | echo -e "\n\n >>>> BUG!!!!\n\n" 9 | fi 10 | -------------------------------------------------------------------------------- /dependencies/lua/src/lapi.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lapi.h $ 3 | ** Auxiliary functions from Lua API 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lapi_h 8 | #define lapi_h 9 | 10 | 11 | #include "llimits.h" 12 | #include "lstate.h" 13 | 14 | 15 | /* Increments 'L->top', checking for stack overflows */ 16 | #define api_incr_top(L) {L->top++; api_check(L, L->top <= L->ci->top, \ 17 | "stack overflow");} 18 | 19 | 20 | /* 21 | ** If a call returns too many multiple returns, the callee may not have 22 | ** stack space to accommodate all results. In this case, this macro 23 | ** increases its stack space ('L->ci->top'). 24 | */ 25 | #define adjustresults(L,nres) \ 26 | { if ((nres) <= LUA_MULTRET && L->ci->top < L->top) L->ci->top = L->top; } 27 | 28 | 29 | /* Ensure the stack has at least 'n' elements */ 30 | #define api_checknelems(L,n) api_check(L, (n) < (L->top - L->ci->func), \ 31 | "not enough elements in the stack") 32 | 33 | 34 | /* 35 | ** To reduce the overhead of returning from C functions, the presence of 36 | ** to-be-closed variables in these functions is coded in the CallInfo's 37 | ** field 'nresults', in a way that functions with no to-be-closed variables 38 | ** with zero, one, or "all" wanted results have no overhead. Functions 39 | ** with other number of wanted results, as well as functions with 40 | ** variables to be closed, have an extra check. 41 | */ 42 | 43 | #define hastocloseCfunc(n) ((n) < LUA_MULTRET) 44 | 45 | /* Map [-1, inf) (range of 'nresults') into (-inf, -2] */ 46 | #define codeNresults(n) (-(n) - 3) 47 | #define decodeNresults(n) (-(n) - 3) 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /dependencies/lua/src/lcode.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lcode.h $ 3 | ** Code generator for Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lcode_h 8 | #define lcode_h 9 | 10 | #include "llex.h" 11 | #include "lobject.h" 12 | #include "lopcodes.h" 13 | #include "lparser.h" 14 | 15 | 16 | /* 17 | ** Marks the end of a patch list. It is an invalid value both as an absolute 18 | ** address, and as a list link (would link an element to itself). 19 | */ 20 | #define NO_JUMP (-1) 21 | 22 | 23 | /* 24 | ** grep "ORDER OPR" if you change these enums (ORDER OP) 25 | */ 26 | typedef enum BinOpr { 27 | /* arithmetic operators */ 28 | OPR_ADD, OPR_SUB, OPR_MUL, OPR_MOD, OPR_POW, 29 | OPR_DIV, OPR_IDIV, 30 | /* bitwise operators */ 31 | OPR_BAND, OPR_BOR, OPR_BXOR, 32 | OPR_SHL, OPR_SHR, 33 | /* string operator */ 34 | OPR_CONCAT, 35 | /* comparison operators */ 36 | OPR_EQ, OPR_LT, OPR_LE, 37 | OPR_NE, OPR_GT, OPR_GE, 38 | /* logical operators */ 39 | OPR_AND, OPR_OR, 40 | OPR_NOBINOPR 41 | } BinOpr; 42 | 43 | 44 | /* true if operation is foldable (that is, it is arithmetic or bitwise) */ 45 | #define foldbinop(op) ((op) <= OPR_SHR) 46 | 47 | 48 | #define luaK_codeABC(fs,o,a,b,c) luaK_codeABCk(fs,o,a,b,c,0) 49 | 50 | 51 | typedef enum UnOpr { OPR_MINUS, OPR_BNOT, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr; 52 | 53 | 54 | /* get (pointer to) instruction of given 'expdesc' */ 55 | #define getinstruction(fs,e) ((fs)->f->code[(e)->u.info]) 56 | 57 | 58 | #define luaK_setmultret(fs,e) luaK_setreturns(fs, e, LUA_MULTRET) 59 | 60 | #define luaK_jumpto(fs,t) luaK_patchlist(fs, luaK_jump(fs), t) 61 | 62 | LUAI_FUNC int luaK_code (FuncState *fs, Instruction i); 63 | LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx); 64 | LUAI_FUNC int luaK_codeAsBx (FuncState *fs, OpCode o, int A, int Bx); 65 | LUAI_FUNC int luaK_codeABCk (FuncState *fs, OpCode o, int A, 66 | int B, int C, int k); 67 | LUAI_FUNC int luaK_isKint (expdesc *e); 68 | LUAI_FUNC int luaK_exp2const (FuncState *fs, const expdesc *e, TValue *v); 69 | LUAI_FUNC void luaK_fixline (FuncState *fs, int line); 70 | LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n); 71 | LUAI_FUNC void luaK_reserveregs (FuncState *fs, int n); 72 | LUAI_FUNC void luaK_checkstack (FuncState *fs, int n); 73 | LUAI_FUNC void luaK_int (FuncState *fs, int reg, lua_Integer n); 74 | LUAI_FUNC void luaK_dischargevars (FuncState *fs, expdesc *e); 75 | LUAI_FUNC int luaK_exp2anyreg (FuncState *fs, expdesc *e); 76 | LUAI_FUNC void luaK_exp2anyregup (FuncState *fs, expdesc *e); 77 | LUAI_FUNC void luaK_exp2nextreg (FuncState *fs, expdesc *e); 78 | LUAI_FUNC void luaK_exp2val (FuncState *fs, expdesc *e); 79 | LUAI_FUNC int luaK_exp2RK (FuncState *fs, expdesc *e); 80 | LUAI_FUNC void luaK_self (FuncState *fs, expdesc *e, expdesc *key); 81 | LUAI_FUNC void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k); 82 | LUAI_FUNC void luaK_goiftrue (FuncState *fs, expdesc *e); 83 | LUAI_FUNC void luaK_goiffalse (FuncState *fs, expdesc *e); 84 | LUAI_FUNC void luaK_storevar (FuncState *fs, expdesc *var, expdesc *e); 85 | LUAI_FUNC void luaK_setreturns (FuncState *fs, expdesc *e, int nresults); 86 | LUAI_FUNC void luaK_setoneret (FuncState *fs, expdesc *e); 87 | LUAI_FUNC int luaK_jump (FuncState *fs); 88 | LUAI_FUNC void luaK_ret (FuncState *fs, int first, int nret); 89 | LUAI_FUNC void luaK_patchlist (FuncState *fs, int list, int target); 90 | LUAI_FUNC void luaK_patchtohere (FuncState *fs, int list); 91 | LUAI_FUNC void luaK_concat (FuncState *fs, int *l1, int l2); 92 | LUAI_FUNC int luaK_getlabel (FuncState *fs); 93 | LUAI_FUNC void luaK_prefix (FuncState *fs, UnOpr op, expdesc *v, int line); 94 | LUAI_FUNC void luaK_infix (FuncState *fs, BinOpr op, expdesc *v); 95 | LUAI_FUNC void luaK_posfix (FuncState *fs, BinOpr op, expdesc *v1, 96 | expdesc *v2, int line); 97 | LUAI_FUNC void luaK_settablesize (FuncState *fs, int pc, 98 | int ra, int asize, int hsize); 99 | LUAI_FUNC void luaK_setlist (FuncState *fs, int base, int nelems, int tostore); 100 | LUAI_FUNC void luaK_finish (FuncState *fs); 101 | LUAI_FUNC l_noret luaK_semerror (LexState *ls, const char *msg); 102 | 103 | 104 | #endif 105 | -------------------------------------------------------------------------------- /dependencies/lua/src/lctype.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lctype.c $ 3 | ** 'ctype' functions for Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #define lctype_c 8 | #define LUA_CORE 9 | 10 | #include "lprefix.h" 11 | 12 | 13 | #include "lctype.h" 14 | 15 | #if !LUA_USE_CTYPE /* { */ 16 | 17 | #include 18 | 19 | 20 | #if defined (LUA_UCID) /* accept UniCode IDentifiers? */ 21 | /* consider all non-ascii codepoints to be alphabetic */ 22 | #define NONA 0x01 23 | #else 24 | #define NONA 0x00 /* default */ 25 | #endif 26 | 27 | 28 | LUAI_DDEF const lu_byte luai_ctype_[UCHAR_MAX + 2] = { 29 | 0x00, /* EOZ */ 30 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0. */ 31 | 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 32 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 1. */ 33 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 34 | 0x0c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, /* 2. */ 35 | 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 36 | 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, /* 3. */ 37 | 0x16, 0x16, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 38 | 0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 4. */ 39 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 40 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 5. */ 41 | 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x05, 42 | 0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 6. */ 43 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 44 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 7. */ 45 | 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x00, 46 | NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, /* 8. */ 47 | NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, 48 | NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, /* 9. */ 49 | NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, 50 | NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, /* a. */ 51 | NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, 52 | NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, /* b. */ 53 | NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, 54 | 0x00, 0x00, NONA, NONA, NONA, NONA, NONA, NONA, /* c. */ 55 | NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, 56 | NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, /* d. */ 57 | NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, 58 | NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, /* e. */ 59 | NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, 60 | NONA, NONA, NONA, NONA, NONA, 0x00, 0x00, 0x00, /* f. */ 61 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 62 | }; 63 | 64 | #endif /* } */ 65 | -------------------------------------------------------------------------------- /dependencies/lua/src/lctype.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lctype.h $ 3 | ** 'ctype' functions for Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lctype_h 8 | #define lctype_h 9 | 10 | #include "lua.h" 11 | 12 | 13 | /* 14 | ** WARNING: the functions defined here do not necessarily correspond 15 | ** to the similar functions in the standard C ctype.h. They are 16 | ** optimized for the specific needs of Lua. 17 | */ 18 | 19 | #if !defined(LUA_USE_CTYPE) 20 | 21 | #if 'A' == 65 && '0' == 48 22 | /* ASCII case: can use its own tables; faster and fixed */ 23 | #define LUA_USE_CTYPE 0 24 | #else 25 | /* must use standard C ctype */ 26 | #define LUA_USE_CTYPE 1 27 | #endif 28 | 29 | #endif 30 | 31 | 32 | #if !LUA_USE_CTYPE /* { */ 33 | 34 | #include 35 | 36 | #include "llimits.h" 37 | 38 | 39 | #define ALPHABIT 0 40 | #define DIGITBIT 1 41 | #define PRINTBIT 2 42 | #define SPACEBIT 3 43 | #define XDIGITBIT 4 44 | 45 | 46 | #define MASK(B) (1 << (B)) 47 | 48 | 49 | /* 50 | ** add 1 to char to allow index -1 (EOZ) 51 | */ 52 | #define testprop(c,p) (luai_ctype_[(c)+1] & (p)) 53 | 54 | /* 55 | ** 'lalpha' (Lua alphabetic) and 'lalnum' (Lua alphanumeric) both include '_' 56 | */ 57 | #define lislalpha(c) testprop(c, MASK(ALPHABIT)) 58 | #define lislalnum(c) testprop(c, (MASK(ALPHABIT) | MASK(DIGITBIT))) 59 | #define lisdigit(c) testprop(c, MASK(DIGITBIT)) 60 | #define lisspace(c) testprop(c, MASK(SPACEBIT)) 61 | #define lisprint(c) testprop(c, MASK(PRINTBIT)) 62 | #define lisxdigit(c) testprop(c, MASK(XDIGITBIT)) 63 | 64 | 65 | /* 66 | ** In ASCII, this 'ltolower' is correct for alphabetic characters and 67 | ** for '.'. That is enough for Lua needs. ('check_exp' ensures that 68 | ** the character either is an upper-case letter or is unchanged by 69 | ** the transformation, which holds for lower-case letters and '.'.) 70 | */ 71 | #define ltolower(c) \ 72 | check_exp(('A' <= (c) && (c) <= 'Z') || (c) == ((c) | ('A' ^ 'a')), \ 73 | (c) | ('A' ^ 'a')) 74 | 75 | 76 | /* one entry for each character and for -1 (EOZ) */ 77 | LUAI_DDEC(const lu_byte luai_ctype_[UCHAR_MAX + 2];) 78 | 79 | 80 | #else /* }{ */ 81 | 82 | /* 83 | ** use standard C ctypes 84 | */ 85 | 86 | #include 87 | 88 | 89 | #define lislalpha(c) (isalpha(c) || (c) == '_') 90 | #define lislalnum(c) (isalnum(c) || (c) == '_') 91 | #define lisdigit(c) (isdigit(c)) 92 | #define lisspace(c) (isspace(c)) 93 | #define lisprint(c) (isprint(c)) 94 | #define lisxdigit(c) (isxdigit(c)) 95 | 96 | #define ltolower(c) (tolower(c)) 97 | 98 | #endif /* } */ 99 | 100 | #endif 101 | 102 | -------------------------------------------------------------------------------- /dependencies/lua/src/ldebug.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldebug.h $ 3 | ** Auxiliary functions from Debug Interface module 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ldebug_h 8 | #define ldebug_h 9 | 10 | 11 | #include "lstate.h" 12 | 13 | 14 | #define pcRel(pc, p) (cast_int((pc) - (p)->code) - 1) 15 | 16 | 17 | /* Active Lua function (given call info) */ 18 | #define ci_func(ci) (clLvalue(s2v((ci)->func))) 19 | 20 | 21 | #define resethookcount(L) (L->hookcount = L->basehookcount) 22 | 23 | /* 24 | ** mark for entries in 'lineinfo' array that has absolute information in 25 | ** 'abslineinfo' array 26 | */ 27 | #define ABSLINEINFO (-0x80) 28 | 29 | 30 | /* 31 | ** MAXimum number of successive Instructions WiTHout ABSolute line 32 | ** information. (A power of two allows fast divisions.) 33 | */ 34 | #if !defined(MAXIWTHABS) 35 | #define MAXIWTHABS 128 36 | #endif 37 | 38 | 39 | LUAI_FUNC int luaG_getfuncline (const Proto *f, int pc); 40 | LUAI_FUNC const char *luaG_findlocal (lua_State *L, CallInfo *ci, int n, 41 | StkId *pos); 42 | LUAI_FUNC l_noret luaG_typeerror (lua_State *L, const TValue *o, 43 | const char *opname); 44 | LUAI_FUNC l_noret luaG_callerror (lua_State *L, const TValue *o); 45 | LUAI_FUNC l_noret luaG_forerror (lua_State *L, const TValue *o, 46 | const char *what); 47 | LUAI_FUNC l_noret luaG_concaterror (lua_State *L, const TValue *p1, 48 | const TValue *p2); 49 | LUAI_FUNC l_noret luaG_opinterror (lua_State *L, const TValue *p1, 50 | const TValue *p2, 51 | const char *msg); 52 | LUAI_FUNC l_noret luaG_tointerror (lua_State *L, const TValue *p1, 53 | const TValue *p2); 54 | LUAI_FUNC l_noret luaG_ordererror (lua_State *L, const TValue *p1, 55 | const TValue *p2); 56 | LUAI_FUNC l_noret luaG_runerror (lua_State *L, const char *fmt, ...); 57 | LUAI_FUNC const char *luaG_addinfo (lua_State *L, const char *msg, 58 | TString *src, int line); 59 | LUAI_FUNC l_noret luaG_errormsg (lua_State *L); 60 | LUAI_FUNC int luaG_traceexec (lua_State *L, const Instruction *pc); 61 | 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /dependencies/lua/src/ldo.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldo.h $ 3 | ** Stack and Call structure of Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ldo_h 8 | #define ldo_h 9 | 10 | 11 | #include "lobject.h" 12 | #include "lstate.h" 13 | #include "lzio.h" 14 | 15 | 16 | /* 17 | ** Macro to check stack size and grow stack if needed. Parameters 18 | ** 'pre'/'pos' allow the macro to preserve a pointer into the 19 | ** stack across reallocations, doing the work only when needed. 20 | ** It also allows the running of one GC step when the stack is 21 | ** reallocated. 22 | ** 'condmovestack' is used in heavy tests to force a stack reallocation 23 | ** at every check. 24 | */ 25 | #define luaD_checkstackaux(L,n,pre,pos) \ 26 | if (l_unlikely(L->stack_last - L->top <= (n))) \ 27 | { pre; luaD_growstack(L, n, 1); pos; } \ 28 | else { condmovestack(L,pre,pos); } 29 | 30 | /* In general, 'pre'/'pos' are empty (nothing to save) */ 31 | #define luaD_checkstack(L,n) luaD_checkstackaux(L,n,(void)0,(void)0) 32 | 33 | 34 | 35 | #define savestack(L,p) ((char *)(p) - (char *)L->stack) 36 | #define restorestack(L,n) ((StkId)((char *)L->stack + (n))) 37 | 38 | 39 | /* macro to check stack size, preserving 'p' */ 40 | #define checkstackGCp(L,n,p) \ 41 | luaD_checkstackaux(L, n, \ 42 | ptrdiff_t t__ = savestack(L, p); /* save 'p' */ \ 43 | luaC_checkGC(L), /* stack grow uses memory */ \ 44 | p = restorestack(L, t__)) /* 'pos' part: restore 'p' */ 45 | 46 | 47 | /* macro to check stack size and GC */ 48 | #define checkstackGC(L,fsize) \ 49 | luaD_checkstackaux(L, (fsize), luaC_checkGC(L), (void)0) 50 | 51 | 52 | /* type of protected functions, to be ran by 'runprotected' */ 53 | typedef void (*Pfunc) (lua_State *L, void *ud); 54 | 55 | LUAI_FUNC void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop); 56 | LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name, 57 | const char *mode); 58 | LUAI_FUNC void luaD_hook (lua_State *L, int event, int line, 59 | int fTransfer, int nTransfer); 60 | LUAI_FUNC void luaD_hookcall (lua_State *L, CallInfo *ci); 61 | LUAI_FUNC int luaD_pretailcall (lua_State *L, CallInfo *ci, StkId func, int narg1, int delta); 62 | LUAI_FUNC CallInfo *luaD_precall (lua_State *L, StkId func, int nResults); 63 | LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults); 64 | LUAI_FUNC void luaD_callnoyield (lua_State *L, StkId func, int nResults); 65 | LUAI_FUNC StkId luaD_tryfuncTM (lua_State *L, StkId func); 66 | LUAI_FUNC int luaD_closeprotected (lua_State *L, ptrdiff_t level, int status); 67 | LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u, 68 | ptrdiff_t oldtop, ptrdiff_t ef); 69 | LUAI_FUNC void luaD_poscall (lua_State *L, CallInfo *ci, int nres); 70 | LUAI_FUNC int luaD_reallocstack (lua_State *L, int newsize, int raiseerror); 71 | LUAI_FUNC int luaD_growstack (lua_State *L, int n, int raiseerror); 72 | LUAI_FUNC void luaD_shrinkstack (lua_State *L); 73 | LUAI_FUNC void luaD_inctop (lua_State *L); 74 | 75 | LUAI_FUNC l_noret luaD_throw (lua_State *L, int errcode); 76 | LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud); 77 | 78 | #endif 79 | 80 | -------------------------------------------------------------------------------- /dependencies/lua/src/lfunc.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lfunc.h $ 3 | ** Auxiliary functions to manipulate prototypes and closures 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lfunc_h 8 | #define lfunc_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | 14 | #define sizeCclosure(n) (cast_int(offsetof(CClosure, upvalue)) + \ 15 | cast_int(sizeof(TValue)) * (n)) 16 | 17 | #define sizeLclosure(n) (cast_int(offsetof(LClosure, upvals)) + \ 18 | cast_int(sizeof(TValue *)) * (n)) 19 | 20 | 21 | /* test whether thread is in 'twups' list */ 22 | #define isintwups(L) (L->twups != L) 23 | 24 | 25 | /* 26 | ** maximum number of upvalues in a closure (both C and Lua). (Value 27 | ** must fit in a VM register.) 28 | */ 29 | #define MAXUPVAL 255 30 | 31 | 32 | #define upisopen(up) ((up)->v != &(up)->u.value) 33 | 34 | 35 | #define uplevel(up) check_exp(upisopen(up), cast(StkId, (up)->v)) 36 | 37 | 38 | /* 39 | ** maximum number of misses before giving up the cache of closures 40 | ** in prototypes 41 | */ 42 | #define MAXMISS 10 43 | 44 | 45 | 46 | /* special status to close upvalues preserving the top of the stack */ 47 | #define CLOSEKTOP (-1) 48 | 49 | 50 | LUAI_FUNC Proto *luaF_newproto (lua_State *L); 51 | LUAI_FUNC CClosure *luaF_newCclosure (lua_State *L, int nupvals); 52 | LUAI_FUNC LClosure *luaF_newLclosure (lua_State *L, int nupvals); 53 | LUAI_FUNC void luaF_initupvals (lua_State *L, LClosure *cl); 54 | LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); 55 | LUAI_FUNC void luaF_newtbcupval (lua_State *L, StkId level); 56 | LUAI_FUNC void luaF_closeupval (lua_State *L, StkId level); 57 | LUAI_FUNC void luaF_close (lua_State *L, StkId level, int status, int yy); 58 | LUAI_FUNC void luaF_unlinkupval (UpVal *uv); 59 | LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f); 60 | LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number, 61 | int pc); 62 | 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /dependencies/lua/src/linit.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: linit.c $ 3 | ** Initialization of libraries for lua.c and other clients 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #define linit_c 9 | #define LUA_LIB 10 | 11 | /* 12 | ** If you embed Lua in your program and need to open the standard 13 | ** libraries, call luaL_openlibs in your program. If you need a 14 | ** different set of libraries, copy this file to your project and edit 15 | ** it to suit your needs. 16 | ** 17 | ** You can also *preload* libraries, so that a later 'require' can 18 | ** open the library, which is already linked to the application. 19 | ** For that, do the following code: 20 | ** 21 | ** luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_PRELOAD_TABLE); 22 | ** lua_pushcfunction(L, luaopen_modname); 23 | ** lua_setfield(L, -2, modname); 24 | ** lua_pop(L, 1); // remove PRELOAD table 25 | */ 26 | 27 | #include "lprefix.h" 28 | 29 | 30 | #include 31 | 32 | #include "lua.h" 33 | 34 | #include "lualib.h" 35 | #include "lauxlib.h" 36 | 37 | 38 | /* 39 | ** these libs are loaded by lua.c and are readily available to any Lua 40 | ** program 41 | */ 42 | static const luaL_Reg loadedlibs[] = { 43 | {LUA_GNAME, luaopen_base}, 44 | {LUA_LOADLIBNAME, luaopen_package}, 45 | {LUA_COLIBNAME, luaopen_coroutine}, 46 | {LUA_TABLIBNAME, luaopen_table}, 47 | {LUA_IOLIBNAME, luaopen_io}, 48 | {LUA_OSLIBNAME, luaopen_os}, 49 | {LUA_STRLIBNAME, luaopen_string}, 50 | {LUA_MATHLIBNAME, luaopen_math}, 51 | {LUA_UTF8LIBNAME, luaopen_utf8}, 52 | {LUA_DBLIBNAME, luaopen_debug}, 53 | {NULL, NULL} 54 | }; 55 | 56 | 57 | LUALIB_API void luaL_openlibs (lua_State *L) { 58 | const luaL_Reg *lib; 59 | /* "require" functions from 'loadedlibs' and set results to global table */ 60 | for (lib = loadedlibs; lib->func; lib++) { 61 | luaL_requiref(L, lib->name, lib->func, 1); 62 | lua_pop(L, 1); /* remove lib */ 63 | } 64 | } 65 | 66 | -------------------------------------------------------------------------------- /dependencies/lua/src/ljumptab.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ljumptab.h $ 3 | ** Jump Table for the Lua interpreter 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #undef vmdispatch 9 | #undef vmcase 10 | #undef vmbreak 11 | 12 | #define vmdispatch(x) goto *disptab[x]; 13 | 14 | #define vmcase(l) L_##l: 15 | 16 | #define vmbreak vmfetch(); vmdispatch(GET_OPCODE(i)); 17 | 18 | 19 | static const void *const disptab[NUM_OPCODES] = { 20 | 21 | #if 0 22 | ** you can update the following list with this command: 23 | ** 24 | ** sed -n '/^OP_/\!d; s/OP_/\&\&L_OP_/ ; s/,.*/,/ ; s/\/.*// ; p' lopcodes.h 25 | ** 26 | #endif 27 | 28 | &&L_OP_MOVE, 29 | &&L_OP_LOADI, 30 | &&L_OP_LOADF, 31 | &&L_OP_LOADK, 32 | &&L_OP_LOADKX, 33 | &&L_OP_LOADFALSE, 34 | &&L_OP_LFALSESKIP, 35 | &&L_OP_LOADTRUE, 36 | &&L_OP_LOADNIL, 37 | &&L_OP_GETUPVAL, 38 | &&L_OP_SETUPVAL, 39 | &&L_OP_GETTABUP, 40 | &&L_OP_GETTABLE, 41 | &&L_OP_GETI, 42 | &&L_OP_GETFIELD, 43 | &&L_OP_SETTABUP, 44 | &&L_OP_SETTABLE, 45 | &&L_OP_SETI, 46 | &&L_OP_SETFIELD, 47 | &&L_OP_NEWTABLE, 48 | &&L_OP_SELF, 49 | &&L_OP_ADDI, 50 | &&L_OP_ADDK, 51 | &&L_OP_SUBK, 52 | &&L_OP_MULK, 53 | &&L_OP_MODK, 54 | &&L_OP_POWK, 55 | &&L_OP_DIVK, 56 | &&L_OP_IDIVK, 57 | &&L_OP_BANDK, 58 | &&L_OP_BORK, 59 | &&L_OP_BXORK, 60 | &&L_OP_SHRI, 61 | &&L_OP_SHLI, 62 | &&L_OP_ADD, 63 | &&L_OP_SUB, 64 | &&L_OP_MUL, 65 | &&L_OP_MOD, 66 | &&L_OP_POW, 67 | &&L_OP_DIV, 68 | &&L_OP_IDIV, 69 | &&L_OP_BAND, 70 | &&L_OP_BOR, 71 | &&L_OP_BXOR, 72 | &&L_OP_SHL, 73 | &&L_OP_SHR, 74 | &&L_OP_MMBIN, 75 | &&L_OP_MMBINI, 76 | &&L_OP_MMBINK, 77 | &&L_OP_UNM, 78 | &&L_OP_BNOT, 79 | &&L_OP_NOT, 80 | &&L_OP_LEN, 81 | &&L_OP_CONCAT, 82 | &&L_OP_CLOSE, 83 | &&L_OP_TBC, 84 | &&L_OP_JMP, 85 | &&L_OP_EQ, 86 | &&L_OP_LT, 87 | &&L_OP_LE, 88 | &&L_OP_EQK, 89 | &&L_OP_EQI, 90 | &&L_OP_LTI, 91 | &&L_OP_LEI, 92 | &&L_OP_GTI, 93 | &&L_OP_GEI, 94 | &&L_OP_TEST, 95 | &&L_OP_TESTSET, 96 | &&L_OP_CALL, 97 | &&L_OP_TAILCALL, 98 | &&L_OP_RETURN, 99 | &&L_OP_RETURN0, 100 | &&L_OP_RETURN1, 101 | &&L_OP_FORLOOP, 102 | &&L_OP_FORPREP, 103 | &&L_OP_TFORPREP, 104 | &&L_OP_TFORCALL, 105 | &&L_OP_TFORLOOP, 106 | &&L_OP_SETLIST, 107 | &&L_OP_CLOSURE, 108 | &&L_OP_VARARG, 109 | &&L_OP_VARARGPREP, 110 | &&L_OP_EXTRAARG 111 | 112 | }; 113 | -------------------------------------------------------------------------------- /dependencies/lua/src/llex.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: llex.h $ 3 | ** Lexical Analyzer 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef llex_h 8 | #define llex_h 9 | 10 | #include 11 | 12 | #include "lobject.h" 13 | #include "lzio.h" 14 | 15 | 16 | /* 17 | ** Single-char tokens (terminal symbols) are represented by their own 18 | ** numeric code. Other tokens start at the following value. 19 | */ 20 | #define FIRST_RESERVED (UCHAR_MAX + 1) 21 | 22 | 23 | #if !defined(LUA_ENV) 24 | #define LUA_ENV "_ENV" 25 | #endif 26 | 27 | 28 | /* 29 | * WARNING: if you change the order of this enumeration, 30 | * grep "ORDER RESERVED" 31 | */ 32 | enum RESERVED { 33 | /* terminal symbols denoted by reserved words */ 34 | TK_AND = FIRST_RESERVED, TK_BREAK, 35 | TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION, 36 | TK_GOTO, TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT, 37 | TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE, 38 | /* other terminal symbols */ 39 | TK_IDIV, TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, 40 | TK_SHL, TK_SHR, 41 | TK_DBCOLON, TK_EOS, 42 | TK_FLT, TK_INT, TK_NAME, TK_STRING 43 | }; 44 | 45 | /* number of reserved words */ 46 | #define NUM_RESERVED (cast_int(TK_WHILE-FIRST_RESERVED + 1)) 47 | 48 | 49 | typedef union { 50 | lua_Number r; 51 | lua_Integer i; 52 | TString *ts; 53 | } SemInfo; /* semantics information */ 54 | 55 | 56 | typedef struct Token { 57 | int token; 58 | SemInfo seminfo; 59 | } Token; 60 | 61 | 62 | /* state of the lexer plus state of the parser when shared by all 63 | functions */ 64 | typedef struct LexState { 65 | int current; /* current character (charint) */ 66 | int linenumber; /* input line counter */ 67 | int lastline; /* line of last token 'consumed' */ 68 | Token t; /* current token */ 69 | Token lookahead; /* look ahead token */ 70 | struct FuncState *fs; /* current function (parser) */ 71 | struct lua_State *L; 72 | ZIO *z; /* input stream */ 73 | Mbuffer *buff; /* buffer for tokens */ 74 | Table *h; /* to avoid collection/reuse strings */ 75 | struct Dyndata *dyd; /* dynamic structures used by the parser */ 76 | TString *source; /* current source name */ 77 | TString *envn; /* environment variable name */ 78 | } LexState; 79 | 80 | 81 | LUAI_FUNC void luaX_init (lua_State *L); 82 | LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, 83 | TString *source, int firstchar); 84 | LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l); 85 | LUAI_FUNC void luaX_next (LexState *ls); 86 | LUAI_FUNC int luaX_lookahead (LexState *ls); 87 | LUAI_FUNC l_noret luaX_syntaxerror (LexState *ls, const char *s); 88 | LUAI_FUNC const char *luaX_token2str (LexState *ls, int token); 89 | 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /dependencies/lua/src/lmem.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lmem.h $ 3 | ** Interface to Memory Manager 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lmem_h 8 | #define lmem_h 9 | 10 | 11 | #include 12 | 13 | #include "llimits.h" 14 | #include "lua.h" 15 | 16 | 17 | #define luaM_error(L) luaD_throw(L, LUA_ERRMEM) 18 | 19 | 20 | /* 21 | ** This macro tests whether it is safe to multiply 'n' by the size of 22 | ** type 't' without overflows. Because 'e' is always constant, it avoids 23 | ** the runtime division MAX_SIZET/(e). 24 | ** (The macro is somewhat complex to avoid warnings: The 'sizeof' 25 | ** comparison avoids a runtime comparison when overflow cannot occur. 26 | ** The compiler should be able to optimize the real test by itself, but 27 | ** when it does it, it may give a warning about "comparison is always 28 | ** false due to limited range of data type"; the +1 tricks the compiler, 29 | ** avoiding this warning but also this optimization.) 30 | */ 31 | #define luaM_testsize(n,e) \ 32 | (sizeof(n) >= sizeof(size_t) && cast_sizet((n)) + 1 > MAX_SIZET/(e)) 33 | 34 | #define luaM_checksize(L,n,e) \ 35 | (luaM_testsize(n,e) ? luaM_toobig(L) : cast_void(0)) 36 | 37 | 38 | /* 39 | ** Computes the minimum between 'n' and 'MAX_SIZET/sizeof(t)', so that 40 | ** the result is not larger than 'n' and cannot overflow a 'size_t' 41 | ** when multiplied by the size of type 't'. (Assumes that 'n' is an 42 | ** 'int' or 'unsigned int' and that 'int' is not larger than 'size_t'.) 43 | */ 44 | #define luaM_limitN(n,t) \ 45 | ((cast_sizet(n) <= MAX_SIZET/sizeof(t)) ? (n) : \ 46 | cast_uint((MAX_SIZET/sizeof(t)))) 47 | 48 | 49 | /* 50 | ** Arrays of chars do not need any test 51 | */ 52 | #define luaM_reallocvchar(L,b,on,n) \ 53 | cast_charp(luaM_saferealloc_(L, (b), (on)*sizeof(char), (n)*sizeof(char))) 54 | 55 | #define luaM_freemem(L, b, s) luaM_free_(L, (b), (s)) 56 | #define luaM_free(L, b) luaM_free_(L, (b), sizeof(*(b))) 57 | #define luaM_freearray(L, b, n) luaM_free_(L, (b), (n)*sizeof(*(b))) 58 | 59 | #define luaM_new(L,t) cast(t*, luaM_malloc_(L, sizeof(t), 0)) 60 | #define luaM_newvector(L,n,t) cast(t*, luaM_malloc_(L, (n)*sizeof(t), 0)) 61 | #define luaM_newvectorchecked(L,n,t) \ 62 | (luaM_checksize(L,n,sizeof(t)), luaM_newvector(L,n,t)) 63 | 64 | #define luaM_newobject(L,tag,s) luaM_malloc_(L, (s), tag) 65 | 66 | #define luaM_growvector(L,v,nelems,size,t,limit,e) \ 67 | ((v)=cast(t *, luaM_growaux_(L,v,nelems,&(size),sizeof(t), \ 68 | luaM_limitN(limit,t),e))) 69 | 70 | #define luaM_reallocvector(L, v,oldn,n,t) \ 71 | (cast(t *, luaM_realloc_(L, v, cast_sizet(oldn) * sizeof(t), \ 72 | cast_sizet(n) * sizeof(t)))) 73 | 74 | #define luaM_shrinkvector(L,v,size,fs,t) \ 75 | ((v)=cast(t *, luaM_shrinkvector_(L, v, &(size), fs, sizeof(t)))) 76 | 77 | LUAI_FUNC l_noret luaM_toobig (lua_State *L); 78 | 79 | /* not to be called directly */ 80 | LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize, 81 | size_t size); 82 | LUAI_FUNC void *luaM_saferealloc_ (lua_State *L, void *block, size_t oldsize, 83 | size_t size); 84 | LUAI_FUNC void luaM_free_ (lua_State *L, void *block, size_t osize); 85 | LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int nelems, 86 | int *size, int size_elem, int limit, 87 | const char *what); 88 | LUAI_FUNC void *luaM_shrinkvector_ (lua_State *L, void *block, int *nelem, 89 | int final_n, int size_elem); 90 | LUAI_FUNC void *luaM_malloc_ (lua_State *L, size_t size, int tag); 91 | 92 | #endif 93 | 94 | -------------------------------------------------------------------------------- /dependencies/lua/src/lopcodes.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lopcodes.c $ 3 | ** Opcodes for Lua virtual machine 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #define lopcodes_c 8 | #define LUA_CORE 9 | 10 | #include "lprefix.h" 11 | 12 | 13 | #include "lopcodes.h" 14 | 15 | 16 | /* ORDER OP */ 17 | 18 | LUAI_DDEF const lu_byte luaP_opmodes[NUM_OPCODES] = { 19 | /* MM OT IT T A mode opcode */ 20 | opmode(0, 0, 0, 0, 1, iABC) /* OP_MOVE */ 21 | ,opmode(0, 0, 0, 0, 1, iAsBx) /* OP_LOADI */ 22 | ,opmode(0, 0, 0, 0, 1, iAsBx) /* OP_LOADF */ 23 | ,opmode(0, 0, 0, 0, 1, iABx) /* OP_LOADK */ 24 | ,opmode(0, 0, 0, 0, 1, iABx) /* OP_LOADKX */ 25 | ,opmode(0, 0, 0, 0, 1, iABC) /* OP_LOADFALSE */ 26 | ,opmode(0, 0, 0, 0, 1, iABC) /* OP_LFALSESKIP */ 27 | ,opmode(0, 0, 0, 0, 1, iABC) /* OP_LOADTRUE */ 28 | ,opmode(0, 0, 0, 0, 1, iABC) /* OP_LOADNIL */ 29 | ,opmode(0, 0, 0, 0, 1, iABC) /* OP_GETUPVAL */ 30 | ,opmode(0, 0, 0, 0, 0, iABC) /* OP_SETUPVAL */ 31 | ,opmode(0, 0, 0, 0, 1, iABC) /* OP_GETTABUP */ 32 | ,opmode(0, 0, 0, 0, 1, iABC) /* OP_GETTABLE */ 33 | ,opmode(0, 0, 0, 0, 1, iABC) /* OP_GETI */ 34 | ,opmode(0, 0, 0, 0, 1, iABC) /* OP_GETFIELD */ 35 | ,opmode(0, 0, 0, 0, 0, iABC) /* OP_SETTABUP */ 36 | ,opmode(0, 0, 0, 0, 0, iABC) /* OP_SETTABLE */ 37 | ,opmode(0, 0, 0, 0, 0, iABC) /* OP_SETI */ 38 | ,opmode(0, 0, 0, 0, 0, iABC) /* OP_SETFIELD */ 39 | ,opmode(0, 0, 0, 0, 1, iABC) /* OP_NEWTABLE */ 40 | ,opmode(0, 0, 0, 0, 1, iABC) /* OP_SELF */ 41 | ,opmode(0, 0, 0, 0, 1, iABC) /* OP_ADDI */ 42 | ,opmode(0, 0, 0, 0, 1, iABC) /* OP_ADDK */ 43 | ,opmode(0, 0, 0, 0, 1, iABC) /* OP_SUBK */ 44 | ,opmode(0, 0, 0, 0, 1, iABC) /* OP_MULK */ 45 | ,opmode(0, 0, 0, 0, 1, iABC) /* OP_MODK */ 46 | ,opmode(0, 0, 0, 0, 1, iABC) /* OP_POWK */ 47 | ,opmode(0, 0, 0, 0, 1, iABC) /* OP_DIVK */ 48 | ,opmode(0, 0, 0, 0, 1, iABC) /* OP_IDIVK */ 49 | ,opmode(0, 0, 0, 0, 1, iABC) /* OP_BANDK */ 50 | ,opmode(0, 0, 0, 0, 1, iABC) /* OP_BORK */ 51 | ,opmode(0, 0, 0, 0, 1, iABC) /* OP_BXORK */ 52 | ,opmode(0, 0, 0, 0, 1, iABC) /* OP_SHRI */ 53 | ,opmode(0, 0, 0, 0, 1, iABC) /* OP_SHLI */ 54 | ,opmode(0, 0, 0, 0, 1, iABC) /* OP_ADD */ 55 | ,opmode(0, 0, 0, 0, 1, iABC) /* OP_SUB */ 56 | ,opmode(0, 0, 0, 0, 1, iABC) /* OP_MUL */ 57 | ,opmode(0, 0, 0, 0, 1, iABC) /* OP_MOD */ 58 | ,opmode(0, 0, 0, 0, 1, iABC) /* OP_POW */ 59 | ,opmode(0, 0, 0, 0, 1, iABC) /* OP_DIV */ 60 | ,opmode(0, 0, 0, 0, 1, iABC) /* OP_IDIV */ 61 | ,opmode(0, 0, 0, 0, 1, iABC) /* OP_BAND */ 62 | ,opmode(0, 0, 0, 0, 1, iABC) /* OP_BOR */ 63 | ,opmode(0, 0, 0, 0, 1, iABC) /* OP_BXOR */ 64 | ,opmode(0, 0, 0, 0, 1, iABC) /* OP_SHL */ 65 | ,opmode(0, 0, 0, 0, 1, iABC) /* OP_SHR */ 66 | ,opmode(1, 0, 0, 0, 0, iABC) /* OP_MMBIN */ 67 | ,opmode(1, 0, 0, 0, 0, iABC) /* OP_MMBINI*/ 68 | ,opmode(1, 0, 0, 0, 0, iABC) /* OP_MMBINK*/ 69 | ,opmode(0, 0, 0, 0, 1, iABC) /* OP_UNM */ 70 | ,opmode(0, 0, 0, 0, 1, iABC) /* OP_BNOT */ 71 | ,opmode(0, 0, 0, 0, 1, iABC) /* OP_NOT */ 72 | ,opmode(0, 0, 0, 0, 1, iABC) /* OP_LEN */ 73 | ,opmode(0, 0, 0, 0, 1, iABC) /* OP_CONCAT */ 74 | ,opmode(0, 0, 0, 0, 0, iABC) /* OP_CLOSE */ 75 | ,opmode(0, 0, 0, 0, 0, iABC) /* OP_TBC */ 76 | ,opmode(0, 0, 0, 0, 0, isJ) /* OP_JMP */ 77 | ,opmode(0, 0, 0, 1, 0, iABC) /* OP_EQ */ 78 | ,opmode(0, 0, 0, 1, 0, iABC) /* OP_LT */ 79 | ,opmode(0, 0, 0, 1, 0, iABC) /* OP_LE */ 80 | ,opmode(0, 0, 0, 1, 0, iABC) /* OP_EQK */ 81 | ,opmode(0, 0, 0, 1, 0, iABC) /* OP_EQI */ 82 | ,opmode(0, 0, 0, 1, 0, iABC) /* OP_LTI */ 83 | ,opmode(0, 0, 0, 1, 0, iABC) /* OP_LEI */ 84 | ,opmode(0, 0, 0, 1, 0, iABC) /* OP_GTI */ 85 | ,opmode(0, 0, 0, 1, 0, iABC) /* OP_GEI */ 86 | ,opmode(0, 0, 0, 1, 0, iABC) /* OP_TEST */ 87 | ,opmode(0, 0, 0, 1, 1, iABC) /* OP_TESTSET */ 88 | ,opmode(0, 1, 1, 0, 1, iABC) /* OP_CALL */ 89 | ,opmode(0, 1, 1, 0, 1, iABC) /* OP_TAILCALL */ 90 | ,opmode(0, 0, 1, 0, 0, iABC) /* OP_RETURN */ 91 | ,opmode(0, 0, 0, 0, 0, iABC) /* OP_RETURN0 */ 92 | ,opmode(0, 0, 0, 0, 0, iABC) /* OP_RETURN1 */ 93 | ,opmode(0, 0, 0, 0, 1, iABx) /* OP_FORLOOP */ 94 | ,opmode(0, 0, 0, 0, 1, iABx) /* OP_FORPREP */ 95 | ,opmode(0, 0, 0, 0, 0, iABx) /* OP_TFORPREP */ 96 | ,opmode(0, 0, 0, 0, 0, iABC) /* OP_TFORCALL */ 97 | ,opmode(0, 0, 0, 0, 1, iABx) /* OP_TFORLOOP */ 98 | ,opmode(0, 0, 1, 0, 0, iABC) /* OP_SETLIST */ 99 | ,opmode(0, 0, 0, 0, 1, iABx) /* OP_CLOSURE */ 100 | ,opmode(0, 1, 0, 0, 1, iABC) /* OP_VARARG */ 101 | ,opmode(0, 0, 1, 0, 1, iABC) /* OP_VARARGPREP */ 102 | ,opmode(0, 0, 0, 0, 0, iAx) /* OP_EXTRAARG */ 103 | }; 104 | 105 | -------------------------------------------------------------------------------- /dependencies/lua/src/lopnames.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lopnames.h $ 3 | ** Opcode names 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #if !defined(lopnames_h) 8 | #define lopnames_h 9 | 10 | #include 11 | 12 | 13 | /* ORDER OP */ 14 | 15 | static const char *const opnames[] = { 16 | "MOVE", 17 | "LOADI", 18 | "LOADF", 19 | "LOADK", 20 | "LOADKX", 21 | "LOADFALSE", 22 | "LFALSESKIP", 23 | "LOADTRUE", 24 | "LOADNIL", 25 | "GETUPVAL", 26 | "SETUPVAL", 27 | "GETTABUP", 28 | "GETTABLE", 29 | "GETI", 30 | "GETFIELD", 31 | "SETTABUP", 32 | "SETTABLE", 33 | "SETI", 34 | "SETFIELD", 35 | "NEWTABLE", 36 | "SELF", 37 | "ADDI", 38 | "ADDK", 39 | "SUBK", 40 | "MULK", 41 | "MODK", 42 | "POWK", 43 | "DIVK", 44 | "IDIVK", 45 | "BANDK", 46 | "BORK", 47 | "BXORK", 48 | "SHRI", 49 | "SHLI", 50 | "ADD", 51 | "SUB", 52 | "MUL", 53 | "MOD", 54 | "POW", 55 | "DIV", 56 | "IDIV", 57 | "BAND", 58 | "BOR", 59 | "BXOR", 60 | "SHL", 61 | "SHR", 62 | "MMBIN", 63 | "MMBINI", 64 | "MMBINK", 65 | "UNM", 66 | "BNOT", 67 | "NOT", 68 | "LEN", 69 | "CONCAT", 70 | "CLOSE", 71 | "TBC", 72 | "JMP", 73 | "EQ", 74 | "LT", 75 | "LE", 76 | "EQK", 77 | "EQI", 78 | "LTI", 79 | "LEI", 80 | "GTI", 81 | "GEI", 82 | "TEST", 83 | "TESTSET", 84 | "CALL", 85 | "TAILCALL", 86 | "RETURN", 87 | "RETURN0", 88 | "RETURN1", 89 | "FORLOOP", 90 | "FORPREP", 91 | "TFORPREP", 92 | "TFORCALL", 93 | "TFORLOOP", 94 | "SETLIST", 95 | "CLOSURE", 96 | "VARARG", 97 | "VARARGPREP", 98 | "EXTRAARG", 99 | NULL 100 | }; 101 | 102 | #endif 103 | 104 | -------------------------------------------------------------------------------- /dependencies/lua/src/lprefix.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lprefix.h $ 3 | ** Definitions for Lua code that must come before any other header file 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lprefix_h 8 | #define lprefix_h 9 | 10 | 11 | /* 12 | ** Allows POSIX/XSI stuff 13 | */ 14 | #if !defined(LUA_USE_C89) /* { */ 15 | 16 | #if !defined(_XOPEN_SOURCE) 17 | #define _XOPEN_SOURCE 600 18 | #elif _XOPEN_SOURCE == 0 19 | #undef _XOPEN_SOURCE /* use -D_XOPEN_SOURCE=0 to undefine it */ 20 | #endif 21 | 22 | /* 23 | ** Allows manipulation of large files in gcc and some other compilers 24 | */ 25 | #if !defined(LUA_32BITS) && !defined(_FILE_OFFSET_BITS) 26 | #define _LARGEFILE_SOURCE 1 27 | #define _FILE_OFFSET_BITS 64 28 | #endif 29 | 30 | #endif /* } */ 31 | 32 | 33 | /* 34 | ** Windows stuff 35 | */ 36 | #if defined(_WIN32) /* { */ 37 | 38 | #if !defined(_CRT_SECURE_NO_WARNINGS) 39 | #define _CRT_SECURE_NO_WARNINGS /* avoid warnings about ISO C functions */ 40 | #endif 41 | 42 | #endif /* } */ 43 | 44 | #endif 45 | 46 | -------------------------------------------------------------------------------- /dependencies/lua/src/lstring.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lstring.h $ 3 | ** String table (keep all strings handled by Lua) 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lstring_h 8 | #define lstring_h 9 | 10 | #include "lgc.h" 11 | #include "lobject.h" 12 | #include "lstate.h" 13 | 14 | 15 | /* 16 | ** Memory-allocation error message must be preallocated (it cannot 17 | ** be created after memory is exhausted) 18 | */ 19 | #define MEMERRMSG "not enough memory" 20 | 21 | 22 | /* 23 | ** Size of a TString: Size of the header plus space for the string 24 | ** itself (including final '\0'). 25 | */ 26 | #define sizelstring(l) (offsetof(TString, contents) + ((l) + 1) * sizeof(char)) 27 | 28 | #define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \ 29 | (sizeof(s)/sizeof(char))-1)) 30 | 31 | 32 | /* 33 | ** test whether a string is a reserved word 34 | */ 35 | #define isreserved(s) ((s)->tt == LUA_VSHRSTR && (s)->extra > 0) 36 | 37 | 38 | /* 39 | ** equality for short strings, which are always internalized 40 | */ 41 | #define eqshrstr(a,b) check_exp((a)->tt == LUA_VSHRSTR, (a) == (b)) 42 | 43 | 44 | LUAI_FUNC unsigned int luaS_hash (const char *str, size_t l, unsigned int seed); 45 | LUAI_FUNC unsigned int luaS_hashlongstr (TString *ts); 46 | LUAI_FUNC int luaS_eqlngstr (TString *a, TString *b); 47 | LUAI_FUNC void luaS_resize (lua_State *L, int newsize); 48 | LUAI_FUNC void luaS_clearcache (global_State *g); 49 | LUAI_FUNC void luaS_init (lua_State *L); 50 | LUAI_FUNC void luaS_remove (lua_State *L, TString *ts); 51 | LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, int nuvalue); 52 | LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); 53 | LUAI_FUNC TString *luaS_new (lua_State *L, const char *str); 54 | LUAI_FUNC TString *luaS_createlngstrobj (lua_State *L, size_t l); 55 | 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /dependencies/lua/src/ltable.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltable.h $ 3 | ** Lua tables (hash) 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ltable_h 8 | #define ltable_h 9 | 10 | #include "lobject.h" 11 | 12 | 13 | #define gnode(t,i) (&(t)->node[i]) 14 | #define gval(n) (&(n)->i_val) 15 | #define gnext(n) ((n)->u.next) 16 | 17 | 18 | /* 19 | ** Clear all bits of fast-access metamethods, which means that the table 20 | ** may have any of these metamethods. (First access that fails after the 21 | ** clearing will set the bit again.) 22 | */ 23 | #define invalidateTMcache(t) ((t)->flags &= ~maskflags) 24 | 25 | 26 | /* true when 't' is using 'dummynode' as its hash part */ 27 | #define isdummy(t) ((t)->lastfree == NULL) 28 | 29 | 30 | /* allocated size for hash nodes */ 31 | #define allocsizenode(t) (isdummy(t) ? 0 : sizenode(t)) 32 | 33 | 34 | /* returns the Node, given the value of a table entry */ 35 | #define nodefromval(v) cast(Node *, (v)) 36 | 37 | 38 | LUAI_FUNC const TValue *luaH_getint (Table *t, lua_Integer key); 39 | LUAI_FUNC void luaH_setint (lua_State *L, Table *t, lua_Integer key, 40 | TValue *value); 41 | LUAI_FUNC const TValue *luaH_getshortstr (Table *t, TString *key); 42 | LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key); 43 | LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key); 44 | LUAI_FUNC void luaH_newkey (lua_State *L, Table *t, const TValue *key, 45 | TValue *value); 46 | LUAI_FUNC void luaH_set (lua_State *L, Table *t, const TValue *key, 47 | TValue *value); 48 | LUAI_FUNC void luaH_finishset (lua_State *L, Table *t, const TValue *key, 49 | const TValue *slot, TValue *value); 50 | LUAI_FUNC Table *luaH_new (lua_State *L); 51 | LUAI_FUNC void luaH_resize (lua_State *L, Table *t, unsigned int nasize, 52 | unsigned int nhsize); 53 | LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, unsigned int nasize); 54 | LUAI_FUNC void luaH_free (lua_State *L, Table *t); 55 | LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key); 56 | LUAI_FUNC lua_Unsigned luaH_getn (Table *t); 57 | LUAI_FUNC unsigned int luaH_realasize (const Table *t); 58 | 59 | 60 | #if defined(LUA_DEBUG) 61 | LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key); 62 | LUAI_FUNC int luaH_isdummy (const Table *t); 63 | #endif 64 | 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /dependencies/lua/src/ltests.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltests.h $ 3 | ** Internal Header for Debugging of the Lua Implementation 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ltests_h 8 | #define ltests_h 9 | 10 | 11 | #include 12 | #include 13 | 14 | /* test Lua with compatibility code */ 15 | #define LUA_COMPAT_MATHLIB 16 | #define LUA_COMPAT_LT_LE 17 | 18 | 19 | #define LUA_DEBUG 20 | 21 | 22 | /* turn on assertions */ 23 | #define LUAI_ASSERT 24 | 25 | 26 | /* to avoid warnings, and to make sure value is really unused */ 27 | #define UNUSED(x) (x=0, (void)(x)) 28 | 29 | 30 | /* test for sizes in 'l_sprintf' (make sure whole buffer is available) */ 31 | #undef l_sprintf 32 | #if !defined(LUA_USE_C89) 33 | #define l_sprintf(s,sz,f,i) (memset(s,0xAB,sz), snprintf(s,sz,f,i)) 34 | #else 35 | #define l_sprintf(s,sz,f,i) (memset(s,0xAB,sz), sprintf(s,f,i)) 36 | #endif 37 | 38 | 39 | /* get a chance to test code without jump tables */ 40 | #define LUA_USE_JUMPTABLE 0 41 | 42 | 43 | /* use 32-bit integers in random generator */ 44 | #define LUA_RAND32 45 | 46 | 47 | /* memory-allocator control variables */ 48 | typedef struct Memcontrol { 49 | int failnext; 50 | unsigned long numblocks; 51 | unsigned long total; 52 | unsigned long maxmem; 53 | unsigned long memlimit; 54 | unsigned long countlimit; 55 | unsigned long objcount[LUA_NUMTYPES]; 56 | } Memcontrol; 57 | 58 | LUA_API Memcontrol l_memcontrol; 59 | 60 | 61 | /* 62 | ** generic variable for debug tricks 63 | */ 64 | extern void *l_Trick; 65 | 66 | 67 | 68 | /* 69 | ** Function to traverse and check all memory used by Lua 70 | */ 71 | LUAI_FUNC int lua_checkmemory (lua_State *L); 72 | 73 | /* 74 | ** Function to print an object GC-friendly 75 | */ 76 | struct GCObject; 77 | LUAI_FUNC void lua_printobj (lua_State *L, struct GCObject *o); 78 | 79 | 80 | /* test for lock/unlock */ 81 | 82 | struct L_EXTRA { int lock; int *plock; }; 83 | #undef LUA_EXTRASPACE 84 | #define LUA_EXTRASPACE sizeof(struct L_EXTRA) 85 | #define getlock(l) cast(struct L_EXTRA*, lua_getextraspace(l)) 86 | #define luai_userstateopen(l) \ 87 | (getlock(l)->lock = 0, getlock(l)->plock = &(getlock(l)->lock)) 88 | #define luai_userstateclose(l) \ 89 | lua_assert(getlock(l)->lock == 1 && getlock(l)->plock == &(getlock(l)->lock)) 90 | #define luai_userstatethread(l,l1) \ 91 | lua_assert(getlock(l1)->plock == getlock(l)->plock) 92 | #define luai_userstatefree(l,l1) \ 93 | lua_assert(getlock(l)->plock == getlock(l1)->plock) 94 | #define lua_lock(l) lua_assert((*getlock(l)->plock)++ == 0) 95 | #define lua_unlock(l) lua_assert(--(*getlock(l)->plock) == 0) 96 | 97 | 98 | 99 | LUA_API int luaB_opentests (lua_State *L); 100 | 101 | LUA_API void *debug_realloc (void *ud, void *block, 102 | size_t osize, size_t nsize); 103 | 104 | #if defined(lua_c) 105 | #define luaL_newstate() lua_newstate(debug_realloc, &l_memcontrol) 106 | #define luaL_openlibs(L) \ 107 | { (luaL_openlibs)(L); \ 108 | luaL_requiref(L, "T", luaB_opentests, 1); \ 109 | lua_pop(L, 1); } 110 | #endif 111 | 112 | 113 | 114 | /* change some sizes to give some bugs a chance */ 115 | 116 | #undef LUAL_BUFFERSIZE 117 | #define LUAL_BUFFERSIZE 23 118 | #define MINSTRTABSIZE 2 119 | #define MAXIWTHABS 3 120 | 121 | #define STRCACHE_N 23 122 | #define STRCACHE_M 5 123 | 124 | #undef LUAI_USER_ALIGNMENT_T 125 | #define LUAI_USER_ALIGNMENT_T union { char b[sizeof(void*) * 8]; } 126 | 127 | 128 | /* make stack-overflow tests run faster */ 129 | #undef LUAI_MAXSTACK 130 | #define LUAI_MAXSTACK 50000 131 | 132 | 133 | /* test mode uses more stack space */ 134 | #undef LUAI_MAXCCALLS 135 | #define LUAI_MAXCCALLS 180 136 | 137 | 138 | /* force Lua to use its own implementations */ 139 | #undef lua_strx2number 140 | #undef lua_number2strx 141 | 142 | 143 | #endif 144 | 145 | -------------------------------------------------------------------------------- /dependencies/lua/src/ltm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltm.h $ 3 | ** Tag methods 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ltm_h 8 | #define ltm_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | 14 | /* 15 | * WARNING: if you change the order of this enumeration, 16 | * grep "ORDER TM" and "ORDER OP" 17 | */ 18 | typedef enum { 19 | TM_INDEX, 20 | TM_NEWINDEX, 21 | TM_GC, 22 | TM_MODE, 23 | TM_LEN, 24 | TM_EQ, /* last tag method with fast access */ 25 | TM_ADD, 26 | TM_SUB, 27 | TM_MUL, 28 | TM_MOD, 29 | TM_POW, 30 | TM_DIV, 31 | TM_IDIV, 32 | TM_BAND, 33 | TM_BOR, 34 | TM_BXOR, 35 | TM_SHL, 36 | TM_SHR, 37 | TM_UNM, 38 | TM_BNOT, 39 | TM_LT, 40 | TM_LE, 41 | TM_CONCAT, 42 | TM_CALL, 43 | TM_CLOSE, 44 | TM_N /* number of elements in the enum */ 45 | } TMS; 46 | 47 | 48 | /* 49 | ** Mask with 1 in all fast-access methods. A 1 in any of these bits 50 | ** in the flag of a (meta)table means the metatable does not have the 51 | ** corresponding metamethod field. (Bit 7 of the flag is used for 52 | ** 'isrealasize'.) 53 | */ 54 | #define maskflags (~(~0u << (TM_EQ + 1))) 55 | 56 | 57 | /* 58 | ** Test whether there is no tagmethod. 59 | ** (Because tagmethods use raw accesses, the result may be an "empty" nil.) 60 | */ 61 | #define notm(tm) ttisnil(tm) 62 | 63 | 64 | #define gfasttm(g,et,e) ((et) == NULL ? NULL : \ 65 | ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e])) 66 | 67 | #define fasttm(l,et,e) gfasttm(G(l), et, e) 68 | 69 | #define ttypename(x) luaT_typenames_[(x) + 1] 70 | 71 | LUAI_DDEC(const char *const luaT_typenames_[LUA_TOTALTYPES];) 72 | 73 | 74 | LUAI_FUNC const char *luaT_objtypename (lua_State *L, const TValue *o); 75 | 76 | LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename); 77 | LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, 78 | TMS event); 79 | LUAI_FUNC void luaT_init (lua_State *L); 80 | 81 | LUAI_FUNC void luaT_callTM (lua_State *L, const TValue *f, const TValue *p1, 82 | const TValue *p2, const TValue *p3); 83 | LUAI_FUNC void luaT_callTMres (lua_State *L, const TValue *f, 84 | const TValue *p1, const TValue *p2, StkId p3); 85 | LUAI_FUNC void luaT_trybinTM (lua_State *L, const TValue *p1, const TValue *p2, 86 | StkId res, TMS event); 87 | LUAI_FUNC void luaT_tryconcatTM (lua_State *L); 88 | LUAI_FUNC void luaT_trybinassocTM (lua_State *L, const TValue *p1, 89 | const TValue *p2, int inv, StkId res, TMS event); 90 | LUAI_FUNC void luaT_trybiniTM (lua_State *L, const TValue *p1, lua_Integer i2, 91 | int inv, StkId res, TMS event); 92 | LUAI_FUNC int luaT_callorderTM (lua_State *L, const TValue *p1, 93 | const TValue *p2, TMS event); 94 | LUAI_FUNC int luaT_callorderiTM (lua_State *L, const TValue *p1, int v2, 95 | int inv, int isfloat, TMS event); 96 | 97 | LUAI_FUNC void luaT_adjustvarargs (lua_State *L, int nfixparams, 98 | struct CallInfo *ci, const Proto *p); 99 | LUAI_FUNC void luaT_getvarargs (lua_State *L, struct CallInfo *ci, 100 | StkId where, int wanted); 101 | 102 | 103 | #endif 104 | -------------------------------------------------------------------------------- /dependencies/lua/src/lualib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lualib.h $ 3 | ** Lua standard libraries 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lualib_h 9 | #define lualib_h 10 | 11 | #include "lua.h" 12 | 13 | 14 | /* version suffix for environment variable names */ 15 | #define LUA_VERSUFFIX "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR 16 | 17 | 18 | LUAMOD_API int (luaopen_base) (lua_State *L); 19 | 20 | #define LUA_COLIBNAME "coroutine" 21 | LUAMOD_API int (luaopen_coroutine) (lua_State *L); 22 | 23 | #define LUA_TABLIBNAME "table" 24 | LUAMOD_API int (luaopen_table) (lua_State *L); 25 | 26 | #define LUA_IOLIBNAME "io" 27 | LUAMOD_API int (luaopen_io) (lua_State *L); 28 | 29 | #define LUA_OSLIBNAME "os" 30 | LUAMOD_API int (luaopen_os) (lua_State *L); 31 | 32 | #define LUA_STRLIBNAME "string" 33 | LUAMOD_API int (luaopen_string) (lua_State *L); 34 | 35 | #define LUA_UTF8LIBNAME "utf8" 36 | LUAMOD_API int (luaopen_utf8) (lua_State *L); 37 | 38 | #define LUA_MATHLIBNAME "math" 39 | LUAMOD_API int (luaopen_math) (lua_State *L); 40 | 41 | #define LUA_DBLIBNAME "debug" 42 | LUAMOD_API int (luaopen_debug) (lua_State *L); 43 | 44 | #define LUA_LOADLIBNAME "package" 45 | LUAMOD_API int (luaopen_package) (lua_State *L); 46 | 47 | 48 | /* open all previous libraries */ 49 | LUALIB_API void (luaL_openlibs) (lua_State *L); 50 | 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /dependencies/lua/src/lundump.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lundump.h $ 3 | ** load precompiled Lua chunks 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lundump_h 8 | #define lundump_h 9 | 10 | #include "llimits.h" 11 | #include "lobject.h" 12 | #include "lzio.h" 13 | 14 | 15 | /* data to catch conversion errors */ 16 | #define LUAC_DATA "\x19\x93\r\n\x1a\n" 17 | 18 | #define LUAC_INT 0x5678 19 | #define LUAC_NUM cast_num(370.5) 20 | 21 | /* 22 | ** Encode major-minor version in one byte, one nibble for each 23 | */ 24 | #define MYINT(s) (s[0]-'0') /* assume one-digit numerals */ 25 | #define LUAC_VERSION (MYINT(LUA_VERSION_MAJOR)*16+MYINT(LUA_VERSION_MINOR)) 26 | 27 | #define LUAC_FORMAT 0 /* this is the official format */ 28 | 29 | /* load one chunk; from lundump.c */ 30 | LUAI_FUNC LClosure* luaU_undump (lua_State* L, ZIO* Z, const char* name); 31 | 32 | /* dump one chunk; from ldump.c */ 33 | LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, 34 | void* data, int strip); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /dependencies/lua/src/lvm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lvm.h $ 3 | ** Lua virtual machine 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lvm_h 8 | #define lvm_h 9 | 10 | 11 | #include "ldo.h" 12 | #include "lobject.h" 13 | #include "ltm.h" 14 | 15 | 16 | #if !defined(LUA_NOCVTN2S) 17 | #define cvt2str(o) ttisnumber(o) 18 | #else 19 | #define cvt2str(o) 0 /* no conversion from numbers to strings */ 20 | #endif 21 | 22 | 23 | #if !defined(LUA_NOCVTS2N) 24 | #define cvt2num(o) ttisstring(o) 25 | #else 26 | #define cvt2num(o) 0 /* no conversion from strings to numbers */ 27 | #endif 28 | 29 | 30 | /* 31 | ** You can define LUA_FLOORN2I if you want to convert floats to integers 32 | ** by flooring them (instead of raising an error if they are not 33 | ** integral values) 34 | */ 35 | #if !defined(LUA_FLOORN2I) 36 | #define LUA_FLOORN2I F2Ieq 37 | #endif 38 | 39 | 40 | /* 41 | ** Rounding modes for float->integer coercion 42 | */ 43 | typedef enum { 44 | F2Ieq, /* no rounding; accepts only integral values */ 45 | F2Ifloor, /* takes the floor of the number */ 46 | F2Iceil /* takes the ceil of the number */ 47 | } F2Imod; 48 | 49 | 50 | /* convert an object to a float (including string coercion) */ 51 | #define tonumber(o,n) \ 52 | (ttisfloat(o) ? (*(n) = fltvalue(o), 1) : luaV_tonumber_(o,n)) 53 | 54 | 55 | /* convert an object to a float (without string coercion) */ 56 | #define tonumberns(o,n) \ 57 | (ttisfloat(o) ? ((n) = fltvalue(o), 1) : \ 58 | (ttisinteger(o) ? ((n) = cast_num(ivalue(o)), 1) : 0)) 59 | 60 | 61 | /* convert an object to an integer (including string coercion) */ 62 | #define tointeger(o,i) \ 63 | (l_likely(ttisinteger(o)) ? (*(i) = ivalue(o), 1) \ 64 | : luaV_tointeger(o,i,LUA_FLOORN2I)) 65 | 66 | 67 | /* convert an object to an integer (without string coercion) */ 68 | #define tointegerns(o,i) \ 69 | (l_likely(ttisinteger(o)) ? (*(i) = ivalue(o), 1) \ 70 | : luaV_tointegerns(o,i,LUA_FLOORN2I)) 71 | 72 | 73 | #define intop(op,v1,v2) l_castU2S(l_castS2U(v1) op l_castS2U(v2)) 74 | 75 | #define luaV_rawequalobj(t1,t2) luaV_equalobj(NULL,t1,t2) 76 | 77 | 78 | /* 79 | ** fast track for 'gettable': if 't' is a table and 't[k]' is present, 80 | ** return 1 with 'slot' pointing to 't[k]' (position of final result). 81 | ** Otherwise, return 0 (meaning it will have to check metamethod) 82 | ** with 'slot' pointing to an empty 't[k]' (if 't' is a table) or NULL 83 | ** (otherwise). 'f' is the raw get function to use. 84 | */ 85 | #define luaV_fastget(L,t,k,slot,f) \ 86 | (!ttistable(t) \ 87 | ? (slot = NULL, 0) /* not a table; 'slot' is NULL and result is 0 */ \ 88 | : (slot = f(hvalue(t), k), /* else, do raw access */ \ 89 | !isempty(slot))) /* result not empty? */ 90 | 91 | 92 | /* 93 | ** Special case of 'luaV_fastget' for integers, inlining the fast case 94 | ** of 'luaH_getint'. 95 | */ 96 | #define luaV_fastgeti(L,t,k,slot) \ 97 | (!ttistable(t) \ 98 | ? (slot = NULL, 0) /* not a table; 'slot' is NULL and result is 0 */ \ 99 | : (slot = (l_castS2U(k) - 1u < hvalue(t)->alimit) \ 100 | ? &hvalue(t)->array[k - 1] : luaH_getint(hvalue(t), k), \ 101 | !isempty(slot))) /* result not empty? */ 102 | 103 | 104 | /* 105 | ** Finish a fast set operation (when fast get succeeds). In that case, 106 | ** 'slot' points to the place to put the value. 107 | */ 108 | #define luaV_finishfastset(L,t,slot,v) \ 109 | { setobj2t(L, cast(TValue *,slot), v); \ 110 | luaC_barrierback(L, gcvalue(t), v); } 111 | 112 | 113 | 114 | 115 | LUAI_FUNC int luaV_equalobj (lua_State *L, const TValue *t1, const TValue *t2); 116 | LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r); 117 | LUAI_FUNC int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r); 118 | LUAI_FUNC int luaV_tonumber_ (const TValue *obj, lua_Number *n); 119 | LUAI_FUNC int luaV_tointeger (const TValue *obj, lua_Integer *p, F2Imod mode); 120 | LUAI_FUNC int luaV_tointegerns (const TValue *obj, lua_Integer *p, 121 | F2Imod mode); 122 | LUAI_FUNC int luaV_flttointeger (lua_Number n, lua_Integer *p, F2Imod mode); 123 | LUAI_FUNC void luaV_finishget (lua_State *L, const TValue *t, TValue *key, 124 | StkId val, const TValue *slot); 125 | LUAI_FUNC void luaV_finishset (lua_State *L, const TValue *t, TValue *key, 126 | TValue *val, const TValue *slot); 127 | LUAI_FUNC void luaV_finishOp (lua_State *L); 128 | LUAI_FUNC void luaV_execute (lua_State *L, CallInfo *ci); 129 | LUAI_FUNC void luaV_concat (lua_State *L, int total); 130 | LUAI_FUNC lua_Integer luaV_idiv (lua_State *L, lua_Integer x, lua_Integer y); 131 | LUAI_FUNC lua_Integer luaV_mod (lua_State *L, lua_Integer x, lua_Integer y); 132 | LUAI_FUNC lua_Number luaV_modf (lua_State *L, lua_Number x, lua_Number y); 133 | LUAI_FUNC lua_Integer luaV_shiftl (lua_Integer x, lua_Integer y); 134 | LUAI_FUNC void luaV_objlen (lua_State *L, StkId ra, const TValue *rb); 135 | 136 | #endif 137 | -------------------------------------------------------------------------------- /dependencies/lua/src/lzio.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lzio.c $ 3 | ** Buffered streams 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #define lzio_c 8 | #define LUA_CORE 9 | 10 | #include "lprefix.h" 11 | 12 | 13 | #include 14 | 15 | #include "lua.h" 16 | 17 | #include "llimits.h" 18 | #include "lmem.h" 19 | #include "lstate.h" 20 | #include "lzio.h" 21 | 22 | 23 | int luaZ_fill (ZIO *z) { 24 | size_t size; 25 | lua_State *L = z->L; 26 | const char *buff; 27 | lua_unlock(L); 28 | buff = z->reader(L, z->data, &size); 29 | lua_lock(L); 30 | if (buff == NULL || size == 0) 31 | return EOZ; 32 | z->n = size - 1; /* discount char being returned */ 33 | z->p = buff; 34 | return cast_uchar(*(z->p++)); 35 | } 36 | 37 | 38 | void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) { 39 | z->L = L; 40 | z->reader = reader; 41 | z->data = data; 42 | z->n = 0; 43 | z->p = NULL; 44 | } 45 | 46 | 47 | /* --------------------------------------------------------------- read --- */ 48 | size_t luaZ_read (ZIO *z, void *b, size_t n) { 49 | while (n) { 50 | size_t m; 51 | if (z->n == 0) { /* no bytes in buffer? */ 52 | if (luaZ_fill(z) == EOZ) /* try to read more */ 53 | return n; /* no more input; return number of missing bytes */ 54 | else { 55 | z->n++; /* luaZ_fill consumed first byte; put it back */ 56 | z->p--; 57 | } 58 | } 59 | m = (n <= z->n) ? n : z->n; /* min. between n and z->n */ 60 | memcpy(b, z->p, m); 61 | z->n -= m; 62 | z->p += m; 63 | b = (char *)b + m; 64 | n -= m; 65 | } 66 | return 0; 67 | } 68 | 69 | -------------------------------------------------------------------------------- /dependencies/lua/src/lzio.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lzio.h $ 3 | ** Buffered streams 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lzio_h 9 | #define lzio_h 10 | 11 | #include "lua.h" 12 | 13 | #include "lmem.h" 14 | 15 | 16 | #define EOZ (-1) /* end of stream */ 17 | 18 | typedef struct Zio ZIO; 19 | 20 | #define zgetc(z) (((z)->n--)>0 ? cast_uchar(*(z)->p++) : luaZ_fill(z)) 21 | 22 | 23 | typedef struct Mbuffer { 24 | char *buffer; 25 | size_t n; 26 | size_t buffsize; 27 | } Mbuffer; 28 | 29 | #define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0) 30 | 31 | #define luaZ_buffer(buff) ((buff)->buffer) 32 | #define luaZ_sizebuffer(buff) ((buff)->buffsize) 33 | #define luaZ_bufflen(buff) ((buff)->n) 34 | 35 | #define luaZ_buffremove(buff,i) ((buff)->n -= (i)) 36 | #define luaZ_resetbuffer(buff) ((buff)->n = 0) 37 | 38 | 39 | #define luaZ_resizebuffer(L, buff, size) \ 40 | ((buff)->buffer = luaM_reallocvchar(L, (buff)->buffer, \ 41 | (buff)->buffsize, size), \ 42 | (buff)->buffsize = size) 43 | 44 | #define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0) 45 | 46 | 47 | LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, 48 | void *data); 49 | LUAI_FUNC size_t luaZ_read (ZIO* z, void *b, size_t n); /* read next n bytes */ 50 | 51 | 52 | 53 | /* --------- Private Part ------------------ */ 54 | 55 | struct Zio { 56 | size_t n; /* bytes still unread */ 57 | const char *p; /* current position in buffer */ 58 | lua_Reader reader; /* reader function */ 59 | void *data; /* additional data */ 60 | lua_State *L; /* Lua state (for reader) */ 61 | }; 62 | 63 | 64 | LUAI_FUNC int luaZ_fill (ZIO *z); 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /dependencies/openvr/.gitattributes: -------------------------------------------------------------------------------- 1 | # Set the default behavior, in case people don't have core.autocrlf set. 2 | * text=auto 3 | 4 | # Explicitly declare text files you want to always be normalized and converted 5 | # to native line endings on checkout. 6 | *.bat text 7 | *.txt text 8 | *.c text 9 | *.h text 10 | *.H text 11 | *.cc text 12 | *.cpp text 13 | *.awk text 14 | *.pl text 15 | *.py text 16 | *.xcconfig text 17 | *.vcd text 18 | *.vbsp text 19 | *.proto text 20 | *.inc text 21 | *.fxc text 22 | *.vsh text 23 | *.lst text 24 | *.mm text 25 | *.cfg text 26 | *.res text 27 | *.rc text 28 | *.def text 29 | *.vmt text 30 | *.inl text 31 | *.asm text 32 | 33 | .gitignore text 34 | README text 35 | CONTRIBUTING text 36 | LICENSE text 37 | 38 | # Declare files that will always have LF line endings on checkout. 39 | *.sh eol=lf 40 | 41 | # Denote all files that are truly binary and should not be modified. 42 | *.exe binary 43 | -------------------------------------------------------------------------------- /dependencies/openvr/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Set the minimum required version of CMake for this project. 2 | cmake_minimum_required(VERSION 2.8) 3 | 4 | # Set project name. 5 | project(OpenVRSDK) 6 | 7 | # Fetch the version from the headers 8 | set(VERSION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/headers/openvr.h") 9 | 10 | set(VERSION_MAJOR_REGEX "\tstatic const uint32_t k_nSteamVRVersionMajor = (.+);") 11 | set(VERSION_MINOR_REGEX "\tstatic const uint32_t k_nSteamVRVersionMinor = (.+);") 12 | set(VERSION_BUILD_REGEX "\tstatic const uint32_t k_nSteamVRVersionBuild = (.+);") 13 | 14 | file(STRINGS "${VERSION_FILE}" VERSION_MAJOR_STRING REGEX "${VERSION_MAJOR_REGEX}") 15 | file(STRINGS "${VERSION_FILE}" VERSION_MINOR_STRING REGEX "${VERSION_MINOR_REGEX}") 16 | file(STRINGS "${VERSION_FILE}" VERSION_BUILD_STRING REGEX "${VERSION_BUILD_REGEX}") 17 | 18 | string(REGEX REPLACE "${VERSION_MAJOR_REGEX}" "\\1" VERSION_MAJOR ${VERSION_MAJOR_STRING}) 19 | string(REGEX REPLACE "${VERSION_MINOR_REGEX}" "\\1" VERSION_MINOR ${VERSION_MINOR_STRING}) 20 | string(REGEX REPLACE "${VERSION_BUILD_REGEX}" "\\1" VERSION_BUILD ${VERSION_BUILD_STRING}) 21 | 22 | set(OPENVR_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_BUILD}") 23 | 24 | # Setup some options. 25 | option(BUILD_SHARED "Builds the library as shared library" OFF) 26 | option(BUILD_FRAMEWORK "Builds the library as an apple Framework" OFF) 27 | option(BUILD_UNIVERSAL "Builds the shared or framework as a universal (fat, 32- & 64-bit) binary" ON) 28 | option(BUILD_OSX_I386 "Builds the shared or framework as a 32-bit binary, even on a 64-bit platform" OFF) 29 | option(USE_LIBCXX "Uses libc++ instead of libstdc++" ON) 30 | option(USE_CUSTOM_LIBCXX "Uses a custom libc++" OFF) 31 | 32 | add_definitions( -DVR_API_PUBLIC ) 33 | 34 | # Check if 32 or 64 bit system. 35 | set(SIZEOF_VOIDP ${CMAKE_SIZEOF_VOID_P}) 36 | if(CMAKE_SIZEOF_VOID_P EQUAL 8) 37 | set(PROCESSOR_ARCH "64") 38 | else() 39 | set(PROCESSOR_ARCH "32") 40 | endif() 41 | 42 | # Get platform. 43 | if(WIN32) 44 | set(PLATFORM_NAME "win") 45 | if(NOT BUILD_SHARED) 46 | add_definitions(-DOPENVR_BUILD_STATIC) 47 | endif() 48 | elseif(UNIX AND NOT APPLE) 49 | if(CMAKE_SYSTEM_NAME MATCHES ".*Linux") 50 | set(PLATFORM_NAME "linux") 51 | add_definitions(-DLINUX -DPOSIX) 52 | if(PROCESSOR_ARCH MATCHES "64") 53 | add_definitions(-DLINUX64) 54 | endif() 55 | endif() 56 | elseif(APPLE) 57 | if(CMAKE_SYSTEM_NAME MATCHES ".*Darwin.*" OR CMAKE_SYSTEM_NAME MATCHES ".*MacOS.*") 58 | set(PLATFORM_NAME "osx") 59 | add_definitions(-DOSX -DPOSIX) 60 | if(BUILD_UNIVERSAL) 61 | set(CMAKE_OSX_ARCHITECTURES "i386;x86_64") 62 | endif() 63 | if(BUILD_OSX_I386) 64 | set(PROCESSOR_ARCH "32") 65 | set(CMAKE_OSX_ARCHITECTURES "i386") 66 | endif() 67 | endif() 68 | endif() 69 | 70 | # Set output folder for static and shared libraries 71 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin/${PLATFORM_NAME}${PROCESSOR_ARCH}) 72 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin/${PLATFORM_NAME}${PROCESSOR_ARCH}) 73 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin/${PLATFORM_NAME}${PROCESSOR_ARCH}) 74 | 75 | # Enable some properties. 76 | if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang") 77 | # Enable c++11 and hide symbols which shouldn't be visible 78 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC -fvisibility=hidden") 79 | 80 | # Set custom libc++ usage here 81 | if(CMAKE_C_COMPILER_ID MATCHES "Clang" AND USE_LIBCXX) 82 | if(USE_CUSTOM_LIBCXX) 83 | if(BUILD_SHARED) 84 | set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -stdlib=libc++") 85 | endif() 86 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -nostdinc++") 87 | include_directories( ${LIBCXX_INCLUDE} ${LIBCXX_ABI_INCLUDE}) 88 | message(STATUS "Using custom libc++") 89 | else() 90 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") 91 | message(STATUS "Using libc++") 92 | endif() 93 | endif() 94 | endif() 95 | 96 | add_subdirectory(src) 97 | -------------------------------------------------------------------------------- /dependencies/openvr/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Valve Corporation 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | 2. Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation and/or 12 | other materials provided with the distribution. 13 | 14 | 3. Neither the name of the copyright holder nor the names of its contributors 15 | may be used to endorse or promote products derived from this software without 16 | specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 22 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 25 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /dependencies/openvr/README.md: -------------------------------------------------------------------------------- 1 | OpenVR SDK 2 | --- 3 | 4 | OpenVR is an API and runtime that allows access to VR hardware from multiple 5 | vendors without requiring that applications have specific knowledge of the 6 | hardware they are targeting. This repository is an SDK that contains the API 7 | and samples. The runtime is under SteamVR in Tools on Steam. 8 | 9 | ### Documentation 10 | 11 | Documentation for the API is available on the [GitHub Wiki](https://github.com/ValveSoftware/openvr/wiki/API-Documentation) 12 | 13 | More information on OpenVR and SteamVR can be found on http://steamvr.com 14 | -------------------------------------------------------------------------------- /dependencies/openvr/Toolchain-clang.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_SYSTEM_NAME Linux) 2 | 3 | set(CMAKE_C_COMPILER clang) 4 | set(CMAKE_CXX_COMPILER clang++) 5 | 6 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 7 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 8 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 9 | set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) 10 | -------------------------------------------------------------------------------- /dependencies/openvr/codegen/README.md: -------------------------------------------------------------------------------- 1 | Codegen 2 | --- 3 | The OpenVR SDK ships with metadata for its headers at [openvr_api.json](https://github.com/ValveSoftware/openvr/blob/master/headers/openvr_api.json). 4 | 5 | This can be used to generate bindings for other languages such as C or C#. 6 | 7 | We include the scripts we use to generate the existing bindings that ship as part of the SDK here. 8 | 9 | ### Usage 10 | 11 | These scripts assume Python 2.7. 12 | 13 | We use [Artistic Style](http://astyle.sourceforge.net/) for formatting. 14 | 15 | #### C# bindings: 16 | 17 | ``` 18 | python openvr_interop.cs.py > openvr_interop.cs 19 | astyle -T -O openvr_interop.cs 20 | ``` 21 | 22 | #### C bindings: 23 | 24 | ``` 25 | python openvr_capi.h.py > openvr_capi.h 26 | astyle -T -O openvr_capi.h 27 | ``` 28 | 29 | #### C implementation: 30 | 31 | This file is build into openvr_api.dll and is used by both the C and C# bindings. 32 | 33 | ``` 34 | python openvr_capi.cpp.py > openvr_capi.cpp 35 | astyle -T -O openvr_capi.cpp 36 | ``` -------------------------------------------------------------------------------- /dependencies/openvr/codegen/openvr_capi.cpp.py: -------------------------------------------------------------------------------- 1 | print ("""//======= Copyright (c) Valve Corporation, All rights reserved. =============== 2 | // 3 | // Purpose: This is a flattened version of the OpenVR_API interfaces. 4 | // This file is auto-generated, do not edit it. 5 | // 6 | //============================================================================= 7 | #ifdef _WIN32 8 | #define WIN32_LEAN_AND_MEAN 9 | #include 10 | #include 11 | #endif 12 | 13 | #if defined(OSX) 14 | #include 15 | #include 16 | #define MAX_PATH PATH_MAX 17 | #elif defined(LINUX) 18 | #include 19 | #include 20 | #define MAX_PATH PATH_MAX 21 | #elif defined(WIN32) 22 | #else 23 | #error 24 | #endif 25 | 26 | #ifdef POSIX 27 | #include 28 | #include // dlopen,dlclose, et al 29 | #include 30 | #include 31 | #define HMODULE void * 32 | #define GetProcAddress dlsym 33 | #define OutputDebugString( pchMsg ) fputs( pchMsg, stderr ) 34 | #define _strnicmp strncasecmp 35 | //#include "../../common/linuxhelpers_nodeps.h" 36 | #endif 37 | 38 | #ifdef OSX 39 | #include 40 | #endif 41 | 42 | #include 43 | #include 44 | 45 | #include "../headers/openvr.h" 46 | #include "openvr_capi.h" 47 | 48 | class FnTableRegistration 49 | { 50 | public: 51 | FnTableRegistration( const char *pchInterfaceName, void *pInterface ) 52 | { 53 | char buffer[255]; 54 | sprintf(buffer, "FnTable:%s", pchInterfaceName); 55 | m_pInterfaceRegistration = new GenericInterfaceRegistration( buffer, pInterface ); 56 | } 57 | ~FnTableRegistration() 58 | { 59 | delete m_pInterfaceRegistration; 60 | } 61 | private: 62 | GenericInterfaceRegistration *m_pInterfaceRegistration; 63 | }; 64 | 65 | """) 66 | 67 | 68 | import json 69 | import sys 70 | with open('../headers/openvr_api.json') as data_file: 71 | data = json.load(data_file) 72 | 73 | import api_shared 74 | api_shared.outputfntablefuncs('vr', data) 75 | api_shared.outputfntabledecls('vr', data) 76 | api_shared.outputfntableinit('vr', data) 77 | api_shared.outputfntableaccess('vr', data) 78 | 79 | -------------------------------------------------------------------------------- /dependencies/openvr/controller_callouts/Callouts.eps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangredli/UEVR/299dea90573357edc148d9ced0ec682450a54c12/dependencies/openvr/controller_callouts/Callouts.eps -------------------------------------------------------------------------------- /dependencies/openvr/controller_callouts/Callouts.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangredli/UEVR/299dea90573357edc148d9ced0ec682450a54c12/dependencies/openvr/controller_callouts/Callouts.pdf -------------------------------------------------------------------------------- /dependencies/openvr/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Project name. 2 | project(openvr_api) 3 | 4 | set( LIBNAME "openvr_api" ) 5 | set(OPENVR_HEADER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../headers) 6 | 7 | # Set some properies for specific files. 8 | if(APPLE) 9 | set(CMAKE_MACOSX_RPATH 1) 10 | if(CMAKE_SYSTEM_NAME MATCHES "Darwin") 11 | set_source_files_properties(vrcommon/pathtools_public.cpp vrcommon/vrpathregistry_public.cpp PROPERTIES COMPILE_FLAGS "-x objective-c++") 12 | endif() 13 | if(BUILD_SHARED OR BUILD_FRAMEWORK) 14 | find_library(FOUNDATION_FRAMEWORK Foundation) 15 | mark_as_advanced(FOUNDATION_FRAMEWORK) 16 | set(EXTRA_LIBS ${EXTRA_LIBS} ${FOUNDATION_FRAMEWORK}) 17 | endif(BUILD_SHARED OR BUILD_FRAMEWORK) 18 | elseif(WIN32) 19 | if(CMAKE_SIZEOF_VOID_P EQUAL 8) 20 | add_definitions( -DWIN64 ) 21 | set( LIBNAME "openvr_api64" ) 22 | endif() 23 | endif() 24 | 25 | # Add include folders. 26 | include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../headers ${CMAKE_CURRENT_SOURCE_DIR}/vrcommon) 27 | 28 | if(USE_CUSTOM_LIBCXX) 29 | link_directories( 30 | ${LIBCXX_LIB_DIR} 31 | ) 32 | endif() 33 | 34 | # Set the source group and files. 35 | set(CORE_FILES 36 | openvr_api_public.cpp 37 | jsoncpp.cpp 38 | ) 39 | set(VRCOMMON_FILES 40 | vrcommon/dirtools_public.cpp 41 | vrcommon/envvartools_public.cpp 42 | vrcommon/pathtools_public.cpp 43 | vrcommon/sharedlibtools_public.cpp 44 | vrcommon/hmderrors_public.cpp 45 | vrcommon/vrpathregistry_public.cpp 46 | vrcommon/strtools_public.cpp 47 | ) 48 | 49 | set(SOURCE_FILES 50 | ${CORE_FILES} 51 | ${VRCOMMON_FILES} 52 | ) 53 | 54 | set(PUBLIC_HEADER_FILES 55 | ${OPENVR_HEADER_DIR}/openvr_driver.h 56 | ${OPENVR_HEADER_DIR}/openvr_capi.h 57 | ${OPENVR_HEADER_DIR}/openvr.h 58 | ) 59 | 60 | source_group("Src" FILES 61 | ${CORE_FILES} 62 | ) 63 | 64 | source_group("VRCommon" FILES 65 | ${VRCOMMON_FILES} 66 | ) 67 | 68 | # Build the library. 69 | if(BUILD_SHARED) 70 | add_library(${LIBNAME} SHARED ${SOURCE_FILES}) 71 | elseif(BUILD_FRAMEWORK) 72 | set( LIBNAME "OpenVR" ) 73 | add_library( ${LIBNAME} 74 | SHARED ${SOURCE_FILES} 75 | ${CMAKE_SOURCE_DIR}/headers/openvr.h 76 | ${CMAKE_SOURCE_DIR}/headers/openvr_api.cs 77 | ${CMAKE_SOURCE_DIR}/headers/openvr_api.json 78 | ${CMAKE_SOURCE_DIR}/headers/openvr_capi.h 79 | ${CMAKE_SOURCE_DIR}/headers/openvr_driver.h 80 | ) 81 | set_target_properties(OpenVR PROPERTIES 82 | FRAMEWORK TRUE 83 | FRAMEWORK_VERSION A 84 | MACOSX_FRAMEWORK_IDENTIFIER com.valvesoftware.OpenVR.framework 85 | MACOSX_FRAMEWORK_INFO_PLIST ${CMAKE_SOURCE_DIR}/src/Info.plist 86 | # "current version" in semantic format in Mach-O binary file 87 | VERSION 1.0.6 88 | # "compatibility version" in semantic format in Mach-O binary file 89 | SOVERSION 1.0.0 90 | PUBLIC_HEADER "${CMAKE_SOURCE_DIR}/headers/openvr.h;${CMAKE_SOURCE_DIR}/headers/openvr_api.cs;${CMAKE_SOURCE_DIR}/headers/openvr_api.json;${CMAKE_SOURCE_DIR}/headers/openvr_capi.h;${CMAKE_SOURCE_DIR}/headers/openvr_driver.h" 91 | LINKER_LANGUAGE CXX 92 | ) 93 | else() 94 | add_library(${LIBNAME} STATIC ${SOURCE_FILES}) 95 | endif() 96 | 97 | if(USE_CUSTOM_LIBCXX) 98 | set(EXTRA_LIBS ${EXTRA_LIBS} c++ c++abi) 99 | endif() 100 | 101 | target_link_libraries(${LIBNAME} ${EXTRA_LIBS} ${CMAKE_DL_LIBS}) 102 | target_include_directories(${LIBNAME} PUBLIC ${OPENVR_HEADER_DIR}) 103 | 104 | install(TARGETS ${LIBNAME} DESTINATION lib) 105 | install(FILES ${PUBLIC_HEADER_FILES} DESTINATION include/openvr) 106 | 107 | # Generate a .pc file for linux environments 108 | if(PLATFORM_NAME MATCHES "linux") 109 | set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_PREFIX}/share/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files") 110 | CONFIGURE_FILE("openvr.pc.in" "openvr.pc" @ONLY) 111 | 112 | set(OPENVR_PC ${CMAKE_CURRENT_BINARY_DIR}/openvr.pc) 113 | if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL ) 114 | install(FILES ${OPENVR_PC} DESTINATION "${INSTALL_PKGCONFIG_DIR}") 115 | endif() 116 | endif() 117 | -------------------------------------------------------------------------------- /dependencies/openvr/src/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleIdentifier 6 | com.valvesoftware.OpenVR.framework 7 | CFBundleInfoDictionaryVersion 8 | 6.0 9 | CFBundleName 10 | OpenVR 11 | CFBundlePackageType 12 | FMWK 13 | CFBundleShortVersionString 14 | 1.0 15 | CFBundleVersion 16 | 1.0 17 | 18 | 19 | -------------------------------------------------------------------------------- /dependencies/openvr/src/README: -------------------------------------------------------------------------------- 1 | This is the source code for the OpenVR API client binding library which connects 2 | OpenVR applications to the SteamVR runtime, taking into account the version 3 | of the OpenVR interface they were compiled against. 4 | 5 | The client binding library - openvr_api.dll on Windows, openvr_api.so on 6 | Linux, and openvr_api.dylib or OpenVR.framework on macOS - knows how to find 7 | and read the SteamVR runtime installation information which allows it to 8 | find and dynamically connect to the installed runtime. In combination with the 9 | interface version identifiers from /include/openvr.h which are baked 10 | into applications at the time they are built, the OpenVR API client 11 | binding library captures and conveys to the SteamVR runtime the version 12 | of the OpenVR API interface behavior that the application expects. 13 | 14 | Applications carry with them a private/local copy of the client binding 15 | library when they ship, and they should install it locally to their 16 | application. Applications should not install the client binding library 17 | globally or attempt to link to a globally installed client binding library. 18 | Doing so negates at least part of the ability for the client binding library 19 | to accurately reflect the version of the OpenVR API that the application 20 | was built against, and so hinders compatibility support in the face of 21 | API changes. 22 | 23 | Most applications should simply link to and redistribute with their application 24 | the pre-built client binding library found in the /bin directory of this 25 | repository. Some small number of applications which have specific requirements 26 | around redistributing only binaries they build themselves should build 27 | the client library from this source and either statically link it into 28 | their application or redistribute the binary they build. 29 | 30 | This is a cmake project, to build it use the version of cmake appropriate 31 | for your platform. For example, to build on a POSIX system simply perform 32 | 33 | cd src; mkdir _build; cd _build; cmake ..; make 34 | 35 | and you will end up with the static library /src/bin//libopenvr_api.a 36 | 37 | To build a shared library, pass -DBUILD_SHARED=1 to cmake. 38 | To build as a framework on apple platforms, pass -DBUILD_FRAMEWORK=1 to cmake. 39 | To see a complete list of configurable build options, use `cmake -LAH` 40 | -------------------------------------------------------------------------------- /dependencies/openvr/src/ivrclientcore.h: -------------------------------------------------------------------------------- 1 | //========= Copyright Valve Corporation ============// 2 | #pragma once 3 | 4 | namespace vr 5 | { 6 | 7 | class IVRClientCore 8 | { 9 | public: 10 | /** Initializes the system */ 11 | virtual EVRInitError Init( vr::EVRApplicationType eApplicationType, const char *pStartupInfo ) = 0; 12 | 13 | /** cleans up everything in vrclient.dll and prepares the DLL to be unloaded */ 14 | virtual void Cleanup() = 0; 15 | 16 | /** checks to see if the specified interface/version is supported in this vrclient.dll */ 17 | virtual EVRInitError IsInterfaceVersionValid( const char *pchInterfaceVersion ) = 0; 18 | 19 | /** Retrieves any interface from vrclient.dll */ 20 | virtual void *GetGenericInterface( const char *pchNameAndVersion, EVRInitError *peError ) = 0; 21 | 22 | /** Returns true if any driver has an HMD attached. Can be called outside of Init/Cleanup */ 23 | virtual bool BIsHmdPresent() = 0; 24 | 25 | /** Returns an English error string from inside vrclient.dll which might be newer than the API DLL */ 26 | virtual const char *GetEnglishStringForHmdError( vr::EVRInitError eError ) = 0; 27 | 28 | /** Returns an error symbol from inside vrclient.dll which might be newer than the API DLL */ 29 | virtual const char *GetIDForVRInitError( vr::EVRInitError eError ) = 0; 30 | }; 31 | 32 | static const char * const IVRClientCore_Version = "IVRClientCore_003"; 33 | 34 | 35 | } 36 | -------------------------------------------------------------------------------- /dependencies/openvr/src/openvr.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | exec_prefix=${prefix} 3 | libdir=${prefix}/lib 4 | includedir=${prefix}/include/openvr 5 | 6 | Name: openvr 7 | Description: OpenVR is an API and runtime that allos access to VR hardware. 8 | Version: @OPENVR_VERSION@ 9 | 10 | Libs: -L${libdir} -lopenvr_api -ldl 11 | Cflags: -I${includedir} 12 | -------------------------------------------------------------------------------- /dependencies/openvr/src/vrcommon/dirtools_public.cpp: -------------------------------------------------------------------------------- 1 | //========= Copyright Valve Corporation ============// 2 | #include "dirtools_public.h" 3 | #include "strtools_public.h" 4 | #include "pathtools_public.h" 5 | 6 | #include 7 | #include 8 | 9 | #ifdef _WIN32 10 | #include "windows.h" 11 | #else 12 | #include 13 | #include 14 | #include 15 | #include 16 | #endif 17 | 18 | #if defined( OSX ) 19 | #include 20 | #endif 21 | 22 | 23 | //----------------------------------------------------------------------------- 24 | // Purpose: utility function to create dirs & subdirs 25 | //----------------------------------------------------------------------------- 26 | bool BCreateDirectoryRecursive( const char *pchPath ) 27 | { 28 | // Does it already exist? 29 | if ( Path_IsDirectory( pchPath ) ) 30 | return true; 31 | 32 | // copy the path into something we can munge 33 | int len = (int)strlen( pchPath ); 34 | char *path = (char *)malloc( len + 1 ); 35 | strcpy( path, pchPath ); 36 | 37 | // Walk backwards to first non-existing dir that we find 38 | char *s = path + len - 1; 39 | 40 | const char slash = Path_GetSlash(); 41 | while ( s > path ) 42 | { 43 | if ( *s == slash ) 44 | { 45 | *s = '\0'; 46 | bool bExists = Path_IsDirectory( path ); 47 | *s = slash; 48 | 49 | if ( bExists ) 50 | { 51 | ++s; 52 | break; 53 | } 54 | } 55 | --s; 56 | } 57 | 58 | // and then move forwards from there 59 | 60 | while ( *s ) 61 | { 62 | if ( *s == slash ) 63 | { 64 | *s = '\0'; 65 | BCreateDirectory( path ); 66 | *s = slash; 67 | } 68 | s++; 69 | } 70 | 71 | bool bRetVal = BCreateDirectory( path ); 72 | free( path ); 73 | return bRetVal; 74 | } 75 | 76 | 77 | //----------------------------------------------------------------------------- 78 | // Purpose: Creates the directory, returning true if it is created, or if it already existed 79 | //----------------------------------------------------------------------------- 80 | bool BCreateDirectory( const char *pchPath ) 81 | { 82 | #ifdef WIN32 83 | std::wstring wPath = UTF8to16( pchPath ); 84 | if ( ::CreateDirectoryW( wPath.c_str(), NULL ) ) 85 | return true; 86 | 87 | if ( ::GetLastError() == ERROR_ALREADY_EXISTS ) 88 | return true; 89 | 90 | return false; 91 | #else 92 | int i = mkdir( pchPath, S_IRWXU | S_IRWXG | S_IRWXO ); 93 | if ( i == 0 ) 94 | return true; 95 | if ( errno == EEXIST ) 96 | return true; 97 | 98 | return false; 99 | #endif 100 | } 101 | 102 | -------------------------------------------------------------------------------- /dependencies/openvr/src/vrcommon/dirtools_public.h: -------------------------------------------------------------------------------- 1 | //========= Copyright Valve Corporation ============// 2 | #pragma once 3 | 4 | #include 5 | #include 6 | 7 | 8 | #if !defined(_WIN32) 9 | #include 10 | #include 11 | #endif 12 | 13 | 14 | extern bool BCreateDirectoryRecursive( const char *pchPath ); 15 | extern bool BCreateDirectory( const char *pchPath ); 16 | 17 | 18 | -------------------------------------------------------------------------------- /dependencies/openvr/src/vrcommon/envvartools_public.cpp: -------------------------------------------------------------------------------- 1 | //========= Copyright Valve Corporation ============// 2 | #include "envvartools_public.h" 3 | #include "strtools_public.h" 4 | #include 5 | #include 6 | #include 7 | 8 | #if defined(_WIN32) 9 | #include 10 | 11 | #undef GetEnvironmentVariable 12 | #undef SetEnvironmentVariable 13 | #endif 14 | 15 | 16 | std::string GetEnvironmentVariable( const char *pchVarName ) 17 | { 18 | #if defined(_WIN32) 19 | char rchValue[32767]; // max size for an env var on Windows 20 | DWORD cChars = GetEnvironmentVariableA( pchVarName, rchValue, sizeof( rchValue ) ); 21 | if( cChars == 0 ) 22 | return ""; 23 | else 24 | return rchValue; 25 | #elif defined(POSIX) 26 | char *pchValue = getenv( pchVarName ); 27 | if( pchValue ) 28 | return pchValue; 29 | else 30 | return ""; 31 | #else 32 | #error "Unsupported Platform" 33 | #endif 34 | } 35 | 36 | bool GetEnvironmentVariableAsBool( const char *pchVarName, bool bDefault ) 37 | { 38 | std::string sValue = GetEnvironmentVariable( pchVarName ); 39 | 40 | if ( sValue.empty() ) 41 | { 42 | return bDefault; 43 | } 44 | 45 | sValue = StringToLower( sValue ); 46 | std::string sYesValues[] = { "y", "yes", "true" }; 47 | std::string sNoValues[] = { "n", "no", "false" }; 48 | 49 | for ( std::string &sMatch : sYesValues ) 50 | { 51 | if ( sMatch == sValue ) 52 | { 53 | return true; 54 | } 55 | } 56 | 57 | for ( std::string &sMatch : sNoValues ) 58 | { 59 | if ( sMatch == sValue ) 60 | { 61 | return false; 62 | } 63 | } 64 | 65 | if ( std::isdigit( sValue.at(0) ) ) 66 | { 67 | return atoi( sValue.c_str() ) != 0; 68 | } 69 | 70 | fprintf( stderr, 71 | "GetEnvironmentVariableAsBool(%s): Unable to parse value '%s', using default %d\n", 72 | pchVarName, sValue.c_str(), bDefault ); 73 | return bDefault; 74 | } 75 | 76 | bool SetEnvironmentVariable( const char *pchVarName, const char *pchVarValue ) 77 | { 78 | #if defined(_WIN32) 79 | return 0 != SetEnvironmentVariableA( pchVarName, pchVarValue ); 80 | #elif defined(POSIX) 81 | if( pchVarValue == NULL ) 82 | return 0 == unsetenv( pchVarName ); 83 | else 84 | return 0 == setenv( pchVarName, pchVarValue, 1 ); 85 | #else 86 | #error "Unsupported Platform" 87 | #endif 88 | } 89 | -------------------------------------------------------------------------------- /dependencies/openvr/src/vrcommon/envvartools_public.h: -------------------------------------------------------------------------------- 1 | //========= Copyright Valve Corporation ============// 2 | #pragma once 3 | 4 | #include 5 | 6 | std::string GetEnvironmentVariable( const char *pchVarName ); 7 | bool GetEnvironmentVariableAsBool( const char *pchVarName, bool bDefault ); 8 | bool SetEnvironmentVariable( const char *pchVarName, const char *pchVarValue ); 9 | -------------------------------------------------------------------------------- /dependencies/openvr/src/vrcommon/hmderrors_public.h: -------------------------------------------------------------------------------- 1 | //========= Copyright Valve Corporation ============// 2 | #pragma once 3 | 4 | const char *GetEnglishStringForHmdError( vr::EVRInitError eError ); 5 | const char *GetIDForVRInitError( vr::EVRInitError eError ); 6 | 7 | -------------------------------------------------------------------------------- /dependencies/openvr/src/vrcommon/sharedlibtools_public.cpp: -------------------------------------------------------------------------------- 1 | //========= Copyright Valve Corporation ============// 2 | #include "sharedlibtools_public.h" 3 | #include 4 | 5 | #if defined(_WIN32) 6 | #include 7 | #endif 8 | 9 | #if defined(POSIX) 10 | #include 11 | #endif 12 | 13 | 14 | SharedLibHandle SharedLib_Load( const char *pchPath, uint32_t *pErrorCode ) 15 | { 16 | SharedLibHandle pHandle = nullptr; 17 | #if defined( _WIN32) 18 | pHandle = ( SharedLibHandle )LoadLibraryEx( pchPath, NULL, LOAD_WITH_ALTERED_SEARCH_PATH ); 19 | #elif defined(POSIX) 20 | pHandle = (SharedLibHandle) dlopen(pchPath, RTLD_LOCAL|RTLD_NOW); 21 | #endif 22 | 23 | if ( pErrorCode ) 24 | { 25 | if ( pHandle == nullptr ) 26 | { 27 | #if defined( _WIN32) 28 | *pErrorCode = ( uint32_t ) GetLastError(); 29 | #elif defined(POSIX) 30 | *pErrorCode = 1; 31 | #endif 32 | } 33 | else 34 | { 35 | *pErrorCode = 0; 36 | } 37 | } 38 | 39 | return pHandle; 40 | } 41 | 42 | void *SharedLib_GetFunction( SharedLibHandle lib, const char *pchFunctionName) 43 | { 44 | #if defined( _WIN32) 45 | return (void*)GetProcAddress( (HMODULE)lib, pchFunctionName ); 46 | #elif defined(POSIX) 47 | return dlsym( lib, pchFunctionName ); 48 | #endif 49 | } 50 | 51 | 52 | void SharedLib_Unload( SharedLibHandle lib ) 53 | { 54 | if ( !lib ) 55 | return; 56 | #if defined( _WIN32) 57 | FreeLibrary( (HMODULE)lib ); 58 | #elif defined(POSIX) 59 | dlclose( lib ); 60 | #endif 61 | } 62 | 63 | 64 | -------------------------------------------------------------------------------- /dependencies/openvr/src/vrcommon/sharedlibtools_public.h: -------------------------------------------------------------------------------- 1 | //========= Copyright Valve Corporation ============// 2 | #pragma once 3 | 4 | #include 5 | 6 | typedef void *SharedLibHandle; 7 | 8 | SharedLibHandle SharedLib_Load( const char *pchPath, uint32_t *pErrorCode = nullptr ); 9 | void *SharedLib_GetFunction( SharedLibHandle lib, const char *pchFunctionName); 10 | void SharedLib_Unload( SharedLibHandle lib ); 11 | 12 | 13 | -------------------------------------------------------------------------------- /dependencies/openvr/src/vrcommon/vrpathregistry_public.h: -------------------------------------------------------------------------------- 1 | //========= Copyright Valve Corporation ============// 2 | #pragma once 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | static const char *k_pchRuntimeOverrideVar = "VR_OVERRIDE"; 9 | static const char *k_pchConfigOverrideVar = "VR_CONFIG_PATH"; 10 | static const char *k_pchLogOverrideVar = "VR_LOG_PATH"; 11 | 12 | static const uint32_t k_unSteamVRAppId = 250820; 13 | static const uint32_t k_unSteamVRMainAppId = 330050; 14 | 15 | 16 | class CVRPathRegistry_Public 17 | { 18 | public: 19 | static std::string GetVRPathRegistryFilename(); 20 | static std::string GetOpenVRConfigPath(); 21 | static uint32_t GetSteamAppId(); 22 | static bool IsSteamVRMain(); 23 | static uint32_t InitSteamAppId(); 24 | 25 | public: 26 | CVRPathRegistry_Public(); 27 | 28 | /** Returns paths using the path registry and the provided override values. Pass NULL for any paths you don't care about. 29 | * Returns false if the path registry could not be read. Valid paths might still be returned based on environment variables. */ 30 | static bool GetPaths( std::string *psRuntimePath, std::string *psConfigPath, std::string *psLogPath, const char *pchConfigPathOverride, const char *pchLogPathOverride, std::vector *pvecExternalDrivers = NULL ); 31 | 32 | bool BLoadFromFile( std::string *psError = nullptr ); 33 | bool BSaveToFile() const; 34 | 35 | bool ToJsonString( std::string &sJsonString ); 36 | 37 | // methods to get the current values 38 | std::string GetRuntimePath() const; 39 | std::string GetConfigPath() const; 40 | std::string GetLogPath() const; 41 | 42 | protected: 43 | typedef std::vector< std::string > StringVector_t; 44 | 45 | // index 0 is the current setting 46 | StringVector_t m_vecRuntimePath; 47 | StringVector_t m_vecLogPath; 48 | StringVector_t m_vecConfigPath; 49 | 50 | // full list of external drivers 51 | StringVector_t m_vecExternalDrivers; 52 | }; 53 | -------------------------------------------------------------------------------- /dependencies/sol2/LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013-2022 Rapptz, ThePhD, and contributors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /dependencies/sol2/single/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # # # # sol3 2 | # The MIT License (MIT) 3 | # 4 | # Copyright (c) 2013-2019 Rapptz, ThePhD, and contributors 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | # this software and associated documentation files (the "Software"), to deal in 8 | # the Software without restriction, including without limitation the rights to 9 | # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | # the Software, and to permit persons to whom the Software is furnished to do so, 11 | # subject to the following conditions: 12 | # 13 | # The above copyright notice and this permission notice shall be included in all 14 | # copies or substantial portions of the Software. 15 | # 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | 23 | # # # # sol3, single 24 | # # # Required minimum version statement 25 | cmake_minimum_required(VERSION 3.15.0) 26 | 27 | find_package(PythonInterp 3 REQUIRED) 28 | 29 | # to generate, need all of the existing header files 30 | file(GLOB sol2_generated_header_sources ${CMAKE_CURRENT_SOURCE_DIR}/../include/**/*.*) 31 | 32 | # generate the single header if we can find the python3 interpreter 33 | add_custom_command( 34 | COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/include/sol" 35 | COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/single.py" --input "${CMAKE_CURRENT_SOURCE_DIR}/../include" --output "${CMAKE_CURRENT_BINARY_DIR}/include/sol/sol.hpp" 36 | DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/single.py" "${sol2_generated_header_sources}" 37 | OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/include/sol/sol.hpp" "${CMAKE_CURRENT_BINARY_DIR}/include/sol/forward.hpp") 38 | add_custom_target(sol2_single_header_generator ALL 39 | DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/single.py" 40 | "${CMAKE_CURRENT_BINARY_DIR}/include/sol/sol.hpp" "${CMAKE_CURRENT_BINARY_DIR}/include/sol/forward.hpp" 41 | "${sol2_generated_header_sources}") 42 | 43 | # # # sol3 generated single header library 44 | add_library(sol2_single INTERFACE) 45 | add_library(sol2::sol2::single ALIAS sol2_single) 46 | set_target_properties(sol2_single 47 | PROPERTIES 48 | EXPORT_NAME sol2::sol2::single 49 | INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/include") 50 | add_dependencies(sol2_single sol2_single_header_generator) 51 | 52 | if(SOL2_ENABLE_INSTALL) 53 | install(FILES "${CMAKE_CURRENT_BINARY_DIR}/include/sol/sol.hpp" "${CMAKE_CURRENT_BINARY_DIR}/include/sol/config.hpp" "${CMAKE_CURRENT_BINARY_DIR}/include/sol/forward.hpp" 54 | DESTINATION include/sol/single/sol) 55 | endif() 56 | -------------------------------------------------------------------------------- /dependencies/sol2/single/single/include/sol/config.hpp: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | 3 | // Copyright (c) 2013-2020 Rapptz, ThePhD and contributors 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files (the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | // This file was generated with a script. 23 | // Generated 2023-02-10 06:03:41.704702 UTC 24 | // This header was generated with sol (revision d2a6772) 25 | // https://github.com/ThePhD/sol2 26 | 27 | #ifndef SOL_SINGLE_CONFIG_HPP 28 | #define SOL_SINGLE_CONFIG_HPP 29 | 30 | // beginning of sol/config.hpp 31 | 32 | /* Base, empty configuration file! 33 | 34 | To override, place a file in your include paths of the form: 35 | 36 | . (your include path here) 37 | | sol (directory, or equivalent) 38 | | config.hpp (your config.hpp file) 39 | 40 | So that when sol2 includes the file 41 | 42 | #include 43 | 44 | it gives you the configuration values you desire. Configuration values can be 45 | seen in the safety.rst of the doc/src, or at 46 | https://sol2.readthedocs.io/en/latest/safety.html ! You can also pass them through 47 | the build system, or the command line options of your compiler. 48 | 49 | */ 50 | 51 | // end of sol/config.hpp 52 | 53 | #endif // SOL_SINGLE_CONFIG_HPP 54 | -------------------------------------------------------------------------------- /examples/LICENSE: -------------------------------------------------------------------------------- 1 | This license governs the files in this directory ("examples"), its subdirectories, and is separate from the license for the rest of the UEVR codebase. 2 | 3 | The MIT License 4 | 5 | Copyright (c) 2023 praydog 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. -------------------------------------------------------------------------------- /examples/renderlib/imgui/imgui_impl_dx11.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Renderer Backend for DirectX11 2 | // This needs to be used along with a Platform Backend (e.g. Win32) 3 | 4 | // Implemented features: 5 | // [X] Renderer: User texture binding. Use 'ID3D11ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID! 6 | // [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices. 7 | 8 | // You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. 9 | // If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. 10 | // Read online: https://github.com/ocornut/imgui/tree/master/docs 11 | 12 | #pragma once 13 | #include "imgui.h" // IMGUI_IMPL_API 14 | 15 | struct ID3D11Device; 16 | struct ID3D11DeviceContext; 17 | 18 | IMGUI_IMPL_API bool ImGui_ImplDX11_Init(ID3D11Device* device, ID3D11DeviceContext* device_context); 19 | IMGUI_IMPL_API void ImGui_ImplDX11_Shutdown(); 20 | IMGUI_IMPL_API void ImGui_ImplDX11_NewFrame(); 21 | IMGUI_IMPL_API void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data); 22 | 23 | // Use if you want to reset your rendering device without losing Dear ImGui state. 24 | IMGUI_IMPL_API void ImGui_ImplDX11_InvalidateDeviceObjects(); 25 | IMGUI_IMPL_API bool ImGui_ImplDX11_CreateDeviceObjects(); -------------------------------------------------------------------------------- /examples/renderlib/imgui/imgui_impl_dx12.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Renderer Backend for DirectX12 2 | // This needs to be used along with a Platform Backend (e.g. Win32) 3 | 4 | // Implemented features: 5 | // [X] Renderer: User texture binding. Use 'D3D12_GPU_DESCRIPTOR_HANDLE' as ImTextureID. Read the FAQ about ImTextureID! 6 | // [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices. 7 | 8 | // Important: to compile on 32-bit systems, this backend requires code to be compiled with '#define ImTextureID ImU64'. 9 | // This is because we need ImTextureID to carry a 64-bit value and by default ImTextureID is defined as void*. 10 | // This define is set in the example .vcxproj file and need to be replicated in your app or by adding it to your imconfig.h file. 11 | 12 | // You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. 13 | // If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. 14 | // Read online: https://github.com/ocornut/imgui/tree/master/docs 15 | 16 | #pragma once 17 | #include "imgui.h" // IMGUI_IMPL_API 18 | 19 | #ifdef _MSC_VER 20 | #pragma warning (push) 21 | #pragma warning (disable: 4471) // a forward declaration of an unscoped enumeration must have an underlying type 22 | #endif 23 | 24 | enum DXGI_FORMAT; 25 | struct ID3D12Device; 26 | struct ID3D12DescriptorHeap; 27 | struct ID3D12GraphicsCommandList; 28 | struct D3D12_CPU_DESCRIPTOR_HANDLE; 29 | struct D3D12_GPU_DESCRIPTOR_HANDLE; 30 | 31 | // cmd_list is the command list that the implementation will use to render imgui draw lists. 32 | // Before calling the render function, caller must prepare cmd_list by resetting it and setting the appropriate 33 | // render target and descriptor heap that contains font_srv_cpu_desc_handle/font_srv_gpu_desc_handle. 34 | // font_srv_cpu_desc_handle and font_srv_gpu_desc_handle are handles to a single SRV descriptor to use for the internal font texture. 35 | IMGUI_IMPL_API bool ImGui_ImplDX12_Init(ID3D12Device* device, int num_frames_in_flight, DXGI_FORMAT rtv_format, ID3D12DescriptorHeap* cbv_srv_heap, 36 | D3D12_CPU_DESCRIPTOR_HANDLE font_srv_cpu_desc_handle, D3D12_GPU_DESCRIPTOR_HANDLE font_srv_gpu_desc_handle); 37 | IMGUI_IMPL_API void ImGui_ImplDX12_Shutdown(); 38 | IMGUI_IMPL_API void ImGui_ImplDX12_NewFrame(); 39 | IMGUI_IMPL_API void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data, ID3D12GraphicsCommandList* graphics_command_list); 40 | 41 | // Use if you want to reset your rendering device without losing Dear ImGui state. 42 | IMGUI_IMPL_API void ImGui_ImplDX12_InvalidateDeviceObjects(); 43 | IMGUI_IMPL_API bool ImGui_ImplDX12_CreateDeviceObjects(); 44 | 45 | #ifdef _MSC_VER 46 | #pragma warning (pop) 47 | #endif -------------------------------------------------------------------------------- /examples/renderlib/imgui/imgui_impl_win32.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Platform Backend for Windows (standard windows API for 32 and 64 bits applications) 2 | // This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..) 3 | 4 | // Implemented features: 5 | // [X] Platform: Clipboard support (for Win32 this is actually part of core dear imgui) 6 | // [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. 7 | // [X] Platform: Keyboard arrays indexed using VK_* Virtual Key Codes, e.g. ImGui::IsKeyPressed(VK_SPACE). 8 | // [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. 9 | 10 | // You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. 11 | // If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. 12 | // Read online: https://github.com/ocornut/imgui/tree/master/docs 13 | 14 | #pragma once 15 | #include "imgui.h" // IMGUI_IMPL_API 16 | #include 17 | 18 | IMGUI_IMPL_API bool ImGui_ImplWin32_Init(void* hwnd); 19 | IMGUI_IMPL_API void ImGui_ImplWin32_Shutdown(); 20 | IMGUI_IMPL_API void ImGui_ImplWin32_NewFrame(); 21 | 22 | // Win32 message handler your application need to call. 23 | // - Intentionally commented out in a '#if 0' block to avoid dragging dependencies on from this helper. 24 | // - You should COPY the line below into your .cpp code to forward declare the function and then you can call it. 25 | // #if 0 26 | IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); 27 | // #endif 28 | 29 | // DPI-related helpers (optional) 30 | // - Use to enable DPI awareness without having to create an application manifest. 31 | // - Your own app may already do this via a manifest or explicit calls. This is mostly useful for our examples/ apps. 32 | // - In theory we could call simple functions from Windows SDK such as SetProcessDPIAware(), SetProcessDpiAwareness(), etc. 33 | // but most of the functions provided by Microsoft require Windows 8.1/10+ SDK at compile time and Windows 8/10+ at runtime, 34 | // neither we want to require the user to have. So we dynamically select and load those functions to avoid dependencies. 35 | IMGUI_IMPL_API void ImGui_ImplWin32_EnableDpiAwareness(); 36 | IMGUI_IMPL_API float ImGui_ImplWin32_GetDpiScaleForHwnd(void* hwnd); // HWND hwnd 37 | IMGUI_IMPL_API float ImGui_ImplWin32_GetDpiScaleForMonitor(void* monitor); // HMONITOR monitor 38 | 39 | // Transparency related helpers (optional) [experimental] 40 | // - Use to enable alpha compositing transparency with the desktop. 41 | // - Use together with e.g. clearing your framebuffer with zero-alpha. 42 | IMGUI_IMPL_API void ImGui_ImplWin32_EnableAlphaCompositing(void* hwnd); // HWND hwnd 43 | 44 | namespace imgui { 45 | void reset_keystates(); 46 | } -------------------------------------------------------------------------------- /examples/renderlib/rendering/d3d11.cpp: -------------------------------------------------------------------------------- 1 | #include "uevr/API.hpp" 2 | #include "../imgui/imgui_impl_dx11.h" 3 | 4 | #include "d3d11.hpp" 5 | 6 | D3D11 g_d3d11{}; 7 | 8 | bool D3D11::initialize() { 9 | const auto renderer_data = uevr::API::get()->param()->renderer; 10 | auto swapchain = (IDXGISwapChain*)renderer_data->swapchain; 11 | auto device = (ID3D11Device*)renderer_data->device; 12 | 13 | // Get back buffer. 14 | ComPtr backbuffer{}; 15 | 16 | if (FAILED(swapchain->GetBuffer(0, IID_PPV_ARGS(&backbuffer)))) { 17 | return false; 18 | } 19 | 20 | // Create a render target view of the back buffer. 21 | if (FAILED(device->CreateRenderTargetView(backbuffer.Get(), nullptr, &this->bb_rtv))) { 22 | return false; 23 | } 24 | 25 | // Get backbuffer description. 26 | D3D11_TEXTURE2D_DESC backbuffer_desc{}; 27 | 28 | backbuffer->GetDesc(&backbuffer_desc); 29 | 30 | backbuffer_desc.BindFlags |= D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE; 31 | 32 | // Create our render target. 33 | if (FAILED(device->CreateTexture2D(&backbuffer_desc, nullptr, &this->rt))) { 34 | return false; 35 | } 36 | 37 | // Create our render target view. 38 | if (FAILED(device->CreateRenderTargetView(this->rt.Get(), nullptr, &this->rt_rtv))) { 39 | return false; 40 | } 41 | 42 | // Create our render target shader resource view. 43 | if (FAILED(device->CreateShaderResourceView(this->rt.Get(), nullptr, &this->rt_srv))) { 44 | return false; 45 | } 46 | 47 | this->rt_width = backbuffer_desc.Width; 48 | this->rt_height = backbuffer_desc.Height; 49 | 50 | ComPtr context{}; 51 | 52 | device->GetImmediateContext(&context); 53 | 54 | if (!ImGui_ImplDX11_Init(device, context.Get())) { 55 | return false; 56 | } 57 | 58 | return true; 59 | } 60 | 61 | void D3D11::render_imgui() { 62 | auto draw_data = ImGui::GetDrawData(); 63 | 64 | if (draw_data == nullptr) { 65 | return; 66 | } 67 | 68 | ComPtr context{}; 69 | float clear_color[]{0.0f, 0.0f, 0.0f, 0.0f}; 70 | 71 | const auto renderer_data = uevr::API::get()->param()->renderer; 72 | auto device = (ID3D11Device*)renderer_data->device; 73 | device->GetImmediateContext(&context); 74 | context->ClearRenderTargetView(this->rt_rtv.Get(), clear_color); 75 | context->OMSetRenderTargets(1, this->rt_rtv.GetAddressOf(), NULL); 76 | ImGui_ImplDX11_RenderDrawData(draw_data); 77 | 78 | // Set the back buffer to be the render target. 79 | context->OMSetRenderTargets(1, this->bb_rtv.GetAddressOf(), nullptr); 80 | ImGui_ImplDX11_RenderDrawData(draw_data); 81 | } 82 | 83 | void D3D11::render_imgui_vr(ID3D11DeviceContext* context, ID3D11RenderTargetView* rtv) { 84 | if (context == nullptr || rtv == nullptr) { 85 | return; 86 | } 87 | 88 | auto draw_data = ImGui::GetDrawData(); 89 | if (draw_data == nullptr) { 90 | return; 91 | } 92 | 93 | context->OMSetRenderTargets(1, &rtv, NULL); 94 | ImGui_ImplDX11_RenderDrawData(draw_data); 95 | } 96 | -------------------------------------------------------------------------------- /examples/renderlib/rendering/d3d11.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "shared.hpp" 5 | 6 | struct D3D11 { 7 | ComPtr rt{}; 8 | ComPtr rt_rtv{}; 9 | ComPtr rt_srv{}; 10 | uint32_t rt_width{}; 11 | uint32_t rt_height{}; 12 | ComPtr bb_rtv{}; 13 | 14 | bool initialize(); 15 | void render_imgui(); 16 | void render_imgui_vr(ID3D11DeviceContext* context, ID3D11RenderTargetView* rtv); 17 | }; 18 | 19 | extern D3D11 g_d3d11; -------------------------------------------------------------------------------- /examples/renderlib/rendering/d3d12.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | #include "shared.hpp" 9 | 10 | struct D3D12 { 11 | struct Cmd { 12 | ComPtr allocator{}; 13 | ComPtr list{}; 14 | ComPtr fence{}; 15 | UINT64 fence_value{}; 16 | HANDLE fence_event{}; 17 | }; 18 | 19 | enum class RTV : int{ 20 | BACKBUFFER_0, 21 | BACKBUFFER_1, 22 | BACKBUFFER_2, 23 | BACKBUFFER_3, 24 | IMGUI, 25 | BLANK, 26 | COUNT, 27 | }; 28 | 29 | enum class SRV : int { 30 | IMGUI_FONT, 31 | IMGUI, 32 | BLANK, 33 | COUNT 34 | }; 35 | 36 | void reset() { 37 | for (auto& cmd : cmds) { 38 | if (cmd.fence != nullptr && cmd.fence->GetCompletedValue() < cmd.fence_value) { 39 | WaitForSingleObject(cmd.fence_event, 2000); 40 | ResetEvent(cmd.fence_event); 41 | } 42 | 43 | cmd.fence_value = 0; 44 | cmd.fence_event = 0; 45 | cmd.allocator.Reset(); 46 | cmd.list.Reset(); 47 | cmd.fence.Reset(); 48 | } 49 | } 50 | 51 | ~D3D12() { this->reset(); } 52 | 53 | std::array cmds{}; 54 | size_t frame_count{}; 55 | 56 | ComPtr rtv_desc_heap{}; 57 | ComPtr srv_desc_heap{}; 58 | ComPtr rts[(int)RTV::COUNT]{}; 59 | 60 | auto& get_rt(RTV rtv) { return rts[(int)rtv]; } 61 | 62 | D3D12_CPU_DESCRIPTOR_HANDLE get_cpu_rtv(ID3D12Device* device, RTV rtv) { 63 | return {rtv_desc_heap->GetCPUDescriptorHandleForHeapStart().ptr + 64 | (int)rtv * device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV)}; 65 | } 66 | 67 | D3D12_CPU_DESCRIPTOR_HANDLE get_cpu_srv(ID3D12Device* device, SRV srv) { 68 | return {srv_desc_heap->GetCPUDescriptorHandleForHeapStart().ptr + 69 | (int)srv * device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV)}; 70 | } 71 | 72 | D3D12_GPU_DESCRIPTOR_HANDLE get_gpu_srv(ID3D12Device* device, SRV srv) { 73 | return {srv_desc_heap->GetGPUDescriptorHandleForHeapStart().ptr + 74 | (int)srv * device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV)}; 75 | } 76 | 77 | uint32_t rt_width{}; 78 | uint32_t rt_height{}; 79 | 80 | bool initialize(); 81 | void render_imgui(); 82 | void render_imgui_vr(ID3D12GraphicsCommandList* command_list, D3D12_CPU_DESCRIPTOR_HANDLE* rtv); 83 | }; 84 | 85 | extern D3D12 g_d3d12; 86 | -------------------------------------------------------------------------------- /examples/renderlib/rendering/shared.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | template using ComPtr = Microsoft::WRL::ComPtr; -------------------------------------------------------------------------------- /include/LICENSE: -------------------------------------------------------------------------------- 1 | This license governs the files in this directory ("include"), its subdirectories, and is separate from the license for the rest of the UEVR codebase. 2 | 3 | The MIT License 4 | 5 | Copyright (c) 2023 praydog 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. -------------------------------------------------------------------------------- /lua-api/Main.cpp: -------------------------------------------------------------------------------- 1 | // Lua API to expose UEVR functionality to Lua scripts via UE4SS 2 | 3 | #include 4 | #include "ScriptContext.hpp" 5 | 6 | // Main exported function that takes in the lua_State* 7 | extern "C" __declspec(dllexport) int luaopen_LuaVR(lua_State* L) { 8 | luaL_checkversion(L); 9 | 10 | ScriptContext::log("Initializing LuaVR..."); 11 | 12 | auto script_context = ScriptContext::reinitialize(L); 13 | 14 | if (!script_context->valid()) { 15 | ScriptContext::log("LuaVR failed to initialize! Make sure to inject VR first!"); 16 | return 0; 17 | } 18 | 19 | ScriptContext::log("LuaVR initialized!"); 20 | 21 | return script_context->setup_bindings(); 22 | } 23 | 24 | BOOL APIENTRY DllMain(HMODULE module, DWORD ul_reason_for_call, LPVOID reserved) { 25 | switch (ul_reason_for_call) { 26 | case DLL_PROCESS_ATTACH: 27 | break; 28 | case DLL_THREAD_ATTACH: 29 | break; 30 | case DLL_THREAD_DETACH: 31 | break; 32 | case DLL_PROCESS_DETACH: 33 | break; 34 | } 35 | return TRUE; 36 | } -------------------------------------------------------------------------------- /lua-api/ScriptContext.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | class ScriptContext { 12 | public: 13 | static std::shared_ptr get(); 14 | static std::shared_ptr reinitialize(lua_State* l, UEVR_PluginInitializeParam* param = nullptr); 15 | 16 | ScriptContext(lua_State* l, UEVR_PluginInitializeParam* param = nullptr); 17 | 18 | virtual ~ScriptContext(); 19 | 20 | int setup_bindings(); 21 | void setup_callback_bindings(); 22 | 23 | bool valid() { 24 | return m_plugin_initialize_param != nullptr; 25 | } 26 | 27 | auto& lua() { 28 | return m_lua; 29 | } 30 | 31 | UEVR_PluginInitializeParam* plugin_initialize_param() { 32 | return m_plugin_initialize_param; 33 | } 34 | 35 | sol::protected_function_result handle_protected_result(sol::protected_function_result result) { 36 | if (result.valid()) { 37 | return result; 38 | } 39 | 40 | sol::script_default_on_error(m_lua.lua_state(), std::move(result)); 41 | return result; 42 | } 43 | 44 | static void log(const std::string& message); 45 | static void test_function(); 46 | 47 | template 48 | void add_callback(T1&& adder, T2&& cb) { 49 | std::scoped_lock _{m_mtx}; 50 | 51 | if (m_plugin_initialize_param != nullptr) { 52 | adder(cb); 53 | m_callbacks_to_remove.push_back((void*)cb); 54 | } 55 | } 56 | 57 | private: 58 | std::vector m_callbacks_to_remove{}; 59 | 60 | sol::state_view m_lua; 61 | std::recursive_mutex m_mtx{}; 62 | UEVR_PluginInitializeParam* m_plugin_initialize_param{nullptr}; 63 | std::vector m_on_pre_engine_tick_callbacks{}; 64 | std::vector m_on_post_engine_tick_callbacks{}; 65 | std::vector m_on_pre_slate_draw_window_render_thread_callbacks{}; 66 | std::vector m_on_post_slate_draw_window_render_thread_callbacks{}; 67 | std::vector m_on_pre_calculate_stereo_view_offset_callbacks{}; 68 | std::vector m_on_post_calculate_stereo_view_offset_callbacks{}; 69 | std::vector m_on_pre_viewport_client_draw_callbacks{}; 70 | std::vector m_on_post_viewport_client_draw_callbacks{}; 71 | 72 | static void on_pre_engine_tick(UEVR_UGameEngineHandle engine, float delta_seconds); 73 | static void on_post_engine_tick(UEVR_UGameEngineHandle engine, float delta_seconds); 74 | static void on_pre_slate_draw_window_render_thread(UEVR_FSlateRHIRendererHandle renderer, UEVR_FViewportInfoHandle viewport_info); 75 | static void on_post_slate_draw_window_render_thread(UEVR_FSlateRHIRendererHandle renderer, UEVR_FViewportInfoHandle viewport_info); 76 | static void on_pre_calculate_stereo_view_offset(UEVR_StereoRenderingDeviceHandle device, int view_index, float world_to_meters, UEVR_Vector3f* position, UEVR_Rotatorf* rotation, bool is_double); 77 | static void on_post_calculate_stereo_view_offset(UEVR_StereoRenderingDeviceHandle device, int view_index, float world_to_meters, UEVR_Vector3f* position, UEVR_Rotatorf* rotation, bool is_double); 78 | static void on_pre_viewport_client_draw(UEVR_UGameViewportClientHandle viewport_client, UEVR_FViewportHandle viewport, UEVR_FCanvasHandle canvas); 79 | static void on_post_viewport_client_draw(UEVR_UGameViewportClientHandle viewport_client, UEVR_FViewportHandle viewport, UEVR_FCanvasHandle canvas); 80 | }; -------------------------------------------------------------------------------- /nightly-body.md: -------------------------------------------------------------------------------- 1 | ## Installation and quick usage 2 | 3 | Extract the UEVR.zip to a folder of your choice, then: 4 | 5 | 1. Launch the frontend GUI (UEVRInjector.exe) 6 | 2. Launch the target game 7 | 3. Locate the game in the process dropdown list 8 | 4. Select your desired runtime (OpenVR/OpenXR) 9 | 5. Toggle existing VR plugin nullification (if necessary) 10 | 6. Configure pre-injection settings 11 | 7. Inject 12 | 13 | More information and troubleshooting can be found on the [Documentation](https://praydog.github.io/uevr-docs/) page. 14 | 15 | ## Additional notes 16 | 17 | You may need to whitelist the UEVR folder or executable within your antivirus software for the time being. 18 | 19 | If nothing happens, try moving UEVR to a different folder. 20 | 21 | # Links 22 | [Main repository](https://github.com/praydog/UEVR) 23 | 24 | [Website](http://uevr.io) 25 | 26 | [Documentation](https://praydog.github.io/uevr-docs/) 27 | 28 | [Flatscreen to VR Modding Discord](http://flat2vr.com) 29 | 30 | [Donations](https://www.patreon.com/praydog) -------------------------------------------------------------------------------- /side-projects/sdk-test/Main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | #include 12 | 13 | #define SPAWN_CONSOLE 14 | 15 | void startup_thread() { 16 | // Spawn a debug console 17 | #ifdef SPAWN_CONSOLE 18 | AllocConsole(); 19 | freopen("CONOUT$", "w", stdout); 20 | #endif 21 | 22 | // Set up spdlog to sink to the console 23 | spdlog::set_pattern("[%H:%M:%S] [%^%l%$] [iostore-standalone] %v"); 24 | spdlog::set_level(spdlog::level::info); 25 | spdlog::flush_on(spdlog::level::info); 26 | spdlog::set_default_logger(spdlog::stdout_logger_mt("console")); 27 | 28 | SPDLOG_INFO("Test!"); 29 | 30 | sdk::FName::get_constructor(); 31 | sdk::FName::get_to_string(); 32 | sdk::FUObjectArray::get(); 33 | 34 | SPDLOG_INFO("Test finished!"); 35 | } 36 | 37 | BOOL APIENTRY DllMain(HMODULE module, DWORD reason_for_call, LPVOID reserved) { 38 | switch (reason_for_call) 39 | { 40 | case DLL_PROCESS_ATTACH: 41 | //CreateThread(nullptr, 0, (LPTHREAD_START_ROUTINE)startup_thread, nullptr, 0, nullptr); 42 | startup_thread(); 43 | break; 44 | } 45 | 46 | return TRUE; 47 | } -------------------------------------------------------------------------------- /src/ExceptionHandler.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include "Framework.hpp" 12 | 13 | #include "ExceptionHandler.hpp" 14 | 15 | LONG WINAPI framework::global_exception_handler(struct _EXCEPTION_POINTERS* ei) { 16 | spdlog::flush_on(spdlog::level::err); 17 | 18 | spdlog::error("Exception occurred: {:x}", ei->ExceptionRecord->ExceptionCode); 19 | spdlog::error("RIP: {:x}", ei->ContextRecord->Rip); 20 | spdlog::error("RSP: {:x}", ei->ContextRecord->Rsp); 21 | spdlog::error("RCX: {:x}", ei->ContextRecord->Rcx); 22 | spdlog::error("RDX: {:x}", ei->ContextRecord->Rdx); 23 | spdlog::error("R8: {:x}", ei->ContextRecord->R8); 24 | spdlog::error("R9: {:x}", ei->ContextRecord->R9); 25 | spdlog::error("R10: {:x}", ei->ContextRecord->R10); 26 | spdlog::error("R11: {:x}", ei->ContextRecord->R11); 27 | spdlog::error("R12: {:x}", ei->ContextRecord->R12); 28 | spdlog::error("R13: {:x}", ei->ContextRecord->R13); 29 | spdlog::error("R14: {:x}", ei->ContextRecord->R14); 30 | spdlog::error("R15: {:x}", ei->ContextRecord->R15); 31 | spdlog::error("RAX: {:x}", ei->ContextRecord->Rax); 32 | spdlog::error("RBX: {:x}", ei->ContextRecord->Rbx); 33 | spdlog::error("RBP: {:x}", ei->ContextRecord->Rbp); 34 | spdlog::error("RSI: {:x}", ei->ContextRecord->Rsi); 35 | spdlog::error("RDI: {:x}", ei->ContextRecord->Rdi); 36 | spdlog::error("EFLAGS: {:x}", ei->ContextRecord->EFlags); 37 | spdlog::error("CS: {:x}", ei->ContextRecord->SegCs); 38 | spdlog::error("DS: {:x}", ei->ContextRecord->SegDs); 39 | spdlog::error("ES: {:x}", ei->ContextRecord->SegEs); 40 | spdlog::error("FS: {:x}", ei->ContextRecord->SegFs); 41 | spdlog::error("GS: {:x}", ei->ContextRecord->SegGs); 42 | spdlog::error("SS: {:x}", ei->ContextRecord->SegSs); 43 | 44 | const auto module_within = utility::get_module_within(ei->ContextRecord->Rip); 45 | 46 | if (module_within) { 47 | const auto module_path = utility::get_module_path(*module_within); 48 | 49 | if (module_path) { 50 | spdlog::error("Module: {:x} {}", (uintptr_t)*module_within, *module_path); 51 | } else { 52 | spdlog::error("Module: Unknown"); 53 | } 54 | } else { 55 | spdlog::error("Module: Unknown"); 56 | } 57 | 58 | auto dbghelp = LoadLibrary("dbghelp.dll"); 59 | 60 | if (dbghelp) { 61 | const auto final_path = Framework::get_persistent_dir("crash.dmp").string(); 62 | 63 | spdlog::error("Attempting to write dump to {}", final_path); 64 | 65 | auto f = CreateFile(final_path.c_str(), 66 | GENERIC_WRITE, 67 | FILE_SHARE_WRITE, 68 | nullptr, 69 | CREATE_ALWAYS, 70 | FILE_ATTRIBUTE_NORMAL, 71 | nullptr 72 | ); 73 | 74 | if (!f || f == INVALID_HANDLE_VALUE) { 75 | spdlog::error("Exception occurred, but could not create dump file"); 76 | return EXCEPTION_CONTINUE_SEARCH; 77 | } 78 | 79 | MINIDUMP_EXCEPTION_INFORMATION ei_info{ 80 | GetCurrentThreadId(), 81 | ei, 82 | FALSE 83 | }; 84 | 85 | auto minidump_write_dump = (decltype(MiniDumpWriteDump)*)GetProcAddress(dbghelp, "MiniDumpWriteDump"); 86 | 87 | minidump_write_dump(GetCurrentProcess(), 88 | GetCurrentProcessId(), 89 | f, 90 | MINIDUMP_TYPE::MiniDumpNormal, 91 | &ei_info, 92 | nullptr, 93 | nullptr 94 | ); 95 | 96 | CloseHandle(f); 97 | } else { 98 | spdlog::error("Exception occurred, but could not load dbghelp.dll"); 99 | } 100 | 101 | return EXCEPTION_EXECUTE_HANDLER; 102 | } 103 | 104 | void framework::setup_exception_handler() { 105 | SetUnhandledExceptionFilter(global_exception_handler); 106 | } 107 | -------------------------------------------------------------------------------- /src/ExceptionHandler.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace framework { 4 | LONG WINAPI global_exception_handler(struct _EXCEPTION_POINTERS* ei); 5 | void setup_exception_handler(); 6 | } 7 | -------------------------------------------------------------------------------- /src/Main.cpp: -------------------------------------------------------------------------------- 1 | // dllmain 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "Framework.hpp" 10 | 11 | void startup_thread(HMODULE poc_module) { 12 | g_framework = std::make_unique(poc_module); 13 | } 14 | 15 | BOOL APIENTRY DllMain(HANDLE handle, DWORD reason, LPVOID reserved) { 16 | if (reason == DLL_PROCESS_ATTACH) { 17 | CreateThread(nullptr, 0, (LPTHREAD_START_ROUTINE)startup_thread, handle, 0, nullptr); 18 | } 19 | 20 | return TRUE; 21 | } -------------------------------------------------------------------------------- /src/Mods.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "Framework.hpp" 4 | 5 | #include "mods/FrameworkConfig.hpp" 6 | #include "mods/VR.hpp" 7 | #include "mods/PluginLoader.hpp" 8 | #include "mods/UObjectHook.hpp" 9 | #include "Mods.hpp" 10 | 11 | Mods::Mods() { 12 | m_mods.emplace_back(FrameworkConfig::get()); 13 | m_mods.emplace_back(VR::get()); 14 | m_mods.emplace_back(UObjectHook::get()); 15 | 16 | m_mods.emplace_back(PluginLoader::get()); 17 | } 18 | 19 | std::optional Mods::on_initialize() const { 20 | std::scoped_lock _{g_framework->get_hook_monitor_mutex()}; 21 | 22 | for (auto& mod : m_mods) { 23 | spdlog::info("{:s}::on_initialize()", mod->get_name().data()); 24 | 25 | if (auto e = mod->on_initialize(); e != std::nullopt) { 26 | spdlog::info("{:s}::on_initialize() has failed: {:s}", mod->get_name().data(), *e); 27 | return e; 28 | } 29 | } 30 | 31 | return std::nullopt; 32 | } 33 | 34 | std::optional Mods::on_initialize_d3d_thread() const { 35 | std::scoped_lock _{g_framework->get_hook_monitor_mutex()}; 36 | 37 | // once here to at least setup the values 38 | reload_config(); 39 | 40 | for (auto& mod : m_mods) { 41 | spdlog::info("{:s}::on_initialize_d3d_thread()", mod->get_name().data()); 42 | 43 | if (auto e = mod->on_initialize_d3d_thread(); e != std::nullopt) { 44 | spdlog::info("{:s}::on_initialize_d3d_thread() has failed: {:s}", mod->get_name().data(), *e); 45 | return e; 46 | } 47 | } 48 | 49 | reload_config(); 50 | 51 | return std::nullopt; 52 | } 53 | 54 | void Mods::reload_config(bool set_defaults) const { 55 | utility::Config cfg{ Framework::get_persistent_dir("config.txt").string() }; 56 | 57 | for (auto& mod : m_mods) { 58 | spdlog::info("{:s}::on_config_load()", mod->get_name().data()); 59 | mod->on_config_load(cfg, set_defaults); 60 | } 61 | } 62 | 63 | void Mods::on_pre_imgui_frame() const { 64 | for (auto& mod : m_mods) { 65 | mod->on_pre_imgui_frame(); 66 | } 67 | } 68 | 69 | void Mods::on_frame() const { 70 | for (auto& mod : m_mods) { 71 | mod->on_frame(); 72 | } 73 | } 74 | 75 | void Mods::on_present() const { 76 | for (auto& mod : m_mods) { 77 | mod->on_present(); 78 | } 79 | } 80 | 81 | void Mods::on_post_frame() const { 82 | for (auto& mod : m_mods) { 83 | mod->on_post_frame(); 84 | } 85 | } 86 | 87 | void Mods::on_draw_ui() const { 88 | for (auto& mod : m_mods) { 89 | mod->on_draw_ui(); 90 | } 91 | } 92 | 93 | void Mods::on_device_reset() const { 94 | for (auto& mod : m_mods) { 95 | mod->on_device_reset(); 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /src/Mods.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Mod.hpp" 4 | 5 | class Mods { 6 | public: 7 | Mods(); 8 | virtual ~Mods() {} 9 | 10 | std::optional on_initialize() const; 11 | std::optional on_initialize_d3d_thread() const; 12 | void reload_config(bool set_defaults = false) const; 13 | 14 | void on_pre_imgui_frame() const; 15 | void on_frame() const; 16 | void on_present() const; 17 | void on_post_frame() const; 18 | void on_draw_ui() const; 19 | void on_device_reset() const; 20 | 21 | const auto& get_mods() const { 22 | return m_mods; 23 | } 24 | 25 | private: 26 | std::vector> m_mods; 27 | }; -------------------------------------------------------------------------------- /src/UILocalized.hpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangredli/UEVR/299dea90573357edc148d9ced0ec682450a54c12/src/UILocalized.hpp -------------------------------------------------------------------------------- /src/WindowFilter.cpp: -------------------------------------------------------------------------------- 1 | #include "WindowFilter.hpp" 2 | 3 | // To prevent usage of statics (TLS breaks the present thread...?) 4 | std::unique_ptr g_window_filter{}; 5 | 6 | WindowFilter& WindowFilter::get() { 7 | if (g_window_filter == nullptr) { 8 | g_window_filter = std::make_unique(); 9 | } 10 | 11 | return *g_window_filter; 12 | } 13 | 14 | WindowFilter::WindowFilter() { 15 | // We create a job thread because GetWindowTextA can actually deadlock inside 16 | // the present thread... 17 | m_job_thread = std::make_unique([this](std::stop_token s){ 18 | while (!s.stop_requested()) { 19 | std::this_thread::sleep_for(std::chrono::milliseconds{100}); 20 | 21 | m_last_job_tick = std::chrono::steady_clock::now(); 22 | 23 | if (m_window_jobs.empty()) { 24 | return; 25 | } 26 | 27 | std::scoped_lock _{m_mutex}; 28 | 29 | for (const auto hwnd : m_window_jobs) { 30 | if (is_filtered_nocache(hwnd)) { 31 | filter_window(hwnd); 32 | } 33 | } 34 | 35 | m_window_jobs.clear(); 36 | } 37 | }); 38 | } 39 | 40 | WindowFilter::~WindowFilter() { 41 | m_job_thread->request_stop(); 42 | m_job_thread->join(); 43 | } 44 | 45 | bool WindowFilter::is_filtered(HWND hwnd) { 46 | if (hwnd == nullptr) { 47 | return true; 48 | } 49 | 50 | std::scoped_lock _{m_mutex}; 51 | 52 | if (m_filtered_windows.find(hwnd) != m_filtered_windows.end()) { 53 | return true; 54 | } 55 | 56 | // If there is a job for this window, filter it until the job is done 57 | if (m_window_jobs.find(hwnd) != m_window_jobs.end()) { 58 | // If the thread is dead for some reason, do not filter it. 59 | return std::chrono::steady_clock::now() - m_last_job_tick <= std::chrono::seconds{2}; 60 | } 61 | 62 | // if we havent even seen this window yet, add it to the job queue 63 | // and return true; 64 | if (m_seen_windows.find(hwnd) == m_seen_windows.end()) { 65 | m_seen_windows.insert(hwnd); 66 | m_window_jobs.insert(hwnd); 67 | return true; 68 | } 69 | 70 | return false; 71 | } 72 | 73 | bool WindowFilter::is_filtered_nocache(HWND hwnd) { 74 | // get window name 75 | char window_name[256]{}; 76 | GetWindowTextA(hwnd, window_name, sizeof(window_name)); 77 | 78 | const auto sv = std::string_view{window_name}; 79 | 80 | if (sv.find("UE4SS") != std::string_view::npos) { 81 | return true; 82 | } 83 | 84 | if (sv.find("PimaxXR") != std::string_view::npos) { 85 | return true; 86 | } 87 | 88 | // TODO: more problematic windows 89 | return false; 90 | } -------------------------------------------------------------------------------- /src/WindowFilter.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | class WindowFilter { 13 | public: 14 | static WindowFilter& get(); 15 | 16 | public: 17 | WindowFilter(); 18 | virtual ~WindowFilter(); 19 | 20 | bool is_filtered(HWND hwnd); 21 | 22 | void filter_window(HWND hwnd) { 23 | std::scoped_lock _{m_mutex}; 24 | m_filtered_windows.insert(hwnd); 25 | } 26 | 27 | private: 28 | bool is_filtered_nocache(HWND hwnd); 29 | 30 | std::recursive_mutex m_mutex{}; 31 | std::unordered_set m_window_jobs{}; 32 | std::unique_ptr m_job_thread{}; 33 | 34 | std::unordered_set m_seen_windows{}; 35 | std::unordered_set m_filtered_windows{}; 36 | std::chrono::time_point m_last_job_tick{}; 37 | }; -------------------------------------------------------------------------------- /src/hooks/D3D11Hook.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #include "utility/PointerHook.hpp" 10 | 11 | class D3D11Hook { 12 | public: 13 | typedef std::function OnPresentFn; 14 | typedef std::function OnResizeBuffersFn; 15 | 16 | D3D11Hook() = default; 17 | virtual ~D3D11Hook(); 18 | 19 | bool is_hooked() { 20 | return m_hooked; 21 | } 22 | 23 | bool is_inside_present() const { 24 | return m_inside_present; 25 | } 26 | 27 | void ignore_next_present() { 28 | m_ignore_next_present = true; 29 | } 30 | 31 | void set_next_present_interval(uint32_t interval) { 32 | m_next_present_interval = interval; 33 | } 34 | 35 | bool hook(); 36 | bool unhook(); 37 | 38 | void on_present(OnPresentFn fn) { m_on_present = fn; } 39 | void on_post_present(OnPresentFn fn) { m_on_post_present = fn; } 40 | void on_resize_buffers(OnResizeBuffersFn fn) { m_on_resize_buffers = fn; } 41 | 42 | ID3D11Device* get_device() { return m_device; } 43 | IDXGISwapChain* get_swap_chain() { return m_swap_chain; } // The "active" swap chain. 44 | auto get_swapchain_0() { return m_swapchain_0; } 45 | auto get_swapchain_1() { return m_swapchain_1; } 46 | auto& get_last_depthstencil_used() { return m_last_depthstencil_used; } 47 | 48 | protected: 49 | template using ComPtr = Microsoft::WRL::ComPtr; 50 | 51 | ID3D11Device* m_device{ nullptr }; 52 | IDXGISwapChain* m_swap_chain{ nullptr }; 53 | IDXGISwapChain* m_swapchain_0{}; 54 | IDXGISwapChain* m_swapchain_1{}; 55 | bool m_hooked{ false }; 56 | bool m_inside_present{false}; 57 | bool m_ignore_next_present{false}; 58 | 59 | std::optional m_next_present_interval{}; 60 | 61 | std::unique_ptr m_present_hook{}; 62 | std::unique_ptr m_resize_buffers_hook{}; 63 | std::unique_ptr m_set_render_targets_hook{}; 64 | OnPresentFn m_on_present{ nullptr }; 65 | OnPresentFn m_on_post_present{ nullptr }; 66 | OnResizeBuffersFn m_on_resize_buffers{ nullptr }; 67 | ComPtr m_last_depthstencil_used{}; 68 | 69 | static HRESULT WINAPI present(IDXGISwapChain* swap_chain, UINT sync_interval, UINT flags); 70 | static HRESULT WINAPI resize_buffers(IDXGISwapChain* swap_chain, UINT buffer_count, UINT width, UINT height, DXGI_FORMAT new_format, UINT swap_chain_flags); 71 | static void WINAPI set_render_targets( 72 | ID3D11DeviceContext* context, UINT num_views, ID3D11RenderTargetView* const* rtvs, ID3D11DepthStencilView* dsv); 73 | }; 74 | -------------------------------------------------------------------------------- /src/hooks/D3D12Hook.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #pragma comment(lib, "d3d12.lib") 7 | #pragma comment(lib, "dxgi") 8 | 9 | #include 10 | #include 11 | 12 | #include "utility/PointerHook.hpp" 13 | #include "utility/VtableHook.hpp" 14 | 15 | class D3D12Hook 16 | { 17 | public: 18 | typedef std::function OnPresentFn; 19 | typedef std::function OnResizeBuffersFn; 20 | typedef std::function OnResizeTargetFn; 21 | typedef std::function OnCreateSwapChainFn; 22 | 23 | D3D12Hook() = default; 24 | virtual ~D3D12Hook(); 25 | 26 | bool hook(); 27 | bool unhook(); 28 | 29 | bool is_hooked() { 30 | return m_hooked; 31 | } 32 | 33 | void on_present(OnPresentFn fn) { 34 | m_on_present = fn; 35 | } 36 | 37 | void on_post_present(OnPresentFn fn) { 38 | m_on_post_present = fn; 39 | } 40 | 41 | void on_resize_buffers(OnResizeBuffersFn fn) { 42 | m_on_resize_buffers = fn; 43 | } 44 | 45 | void on_resize_target(OnResizeTargetFn fn) { 46 | m_on_resize_target = fn; 47 | } 48 | 49 | /*void on_create_swap_chain(OnCreateSwapChainFn fn) { 50 | m_on_create_swap_chain = fn; 51 | }*/ 52 | 53 | ID3D12Device4* get_device() const { 54 | return m_device; 55 | } 56 | 57 | IDXGISwapChain3* get_swap_chain() const { 58 | return m_swap_chain; 59 | } 60 | 61 | auto get_swapchain_0() { return m_swapchain_0; } 62 | auto get_swapchain_1() { return m_swapchain_1; } 63 | 64 | ID3D12CommandQueue* get_command_queue() const { 65 | return m_command_queue; 66 | } 67 | 68 | UINT get_display_width() const { 69 | return m_display_width; 70 | } 71 | 72 | UINT get_display_height() const { 73 | return m_display_height; 74 | } 75 | 76 | UINT get_render_width() const { 77 | return m_render_width; 78 | } 79 | 80 | UINT get_render_height() const { 81 | return m_render_height; 82 | } 83 | 84 | bool is_inside_present() const { 85 | return m_inside_present; 86 | } 87 | 88 | bool is_proton_swapchain() const { 89 | return m_using_proton_swapchain; 90 | } 91 | 92 | void ignore_next_present() { 93 | m_ignore_next_present = true; 94 | } 95 | 96 | void set_next_present_interval(uint32_t interval) { 97 | m_next_present_interval = interval; 98 | } 99 | 100 | protected: 101 | ID3D12Device4* m_device{ nullptr }; 102 | IDXGISwapChain3* m_swap_chain{ nullptr }; 103 | IDXGISwapChain3* m_swapchain_0{}; 104 | IDXGISwapChain3* m_swapchain_1{}; 105 | ID3D12CommandQueue* m_command_queue{ nullptr }; 106 | UINT m_display_width{ NULL }; 107 | UINT m_display_height{ NULL }; 108 | UINT m_render_width{ NULL }; 109 | UINT m_render_height{ NULL }; 110 | 111 | uint32_t m_command_queue_offset{}; 112 | uint32_t m_proton_swapchain_offset{}; 113 | 114 | std::optional m_next_present_interval{}; 115 | 116 | bool m_using_proton_swapchain{ false }; 117 | bool m_hooked{ false }; 118 | bool m_is_phase_1{ true }; 119 | bool m_inside_present{false}; 120 | bool m_ignore_next_present{false}; 121 | 122 | std::unique_ptr m_present_hook{}; 123 | std::unique_ptr m_swapchain_hook{}; 124 | //std::unique_ptr m_create_swap_chain_hook{}; 125 | 126 | OnPresentFn m_on_present{ nullptr }; 127 | OnPresentFn m_on_post_present{ nullptr }; 128 | OnResizeBuffersFn m_on_resize_buffers{ nullptr }; 129 | OnResizeTargetFn m_on_resize_target{ nullptr }; 130 | //OnCreateSwapChainFn m_on_create_swap_chain{ nullptr }; 131 | 132 | static HRESULT WINAPI present(IDXGISwapChain3* swap_chain, UINT sync_interval, UINT flags); 133 | static HRESULT WINAPI resize_buffers(IDXGISwapChain3* swap_chain, UINT buffer_count, UINT width, UINT height, DXGI_FORMAT new_format, UINT swap_chain_flags); 134 | static HRESULT WINAPI resize_target(IDXGISwapChain3* swap_chain, const DXGI_MODE_DESC* new_target_parameters); 135 | //static HRESULT WINAPI create_swap_chain(IDXGIFactory4* factory, IUnknown* device, HWND hwnd, const DXGI_SWAP_CHAIN_DESC* desc, const DXGI_SWAP_CHAIN_FULLSCREEN_DESC* p_fullscreen_desc, IDXGIOutput* p_restrict_to_output, IDXGISwapChain** swap_chain); 136 | }; 137 | 138 | -------------------------------------------------------------------------------- /src/hooks/DInputHook.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #ifndef DIRECTINPUT_VERSION 9 | #define DIRECTINPUT_VERSION 0x0800 10 | #endif 11 | 12 | #include 13 | 14 | #include 15 | 16 | #include 17 | 18 | class DInputHook { 19 | public: 20 | DInputHook(); 21 | virtual ~DInputHook() = default; 22 | 23 | private: 24 | static HRESULT WINAPI create_hooked( 25 | HINSTANCE hinst, 26 | DWORD dwVersion, 27 | REFIID riidltf, 28 | LPVOID* ppvOut, 29 | LPUNKNOWN punkOuter 30 | ); 31 | 32 | static HRESULT enum_devices_hooked( 33 | LPDIRECTINPUT8W This, 34 | DWORD dwDevType, 35 | LPDIENUMDEVICESCALLBACKW lpCallback, 36 | LPVOID pvRef, 37 | DWORD dwFlags 38 | ); 39 | 40 | // This is recursive because apparently EnumDevices 41 | // can call DirectInput8Create again... wHAT? 42 | std::recursive_mutex m_mutex{}; 43 | 44 | safetyhook::InlineHook m_create_hook{}; 45 | std::unique_ptr m_enum_devices_hook{}; 46 | }; -------------------------------------------------------------------------------- /src/hooks/WindowsMessageHook.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | 7 | #include "utility/Thread.hpp" 8 | 9 | #include "WindowsMessageHook.hpp" 10 | 11 | using namespace std; 12 | 13 | static WindowsMessageHook* g_windows_message_hook{ nullptr }; 14 | std::recursive_mutex g_proc_mutex{}; 15 | 16 | LRESULT WINAPI window_proc(HWND wnd, UINT message, WPARAM w_param, LPARAM l_param) { 17 | std::lock_guard _{ g_proc_mutex }; 18 | 19 | if (g_windows_message_hook == nullptr) { 20 | return 0; 21 | } 22 | 23 | // Call our onMessage callback. 24 | auto& on_message = g_windows_message_hook->on_message; 25 | 26 | if (on_message) { 27 | // If it returns false we don't call the original window procedure. 28 | if (!on_message(wnd, message, w_param, l_param)) { 29 | return DefWindowProc(wnd, message, w_param, l_param); 30 | } 31 | } 32 | 33 | // Call the original message procedure. 34 | return CallWindowProc(g_windows_message_hook->get_original(), wnd, message, w_param, l_param); 35 | } 36 | 37 | WindowsMessageHook::WindowsMessageHook(HWND wnd) 38 | : m_wnd{ wnd }, 39 | m_original_proc{ nullptr } 40 | { 41 | std::lock_guard _{ g_proc_mutex }; 42 | spdlog::info("Initializing WindowsMessageHook"); 43 | 44 | safetyhook::execute_while_frozen([this] { 45 | g_windows_message_hook = this; 46 | 47 | // Save the original window procedure. 48 | m_original_proc = (WNDPROC)GetWindowLongPtr(m_wnd, GWLP_WNDPROC); 49 | 50 | // Set it to our "hook" procedure. 51 | SetWindowLongPtr(m_wnd, GWLP_WNDPROC, (LONG_PTR)&window_proc); 52 | 53 | spdlog::info("Hooked Windows message handler"); 54 | }); 55 | } 56 | 57 | WindowsMessageHook::~WindowsMessageHook() { 58 | std::lock_guard _{ g_proc_mutex }; 59 | spdlog::info("Destroying WindowsMessageHook"); 60 | 61 | safetyhook::execute_while_frozen([this] { 62 | remove(); 63 | g_windows_message_hook = nullptr; 64 | }); 65 | } 66 | 67 | bool WindowsMessageHook::remove() { 68 | // Don't attempt to restore invalid original window procedures. 69 | if (m_original_proc == nullptr || m_wnd == nullptr) { 70 | return true; 71 | } 72 | 73 | // Restore the original window procedure. 74 | auto current_proc = (WNDPROC)GetWindowLongPtr(m_wnd, GWLP_WNDPROC); 75 | 76 | // lets not try to restore the original window procedure if it's not ours. 77 | if (current_proc == &window_proc) { 78 | SetWindowLongPtr(m_wnd, GWLP_WNDPROC, (LONG_PTR)m_original_proc); 79 | } 80 | 81 | // Invalidate this message hook. 82 | m_wnd = nullptr; 83 | m_original_proc = nullptr; 84 | 85 | return true; 86 | } 87 | 88 | bool WindowsMessageHook::is_hook_intact() { 89 | if (!m_wnd) { 90 | return false; 91 | } 92 | 93 | return GetWindowLongPtr(m_wnd, GWLP_WNDPROC) == (LONG_PTR)&window_proc; 94 | } 95 | -------------------------------------------------------------------------------- /src/hooks/WindowsMessageHook.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | #define RE_TOGGLE_CURSOR WM_APP + 1 8 | 9 | // This type of hook replaces a windows message procedure so that it can intercept 10 | // messages sent to the window. 11 | class WindowsMessageHook { 12 | public: 13 | std::function on_message; 14 | 15 | WindowsMessageHook() = delete; 16 | WindowsMessageHook(const WindowsMessageHook& other) = delete; 17 | WindowsMessageHook(WindowsMessageHook&& other) = delete; 18 | WindowsMessageHook(HWND wnd); 19 | virtual ~WindowsMessageHook(); 20 | 21 | // This gets called automatically by the destructor but you can call it 22 | // explicitly if you need to remove the message hook for some reason. 23 | bool remove(); 24 | 25 | auto is_valid() const { 26 | return m_original_proc != nullptr; 27 | } 28 | 29 | auto get_original() const { 30 | return m_original_proc; 31 | } 32 | 33 | inline void window_toggle_cursor(bool show) { 34 | // ONLY FOR RE ENGINE NOT UE!!!! 35 | //::PostMessage(m_wnd, RE_TOGGLE_CURSOR, show, 1); 36 | } 37 | 38 | WindowsMessageHook& operator=(const WindowsMessageHook& other) = delete; 39 | WindowsMessageHook& operator=(const WindowsMessageHook&& other) = delete; 40 | 41 | bool is_hook_intact(); 42 | 43 | private: 44 | HWND m_wnd; 45 | WNDPROC m_original_proc; 46 | }; -------------------------------------------------------------------------------- /src/hooks/XInputHook.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | class XInputHook { 9 | public: 10 | XInputHook(); 11 | 12 | private: 13 | static uint32_t get_state_hook_1_4(uint32_t user_index, XINPUT_STATE* state); 14 | static uint32_t set_state_hook_1_4(uint32_t user_index, XINPUT_VIBRATION* vibration); 15 | 16 | static uint32_t get_state_hook_1_3(uint32_t user_index, XINPUT_STATE* state); 17 | static uint32_t set_state_hook_1_3(uint32_t user_index, XINPUT_VIBRATION* vibration); 18 | 19 | safetyhook::InlineHook m_xinput_1_4_get_state_hook; 20 | safetyhook::InlineHook m_xinput_1_4_set_state_hook; 21 | safetyhook::InlineHook m_xinput_1_3_get_state_hook; 22 | safetyhook::InlineHook m_xinput_1_3_set_state_hook; 23 | 24 | std::unique_ptr m_hook_thread_1_4{}; 25 | std::unique_ptr m_hook_thread_1_3{}; 26 | }; -------------------------------------------------------------------------------- /src/mods/FrameworkConfig.cpp: -------------------------------------------------------------------------------- 1 | #include "Framework.hpp" 2 | 3 | #include "FrameworkConfig.hpp" 4 | 5 | std::shared_ptr& FrameworkConfig::get() { 6 | static std::shared_ptr instance{std::make_shared()}; 7 | return instance; 8 | } 9 | 10 | std::optional FrameworkConfig::on_initialize() { 11 | return Mod::on_initialize(); 12 | } 13 | 14 | void FrameworkConfig::draw_main() { 15 | m_menu_key->draw("Menu Key"); 16 | m_show_cursor_key->draw("Show Cursor Key"); 17 | m_remember_menu_state->draw("Remember Menu Open/Closed State"); 18 | m_enable_l3_r3_toggle->draw("Enable L3 + R3 Toggle"); 19 | ImGui::SameLine(); 20 | m_l3_r3_long_press->draw("L3 + R3 Long Press Menu Toggle"); 21 | m_always_show_cursor->draw("Always Show Cursor"); 22 | 23 | ImGui::Separator(); 24 | if (m_log_level->draw("Log Level")) { 25 | if (m_log_level->value() >= 0 && m_log_level->value() <= spdlog::level::level_enum::n_levels) { 26 | spdlog::set_level((spdlog::level::level_enum)m_log_level->value()); 27 | } 28 | } 29 | } 30 | 31 | void FrameworkConfig::draw_themes() { 32 | get_imgui_theme()->draw("Select GUI Theme"); 33 | get_imgui_language()->draw("Select GUI Language"); 34 | 35 | if (m_font_size->draw("Font Size")) { 36 | g_framework->set_font_size(m_font_size->value()); 37 | } 38 | } 39 | 40 | void FrameworkConfig::on_draw_sidebar_entry(std::string_view in_entry) { 41 | on_draw_ui(); 42 | ImGui::Separator(); 43 | 44 | if (in_entry == "Main") { 45 | draw_main(); 46 | } else if (in_entry == "GUI/Themes") { 47 | draw_themes(); 48 | } 49 | } 50 | 51 | void FrameworkConfig::on_frame() { 52 | if (m_show_cursor_key->is_key_down_once()) { 53 | m_always_show_cursor->toggle(); 54 | } 55 | } 56 | 57 | void FrameworkConfig::on_config_load(const utility::Config& cfg, bool set_defaults) { 58 | for (IModValue& option : m_options) { 59 | option.config_load(cfg, set_defaults); 60 | } 61 | 62 | if (m_remember_menu_state->value()) { 63 | g_framework->set_draw_ui(m_menu_open->value(), false); 64 | } 65 | 66 | g_framework->set_font_size(m_font_size->value()); 67 | 68 | if (m_log_level->value() >= 0 && m_log_level->value() <= spdlog::level::level_enum::n_levels) { 69 | spdlog::set_level((spdlog::level::level_enum)m_log_level->value()); 70 | } 71 | } 72 | 73 | void FrameworkConfig::on_config_save(utility::Config& cfg) { 74 | for (IModValue& option : m_options) { 75 | option.config_save(cfg); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/mods/FrameworkConfig.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | #include 5 | #include "Mod.hpp" 6 | #include "UILocalized.hpp" 7 | 8 | class FrameworkConfig : public Mod { 9 | public: 10 | static std::shared_ptr& get(); 11 | 12 | public: 13 | std::string_view get_name() const { 14 | return "FrameworkConfig"; 15 | } 16 | 17 | std::vector get_sidebar_entries() override { 18 | return { 19 | { "Main", false }, 20 | { "GUI/Themes", false } 21 | }; 22 | } 23 | 24 | std::optional on_initialize() override; 25 | void on_frame() override; 26 | void on_config_load(const utility::Config& cfg, bool set_defaults) override; 27 | void on_config_save(utility::Config& cfg) override; 28 | void on_draw_sidebar_entry(std::string_view in_entry) override; 29 | 30 | void draw_themes(); 31 | void draw_main(); 32 | 33 | auto& get_menu_key() { 34 | return m_menu_key; 35 | } 36 | 37 | auto& get_menu_open() { 38 | return m_menu_open; 39 | } 40 | 41 | bool is_remember_menu_state() { 42 | return m_remember_menu_state->value(); 43 | } 44 | 45 | bool is_enable_l3_r3_toggle() { 46 | return m_enable_l3_r3_toggle->value(); 47 | } 48 | 49 | bool is_l3_r3_long_press() { 50 | return m_l3_r3_long_press->value(); 51 | } 52 | 53 | bool is_always_show_cursor() const { 54 | return m_always_show_cursor->value(); 55 | } 56 | 57 | bool is_advanced_mode() const { 58 | return m_advanced_mode->value(); 59 | } 60 | 61 | void toggle_advanced_mode() const { 62 | m_advanced_mode->toggle(); 63 | } 64 | 65 | auto& get_advanced_mode() const { 66 | return m_advanced_mode; 67 | } 68 | 69 | auto& get_imgui_theme_value() const { 70 | return m_imgui_theme->value(); 71 | } 72 | 73 | auto& get_imgui_theme() const { 74 | return m_imgui_theme; 75 | } 76 | 77 | auto& get_imgui_language() { 78 | return m_imgui_language; 79 | } 80 | 81 | auto& get_imgui_language_value() { 82 | return m_imgui_language->value(); 83 | } 84 | 85 | int32_t get_font_size() const { 86 | return m_font_size->value(); 87 | } 88 | 89 | spdlog::level::level_enum get_log_level() const { 90 | return (spdlog::level::level_enum)m_log_level->value(); 91 | } 92 | 93 | private: 94 | static const inline std::vector s_imgui_themes { 95 | "Default Dark", 96 | "Alternative Dark", 97 | "Default Light", 98 | "High Contrast", 99 | }; 100 | 101 | static inline std::vector s_get_log_levels() { 102 | std::vector log_levels{}; 103 | for (auto& level : SPDLOG_LEVEL_NAMES) { 104 | log_levels.emplace_back(level.data()); 105 | } 106 | 107 | return log_levels; 108 | }; 109 | 110 | ModKey::Ptr m_menu_key{ ModKey::create(generate_name("MenuKey"), VK_INSERT) }; 111 | ModToggle::Ptr m_menu_open{ ModToggle::create(generate_name("MenuOpen"), true) }; 112 | ModToggle::Ptr m_remember_menu_state{ ModToggle::create(generate_name("RememberMenuState"), false) }; 113 | ModToggle::Ptr m_enable_l3_r3_toggle{ ModToggle::create(generate_name("EnableL3R3Toggle"), true) }; 114 | ModToggle::Ptr m_l3_r3_long_press{ ModToggle::create(generate_name("L3R3LongPress"), false) }; 115 | ModToggle::Ptr m_always_show_cursor{ ModToggle::create(generate_name("AlwaysShowCursor"), false) }; 116 | ModToggle::Ptr m_advanced_mode{ ModToggle::create(generate_name("AdvancedMode"), false) }; 117 | 118 | ModCombo::Ptr m_imgui_theme{ ModCombo::create(generate_name("ImGuiTheme"), s_imgui_themes, Framework::ImGuiThemes::DEFAULT_DARK) }; 119 | ModCombo::Ptr m_imgui_language{ ModCombo::create(generate_name("ImGuiLanguage"), UILocalized::s_ui_language, UILocalized::UILanguage::ZH_CN)}; 120 | ModCombo::Ptr m_log_level{ ModCombo::create(generate_name("LogLevel"), s_get_log_levels(), spdlog::level::info) }; 121 | 122 | ModKey::Ptr m_show_cursor_key{ ModKey::create(generate_name("ShowCursorKey")) }; 123 | ModInt32::Ptr m_font_size{ModInt32::create(generate_name("FontSize"), 16)}; 124 | 125 | ValueList m_options { 126 | *m_menu_key, 127 | *m_show_cursor_key, 128 | *m_menu_open, 129 | *m_remember_menu_state, 130 | *m_enable_l3_r3_toggle, 131 | *m_l3_r3_long_press, 132 | *m_advanced_mode, 133 | *m_imgui_theme, 134 | *m_log_level, 135 | *m_always_show_cursor, 136 | *m_font_size, 137 | *m_imgui_language, 138 | }; 139 | }; 140 | -------------------------------------------------------------------------------- /src/mods/FrameworkConfig.hpp.orig: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | #include 5 | #include "Mod.hpp" 6 | #include "UILocalized.hpp" 7 | 8 | class FrameworkConfig : public Mod { 9 | public: 10 | static std::shared_ptr& get(); 11 | 12 | public: 13 | std::string_view get_name() const { 14 | return "FrameworkConfig"; 15 | } 16 | 17 | std::vector get_sidebar_entries() override { 18 | return { 19 | { "Main", false }, 20 | { "GUI/Themes", false } 21 | }; 22 | } 23 | 24 | std::optional on_initialize() override; 25 | void on_frame() override; 26 | void on_config_load(const utility::Config& cfg, bool set_defaults) override; 27 | void on_config_save(utility::Config& cfg) override; 28 | void on_draw_sidebar_entry(std::string_view in_entry) override; 29 | 30 | void draw_themes(); 31 | void draw_main(); 32 | 33 | auto& get_menu_key() { 34 | return m_menu_key; 35 | } 36 | 37 | auto& get_menu_open() { 38 | return m_menu_open; 39 | } 40 | 41 | bool is_remember_menu_state() { 42 | return m_remember_menu_state->value(); 43 | } 44 | 45 | bool is_enable_l3_r3_toggle() { 46 | return m_enable_l3_r3_toggle->value(); 47 | } 48 | 49 | bool is_l3_r3_long_press() { 50 | return m_l3_r3_long_press->value(); 51 | } 52 | 53 | bool is_always_show_cursor() const { 54 | return m_always_show_cursor->value(); 55 | } 56 | 57 | bool is_advanced_mode() const { 58 | return m_advanced_mode->value(); 59 | } 60 | 61 | void toggle_advanced_mode() const { 62 | m_advanced_mode->toggle(); 63 | } 64 | 65 | auto& get_advanced_mode() const { 66 | return m_advanced_mode; 67 | } 68 | 69 | auto& get_imgui_theme_value() const { 70 | return m_imgui_theme->value(); 71 | } 72 | 73 | auto& get_imgui_theme() const { 74 | return m_imgui_theme; 75 | } 76 | 77 | <<<<<<< HEAD 78 | auto& get_imgui_language() { 79 | return m_imgui_language; 80 | } 81 | 82 | auto& get_imgui_language_value() { 83 | return m_imgui_language->value(); 84 | } 85 | 86 | int32_t get_font_size() { 87 | ======= 88 | int32_t get_font_size() const { 89 | >>>>>>> praydog-1.04 90 | return m_font_size->value(); 91 | } 92 | 93 | spdlog::level::level_enum get_log_level() const { 94 | return (spdlog::level::level_enum)m_log_level->value(); 95 | } 96 | 97 | private: 98 | static const inline std::vector s_imgui_themes { 99 | "Default Dark", 100 | "Alternative Dark", 101 | "Default Light", 102 | "High Contrast", 103 | }; 104 | 105 | <<<<<<< HEAD 106 | 107 | ======= 108 | static inline std::vector s_get_log_levels() { 109 | std::vector log_levels{}; 110 | for (auto& level : SPDLOG_LEVEL_NAMES) { 111 | log_levels.emplace_back(level.data()); 112 | } 113 | 114 | return log_levels; 115 | }; 116 | >>>>>>> praydog-1.04 117 | 118 | ModKey::Ptr m_menu_key{ ModKey::create(generate_name("MenuKey"), VK_INSERT) }; 119 | ModToggle::Ptr m_menu_open{ ModToggle::create(generate_name("MenuOpen"), true) }; 120 | ModToggle::Ptr m_remember_menu_state{ ModToggle::create(generate_name("RememberMenuState"), false) }; 121 | ModToggle::Ptr m_enable_l3_r3_toggle{ ModToggle::create(generate_name("EnableL3R3Toggle"), true) }; 122 | ModToggle::Ptr m_l3_r3_long_press{ ModToggle::create(generate_name("L3R3LongPress"), false) }; 123 | ModToggle::Ptr m_always_show_cursor{ ModToggle::create(generate_name("AlwaysShowCursor"), false) }; 124 | ModToggle::Ptr m_advanced_mode{ ModToggle::create(generate_name("AdvancedMode"), false) }; 125 | 126 | ModCombo::Ptr m_imgui_theme{ ModCombo::create(generate_name("ImGuiTheme"), s_imgui_themes, Framework::ImGuiThemes::DEFAULT_DARK) }; 127 | <<<<<<< HEAD 128 | ModCombo::Ptr m_imgui_language{ ModCombo::create(generate_name("ImGuiLanguage"), UILocalized::s_ui_language, UILocalized::UILanguage::ZH_CN)}; 129 | ======= 130 | ModCombo::Ptr m_log_level{ ModCombo::create(generate_name("LogLevel"), s_get_log_levels(), spdlog::level::info) }; 131 | 132 | >>>>>>> praydog-1.04 133 | ModKey::Ptr m_show_cursor_key{ ModKey::create(generate_name("ShowCursorKey")) }; 134 | ModInt32::Ptr m_font_size{ModInt32::create(generate_name("FontSize"), 16)}; 135 | 136 | ValueList m_options { 137 | *m_menu_key, 138 | *m_show_cursor_key, 139 | *m_menu_open, 140 | *m_remember_menu_state, 141 | *m_enable_l3_r3_toggle, 142 | *m_l3_r3_long_press, 143 | *m_advanced_mode, 144 | *m_imgui_theme, 145 | *m_log_level, 146 | *m_always_show_cursor, 147 | *m_font_size, 148 | *m_imgui_language, 149 | }; 150 | }; 151 | -------------------------------------------------------------------------------- /src/mods/ImGuiThemeHelpers.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class ImGuiThemeHelper { 4 | public: 5 | static void StyleColorsDefaultDark(); 6 | static void StyleColorsAlternativeDark(); 7 | static void StyleColorsDefaultLight(); 8 | static void StyleColorsHighContrast(); 9 | }; 10 | -------------------------------------------------------------------------------- /src/mods/pluginloader/FFakeStereoRenderingFunctions.cpp: -------------------------------------------------------------------------------- 1 | #include "uevr/API.h" 2 | 3 | #include "mods/VR.hpp" 4 | #include "FFakeStereoRenderingFunctions.hpp" 5 | 6 | namespace uevr { 7 | UEVR_FRHITexture2DHandle stereo_hook::get_scene_render_target() { 8 | const auto& vr = VR::get(); 9 | if (auto& hook = vr->get_fake_stereo_hook(); hook != nullptr) { 10 | auto rtm = hook->get_render_target_manager(); 11 | if (auto rtm = hook->get_render_target_manager(); rtm != nullptr) { 12 | return (UEVR_FRHITexture2DHandle)rtm->get_render_target(); 13 | } 14 | } 15 | 16 | return nullptr; 17 | } 18 | 19 | UEVR_FRHITexture2DHandle stereo_hook::get_ui_render_target() { 20 | const auto& vr = VR::get(); 21 | if (auto& hook = vr->get_fake_stereo_hook(); hook != nullptr) { 22 | auto rtm = hook->get_render_target_manager(); 23 | if (auto rtm = hook->get_render_target_manager(); rtm != nullptr) { 24 | return (UEVR_FRHITexture2DHandle)rtm->get_ui_target(); 25 | } 26 | } 27 | 28 | return nullptr; 29 | } 30 | 31 | UEVR_FFakeStereoRenderingHookFunctions stereo_hook::functions { 32 | .get_scene_render_target = &stereo_hook::get_scene_render_target, 33 | .get_ui_render_target = &stereo_hook::get_ui_render_target 34 | }; 35 | } -------------------------------------------------------------------------------- /src/mods/pluginloader/FFakeStereoRenderingFunctions.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "uevr/API.h" 4 | 5 | namespace uevr { 6 | namespace stereo_hook { 7 | UEVR_FRHITexture2DHandle get_scene_render_target(); 8 | UEVR_FRHITexture2DHandle get_ui_render_target(); 9 | 10 | extern UEVR_FFakeStereoRenderingHookFunctions functions; 11 | } 12 | } -------------------------------------------------------------------------------- /src/mods/pluginloader/FRHITexture2DFunctions.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "FRHITexture2DFunctions.hpp" 4 | 5 | namespace uevr { 6 | namespace frhitexture2d { 7 | void* get_native_resource(UEVR_FRHITexture2DHandle handle) { 8 | const auto texture = (::FRHITexture2D*)handle; 9 | 10 | if (texture == nullptr) { 11 | return nullptr; 12 | } 13 | 14 | return texture->get_native_resource(); 15 | } 16 | 17 | UEVR_FRHITexture2DFunctions functions { 18 | .get_native_resource = &uevr::frhitexture2d::get_native_resource 19 | }; 20 | } 21 | } -------------------------------------------------------------------------------- /src/mods/pluginloader/FRHITexture2DFunctions.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "uevr/API.h" 4 | 5 | namespace uevr { 6 | namespace frhitexture2d { 7 | void* get_native_resource(UEVR_FRHITexture2DHandle handle); 8 | 9 | extern UEVR_FRHITexture2DFunctions functions; 10 | } 11 | } -------------------------------------------------------------------------------- /src/mods/pluginloader/FRenderTargetPoolHook.cpp: -------------------------------------------------------------------------------- 1 | #include "../mods/VR.hpp" 2 | #include "FRenderTargetPoolHook.hpp" 3 | 4 | namespace uevr { 5 | void render_target_pool_hook::activate() { 6 | const auto& vr = VR::get(); 7 | if (auto& hook = vr->get_render_target_pool_hook(); hook != nullptr) { 8 | hook->activate(); 9 | } 10 | } 11 | 12 | UEVR_IPooledRenderTargetHandle render_target_pool_hook::get_render_target(const wchar_t* name) { 13 | const auto& vr = VR::get(); 14 | if (auto& hook = vr->get_render_target_pool_hook(); hook != nullptr) { 15 | return (UEVR_IPooledRenderTargetHandle)hook->get_render_target(name); 16 | } 17 | 18 | return nullptr; 19 | } 20 | 21 | UEVR_FRenderTargetPoolHookFunctions render_target_pool_hook::functions { 22 | .activate = &render_target_pool_hook::activate, 23 | .get_render_target = &render_target_pool_hook::get_render_target 24 | }; 25 | } -------------------------------------------------------------------------------- /src/mods/pluginloader/FRenderTargetPoolHook.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "uevr/API.h" 4 | 5 | namespace uevr { 6 | namespace render_target_pool_hook { 7 | void activate(); 8 | UEVR_IPooledRenderTargetHandle get_render_target(const wchar_t* name); 9 | extern UEVR_FRenderTargetPoolHookFunctions functions; 10 | } 11 | } -------------------------------------------------------------------------------- /src/mods/pluginloader/FUObjectArrayFunctions.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "FUObjectArrayFunctions.hpp" 4 | 5 | 6 | namespace uevr { 7 | namespace fuobjectarray { 8 | UEVR_UObjectHandle find_uobject(const wchar_t* name) { 9 | return (UEVR_UObjectHandle)sdk::find_uobject(name); 10 | } 11 | 12 | bool is_chunked() { 13 | return sdk::FUObjectArray::is_chunked(); 14 | } 15 | 16 | bool is_inlined() { 17 | return sdk::FUObjectArray::is_inlined(); 18 | } 19 | 20 | unsigned int get_objects_offset() { 21 | return sdk::FUObjectArray::get_objects_offset(); 22 | } 23 | 24 | unsigned int get_item_distance() { 25 | return sdk::FUObjectArray::get_item_distance(); 26 | } 27 | 28 | int get_object_count(UEVR_UObjectArrayHandle array) { 29 | return ((sdk::FUObjectArray*)array)->get_object_count(); 30 | } 31 | 32 | void* get_objects_ptr(UEVR_UObjectArrayHandle array) { 33 | return ((sdk::FUObjectArray*)array)->get_objects_ptr(); 34 | } 35 | 36 | UEVR_UObjectHandle get_object(UEVR_UObjectArrayHandle array, int index) { 37 | auto item = ((sdk::FUObjectArray*)array)->get_object(index); 38 | 39 | if (item == nullptr) { 40 | return nullptr; 41 | } 42 | 43 | return (UEVR_UObjectHandle)item->object; 44 | } 45 | 46 | // messed up naming, I know 47 | UEVR_FUObjectItemHandle get_item(UEVR_UObjectArrayHandle array, int index) { 48 | return (UEVR_FUObjectItemHandle)((sdk::FUObjectArray*)array)->get_object(index); 49 | } 50 | 51 | UEVR_UObjectArrayFunctions functions { 52 | .find_uobject = uevr::fuobjectarray::find_uobject, 53 | .is_chunked = uevr::fuobjectarray::is_chunked, 54 | .is_inlined = uevr::fuobjectarray::is_inlined, 55 | .get_objects_offset = uevr::fuobjectarray::get_objects_offset, 56 | .get_item_distance = uevr::fuobjectarray::get_item_distance, 57 | .get_object_count = uevr::fuobjectarray::get_object_count, 58 | .get_objects_ptr = uevr::fuobjectarray::get_objects_ptr, 59 | .get_object = uevr::fuobjectarray::get_object, 60 | .get_item = uevr::fuobjectarray::get_item 61 | }; 62 | } 63 | } -------------------------------------------------------------------------------- /src/mods/pluginloader/FUObjectArrayFunctions.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "uevr/API.h" 4 | 5 | namespace uevr { 6 | namespace fuobjectarray { 7 | UEVR_UObjectHandle find_uobject(const wchar_t* name); 8 | bool is_chunked(); 9 | bool is_inlined(); 10 | unsigned int get_objects_offset(); 11 | unsigned int get_item_distance(); 12 | int get_object_count(UEVR_UObjectArrayHandle array); 13 | void* get_objects_ptr(UEVR_UObjectArrayHandle array); 14 | UEVR_UObjectHandle get_object(UEVR_UObjectArrayHandle array, int index); 15 | UEVR_FUObjectItemHandle get_item(UEVR_UObjectArrayHandle array, int index); 16 | 17 | extern UEVR_UObjectArrayFunctions functions; 18 | } 19 | } -------------------------------------------------------------------------------- /src/mods/pluginloader/UScriptStructFunctions.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "UScriptStructFunctions.hpp" 4 | 5 | namespace uevr { 6 | namespace uscriptstruct { 7 | UEVR_StructOpsHandle get_struct_ops(UEVR_UScriptStructHandle script_struct) { 8 | return (UEVR_StructOpsHandle)((sdk::UScriptStruct*)script_struct)->get_struct_ops(); 9 | } 10 | 11 | int get_struct_size(UEVR_UScriptStructHandle script_struct) { 12 | return ((sdk::UScriptStruct*)script_struct)->get_struct_size(); 13 | } 14 | 15 | UEVR_UScriptStructFunctions functions { 16 | .get_struct_ops = get_struct_ops, 17 | .get_struct_size = get_struct_size 18 | }; 19 | } 20 | } -------------------------------------------------------------------------------- /src/mods/pluginloader/UScriptStructFunctions.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "uevr/API.h" 4 | 5 | namespace uevr { 6 | namespace uscriptstruct { 7 | UEVR_StructOpsHandle get_struct_ops(UEVR_UScriptStructHandle script_struct); 8 | int get_struct_size(UEVR_UScriptStructHandle script_struct); 9 | 10 | extern UEVR_UScriptStructFunctions functions; 11 | } 12 | } -------------------------------------------------------------------------------- /src/mods/uobjecthook/SDKDumper.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | namespace sdk { 8 | class UStruct; 9 | class UClass; 10 | class FProperty; 11 | } 12 | 13 | class SDKDumper { 14 | public: 15 | virtual ~SDKDumper() = default; 16 | 17 | public: 18 | static void dump(); 19 | 20 | private: 21 | void dump_internal(); 22 | 23 | private: 24 | void initialize_sdk(); 25 | void initialize_boilerplate_classes(); 26 | void initialize_tarray(); 27 | void initialize_uobject(); 28 | void initialize_ustruct(); 29 | void initialize_uobject_array(); 30 | void initialize_fname(); 31 | void populate_sdk(); 32 | void write_sdk(); 33 | 34 | private: 35 | sdkgenny::Struct* get_or_generate_struct(sdk::UStruct* ustruct); 36 | sdkgenny::Namespace* get_or_generate_namespace_chain(sdk::UStruct* uclass); 37 | void generate_inheritance(sdkgenny::Struct* s, sdk::UStruct* ustruct); 38 | void generate_properties(sdkgenny::Struct* s, sdk::UStruct* ustruct); 39 | sdkgenny::Variable* generate_property(sdkgenny::Struct* s, sdk::FProperty* fprop); 40 | void generate_functions(sdkgenny::Struct* s, sdk::UStruct* ustruct); 41 | 42 | private: 43 | std::unique_ptr m_sdk{}; 44 | 45 | struct ExtraSdkClass { 46 | std::string name{}; 47 | std::string header{}; 48 | std::optional source{}; 49 | }; 50 | 51 | std::vector m_extra_classes{}; 52 | }; -------------------------------------------------------------------------------- /src/mods/vr/RenderTargetPoolHook.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "../VR.hpp" 11 | #include "../../utility/Logging.hpp" 12 | #include "RenderTargetPoolHook.hpp" 13 | 14 | RenderTargetPoolHook* g_hook{nullptr}; 15 | 16 | RenderTargetPoolHook::RenderTargetPoolHook() { 17 | g_hook = this; 18 | } 19 | 20 | void RenderTargetPoolHook::on_pre_engine_tick(sdk::UGameEngine* engine, float delta) { 21 | if (!m_attempted_hook && VR::get()->is_depth_enabled()) { 22 | m_wants_activate = true; 23 | } 24 | 25 | if (!m_attempted_hook && m_wants_activate) { 26 | m_attempted_hook = true; 27 | m_hooked = hook(); 28 | } 29 | } 30 | 31 | bool RenderTargetPoolHook::hook() { 32 | SPDLOG_INFO("Attempting to hook RenderTargetPool::FindFreeElement"); 33 | 34 | const auto find_free_element = sdk::FRenderTargetPool::get_find_free_element_fn(); 35 | 36 | if (!find_free_element) { 37 | SPDLOG_ERROR("Failed to find FRenderTargetPool::FindFreeElement, cannot hook"); 38 | return false; 39 | } 40 | 41 | if (VR::get()->get_fake_stereo_hook()->has_double_precision()) { 42 | spdlog::error("Render target pool hook is temporarily disabled on UE5, sorry :("); 43 | return false; 44 | } 45 | 46 | SPDLOG_INFO("Performing hook..."); 47 | 48 | m_find_free_element_hook = safetyhook::create_inline((void*)*find_free_element, find_free_element_hook); 49 | 50 | if (m_find_free_element_hook) { 51 | SPDLOG_INFO("Successfully hooked RenderTargetPool::FindFreeElement"); 52 | } else { 53 | SPDLOG_ERROR("Failed to hook RenderTargetPool::FindFreeElement"); 54 | } 55 | 56 | return true; 57 | } 58 | 59 | bool RenderTargetPoolHook::find_free_element_hook( 60 | sdk::FRenderTargetPool* pool, sdk::FRHICommandListBase* cmd_list, 61 | sdk::FPooledRenderTargetDesc* desc, TRefCountPtr* out, 62 | const wchar_t* name, 63 | uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9, uintptr_t a10) 64 | { 65 | SPDLOG_INFO_ONCE("FRenderTargetPool::FindFreeElement called for the first time!"); 66 | 67 | const auto result = g_hook->m_find_free_element_hook.call(pool, cmd_list, desc, out, name, a6, a7, a8, a9, a10); 68 | 69 | SPDLOG_INFO_ONCE("Finished calling FRenderTargetPool::FindFreeElement!"); 70 | 71 | // Right now we are only using this for depth 72 | // and on some games it will crash if we mess with anything 73 | // so, TODO: fix the games that crash with depth enabled 74 | if (!g_hook->m_wants_activate) { 75 | std::scoped_lock _{g_hook->m_mutex}; 76 | g_hook->m_render_targets.clear(); 77 | return result; 78 | } 79 | 80 | if (name != nullptr) { 81 | //SPDLOG_INFO("FRenderTargetPool::FindFreeElement called with name {}", utility::narrow(name)); 82 | 83 | std::scoped_lock _{g_hook->m_mutex}; 84 | 85 | if (out != nullptr) { 86 | g_hook->m_render_targets[name] = out->reference; 87 | } else { 88 | g_hook->m_render_targets.erase(name); 89 | } 90 | 91 | if (!g_hook->m_seen_names.contains(name)) { 92 | g_hook->m_seen_names.insert(name); 93 | SPDLOG_INFO("FRenderTargetPool::FindFreeElement called with name {}", utility::narrow(name)); 94 | } 95 | } 96 | 97 | return result; 98 | } -------------------------------------------------------------------------------- /src/mods/vr/RenderTargetPoolHook.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "../../Mod.hpp" 7 | 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | namespace sdk { 14 | class FRenderTargetPool; 15 | class FPooledRenderTargetDesc; 16 | } 17 | 18 | class RenderTargetPoolHook : public ModComponent { 19 | public: 20 | RenderTargetPoolHook(); 21 | void on_pre_engine_tick(sdk::UGameEngine* engine, float delta) override; 22 | void activate() { 23 | m_wants_activate = true; 24 | } 25 | 26 | IPooledRenderTarget* get_render_target(const std::wstring& name) { 27 | std::scoped_lock _{m_mutex}; 28 | if (auto it = m_render_targets.find(name); it != m_render_targets.end()) { 29 | return it->second; 30 | } 31 | 32 | return nullptr; 33 | } 34 | 35 | template 36 | Microsoft::WRL::ComPtr get_texture(const std::wstring& name) { 37 | std::scoped_lock _{m_mutex}; 38 | if (auto it = m_render_targets.find(name); it != m_render_targets.end()) { 39 | const auto& rt = it->second; 40 | const auto& tex = rt->item.texture.texture; 41 | 42 | if (tex == nullptr) { 43 | return nullptr; 44 | } 45 | 46 | auto native_resource = (T*)tex->get_native_resource(); 47 | 48 | if (native_resource == nullptr) { 49 | return nullptr; 50 | } 51 | 52 | return native_resource; 53 | } 54 | 55 | return nullptr; 56 | } 57 | 58 | private: 59 | bool hook(); 60 | 61 | // Stuff past name param is added in newer UE versions. 62 | static bool find_free_element_hook( 63 | sdk::FRenderTargetPool* pool, 64 | sdk::FRHICommandListBase* cmd_list, 65 | sdk::FPooledRenderTargetDesc* desc, 66 | TRefCountPtr* out, 67 | const wchar_t* name, 68 | // these arent uintptrs, just defending against future changes to the size of the params 69 | uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9, uintptr_t a10); 70 | 71 | bool m_attempted_hook{false}; 72 | bool m_hooked{false}; 73 | bool m_wants_activate{false}; 74 | 75 | std::recursive_mutex m_mutex{}; 76 | SafetyHookInline m_find_free_element_hook{}; 77 | std::unordered_map m_render_targets{}; 78 | std::unordered_set m_seen_names{}; 79 | }; -------------------------------------------------------------------------------- /src/mods/vr/d3d12/ComPtr.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace d3d12 { 6 | template using ComPtr = Microsoft::WRL::ComPtr; 7 | } -------------------------------------------------------------------------------- /src/mods/vr/d3d12/CommandContext.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "ComPtr.hpp" 7 | 8 | namespace d3d12 { 9 | struct TextureContext; 10 | 11 | struct CommandContext { 12 | CommandContext() = default; 13 | virtual ~CommandContext() { this->reset(); } 14 | 15 | bool setup(const wchar_t* name = L"CommandContext object"); 16 | void reset(); 17 | void wait(uint32_t ms); 18 | void copy(ID3D12Resource* src, ID3D12Resource* dst, 19 | D3D12_RESOURCE_STATES src_state = D3D12_RESOURCE_STATE_PRESENT, 20 | D3D12_RESOURCE_STATES dst_state = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); 21 | void copy_region(ID3D12Resource* src, ID3D12Resource* dst, D3D12_BOX* src_box, 22 | D3D12_RESOURCE_STATES src_state = D3D12_RESOURCE_STATE_PRESENT, 23 | D3D12_RESOURCE_STATES dst_state = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); 24 | void clear_rtv(ID3D12Resource* dst, D3D12_CPU_DESCRIPTOR_HANDLE rtv, const float* color, 25 | D3D12_RESOURCE_STATES dst_state = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); 26 | void clear_rtv(TextureContext& tex, const float* color, D3D12_RESOURCE_STATES dst_state = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); 27 | void execute(); 28 | 29 | ComPtr cmd_allocator{}; 30 | ComPtr cmd_list{}; 31 | ComPtr fence{}; 32 | UINT64 fence_value{}; 33 | HANDLE fence_event{}; 34 | 35 | std::recursive_mutex mtx{}; 36 | 37 | bool waiting_for_fence{false}; 38 | bool has_commands{false}; 39 | 40 | std::wstring internal_name{L"CommandContext object"}; 41 | }; 42 | } -------------------------------------------------------------------------------- /src/mods/vr/d3d12/DirectXTK.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include <../../directxtk12-src/Inc/SpriteBatch.h> 4 | 5 | #include "TextureContext.hpp" 6 | 7 | namespace d3d12 { 8 | void render_srv_to_rtv( 9 | DirectX::DX12::SpriteBatch* sprite_batch, 10 | ID3D12GraphicsCommandList* command_list, 11 | const d3d12::TextureContext& src, 12 | const d3d12::TextureContext& dst, 13 | D3D12_RESOURCE_STATES src_state, 14 | D3D12_RESOURCE_STATES dst_state); 15 | 16 | void render_srv_to_rtv( 17 | DirectX::DX12::SpriteBatch* sprite_batch, 18 | ID3D12GraphicsCommandList* command_list, 19 | const d3d12::TextureContext& src, 20 | const d3d12::TextureContext& dst, 21 | std::optional src_rect, 22 | D3D12_RESOURCE_STATES src_state, 23 | D3D12_RESOURCE_STATES dst_state); 24 | } -------------------------------------------------------------------------------- /src/mods/vr/d3d12/TextureContext.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | #include "CommandContext.hpp" 6 | #include "TextureContext.hpp" 7 | 8 | namespace d3d12 { 9 | bool TextureContext::setup(ID3D12Device* device, ID3D12Resource* rsrc, std::optional rtv_format, std::optional srv_format, const wchar_t* name) { 10 | spdlog::info("Setting up texture context for {}", utility::narrow(name)); 11 | 12 | reset(); 13 | 14 | commands.setup(name); 15 | 16 | texture.Reset(); 17 | texture = rsrc; 18 | 19 | if (rsrc == nullptr) { 20 | return false; 21 | } 22 | 23 | return create_rtv(device, rtv_format) && create_srv(device, srv_format); 24 | } 25 | 26 | bool TextureContext::create_rtv(ID3D12Device* device, std::optional format) { 27 | spdlog::info("Creating RTV for texture context"); 28 | 29 | rtv_heap.reset(); 30 | 31 | // create descriptor heap 32 | try { 33 | rtv_heap = std::make_unique(device, 34 | D3D12_DESCRIPTOR_HEAP_TYPE_RTV, 35 | D3D12_DESCRIPTOR_HEAP_FLAG_NONE, 36 | 1); 37 | } catch(...) { 38 | spdlog::error("Failed to create RTV descriptor heap"); 39 | return false; 40 | } 41 | 42 | if (rtv_heap->Heap() == nullptr) { 43 | return false; 44 | } 45 | 46 | if (format) { 47 | D3D12_RENDER_TARGET_VIEW_DESC rtv_desc{}; 48 | rtv_desc.Format = (DXGI_FORMAT)*format; 49 | rtv_desc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2D; 50 | rtv_desc.Texture2D.MipSlice = 0; 51 | rtv_desc.Texture2D.PlaneSlice = 0; 52 | device->CreateRenderTargetView(texture.Get(), &rtv_desc, get_rtv()); 53 | } else { 54 | device->CreateRenderTargetView(texture.Get(), nullptr, get_rtv()); 55 | } 56 | 57 | return true; 58 | } 59 | 60 | bool TextureContext::create_srv(ID3D12Device* device, std::optional format) { 61 | spdlog::info("Creating SRV for texture context"); 62 | 63 | srv_heap.reset(); 64 | 65 | // create descriptor heap 66 | try { 67 | srv_heap = std::make_unique(device, 68 | D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, 69 | D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE, 70 | 1); 71 | } catch(...) { 72 | spdlog::error("Failed to create SRV descriptor heap"); 73 | return false; 74 | } 75 | 76 | if (srv_heap->Heap() == nullptr) { 77 | return false; 78 | } 79 | 80 | if (format) { 81 | D3D12_SHADER_RESOURCE_VIEW_DESC srv_desc{}; 82 | srv_desc.Format = (DXGI_FORMAT)*format; 83 | srv_desc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D; 84 | srv_desc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; 85 | srv_desc.Texture2D.MipLevels = 1; 86 | srv_desc.Texture2D.MostDetailedMip = 0; 87 | srv_desc.Texture2D.PlaneSlice = 0; 88 | srv_desc.Texture2D.ResourceMinLODClamp = 0.0f; 89 | device->CreateShaderResourceView(texture.Get(), &srv_desc, get_srv_cpu()); 90 | } else { 91 | device->CreateShaderResourceView(texture.Get(), nullptr, get_srv_cpu()); 92 | } 93 | 94 | return true; 95 | } 96 | } -------------------------------------------------------------------------------- /src/mods/vr/d3d12/TextureContext.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include <../../directxtk12-src/Inc/DescriptorHeap.h> 6 | 7 | #include "CommandContext.hpp" 8 | 9 | namespace d3d12 { 10 | struct TextureContext { 11 | CommandContext commands{}; 12 | ComPtr texture{}; 13 | std::unique_ptr rtv_heap{}; 14 | std::unique_ptr srv_heap{}; 15 | 16 | bool setup(ID3D12Device* device, ID3D12Resource* rsrc, std::optional rtv_format, std::optional srv_format, const wchar_t* name = L"TextureContext object"); 17 | bool create_rtv(ID3D12Device* device, std::optional format = std::nullopt); 18 | bool create_srv(ID3D12Device* device, std::optional format = std::nullopt); 19 | 20 | D3D12_CPU_DESCRIPTOR_HANDLE get_rtv() const { 21 | return rtv_heap->GetCpuHandle(0); 22 | } 23 | 24 | D3D12_GPU_DESCRIPTOR_HANDLE get_srv_gpu() const { 25 | return srv_heap->GetGpuHandle(0); 26 | } 27 | 28 | D3D12_CPU_DESCRIPTOR_HANDLE get_srv_cpu() const { 29 | return srv_heap->GetCpuHandle(0); 30 | } 31 | 32 | void reset() { 33 | commands.reset(); 34 | rtv_heap.reset(); 35 | srv_heap.reset(); 36 | texture.Reset(); 37 | } 38 | 39 | virtual ~TextureContext() { 40 | reset(); 41 | } 42 | }; 43 | } -------------------------------------------------------------------------------- /src/mods/vr/runtimes/OpenVR.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "VRRuntime.hpp" 7 | 8 | namespace runtimes { 9 | struct OpenVR final : public VRRuntime { 10 | OpenVR() { 11 | this->custom_stage = SynchronizeStage::VERY_LATE; 12 | } 13 | 14 | virtual ~OpenVR() { 15 | this->destroy(); 16 | } 17 | 18 | std::string_view name() const override { 19 | return "OpenVR"; 20 | } 21 | 22 | VRRuntime::Type type() const override { 23 | return VRRuntime::Type::OPENVR; 24 | } 25 | 26 | bool ready() const override { 27 | return VRRuntime::ready() && this->is_hmd_active && this->got_first_poses; 28 | 29 | } 30 | VRRuntime::Error synchronize_frame(std::optional frame_count = std::nullopt) override; 31 | VRRuntime::Error update_poses(bool from_view_extensions = false, uint32_t frame_count = 0) override; 32 | VRRuntime::Error update_render_target_size() override; 33 | 34 | uint32_t get_width() const override; 35 | uint32_t get_height() const override; 36 | 37 | VRRuntime::Error consume_events(std::function callback) override; 38 | VRRuntime::Error update_matrices(float nearz, float farz) override; 39 | 40 | void destroy() override; 41 | 42 | void enqueue_render_poses(uint32_t frame_count) override; 43 | void enqueue_render_poses_unsafe(uint32_t frame_count); 44 | 45 | vr::HmdMatrix34_t get_hmd_pose(uint32_t frame_count) const { 46 | return this->pose_queue[frame_count % this->pose_queue.size()]; 47 | } 48 | 49 | vr::HmdMatrix34_t get_current_hmd_pose() const { 50 | return this->pose_queue[internal_frame_count % this->pose_queue.size()]; 51 | } 52 | 53 | vr::HmdMatrix34_t get_pose_for_submit(); 54 | 55 | void on_device_reset() override { 56 | std::unique_lock _{ this->pose_mtx }; 57 | } 58 | 59 | bool is_depth_allowed() const override { 60 | return true; 61 | } 62 | 63 | bool is_hmd_active{false}; 64 | bool was_hmd_active{true}; 65 | 66 | uint32_t w{0}; 67 | uint32_t h{0}; 68 | 69 | vr::IVRSystem* hmd{nullptr}; 70 | 71 | std::array real_render_poses; 72 | std::array real_game_poses; 73 | 74 | std::array render_poses; 75 | std::array game_poses; 76 | 77 | std::chrono::system_clock::time_point last_hmd_active_time{}; 78 | 79 | std::array pose_queue{}; 80 | 81 | vr::VRActionHandle_t pose_action{vr::k_ulInvalidActionHandle}; 82 | vr::VRActionHandle_t grip_pose_action{vr::k_ulInvalidActionHandle}; 83 | std::array controller_poses{}; 84 | 85 | vr::TrackedDeviceIndex_t left_controller_index{vr::k_unTrackedDeviceIndexInvalid}; 86 | vr::TrackedDeviceIndex_t right_controller_index{vr::k_unTrackedDeviceIndexInvalid}; 87 | vr::VRInputValueHandle_t left_controller_handle{vr::k_ulInvalidInputValueHandle}; 88 | vr::VRInputValueHandle_t right_controller_handle{vr::k_ulInvalidInputValueHandle}; 89 | }; 90 | } -------------------------------------------------------------------------------- /src/uevr-imgui/imgui_impl_dx11.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Renderer Backend for DirectX11 2 | // This needs to be used along with a Platform Backend (e.g. Win32) 3 | 4 | // Implemented features: 5 | // [X] Renderer: User texture binding. Use 'ID3D11ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID! 6 | // [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices. 7 | 8 | // You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. 9 | // If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. 10 | // Read online: https://github.com/ocornut/imgui/tree/master/docs 11 | 12 | #pragma once 13 | #include "imgui.h" // IMGUI_IMPL_API 14 | 15 | struct ID3D11Device; 16 | struct ID3D11DeviceContext; 17 | 18 | IMGUI_IMPL_API bool ImGui_ImplDX11_Init(ID3D11Device* device, ID3D11DeviceContext* device_context); 19 | IMGUI_IMPL_API void ImGui_ImplDX11_Shutdown(); 20 | IMGUI_IMPL_API void ImGui_ImplDX11_NewFrame(); 21 | IMGUI_IMPL_API void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data); 22 | 23 | // Use if you want to reset your rendering device without losing Dear ImGui state. 24 | IMGUI_IMPL_API void ImGui_ImplDX11_InvalidateDeviceObjects(); 25 | IMGUI_IMPL_API bool ImGui_ImplDX11_CreateDeviceObjects(); -------------------------------------------------------------------------------- /src/uevr-imgui/imgui_impl_dx12.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Renderer Backend for DirectX12 2 | // This needs to be used along with a Platform Backend (e.g. Win32) 3 | 4 | // Implemented features: 5 | // [X] Renderer: User texture binding. Use 'D3D12_GPU_DESCRIPTOR_HANDLE' as ImTextureID. Read the FAQ about ImTextureID! 6 | // [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices. 7 | 8 | // Important: to compile on 32-bit systems, this backend requires code to be compiled with '#define ImTextureID ImU64'. 9 | // See imgui_impl_dx12.cpp file for details. 10 | 11 | // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. 12 | // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. 13 | // If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. 14 | // Read online: https://github.com/ocornut/imgui/tree/master/docs 15 | 16 | #pragma once 17 | #include "imgui.h" // IMGUI_IMPL_API 18 | #include // DXGI_FORMAT 19 | 20 | struct ID3D12Device; 21 | struct ID3D12DescriptorHeap; 22 | struct ID3D12GraphicsCommandList; 23 | struct D3D12_CPU_DESCRIPTOR_HANDLE; 24 | struct D3D12_GPU_DESCRIPTOR_HANDLE; 25 | 26 | // cmd_list is the command list that the implementation will use to render imgui draw lists. 27 | // Before calling the render function, caller must prepare cmd_list by resetting it and setting the appropriate 28 | // render target and descriptor heap that contains font_srv_cpu_desc_handle/font_srv_gpu_desc_handle. 29 | // font_srv_cpu_desc_handle and font_srv_gpu_desc_handle are handles to a single SRV descriptor to use for the internal font texture. 30 | IMGUI_IMPL_API bool ImGui_ImplDX12_Init(ID3D12Device* device, int num_frames_in_flight, DXGI_FORMAT rtv_format, ID3D12DescriptorHeap* cbv_srv_heap, 31 | D3D12_CPU_DESCRIPTOR_HANDLE font_srv_cpu_desc_handle, D3D12_GPU_DESCRIPTOR_HANDLE font_srv_gpu_desc_handle); 32 | IMGUI_IMPL_API void ImGui_ImplDX12_Shutdown(); 33 | IMGUI_IMPL_API void ImGui_ImplDX12_NewFrame(); 34 | IMGUI_IMPL_API void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data, ID3D12GraphicsCommandList* graphics_command_list); 35 | 36 | // Use if you want to reset your rendering device without losing Dear ImGui state. 37 | IMGUI_IMPL_API void ImGui_ImplDX12_InvalidateDeviceObjects(); 38 | IMGUI_IMPL_API bool ImGui_ImplDX12_CreateDeviceObjects(); 39 | -------------------------------------------------------------------------------- /src/uevr-imgui/imgui_impl_win32.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Platform Backend for Windows (standard windows API for 32 and 64 bits applications) 2 | // This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..) 3 | 4 | // Implemented features: 5 | // [X] Platform: Clipboard support (for Win32 this is actually part of core dear imgui) 6 | // [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. 7 | // [X] Platform: Keyboard arrays indexed using VK_* Virtual Key Codes, e.g. ImGui::IsKeyPressed(VK_SPACE). 8 | // [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. 9 | 10 | // You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. 11 | // If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. 12 | // Read online: https://github.com/ocornut/imgui/tree/master/docs 13 | 14 | #pragma once 15 | #include "imgui.h" // IMGUI_IMPL_API 16 | #include 17 | 18 | IMGUI_IMPL_API bool ImGui_ImplWin32_Init(void* hwnd); 19 | IMGUI_IMPL_API void ImGui_ImplWin32_Shutdown(); 20 | IMGUI_IMPL_API void ImGui_ImplWin32_NewFrame(); 21 | 22 | // Win32 message handler your application need to call. 23 | // - Intentionally commented out in a '#if 0' block to avoid dragging dependencies on from this helper. 24 | // - You should COPY the line below into your .cpp code to forward declare the function and then you can call it. 25 | // #if 0 26 | IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); 27 | // #endif 28 | 29 | // DPI-related helpers (optional) 30 | // - Use to enable DPI awareness without having to create an application manifest. 31 | // - Your own app may already do this via a manifest or explicit calls. This is mostly useful for our examples/ apps. 32 | // - In theory we could call simple functions from Windows SDK such as SetProcessDPIAware(), SetProcessDpiAwareness(), etc. 33 | // but most of the functions provided by Microsoft require Windows 8.1/10+ SDK at compile time and Windows 8/10+ at runtime, 34 | // neither we want to require the user to have. So we dynamically select and load those functions to avoid dependencies. 35 | IMGUI_IMPL_API void ImGui_ImplWin32_EnableDpiAwareness(); 36 | IMGUI_IMPL_API float ImGui_ImplWin32_GetDpiScaleForHwnd(void* hwnd); // HWND hwnd 37 | IMGUI_IMPL_API float ImGui_ImplWin32_GetDpiScaleForMonitor(void* monitor); // HMONITOR monitor 38 | 39 | // Transparency related helpers (optional) [experimental] 40 | // - Use to enable alpha compositing transparency with the desktop. 41 | // - Use together with e.g. clearing your framebuffer with zero-alpha. 42 | IMGUI_IMPL_API void ImGui_ImplWin32_EnableAlphaCompositing(void* hwnd); // HWND hwnd 43 | 44 | namespace imgui { 45 | void reset_keystates(); 46 | } -------------------------------------------------------------------------------- /src/utility/ImGui.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "ImGui.hpp" 5 | 6 | namespace imgui { 7 | bool is_point_intersecting_any(float x, float y) { 8 | const auto ctx = ImGui::GetCurrentContext(); 9 | 10 | if (ctx == nullptr) { 11 | return false; 12 | } 13 | 14 | for (int i = 0; i < ctx->Windows.Size; i++) { 15 | const auto window = ctx->Windows[i]; 16 | 17 | if (window->WasActive && window->Active) { 18 | if (x >= window->Pos.x && x <= window->Pos.x + window->Size.x && 19 | y >= window->Pos.y && y <= window->Pos.y + window->Size.y) 20 | { 21 | return true; 22 | } 23 | } 24 | } 25 | 26 | return false; 27 | } 28 | } -------------------------------------------------------------------------------- /src/utility/ImGui.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace imgui { 4 | bool is_point_intersecting_any(float x, float y); 5 | } -------------------------------------------------------------------------------- /src/utility/Logging.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | #define SPDLOG_INFO_ONCE(...) {static bool once = true; if (once) { SPDLOG_INFO(__VA_ARGS__); once = false; }} 8 | #define SPDLOG_WARN_ONCE(...) {static bool once = true; if (once) { SPDLOG_WARN(__VA_ARGS__); once = false; }} 9 | #define SPDLOG_ERROR_ONCE(...) {static bool once = true; if (once) { SPDLOG_ERROR(__VA_ARGS__); once = false; }} 10 | 11 | #define SPDLOG_INFO_EVERY_N_SEC(n, ...) {static auto last = std::chrono::steady_clock::time_point{}; auto now = std::chrono::steady_clock::now(); if (now - last >= std::chrono::seconds(n)) { SPDLOG_INFO(__VA_ARGS__); last = now; }} 12 | #define SPDLOG_WARNING_EVERY_N_SEC(n, ...) {static auto last = std::chrono::steady_clock::time_point{}; auto now = std::chrono::steady_clock::now(); if (now - last >= std::chrono::seconds(n)) { SPDLOG_WARN(__VA_ARGS__); last = now; }} 13 | #define SPDLOG_ERROR_EVERY_N_SEC(n, ...) {static auto last = std::chrono::steady_clock::time_point{}; auto now = std::chrono::steady_clock::now(); if (now - last >= std::chrono::seconds(n)) { SPDLOG_ERROR(__VA_ARGS__); last = now; }} -------------------------------------------------------------------------------- /vr-plugin-nullifier/Main.cpp: -------------------------------------------------------------------------------- 1 | // Standalone DLL to stop UE games from loading the VR plugins 2 | // They constantly try to do this at runtime 3 | // and causes for example, OpenXR (on our end) to fail to create an instance 4 | // among other things. 5 | // This has to be ran before the frontend injects openxr_loader.dll 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | void nullify_openxr(HMODULE game) { 17 | std::cout << "[VR Plugin Nullifier] Scanning for openxr_loader.dll" << std::endl; 18 | 19 | const auto openxr_string = utility::scan_string(game, "openxr_loader.dll"); 20 | 21 | if (!openxr_string) { 22 | std::cout << "[VR Plugin Nullifier] openxr_loader.dll string not found" << std::endl; 23 | return; 24 | } 25 | 26 | // Change the .dll extension at the end of the string to .nul 27 | // This will cause the game to fail to load the plugin 28 | const auto openxr_string_view = std::string_view{(char*)*openxr_string}; 29 | char* openxr_string_chars = (char*)*openxr_string; 30 | 31 | ProtectionOverride _{openxr_string_chars, openxr_string_view.size(), PAGE_EXECUTE_READWRITE}; 32 | 33 | openxr_string_chars[openxr_string_view.size() - 3] = 'n'; 34 | openxr_string_chars[openxr_string_view.size() - 2] = 'u'; 35 | openxr_string_chars[openxr_string_view.size() - 1] = 'l'; 36 | 37 | std::cout << "[VR Plugin Nullifier] openxr_loader.dll string patched" << std::endl; 38 | } 39 | 40 | void nullify_openvr(HMODULE game) { 41 | std::cout << "[VR Plugin Nullifier] Scanning for openvr_api.dll" << std::endl; 42 | 43 | const auto openvr_string = utility::scan_string(game, "openvr_api.dll"); 44 | 45 | if (!openvr_string) { 46 | std::cout << "[VR Plugin Nullifier] openvr_api.dll string not found" << std::endl; 47 | return; 48 | } 49 | 50 | // Change the .dll extension at the end of the string to .nul 51 | // This will cause the game to fail to load the plugin 52 | const auto openvr_string_view = std::string_view{(char*)*openvr_string}; 53 | char* openvr_string_chars = (char*)*openvr_string; 54 | 55 | ProtectionOverride _{openvr_string_chars, openvr_string_view.size(), PAGE_EXECUTE_READWRITE}; 56 | 57 | openvr_string_chars[openvr_string_view.size() - 3] = 'n'; 58 | openvr_string_chars[openvr_string_view.size() - 2] = 'u'; 59 | openvr_string_chars[openvr_string_view.size() - 1] = 'l'; 60 | 61 | std::cout << "[VR Plugin Nullifier] openvr_api.dll string patched" << std::endl; 62 | } 63 | 64 | extern "C" __declspec(dllexport) bool g_finished = false; 65 | 66 | extern "C" __declspec(dllexport) void nullify() try { 67 | // Spawn debug console 68 | //AllocConsole(); 69 | //freopen("CONOUT$", "w", stdout); 70 | 71 | printf("Hello\n"); 72 | 73 | const auto game = utility::get_executable(); 74 | 75 | nullify_openxr(game); 76 | nullify_openvr(game); 77 | 78 | g_finished = true; 79 | } catch(...) { 80 | std::cout << "[VR Plugin Nullifier] Exception thrown" << std::endl; 81 | g_finished = true; 82 | } 83 | 84 | // dllmain 85 | BOOL APIENTRY DllMain(HMODULE module, DWORD ul_reason_for_call, LPVOID reserved) { 86 | switch (ul_reason_for_call) { 87 | case DLL_PROCESS_ATTACH: 88 | break; 89 | } 90 | 91 | return TRUE; 92 | } --------------------------------------------------------------------------------