├── .gitignore ├── .gitmodules ├── L4D2VR ├── SteamVRActionManifest │ ├── action_manifest.json │ ├── bindings_knuckles.json │ ├── bindings_oculus_touch.json │ └── bindings_vive_cosmos_controller.json ├── config.txt ├── dllmain.cpp ├── game.cpp ├── game.h ├── hooks.cpp ├── hooks.h ├── l4d2vr.vcxproj ├── l4d2vr.vcxproj.filters ├── manifest.vrmanifest ├── offsets.h ├── portal2vr_capsule_main.png ├── portal2vr_portrait_main.png ├── sdk │ ├── LICENSE.txt │ ├── bitbuf.cpp │ ├── bitbuf.h │ ├── checksum_crc.cpp │ ├── checksum_crc.h │ ├── cnewparticleeffect.h │ ├── common_defs.h │ ├── coordsize.h │ ├── material.h │ ├── newbitbuf.cpp │ ├── platform.h │ ├── sdk.h │ ├── sdk_server.h │ ├── texture.h │ ├── trace.h │ ├── usercmd.h │ ├── vector.h │ └── worldsize.h ├── sigscanner.h ├── vr.cpp └── vr.h ├── README.md ├── imgs ├── icon.jpg └── logo.png ├── l4d2vr.sln └── thirdparty ├── minhook ├── include │ └── MinHook.h └── lib │ ├── Debug │ └── libMinHook.x86.lib │ └── Release │ └── libMinHook.x86.lib └── openvr ├── bin └── win32 │ └── openvr_api.dll ├── include ├── openvr.h ├── openvr_api.cs ├── openvr_api.json ├── openvr_capi.h └── openvr_driver.h └── lib └── win32 └── openvr_api.lib /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebugPublic/ 21 | [Rr]eleases/ 22 | x64/ 23 | x86/ 24 | [Aa][Rr][Mm]/ 25 | [Aa][Rr][Mm]64/ 26 | bld/ 27 | [Oo]bj/ 28 | [Ll]og/ 29 | [Ll]ogs/ 30 | 31 | # Visual Studio 2015/2017 cache/options directory 32 | .vs/ 33 | # Uncomment if you have tasks that create the project's static files in wwwroot 34 | #wwwroot/ 35 | 36 | # Visual Studio 2017 auto generated files 37 | Generated\ Files/ 38 | 39 | # MSTest test Results 40 | [Tt]est[Rr]esult*/ 41 | [Bb]uild[Ll]og.* 42 | 43 | # NUnit 44 | *.VisualState.xml 45 | TestResult.xml 46 | nunit-*.xml 47 | 48 | # Build Results of an ATL Project 49 | [Dd]ebugPS/ 50 | [Rr]eleasePS/ 51 | dlldata.c 52 | 53 | # Benchmark Results 54 | BenchmarkDotNet.Artifacts/ 55 | 56 | # .NET Core 57 | project.lock.json 58 | project.fragment.lock.json 59 | artifacts/ 60 | 61 | # ASP.NET Scaffolding 62 | ScaffoldingReadMe.txt 63 | 64 | # StyleCop 65 | StyleCopReport.xml 66 | 67 | # Files built by Visual Studio 68 | *_i.c 69 | *_p.c 70 | *_h.h 71 | *.ilk 72 | *.meta 73 | *.obj 74 | *.iobj 75 | *.pch 76 | *.pdb 77 | *.ipdb 78 | *.pgc 79 | *.pgd 80 | *.rsp 81 | *.sbr 82 | *.tlb 83 | *.tli 84 | *.tlh 85 | *.tmp 86 | *.tmp_proj 87 | *_wpftmp.csproj 88 | *.log 89 | *.tlog 90 | *.vspscc 91 | *.vssscc 92 | .builds 93 | *.pidb 94 | *.svclog 95 | *.scc 96 | 97 | # Chutzpah Test files 98 | _Chutzpah* 99 | 100 | # Visual C++ cache files 101 | ipch/ 102 | *.aps 103 | *.ncb 104 | *.opendb 105 | *.opensdf 106 | *.sdf 107 | *.cachefile 108 | *.VC.db 109 | *.VC.VC.opendb 110 | 111 | # Visual Studio profiler 112 | *.psess 113 | *.vsp 114 | *.vspx 115 | *.sap 116 | 117 | # Visual Studio Trace Files 118 | *.e2e 119 | 120 | # TFS 2012 Local Workspace 121 | $tf/ 122 | 123 | # Guidance Automation Toolkit 124 | *.gpState 125 | 126 | # ReSharper is a .NET coding add-in 127 | _ReSharper*/ 128 | *.[Rr]e[Ss]harper 129 | *.DotSettings.user 130 | 131 | # TeamCity is a build add-in 132 | _TeamCity* 133 | 134 | # DotCover is a Code Coverage Tool 135 | *.dotCover 136 | 137 | # AxoCover is a Code Coverage Tool 138 | .axoCover/* 139 | !.axoCover/settings.json 140 | 141 | # Coverlet is a free, cross platform Code Coverage Tool 142 | coverage*.json 143 | coverage*.xml 144 | coverage*.info 145 | 146 | # Visual Studio code coverage results 147 | *.coverage 148 | *.coveragexml 149 | 150 | # NCrunch 151 | _NCrunch_* 152 | .*crunch*.local.xml 153 | nCrunchTemp_* 154 | 155 | # MightyMoose 156 | *.mm.* 157 | AutoTest.Net/ 158 | 159 | # Web workbench (sass) 160 | .sass-cache/ 161 | 162 | # Installshield output folder 163 | [Ee]xpress/ 164 | 165 | # DocProject is a documentation generator add-in 166 | DocProject/buildhelp/ 167 | DocProject/Help/*.HxT 168 | DocProject/Help/*.HxC 169 | DocProject/Help/*.hhc 170 | DocProject/Help/*.hhk 171 | DocProject/Help/*.hhp 172 | DocProject/Help/Html2 173 | DocProject/Help/html 174 | 175 | # Click-Once directory 176 | publish/ 177 | 178 | # Publish Web Output 179 | *.[Pp]ublish.xml 180 | *.azurePubxml 181 | # Note: Comment the next line if you want to checkin your web deploy settings, 182 | # but database connection strings (with potential passwords) will be unencrypted 183 | *.pubxml 184 | *.publishproj 185 | 186 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 187 | # checkin your Azure Web App publish settings, but sensitive information contained 188 | # in these scripts will be unencrypted 189 | PublishScripts/ 190 | 191 | # NuGet Packages 192 | *.nupkg 193 | # NuGet Symbol Packages 194 | *.snupkg 195 | # The packages folder can be ignored because of Package Restore 196 | **/[Pp]ackages/* 197 | # except build/, which is used as an MSBuild target. 198 | !**/[Pp]ackages/build/ 199 | # Uncomment if necessary however generally it will be regenerated when needed 200 | #!**/[Pp]ackages/repositories.config 201 | # NuGet v3's project.json files produces more ignorable files 202 | *.nuget.props 203 | *.nuget.targets 204 | 205 | # Microsoft Azure Build Output 206 | csx/ 207 | *.build.csdef 208 | 209 | # Microsoft Azure Emulator 210 | ecf/ 211 | rcf/ 212 | 213 | # Windows Store app package directories and files 214 | AppPackages/ 215 | BundleArtifacts/ 216 | Package.StoreAssociation.xml 217 | _pkginfo.txt 218 | *.appx 219 | *.appxbundle 220 | *.appxupload 221 | 222 | # Visual Studio cache files 223 | # files ending in .cache can be ignored 224 | *.[Cc]ache 225 | # but keep track of directories ending in .cache 226 | !?*.[Cc]ache/ 227 | 228 | # Others 229 | ClientBin/ 230 | ~$* 231 | *~ 232 | *.dbmdl 233 | *.dbproj.schemaview 234 | *.jfm 235 | *.pfx 236 | *.publishsettings 237 | orleans.codegen.cs 238 | 239 | # Including strong name files can present a security risk 240 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 241 | #*.snk 242 | 243 | # Since there are multiple workflows, uncomment next line to ignore bower_components 244 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 245 | #bower_components/ 246 | 247 | # RIA/Silverlight projects 248 | Generated_Code/ 249 | 250 | # Backup & report files from converting an old project file 251 | # to a newer Visual Studio version. Backup files are not needed, 252 | # because we have git ;-) 253 | _UpgradeReport_Files/ 254 | Backup*/ 255 | UpgradeLog*.XML 256 | UpgradeLog*.htm 257 | ServiceFabricBackup/ 258 | *.rptproj.bak 259 | 260 | # SQL Server files 261 | *.mdf 262 | *.ldf 263 | *.ndf 264 | 265 | # Business Intelligence projects 266 | *.rdl.data 267 | *.bim.layout 268 | *.bim_*.settings 269 | *.rptproj.rsuser 270 | *- [Bb]ackup.rdl 271 | *- [Bb]ackup ([0-9]).rdl 272 | *- [Bb]ackup ([0-9][0-9]).rdl 273 | 274 | # Microsoft Fakes 275 | FakesAssemblies/ 276 | 277 | # GhostDoc plugin setting file 278 | *.GhostDoc.xml 279 | 280 | # Node.js Tools for Visual Studio 281 | .ntvs_analysis.dat 282 | node_modules/ 283 | 284 | # Visual Studio 6 build log 285 | *.plg 286 | 287 | # Visual Studio 6 workspace options file 288 | *.opt 289 | 290 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 291 | *.vbw 292 | 293 | # Visual Studio 6 auto-generated project file (contains which files were open etc.) 294 | *.vbp 295 | 296 | # Visual Studio 6 workspace and project file (working project files containing files to include in project) 297 | *.dsw 298 | *.dsp 299 | 300 | # Visual Studio 6 technical files 301 | *.ncb 302 | *.aps 303 | 304 | # Visual Studio LightSwitch build output 305 | **/*.HTMLClient/GeneratedArtifacts 306 | **/*.DesktopClient/GeneratedArtifacts 307 | **/*.DesktopClient/ModelManifest.xml 308 | **/*.Server/GeneratedArtifacts 309 | **/*.Server/ModelManifest.xml 310 | _Pvt_Extensions 311 | 312 | # Paket dependency manager 313 | .paket/paket.exe 314 | paket-files/ 315 | 316 | # FAKE - F# Make 317 | .fake/ 318 | 319 | # CodeRush personal settings 320 | .cr/personal 321 | 322 | # Python Tools for Visual Studio (PTVS) 323 | __pycache__/ 324 | *.pyc 325 | 326 | # Cake - Uncomment if you are using it 327 | # tools/** 328 | # !tools/packages.config 329 | 330 | # Tabs Studio 331 | *.tss 332 | 333 | # Telerik's JustMock configuration file 334 | *.jmconfig 335 | 336 | # BizTalk build output 337 | *.btp.cs 338 | *.btm.cs 339 | *.odx.cs 340 | *.xsd.cs 341 | 342 | # OpenCover UI analysis results 343 | OpenCover/ 344 | 345 | # Azure Stream Analytics local run output 346 | ASALocalRun/ 347 | 348 | # MSBuild Binary and Structured Log 349 | *.binlog 350 | 351 | # NVidia Nsight GPU debugger configuration file 352 | *.nvuser 353 | 354 | # MFractors (Xamarin productivity tool) working folder 355 | .mfractor/ 356 | 357 | # Local History for Visual Studio 358 | .localhistory/ 359 | 360 | # Visual Studio History (VSHistory) files 361 | .vshistory/ 362 | 363 | # BeatPulse healthcheck temp database 364 | healthchecksdb 365 | 366 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 367 | MigrationBackup/ 368 | 369 | # Ionide (cross platform F# VS Code tools) working folder 370 | .ionide/ 371 | 372 | # Fody - auto-generated XML schema 373 | FodyWeavers.xsd 374 | 375 | # VS Code files for those working on multiple tools 376 | .vscode/* 377 | !.vscode/settings.json 378 | !.vscode/tasks.json 379 | !.vscode/launch.json 380 | !.vscode/extensions.json 381 | *.code-workspace 382 | 383 | # Local History for Visual Studio Code 384 | .history/ 385 | 386 | # Windows Installer files from build outputs 387 | *.cab 388 | *.msi 389 | *.msix 390 | *.msm 391 | *.msp 392 | 393 | # JetBrains Rider 394 | *.sln.iml 395 | 396 | /Release 397 | /Debug 398 | /L4D2VR/Debug 399 | /L4D2VR/Release -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "dxvk"] 2 | path = dxvk 3 | url = https://github.com/fholger/dxvk_l4d2vr.git 4 | branch = msaa -------------------------------------------------------------------------------- /L4D2VR/SteamVRActionManifest/action_manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "default_bindings": [ 3 | { 4 | "controller_type": "oculus_touch", 5 | "binding_url": "bindings_oculus_touch.json" 6 | }, 7 | { 8 | "controller_type": "knuckles", 9 | "binding_url": "bindings_knuckles.json" 10 | }, 11 | { 12 | "controller_type": "vive_cosmos_controller", 13 | "binding_url": "bindings_vive_cosmos_controller.json" 14 | } 15 | ], 16 | 17 | "actions": [ 18 | { 19 | "name": "/actions/base/in/pose_lefthand", 20 | "type": "pose" 21 | }, 22 | { 23 | "name": "/actions/base/in/pose_righthand", 24 | "type": "pose" 25 | }, 26 | { 27 | "name": "/actions/base/out/vibration_left", 28 | "type": "vibration" 29 | }, 30 | { 31 | "name": "/actions/base/out/vibration_right", 32 | "type": "vibration" 33 | }, 34 | { 35 | "name" : "/actions/base/in/skeleton_lefthand", 36 | "skeleton" : "/skeleton/hand/left", 37 | "type" : "skeleton" 38 | }, 39 | { 40 | "name" : "/actions/base/in/skeleton_righthand", 41 | "skeleton" : "/skeleton/hand/right", 42 | "type" : "skeleton" 43 | }, 44 | { 45 | "name": "/actions/main/in/PrimaryAttack", 46 | "type": "boolean" 47 | }, 48 | { 49 | "name": "/actions/main/in/SecondaryAttack", 50 | "type": "boolean" 51 | }, 52 | { 53 | "name": "/actions/main/in/Jump", 54 | "type": "boolean" 55 | }, 56 | { 57 | "name": "/actions/main/in/Walk", 58 | "type": "vector2" 59 | }, 60 | { 61 | "name": "/actions/main/in/Turn", 62 | "type": "vector2" 63 | }, 64 | { 65 | "name": "/actions/main/in/Reload", 66 | "type": "boolean" 67 | }, 68 | { 69 | "name": "/actions/main/in/Use", 70 | "type": "boolean" 71 | }, 72 | { 73 | "name": "/actions/main/in/NextItem", 74 | "type": "boolean" 75 | }, 76 | { 77 | "name": "/actions/main/in/PrevItem", 78 | "type": "boolean" 79 | }, 80 | { 81 | "name": "/actions/main/in/ResetPosition", 82 | "type": "boolean" 83 | }, 84 | { 85 | "name": "/actions/main/in/Crouch", 86 | "type": "boolean" 87 | }, 88 | { 89 | "name": "/actions/main/in/Flashlight", 90 | "type": "boolean" 91 | }, 92 | { 93 | "name": "/actions/main/in/ActivateVR", 94 | "type": "boolean" 95 | }, 96 | { 97 | "name": "/actions/main/in/MenuSelect", 98 | "type": "boolean" 99 | }, 100 | { 101 | "name": "/actions/main/in/MenuBack", 102 | "type": "boolean" 103 | }, 104 | { 105 | "name": "/actions/main/in/MenuUp", 106 | "type": "boolean" 107 | }, 108 | { 109 | "name": "/actions/main/in/MenuDown", 110 | "type": "boolean" 111 | }, 112 | { 113 | "name": "/actions/main/in/MenuLeft", 114 | "type": "boolean" 115 | }, 116 | { 117 | "name": "/actions/main/in/MenuRight", 118 | "type": "boolean" 119 | }, 120 | { 121 | "name": "/actions/main/in/Spray", 122 | "type": "boolean", 123 | "requirement": "optional" 124 | }, 125 | { 126 | "name": "/actions/main/in/Scoreboard", 127 | "type": "boolean" 128 | }, 129 | { 130 | "name": "/actions/main/in/ShowHUD", 131 | "type": "boolean", 132 | "requirement": "optional" 133 | }, 134 | { 135 | "name": "/actions/main/in/Pause", 136 | "type": "boolean" 137 | } 138 | ], 139 | 140 | "action_sets": [ 141 | { 142 | "name": "/actions/main", 143 | "usage": "leftright" 144 | }, 145 | { 146 | "name": "/actions/base", 147 | "usage": "hidden" 148 | } 149 | ], 150 | 151 | "localization" : [ 152 | { 153 | "language_tag": "en_us", 154 | "/actions/main" : "Main", 155 | "/actions/main/in/PrimaryAttack" : "Primary Attack", 156 | "/actions/main/in/SecondaryAttack" : "Secondary Attack", 157 | "/actions/main/in/Jump" : "Jump", 158 | "/actions/main/in/Walk" : "Walk", 159 | "/actions/main/in/Turn" : "Turn", 160 | "/actions/main/in/Reload" : "Reload", 161 | "/actions/main/in/Use" : "Use", 162 | "/actions/main/in/NextItem" : "Next Item", 163 | "/actions/main/in/PrevItem" : "Previous Item", 164 | "/actions/main/in/ResetPosition" : "Reset Position", 165 | "/actions/main/in/Crouch" : "Crouch", 166 | "/actions/main/in/Flashlight" : "Flashlight", 167 | "/actions/main/in/ActivateVR" : "Activate VR", 168 | "/actions/main/in/MenuSelect" : "Menu Select", 169 | "/actions/main/in/MenuBack" : "Menu Back", 170 | "/actions/main/in/MenuUp" : "Menu Up", 171 | "/actions/main/in/MenuDown" : "Menu Down", 172 | "/actions/main/in/MenuLeft" : "Menu Left", 173 | "/actions/main/in/MenuRight" : "Menu Right", 174 | "/actions/main/in/Spray" : "Spray", 175 | "/actions/main/in/Scoreboard" : "Show Scoreboard", 176 | "/actions/main/in/ShowHUD" : "Show HUD", 177 | "/actions/main/in/Pause" : "Pause" 178 | } 179 | ] 180 | } 181 | -------------------------------------------------------------------------------- /L4D2VR/SteamVRActionManifest/bindings_knuckles.json: -------------------------------------------------------------------------------- 1 | { 2 | "action_manifest_version" : 0, 3 | "alias_info" : {}, 4 | "bindings" : { 5 | "/actions/base" : { 6 | "chords" : [], 7 | "haptics" : [ 8 | { 9 | "output" : "/actions/base/out/vibration_left", 10 | "path" : "/user/hand/left/output/haptic" 11 | }, 12 | { 13 | "output" : "/actions/base/out/vibration_right", 14 | "path" : "/user/hand/right/output/haptic" 15 | } 16 | ], 17 | "poses" : [ 18 | { 19 | "output" : "/actions/base/in/pose_lefthand", 20 | "path" : "/user/hand/left/pose/raw" 21 | }, 22 | { 23 | "output" : "/actions/base/in/pose_righthand", 24 | "path" : "/user/hand/right/pose/raw" 25 | } 26 | ], 27 | "skeleton" : [ 28 | { 29 | "output" : "/actions/base/in/skeleton_lefthand", 30 | "path" : "/user/hand/left/input/skeleton/left" 31 | }, 32 | { 33 | "output" : "/actions/base/in/skeleton_righthand", 34 | "path" : "/user/hand/right/input/skeleton/right" 35 | } 36 | ], 37 | "sources" : [] 38 | }, 39 | "/actions/main" : { 40 | "sources" : [ 41 | { 42 | "inputs" : { 43 | "click" : { 44 | "output" : "/actions/main/in/ResetPosition" 45 | }, 46 | "position" : { 47 | "output" : "/actions/main/in/Walk" 48 | } 49 | }, 50 | "mode" : "joystick", 51 | "parameters" : { 52 | "deadzone_pct" : "10" 53 | }, 54 | "path" : "/user/hand/left/input/thumbstick" 55 | }, 56 | { 57 | "inputs" : { 58 | "click" : { 59 | "output" : "/actions/main/in/Flashlight" 60 | }, 61 | "position" : { 62 | "output" : "/actions/main/in/Turn" 63 | } 64 | }, 65 | "mode" : "joystick", 66 | "parameters" : { 67 | "deadzone_pct" : "10" 68 | }, 69 | "path" : "/user/hand/right/input/thumbstick" 70 | }, 71 | { 72 | "inputs" : { 73 | "click" : { 74 | "output" : "/actions/main/in/Reload" 75 | } 76 | }, 77 | "mode" : "button", 78 | "parameters" : { 79 | "force_input" : "force", 80 | "click_activate_threshold": "0.45", 81 | "click_deactivate_threshold": "0.4" 82 | }, 83 | "path" : "/user/hand/left/input/grip" 84 | }, 85 | { 86 | "inputs" : { 87 | "click" : { 88 | "output" : "/actions/main/in/PrimaryAttack" 89 | } 90 | }, 91 | "mode" : "button", 92 | "path" : "/user/hand/right/input/trigger" 93 | }, 94 | { 95 | "inputs" : { 96 | "east" : { 97 | "output" : "/actions/main/in/boolean_turnright" 98 | }, 99 | "north" : { 100 | "output" : "/actions/main/in/PrevItem" 101 | }, 102 | "south" : { 103 | "output" : "/actions/main/in/NextItem" 104 | }, 105 | "west" : { 106 | "output" : "/actions/main/in/boolean_turnleft" 107 | } 108 | }, 109 | "mode" : "dpad", 110 | "parameters" : { 111 | "deadzone_pct" : "70", 112 | "overlap_pct" : "0", 113 | "sub_mode" : "touch" 114 | }, 115 | "path" : "/user/hand/right/input/thumbstick" 116 | }, 117 | { 118 | "inputs" : { 119 | "click" : { 120 | "output" : "/actions/main/in/Use" 121 | } 122 | }, 123 | "mode" : "button", 124 | "path" : "/user/hand/right/input/b" 125 | }, 126 | { 127 | "inputs" : { 128 | "click" : { 129 | "output" : "/actions/main/in/ActivateVR" 130 | } 131 | }, 132 | "mode" : "button", 133 | "path" : "/user/hand/right/input/a" 134 | }, 135 | { 136 | "inputs" : { 137 | "click" : { 138 | "output" : "/actions/main/in/Jump" 139 | } 140 | }, 141 | "mode" : "button", 142 | "path" : "/user/hand/right/input/a" 143 | }, 144 | { 145 | "inputs" : { 146 | "click" : { 147 | "output" : "/actions/main/in/MenuSelect" 148 | } 149 | }, 150 | "mode" : "button", 151 | "path" : "/user/hand/right/input/a" 152 | }, 153 | { 154 | "inputs" : { 155 | "click" : { 156 | "output" : "/actions/main/in/MenuBack" 157 | } 158 | }, 159 | "mode" : "button", 160 | "path" : "/user/hand/right/input/b" 161 | }, 162 | { 163 | "inputs" : { 164 | "east" : { 165 | "output" : "/actions/main/in/MenuRight" 166 | }, 167 | "north" : { 168 | "output" : "/actions/main/in/MenuUp" 169 | }, 170 | "south" : { 171 | "output" : "/actions/main/in/MenuDown" 172 | }, 173 | "west" : { 174 | "output" : "/actions/main/in/MenuLeft" 175 | } 176 | }, 177 | "mode" : "dpad", 178 | "parameters" : { 179 | "deadzone_pct" : "70", 180 | "overlap_pct" : "0", 181 | "sub_mode" : "touch" 182 | }, 183 | "path" : "/user/hand/left/input/thumbstick" 184 | }, 185 | { 186 | "inputs" : { 187 | "click" : { 188 | "output" : "/actions/main/in/Scoreboard" 189 | } 190 | }, 191 | "mode" : "button", 192 | "path" : "/user/hand/left/input/a" 193 | }, 194 | { 195 | "inputs" : { 196 | "click" : { 197 | "output" : "/actions/main/in/Pause" 198 | } 199 | }, 200 | "mode" : "button", 201 | "path" : "/user/hand/left/input/b" 202 | }, 203 | { 204 | "inputs" : { 205 | "click" : { 206 | "output" : "/actions/main/in/Crouch" 207 | } 208 | }, 209 | "mode" : "button", 210 | "parameters" : { 211 | "force_input" : "force", 212 | "click_activate_threshold": "0.45", 213 | "click_deactivate_threshold": "0.4" 214 | }, 215 | "path" : "/user/hand/left/input/grip" 216 | }, 217 | { 218 | "inputs" : { 219 | "click" : { 220 | "output" : "/actions/main/in/SecondaryAttack" 221 | } 222 | }, 223 | "mode" : "button", 224 | "parameters" : { 225 | "force_input" : "force", 226 | "click_activate_threshold": "0.45", 227 | "click_deactivate_threshold": "0.4" 228 | }, 229 | "path" : "/user/hand/right/input/grip" 230 | } 231 | ] 232 | } 233 | }, 234 | "category" : "steamvr_input", 235 | "controller_type" : "knuckles", 236 | "description" : "", 237 | "name" : "Default Portal 2 VR bindings for Index Controllers", 238 | "options" : {}, 239 | "simulated_actions" : [] 240 | } 241 | 242 | -------------------------------------------------------------------------------- /L4D2VR/SteamVRActionManifest/bindings_oculus_touch.json: -------------------------------------------------------------------------------- 1 | { 2 | "action_manifest_version" : 0, 3 | "alias_info" : {}, 4 | "bindings" : { 5 | "/actions/base" : { 6 | "chords" : [], 7 | "haptics" : [ 8 | { 9 | "output" : "/actions/base/out/vibration_left", 10 | "path" : "/user/hand/left/output/haptic" 11 | }, 12 | { 13 | "output" : "/actions/base/out/vibration_right", 14 | "path" : "/user/hand/right/output/haptic" 15 | } 16 | ], 17 | "poses" : [ 18 | { 19 | "output" : "/actions/base/in/pose_lefthand", 20 | "path" : "/user/hand/left/pose/raw" 21 | }, 22 | { 23 | "output" : "/actions/base/in/pose_righthand", 24 | "path" : "/user/hand/right/pose/raw" 25 | } 26 | ], 27 | "skeleton" : [ 28 | { 29 | "output" : "/actions/base/in/skeleton_lefthand", 30 | "path" : "/user/hand/left/input/skeleton/left" 31 | }, 32 | { 33 | "output" : "/actions/base/in/skeleton_righthand", 34 | "path" : "/user/hand/right/input/skeleton/right" 35 | } 36 | ], 37 | "sources" : [] 38 | }, 39 | "/actions/main" : { 40 | "sources" : [ 41 | { 42 | "inputs" : { 43 | "click" : { 44 | "output" : "/actions/main/in/ResetPosition" 45 | }, 46 | "position" : { 47 | "output" : "/actions/main/in/Walk" 48 | } 49 | }, 50 | "mode" : "joystick", 51 | "parameters" : { 52 | "deadzone_pct" : "10" 53 | }, 54 | "path" : "/user/hand/left/input/joystick" 55 | }, 56 | { 57 | "inputs" : { 58 | "click" : { 59 | "output" : "/actions/main/in/Flashlight" 60 | }, 61 | "position" : { 62 | "output" : "/actions/main/in/Turn" 63 | } 64 | }, 65 | "mode" : "joystick", 66 | "parameters" : { 67 | "deadzone_pct" : "10" 68 | }, 69 | "path" : "/user/hand/right/input/joystick" 70 | }, 71 | { 72 | "inputs" : { 73 | "click" : { 74 | "output" : "/actions/main/in/Reload" 75 | } 76 | }, 77 | "mode" : "button", 78 | "path" : "/user/hand/left/input/trigger" 79 | }, 80 | { 81 | "inputs" : { 82 | "click" : { 83 | "output" : "/actions/main/in/PrimaryAttack" 84 | } 85 | }, 86 | "mode" : "button", 87 | "path" : "/user/hand/right/input/trigger" 88 | }, 89 | { 90 | "inputs" : { 91 | "east" : { 92 | "output" : "/actions/main/in/boolean_turnright" 93 | }, 94 | "north" : { 95 | "output" : "/actions/main/in/PrevItem" 96 | }, 97 | "south" : { 98 | "output" : "/actions/main/in/NextItem" 99 | }, 100 | "west" : { 101 | "output" : "/actions/main/in/boolean_turnleft" 102 | } 103 | }, 104 | "mode" : "dpad", 105 | "parameters" : { 106 | "deadzone_pct" : "70", 107 | "overlap_pct" : "0", 108 | "sub_mode" : "touch" 109 | }, 110 | "path" : "/user/hand/right/input/joystick" 111 | }, 112 | { 113 | "inputs" : { 114 | "click" : { 115 | "output" : "/actions/main/in/Use" 116 | } 117 | }, 118 | "mode" : "button", 119 | "path" : "/user/hand/right/input/b" 120 | }, 121 | { 122 | "inputs" : { 123 | "click" : { 124 | "output" : "/actions/main/in/ActivateVR" 125 | } 126 | }, 127 | "mode" : "button", 128 | "path" : "/user/hand/right/input/a" 129 | }, 130 | { 131 | "inputs" : { 132 | "click" : { 133 | "output" : "/actions/main/in/Jump" 134 | } 135 | }, 136 | "mode" : "button", 137 | "path" : "/user/hand/right/input/a" 138 | }, 139 | { 140 | "inputs" : { 141 | "click" : { 142 | "output" : "/actions/main/in/MenuSelect" 143 | } 144 | }, 145 | "mode" : "button", 146 | "path" : "/user/hand/right/input/a" 147 | }, 148 | { 149 | "inputs" : { 150 | "click" : { 151 | "output" : "/actions/main/in/MenuBack" 152 | } 153 | }, 154 | "mode" : "button", 155 | "path" : "/user/hand/right/input/b" 156 | }, 157 | { 158 | "inputs" : { 159 | "east" : { 160 | "output" : "/actions/main/in/MenuRight" 161 | }, 162 | "north" : { 163 | "output" : "/actions/main/in/MenuUp" 164 | }, 165 | "south" : { 166 | "output" : "/actions/main/in/MenuDown" 167 | }, 168 | "west" : { 169 | "output" : "/actions/main/in/MenuLeft" 170 | } 171 | }, 172 | "mode" : "dpad", 173 | "parameters" : { 174 | "deadzone_pct" : "70", 175 | "overlap_pct" : "0", 176 | "sub_mode" : "touch" 177 | }, 178 | "path" : "/user/hand/left/input/joystick" 179 | }, 180 | { 181 | "inputs" : { 182 | "click" : { 183 | "output" : "/actions/main/in/Scoreboard" 184 | } 185 | }, 186 | "mode" : "button", 187 | "path" : "/user/hand/left/input/x" 188 | }, 189 | { 190 | "inputs" : { 191 | "click" : { 192 | "output" : "/actions/main/in/Pause" 193 | } 194 | }, 195 | "mode" : "button", 196 | "path" : "/user/hand/left/input/y" 197 | }, 198 | { 199 | "inputs" : { 200 | "click" : { 201 | "output" : "/actions/main/in/Crouch" 202 | } 203 | }, 204 | "mode" : "button", 205 | "path" : "/user/hand/left/input/grip" 206 | }, 207 | { 208 | "inputs" : { 209 | "click" : { 210 | "output" : "/actions/main/in/SecondaryAttack" 211 | } 212 | }, 213 | "mode" : "button", 214 | "path" : "/user/hand/right/input/grip" 215 | } 216 | ] 217 | } 218 | }, 219 | "category" : "steamvr_input", 220 | "controller_type" : "oculus_touch", 221 | "description" : "", 222 | "name" : "Portal 2 VR bindings for Oculus Touch", 223 | "options" : {}, 224 | "simulated_actions" : [] 225 | } 226 | 227 | -------------------------------------------------------------------------------- /L4D2VR/SteamVRActionManifest/bindings_vive_cosmos_controller.json: -------------------------------------------------------------------------------- 1 | { 2 | "action_manifest_version" : 0, 3 | "alias_info" : {}, 4 | "bindings" : { 5 | "/actions/base" : { 6 | "chords" : [], 7 | "haptics" : [ 8 | { 9 | "output" : "/actions/base/out/vibration_left", 10 | "path" : "/user/hand/left/output/haptic" 11 | }, 12 | { 13 | "output" : "/actions/base/out/vibration_right", 14 | "path" : "/user/hand/right/output/haptic" 15 | } 16 | ], 17 | "poses" : [ 18 | { 19 | "output" : "/actions/base/in/pose_lefthand", 20 | "path" : "/user/hand/left/pose/raw" 21 | }, 22 | { 23 | "output" : "/actions/base/in/pose_righthand", 24 | "path" : "/user/hand/right/pose/raw" 25 | } 26 | ], 27 | "skeleton" : [ 28 | { 29 | "output" : "/actions/base/in/skeleton_lefthand", 30 | "path" : "/user/hand/left/input/skeleton/left" 31 | }, 32 | { 33 | "output" : "/actions/base/in/skeleton_righthand", 34 | "path" : "/user/hand/right/input/skeleton/right" 35 | } 36 | ], 37 | "sources" : [] 38 | }, 39 | "/actions/main" : { 40 | "sources" : [ 41 | { 42 | "inputs" : { 43 | "click" : { 44 | "output" : "/actions/main/in/ResetPosition" 45 | }, 46 | "position" : { 47 | "output" : "/actions/main/in/Walk" 48 | } 49 | }, 50 | "mode" : "joystick", 51 | "parameters" : { 52 | "deadzone_pct" : "10" 53 | }, 54 | "path" : "/user/hand/left/input/joystick" 55 | }, 56 | { 57 | "inputs" : { 58 | "click" : { 59 | "output" : "/actions/main/in/Flashlight" 60 | }, 61 | "position" : { 62 | "output" : "/actions/main/in/Turn" 63 | } 64 | }, 65 | "mode" : "joystick", 66 | "parameters" : { 67 | "deadzone_pct" : "10" 68 | }, 69 | "path" : "/user/hand/right/input/joystick" 70 | }, 71 | { 72 | "inputs" : { 73 | "click" : { 74 | "output" : "/actions/main/in/Reload" 75 | } 76 | }, 77 | "mode" : "button", 78 | "path" : "/user/hand/left/input/trigger" 79 | }, 80 | { 81 | "inputs" : { 82 | "click" : { 83 | "output" : "/actions/main/in/PrimaryAttack" 84 | } 85 | }, 86 | "mode" : "button", 87 | "path" : "/user/hand/right/input/trigger" 88 | }, 89 | { 90 | "inputs" : { 91 | "east" : { 92 | "output" : "/actions/main/in/boolean_turnright" 93 | }, 94 | "north" : { 95 | "output" : "/actions/main/in/PrevItem" 96 | }, 97 | "south" : { 98 | "output" : "/actions/main/in/NextItem" 99 | }, 100 | "west" : { 101 | "output" : "/actions/main/in/boolean_turnleft" 102 | } 103 | }, 104 | "mode" : "dpad", 105 | "parameters" : { 106 | "deadzone_pct" : "70", 107 | "overlap_pct" : "0", 108 | "sub_mode" : "touch" 109 | }, 110 | "path" : "/user/hand/right/input/joystick" 111 | }, 112 | { 113 | "inputs" : { 114 | "click" : { 115 | "output" : "/actions/main/in/Use" 116 | } 117 | }, 118 | "mode" : "button", 119 | "path" : "/user/hand/right/input/b" 120 | }, 121 | { 122 | "inputs" : { 123 | "click" : { 124 | "output" : "/actions/main/in/ActivateVR" 125 | } 126 | }, 127 | "mode" : "button", 128 | "path" : "/user/hand/right/input/a" 129 | }, 130 | { 131 | "inputs" : { 132 | "click" : { 133 | "output" : "/actions/main/in/Jump" 134 | } 135 | }, 136 | "mode" : "button", 137 | "path" : "/user/hand/right/input/a" 138 | }, 139 | { 140 | "inputs" : { 141 | "click" : { 142 | "output" : "/actions/main/in/MenuSelect" 143 | } 144 | }, 145 | "mode" : "button", 146 | "path" : "/user/hand/right/input/a" 147 | }, 148 | { 149 | "inputs" : { 150 | "click" : { 151 | "output" : "/actions/main/in/MenuBack" 152 | } 153 | }, 154 | "mode" : "button", 155 | "path" : "/user/hand/right/input/b" 156 | }, 157 | { 158 | "inputs" : { 159 | "east" : { 160 | "output" : "/actions/main/in/MenuRight" 161 | }, 162 | "north" : { 163 | "output" : "/actions/main/in/MenuUp" 164 | }, 165 | "south" : { 166 | "output" : "/actions/main/in/MenuDown" 167 | }, 168 | "west" : { 169 | "output" : "/actions/main/in/MenuLeft" 170 | } 171 | }, 172 | "mode" : "dpad", 173 | "parameters" : { 174 | "deadzone_pct" : "70", 175 | "overlap_pct" : "0", 176 | "sub_mode" : "touch" 177 | }, 178 | "path" : "/user/hand/left/input/joystick" 179 | }, 180 | { 181 | "inputs" : { 182 | "click" : { 183 | "output" : "/actions/main/in/Scoreboard" 184 | } 185 | }, 186 | "mode" : "button", 187 | "path" : "/user/hand/left/input/x" 188 | }, 189 | { 190 | "inputs" : { 191 | "click" : { 192 | "output" : "/actions/main/in/Pause" 193 | } 194 | }, 195 | "mode" : "button", 196 | "path" : "/user/hand/left/input/y" 197 | }, 198 | { 199 | "inputs" : { 200 | "click" : { 201 | "output" : "/actions/main/in/Crouch" 202 | } 203 | }, 204 | "mode" : "button", 205 | "path" : "/user/hand/left/input/grip" 206 | }, 207 | { 208 | "inputs" : { 209 | "click" : { 210 | "output" : "/actions/main/in/SecondaryAttack" 211 | } 212 | }, 213 | "mode" : "button", 214 | "path" : "/user/hand/right/input/grip" 215 | } 216 | ] 217 | } 218 | }, 219 | "category" : "steamvr_input", 220 | "controller_type" : "vive_cosmos_controller", 221 | "description" : "", 222 | "name" : "Portal 2 VR bindings for Vive Cosmos Controllers", 223 | "options" : {}, 224 | "simulated_actions" : [] 225 | } 226 | 227 | -------------------------------------------------------------------------------- /L4D2VR/config.txt: -------------------------------------------------------------------------------- 1 | TurnSpeed=0.15 2 | SnapTurning=false 3 | SnapTurnAngle=45.0 4 | LeftHanded=false 5 | VRScale=43.2 # Real word units to source units scale 6 | IPDScale=1.0 # Scale of interpupillary distance 7 | 6DOF=true 8 | AimMode=2 # 0 = None, 1 = Crosshair (does not work properly), 2 = Laser sight/beam 9 | AntiAliasing=0 # 0, 2, 4 8 10 | RenderWindow=0 # Whether or not to render the game a third time for the window, yes you heard it right, so use this wisely 11 | ViewmodelPosCustomOffsetX=0.0 12 | ViewmodelPosCustomOffsetY=0.0 13 | ViewmodelPosCustomOffsetZ=0.0 14 | ViewmodelAngCustomOffsetX=0.0 15 | ViewmodelAngCustomOffsetY=0.0 16 | ViewmodelAngCustomOffsetZ=0.0 -------------------------------------------------------------------------------- /L4D2VR/dllmain.cpp: -------------------------------------------------------------------------------- 1 | // dllmain.cpp : Defines the entry point for the DLL application. 2 | #include 3 | #include 4 | #include "game.h" 5 | #include "hooks.h" 6 | #include "vr.h" 7 | #include "sdk.h" 8 | 9 | DWORD WINAPI InitL4D2VR(HMODULE hModule) 10 | { 11 | // Release if buggy, so we'll be releasing the debug binary 12 | #ifdef _DEBUG 13 | AllocConsole(); 14 | FILE *fp; 15 | freopen_s(&fp, "CONOUT$", "w", stdout); 16 | #endif 17 | 18 | // Make sure -insecure is used 19 | LPWSTR *szArglist; 20 | int nArgs; 21 | szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs); 22 | bool insecureEnabled = false; 23 | for (int i = 0; i < nArgs; ++i) 24 | { 25 | if (wcscmp(szArglist[i], L"-insecure") == 0) 26 | insecureEnabled = true; 27 | } 28 | LocalFree(szArglist); 29 | 30 | if (!insecureEnabled) 31 | ExitProcess(0); 32 | 33 | g_Game = new Game(); 34 | 35 | return 0; 36 | } 37 | 38 | 39 | 40 | BOOL APIENTRY DllMain( HMODULE hModule, 41 | DWORD ul_reason_for_call, 42 | LPVOID lpReserved 43 | ) 44 | { 45 | switch (ul_reason_for_call) 46 | { 47 | case DLL_PROCESS_ATTACH: 48 | CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)InitL4D2VR, hModule, 0, NULL); 49 | case DLL_THREAD_ATTACH: 50 | case DLL_THREAD_DETACH: 51 | case DLL_PROCESS_DETACH: 52 | break; 53 | } 54 | return TRUE; 55 | } 56 | 57 | 58 | -------------------------------------------------------------------------------- /L4D2VR/game.cpp: -------------------------------------------------------------------------------- 1 | #include "game.h" 2 | #include 3 | #include 4 | #include "sdk.h" 5 | #include "vr.h" 6 | #include "hooks.h" 7 | #include "offsets.h" 8 | #include "sigscanner.h" 9 | 10 | Game::Game() 11 | { 12 | while (!(m_BaseClient = (uintptr_t)GetModuleHandle("client.dll"))) 13 | Sleep(50); 14 | while (!(m_BaseEngine = (uintptr_t)GetModuleHandle("engine.dll"))) 15 | Sleep(50); 16 | while (!(m_BaseMaterialSystem = (uintptr_t)GetModuleHandle("materialsystem.dll"))) 17 | Sleep(50); 18 | while (!(m_BaseServer = (uintptr_t)GetModuleHandle("server.dll"))) 19 | Sleep(50); 20 | while (!(m_BaseVgui2 = (uintptr_t)GetModuleHandle("vgui2.dll"))) 21 | Sleep(50); 22 | 23 | m_ClientEntityList = (IClientEntityList *)GetInterface("client.dll", "VClientEntityList003"); 24 | m_EngineTrace = (IEngineTrace *)GetInterface("engine.dll", "EngineTraceClient004"); 25 | m_EngineClient = (IEngineClient *)GetInterface("engine.dll", "VEngineClient015"); 26 | m_MaterialSystem = (IMaterialSystem *)GetInterface("MaterialSystem.dll", "VMaterialSystem080"); 27 | m_ClientViewRender = (IViewRender *)GetInterface("client.dll", "VEngineRenderView013"); 28 | m_EngineViewRender = (IViewRender *)GetInterface("engine.dll", "VEngineRenderView013"); 29 | m_ModelInfo = (IModelInfo *)GetInterface("engine.dll", "VModelInfoClient004"); 30 | m_ModelRender = (IModelRender *)GetInterface("engine.dll", "VEngineModel016"); 31 | m_VguiInput = (IInput *)GetInterface("vgui2.dll", "VGUI_InputInternal001"); 32 | m_VguiSurface = (ISurface *)GetInterface("vguimatsurface.dll", "VGUI_Surface031"); 33 | 34 | m_Offsets = new Offsets(); 35 | 36 | m_ClientMode = **(IClientMode***)(m_Offsets->g_pClientMode.address); 37 | 38 | m_VR = new VR(this); 39 | m_Hooks = new Hooks(this); 40 | 41 | m_Initialized = true; 42 | } 43 | 44 | void *Game::GetInterface(const char *dllname, const char *interfacename) 45 | { 46 | tCreateInterface CreateInterface = (tCreateInterface)GetProcAddress(GetModuleHandle(dllname), "CreateInterface"); 47 | 48 | int returnCode = 0; 49 | void *createdInterface = CreateInterface(interfacename, &returnCode); 50 | 51 | return createdInterface; 52 | } 53 | 54 | void Game::errorMsg(const char *msg) 55 | { 56 | MessageBox(0, msg, "L4D2VR", MB_ICONERROR | MB_OK); 57 | } 58 | 59 | CBaseEntity *Game::GetClientEntity(int entityIndex) 60 | { 61 | return (CBaseEntity *)(m_ClientEntityList->GetClientEntity(entityIndex)); 62 | } 63 | 64 | char *Game::getNetworkName(uintptr_t *entity) 65 | { 66 | uintptr_t *IClientNetworkableVtable = (uintptr_t *)*(entity + 0x8); 67 | uintptr_t *GetClientClassPtr = (uintptr_t *)*(IClientNetworkableVtable + 0x8); 68 | uintptr_t *ClientClassPtr = (uintptr_t *)*(GetClientClassPtr + 0x1); 69 | char *m_pNetworkName = (char *)*(ClientClassPtr + 0x8); 70 | int classID = (int)*(ClientClassPtr + 0x10); 71 | std::cout << "ClassID: " << classID << std::endl; 72 | return m_pNetworkName; 73 | } 74 | 75 | void Game::ClientCmd(const char *szCmdString) 76 | { 77 | m_EngineClient->ClientCmd(szCmdString); 78 | } 79 | 80 | void Game::ClientCmd_Unrestricted(const char *szCmdString) 81 | { 82 | m_EngineClient->ClientCmd_Unrestricted(szCmdString); 83 | } 84 | 85 | 86 | -------------------------------------------------------------------------------- /L4D2VR/game.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include "vector.h" 5 | 6 | class IClientEntityList; 7 | class IEngineTrace; 8 | class IEngineClient; 9 | class IMaterialSystem; 10 | class IBaseClientDLL; 11 | class IViewRender; 12 | class IViewRender; 13 | class CBaseEntity; 14 | class IModelInfo; 15 | class IModelRender; 16 | class IMaterial; 17 | class IInput; 18 | class ISurface; 19 | class IClientMode; 20 | class C_BasePlayer; 21 | struct model_t; 22 | 23 | class Game; 24 | class Offsets; 25 | class VR; 26 | class Hooks; 27 | 28 | inline Game *g_Game; 29 | 30 | struct Player 31 | { 32 | C_BasePlayer *pPlayer; 33 | bool isUsingVR; 34 | QAngle controllerAngle; 35 | Vector controllerPos; 36 | QAngle prevControllerAngle; 37 | 38 | Player() 39 | : isUsingVR(false), 40 | controllerAngle({ 0,0,0 }), 41 | controllerPos({ 0,0,0 }), 42 | prevControllerAngle({ 0,0,0 }) 43 | {} 44 | }; 45 | 46 | class Game 47 | { 48 | public: 49 | IClientEntityList* m_ClientEntityList = nullptr; 50 | IEngineTrace* m_EngineTrace = nullptr; 51 | IEngineClient* m_EngineClient = nullptr; 52 | IMaterialSystem* m_MaterialSystem = nullptr; 53 | IBaseClientDLL* m_BaseClientDll = nullptr; 54 | IViewRender* m_ClientViewRender = nullptr; 55 | IViewRender* m_EngineViewRender = nullptr; 56 | IModelInfo* m_ModelInfo = nullptr; 57 | IModelRender* m_ModelRender = nullptr; 58 | IInput* m_VguiInput = nullptr; 59 | ISurface* m_VguiSurface = nullptr; 60 | IClientMode* m_ClientMode = nullptr; 61 | 62 | uintptr_t m_BaseEngine; 63 | uintptr_t m_BaseClient; 64 | uintptr_t m_BaseServer; 65 | uintptr_t m_BaseMaterialSystem; 66 | uintptr_t m_BaseVgui2; 67 | 68 | Vector m_singlePlayerPortalColors[3] = { Vector(255.0f, 255.0f, 255.0f), Vector(64.0f, 160.0f, 255.0f), Vector(255.0f, 160.0f, 32.0f) }; 69 | 70 | Offsets *m_Offsets = nullptr; 71 | VR *m_VR = nullptr; 72 | Hooks *m_Hooks = nullptr; 73 | 74 | bool m_Initialized = false; 75 | 76 | std::array m_PlayersVRInfo; 77 | int m_CurrentUsercmdID = -1; 78 | 79 | model_t *m_ArmsModel = nullptr; 80 | IMaterial *m_ArmsMaterial = nullptr; 81 | bool m_CachedArmsModel = false; 82 | 83 | Game(); 84 | 85 | void *GetInterface(const char *dllname, const char *interfacename); 86 | 87 | static void errorMsg(const char *msg); 88 | 89 | CBaseEntity *GetClientEntity(int entityIndex); 90 | char *getNetworkName(uintptr_t *entity); 91 | void ClientCmd(const char *szCmdString); 92 | void ClientCmd_Unrestricted(const char *szCmdString); 93 | 94 | typedef void *(__cdecl *tCreateInterface)(const char *name, int *returnCode); 95 | }; 96 | 97 | -------------------------------------------------------------------------------- /L4D2VR/hooks.cpp: -------------------------------------------------------------------------------- 1 | #include "hooks.h" 2 | #include "game.h" 3 | #include "texture.h" 4 | #include "sdk.h" 5 | #include "sdk_server.h" 6 | #include "vr.h" 7 | #include "offsets.h" 8 | #include 9 | 10 | Hooks::Hooks(Game *game) 11 | { 12 | if (MH_Initialize() != MH_OK) 13 | { 14 | Game::errorMsg("Failed to init MinHook"); 15 | } 16 | 17 | m_Game = game; 18 | m_VR = m_Game->m_VR; 19 | 20 | m_PushHUDStep = -999; 21 | m_PushedHud = true; 22 | 23 | initSourceHooks(); 24 | 25 | //hkGetRenderTarget.enableHook(); 26 | hkCalcViewModelView.enableHook(); 27 | 28 | hkProcessUsercmds.enableHook(); 29 | hkReadUsercmd.enableHook(); 30 | 31 | //hkWriteUsercmdDeltaToBuffer.enableHook(); 32 | hkWriteUsercmd.enableHook(); 33 | 34 | hkCreateMove.enableHook(); 35 | hkEyePosition.enableHook(); 36 | hkRenderView.enableHook(); 37 | 38 | 39 | hkWeapon_ShootPosition.enableHook(); 40 | hkTraceFirePortal.enableHook(); 41 | hkCWeaponPortalgun_FirePortal.enableHook(); 42 | 43 | hkDrawSelf.enableHook(); 44 | hkPlayerPortalled.enableHook(); 45 | 46 | //hkComputeError.enableHook(); 47 | hkUpdateObject.enableHook(); 48 | hkUpdateObjectVM.enableHook(); 49 | //hkRotateObject.enableHook(); 50 | hkEyeAngles.enableHook(); 51 | 52 | hkGetDefaultFOV.enableHook(); 53 | hkGetFOV.enableHook(); 54 | hkGetViewModelFOV.enableHook(); 55 | 56 | hkSetDrawOnlyForSplitScreenUser.enableHook(); 57 | //kClientThink.enableHook(); 58 | hkPrecache.enableHook(); 59 | hkCHudCrosshair_ShouldDraw.enableHook(); 60 | } 61 | 62 | Hooks::~Hooks() 63 | { 64 | if (MH_Uninitialize() != MH_OK) 65 | { 66 | Game::errorMsg("Failed to uninitialize MinHook"); 67 | } 68 | } 69 | 70 | 71 | int Hooks::initSourceHooks() 72 | { 73 | /*LPVOID pGetRenderTargetVFunc = (LPVOID)(m_Game->m_Offsets->GetRenderTarget.address); 74 | hkGetRenderTarget.createHook(pGetRenderTargetVFunc, &dGetRenderTarget);*/ 75 | 76 | LPVOID pRenderViewVFunc = (LPVOID)(m_Game->m_Offsets->RenderView.address); 77 | hkRenderView.createHook(pRenderViewVFunc, &dRenderView); 78 | 79 | LPVOID calcViewModelViewAddr = (LPVOID)(m_Game->m_Offsets->CalcViewModelView.address); 80 | hkCalcViewModelView.createHook(calcViewModelViewAddr, &dCalcViewModelView); 81 | 82 | LPVOID ProcessUsercmdsAddr = (LPVOID)(m_Game->m_Offsets->ProcessUsercmds.address); 83 | hkProcessUsercmds.createHook(ProcessUsercmdsAddr, &dProcessUsercmds); 84 | 85 | LPVOID ReadUserCmdAddr = (LPVOID)(m_Game->m_Offsets->ReadUserCmd.address); 86 | hkReadUsercmd.createHook(ReadUserCmdAddr, &dReadUsercmd); 87 | 88 | /*LPVOID WriteUsercmdDeltaToBufferAddr = (LPVOID)(m_Game->m_Offsets->WriteUsercmdDeltaToBuffer.address); 89 | hkWriteUsercmdDeltaToBuffer.createHook(WriteUsercmdDeltaToBufferAddr, &dWriteUsercmdDeltaToBuffer);*/ 90 | 91 | LPVOID WriteUsercmdAddr = (LPVOID)(m_Game->m_Offsets->WriteUsercmd.address); 92 | hkWriteUsercmd.createHook(WriteUsercmdAddr, &dWriteUsercmd); 93 | 94 | /*LPVOID AdjustEngineViewportAddr = (LPVOID)(m_Game->m_Offsets->AdjustEngineViewport.address); 95 | hkAdjustEngineViewport.createHook(AdjustEngineViewportAddr, &dAdjustEngineViewport); 96 | 97 | LPVOID ViewportAddr = (LPVOID)(m_Game->m_Offsets->Viewport.address); 98 | hkViewport.createHook(ViewportAddr, &dViewport); 99 | 100 | LPVOID GetViewportAddr = (LPVOID)(m_Game->m_Offsets->GetViewport.address); 101 | hkGetViewport.createHook(GetViewportAddr, &dGetViewport);*/ 102 | 103 | LPVOID EyePositionAddr = (LPVOID)(m_Game->m_Offsets->EyePosition.address); 104 | hkEyePosition.createHook(EyePositionAddr, &dEyePosition); 105 | 106 | /*LPVOID DrawModelExecuteAddr = (LPVOID)(m_Game->m_Offsets->DrawModelExecute.address); 107 | hkDrawModelExecute.createHook(DrawModelExecuteAddr, &dDrawModelExecute);*/ 108 | 109 | LPVOID PushRenderTargetAddr = (LPVOID)(m_Game->m_Offsets->PushRenderTargetAndViewport.address); 110 | hkPushRenderTargetAndViewport.createHook(PushRenderTargetAddr, &dPushRenderTargetAndViewport); 111 | 112 | LPVOID PopRenderTargetAddr = (LPVOID)(m_Game->m_Offsets->PopRenderTargetAndViewport.address); 113 | hkPopRenderTargetAndViewport.createHook(PopRenderTargetAddr, &dPopRenderTargetAndViewport); 114 | 115 | LPVOID VGui_PaintAddr = (LPVOID)(m_Game->m_Offsets->VGui_Paint.address); 116 | hkVgui_Paint.createHook(VGui_PaintAddr, &dVGui_Paint); 117 | 118 | /*LPVOID IsSplitScreenAddr = (LPVOID)(m_Game->m_Offsets->IsSplitScreen.address); 119 | hkIsSplitScreen.createHook(IsSplitScreenAddr, &dIsSplitScreen);*/ 120 | 121 | LPVOID PrePushRenderTargetAddr = (LPVOID)(m_Game->m_Offsets->PrePushRenderTarget.address); 122 | hkPrePushRenderTarget.createHook(PrePushRenderTargetAddr, &dPrePushRenderTarget); 123 | 124 | /*LPVOID GetFullScreenTextureAddr = (LPVOID)(m_Game->m_Offsets->GetFullScreenTexture.address); 125 | hkGetFullScreenTexture.createHook(GetFullScreenTextureAddr, &dGetFullScreenTexture);*/ 126 | 127 | LPVOID Weapon_ShootPositionAddr = (LPVOID)(m_Game->m_Offsets->Weapon_ShootPosition.address); 128 | hkWeapon_ShootPosition.createHook(Weapon_ShootPositionAddr, &dWeapon_ShootPosition); 129 | 130 | LPVOID TraceFirePortalAddr = (LPVOID)(m_Game->m_Offsets->TraceFirePortalServer.address); 131 | hkTraceFirePortal.createHook(TraceFirePortalAddr, &dTraceFirePortal); 132 | 133 | hkCWeaponPortalgun_FirePortal.createHook((LPVOID)m_Game->m_Offsets->CWeaponPortalgun_FirePortal.address, &dCWeaponPortalgun_FirePortal); 134 | 135 | LPVOID DrawSelfAddr = (LPVOID)(m_Game->m_Offsets->DrawSelf.address); 136 | hkDrawSelf.createHook(DrawSelfAddr, &dDrawSelf); 137 | 138 | LPVOID ClipTransformAddr = (LPVOID)(m_Game->m_Offsets->ClipTransform.address); 139 | hkClipTransform.createHook(ClipTransformAddr, &dClipTransform); 140 | 141 | // Portalling 142 | LPVOID PlayerPortalledAddr = (LPVOID)(m_Game->m_Offsets->PlayerPortalled.address); 143 | hkPlayerPortalled.createHook(PlayerPortalledAddr, &dPlayerPortalled); 144 | 145 | UTIL_Portal_FirstAlongRay = (tUTIL_Portal_FirstAlongRay)m_Game->m_Offsets->UTIL_Portal_FirstAlongRay.address; 146 | UTIL_IntersectRayWithPortal = (tUTIL_IntersectRayWithPortal)m_Game->m_Offsets->UTIL_IntersectRayWithPortal.address; 147 | UTIL_Portal_AngleTransform = (tUTIL_Portal_AngleTransform)m_Game->m_Offsets->UTIL_Portal_AngleTransform.address; 148 | 149 | LPVOID CreateMoveAddr = (LPVOID)(m_Game->m_Offsets->CreateMove.address); 150 | hkCreateMove.createHook(CreateMoveAddr, &dCreateMove); 151 | 152 | // Grababbles 153 | hkComputeError.createHook((LPVOID)(m_Game->m_Offsets->ComputeError.address), &dComputeError); 154 | hkUpdateObject.createHook((LPVOID)(m_Game->m_Offsets->UpdateObject.address), &dUpdateObject); 155 | hkUpdateObjectVM.createHook((LPVOID)(m_Game->m_Offsets->UpdateObjectVM.address), &dUpdateObjectVM); 156 | hkRotateObject.createHook((LPVOID)(m_Game->m_Offsets->RotateObject.address), &dRotateObject); 157 | hkEyeAngles.createHook((LPVOID)(m_Game->m_Offsets->EyeAngles.address), &dEyeAngles); 158 | 159 | // Portal Gun VFX 160 | hkGetDefaultFOV.createHook((LPVOID)(m_Game->m_Offsets->GetDefaultFOV.address), &dGetDefaultFOV); 161 | hkGetFOV.createHook((LPVOID)(m_Game->m_Offsets->GetFOV.address), &dGetFOV); 162 | hkGetViewModelFOV.createHook((LPVOID)(m_Game->m_Offsets->GetViewModelFOV.address), &dGetViewModelFOV); 163 | 164 | // Laser Pointer 165 | GetPortalPlayer = (tGetPortalPlayer)m_Game->m_Offsets->GetPortalPlayer.address; 166 | CreatePingPointer = (tCreatePingPointer)m_Game->m_Offsets->CreatePingPointer.address; 167 | PrecacheParticleSystem = (tPrecacheParticleSystem)m_Game->m_Offsets->PrecacheParticleSystem.address; 168 | hkPrecache.createHook((LPVOID)(m_Game->m_Offsets->Precache.address), &dPrecache); 169 | hkSetDrawOnlyForSplitScreenUser.createHook((LPVOID)m_Game->m_Offsets->SetDrawOnlyForSplitScreenUser.address, &dSetDrawOnlyForSplitScreenUser); 170 | hkCHudCrosshair_ShouldDraw.createHook((LPVOID)m_Game->m_Offsets->CHudCrosshair_ShouldDraw.address, &dCHudCrosshair_ShouldDraw); 171 | 172 | // 173 | EntityIndex = (tEntindex)m_Game->m_Offsets->CBaseEntity_entindex.address; 174 | GetOwner = (tGetOwner)m_Game->m_Offsets->GetOwner.address; 175 | GetFullScreenTexture = (tGetFullScreenTexture)m_Game->m_Offsets->GetFullScreenTexture.address; 176 | return 1; 177 | } 178 | 179 | bool __fastcall Hooks::dCHudCrosshair_ShouldDraw(void* ecx, void* edx) { 180 | bool shouldDraw = hkCHudCrosshair_ShouldDraw.fOriginal(ecx); 181 | 182 | m_VR->m_DrawCrosshair = shouldDraw; 183 | 184 | return ((m_VR->m_AimMode == 1) ? shouldDraw : false); 185 | } 186 | 187 | void __fastcall Hooks::dPrecache(void* ecx, void* edx) { 188 | hkPrecache.fOriginal(ecx); 189 | PrecacheParticleSystem("robot_point_beam"); 190 | } 191 | 192 | void __fastcall Hooks::dClientThink(void* ecx, void* edx) { 193 | hkClientThink.fOriginal(ecx); 194 | } 195 | 196 | void __fastcall Hooks::dSetDrawOnlyForSplitScreenUser(void* ecx, void* edx, int nSlot) { 197 | hkSetDrawOnlyForSplitScreenUser.fOriginal(ecx, -1); 198 | } 199 | 200 | ITexture *__fastcall Hooks::dGetFullScreenTexture() 201 | { 202 | ITexture *result = hkGetFullScreenTexture.fOriginal(); 203 | return result; 204 | } 205 | 206 | ITexture* __fastcall Hooks::dGetRenderTarget(void* ecx, void* edx) 207 | { 208 | ITexture* result = hkGetRenderTarget.fOriginal(ecx); 209 | return result; 210 | } 211 | 212 | void __fastcall Hooks::dRenderView(void *ecx, void *edx, CViewSetup &setup, CViewSetup &hudViewSetup, int nClearFlags, int whatToDraw) 213 | { 214 | if (!m_VR->m_CreatedVRTextures) { 215 | m_VR->CreateVRTextures(); 216 | } 217 | 218 | if (m_Game->m_VguiSurface->IsCursorVisible()) 219 | return hkRenderView.fOriginal(ecx, setup, hudViewSetup, nClearFlags, whatToDraw); 220 | 221 | //VPanel* g_pFullscreenRootPanel = *(VPanel**)(m_Game->m_Offsets->g_pFullscreenRootPanel.address); 222 | 223 | IMaterialSystem* matSystem = m_Game->m_MaterialSystem; 224 | 225 | hudViewSetup.width = m_VR->m_RenderWidth; 226 | hudViewSetup.height = m_VR->m_RenderHeight; 227 | hudViewSetup.fov = m_VR->m_Fov; 228 | //hudViewSetup.fovViewmodel = m_VR->m_Fov; 229 | hudViewSetup.m_flAspectRatio = m_VR->m_Aspect; 230 | 231 | hudViewSetup.m_nUnscaledWidth = m_VR->m_RenderWidth; 232 | hudViewSetup.m_nUnscaledHeight = m_VR->m_RenderHeight; 233 | 234 | Vector position = setup.origin; 235 | 236 | if (m_VR->m_ApplyPortalRotationOffset) { 237 | Vector vec = position - m_VR->m_SetupOrigin; 238 | float distance = sqrt(vec.x * vec.x + vec.y * vec.y + vec.z * vec.z); 239 | 240 | // Rudimentary portalling detection 241 | if (distance > 35) { 242 | //m_VR->m_RotationOffset.x += m_VR->m_PortalRotationOffset.x; 243 | m_VR->m_RotationOffset.y += m_VR->m_PortalRotationOffset.y; 244 | //m_VR->m_RotationOffset.z += m_VR->m_PortalRotationOffset.z; 245 | 246 | m_VR->UpdateHMDAngles(); 247 | 248 | m_VR->m_ApplyPortalRotationOffset = false; 249 | } 250 | } 251 | 252 | m_VR->m_SetupOrigin = position; 253 | 254 | Vector hmdAngle = m_VR->GetViewAngle(); 255 | QAngle inGameAngle(hmdAngle.x, hmdAngle.y, hmdAngle.z); 256 | m_Game->m_EngineClient->SetViewAngles(inGameAngle); 257 | 258 | float aspect = setup.m_flAspectRatio; 259 | 260 | setup.x = 0; 261 | setup.y = 0; 262 | setup.width = m_VR->m_RenderWidth; 263 | setup.height = m_VR->m_RenderHeight; 264 | setup.m_nUnscaledWidth = m_VR->m_RenderWidth; 265 | setup.m_nUnscaledHeight = m_VR->m_RenderHeight; 266 | setup.fov = m_VR->m_Fov; 267 | setup.fovViewmodel = m_VR->m_Fov; 268 | setup.m_flAspectRatio = m_VR->m_Aspect; 269 | setup.zNear = 6; 270 | setup.zNearViewmodel = 2; 271 | setup.angles = hmdAngle; 272 | 273 | CViewSetup leftEyeView = setup; 274 | CViewSetup rightEyeView = setup; 275 | 276 | int playerIndex = m_Game->m_EngineClient->GetLocalPlayer(); 277 | C_BasePlayer* localPlayer = (C_BasePlayer*)m_Game->GetClientEntity(playerIndex); 278 | 279 | // Left eye CViewSetup 280 | QAngle tempAngle = QAngle(setup.angles.x, setup.angles.y, setup.angles.z); 281 | leftEyeView.origin = m_VR->TraceEye((uint32_t*)localPlayer, position, m_VR->GetViewOriginLeft(position), tempAngle); 282 | leftEyeView.angles.y = tempAngle.y; 283 | 284 | //std::cout << "dRenderView - Left Start\n"; 285 | IMatRenderContext* rndrContext = matSystem->GetRenderContext(); 286 | rndrContext->SetRenderTarget(m_VR->m_LeftEyeTexture); 287 | rndrContext->Release(); 288 | hkRenderView.fOriginal(ecx, leftEyeView, hudViewSetup, nClearFlags, whatToDraw); 289 | 290 | // Right eye CViewSetup 291 | tempAngle = QAngle(setup.angles.x, setup.angles.y, setup.angles.z); 292 | rightEyeView.origin = m_VR->TraceEye((uint32_t*)localPlayer, position, m_VR->GetViewOriginRight(position), tempAngle); 293 | rightEyeView.angles.y = tempAngle.y; 294 | 295 | //std::cout << "dRenderView - Right Start\n"; 296 | rndrContext = matSystem->GetRenderContext(); 297 | rndrContext->SetRenderTarget(m_VR->m_RightEyeTexture); 298 | rndrContext->Release(); 299 | hkRenderView.fOriginal(ecx, rightEyeView, hudViewSetup, nClearFlags, whatToDraw); 300 | 301 | m_PushedHud = false; 302 | 303 | 304 | 305 | rndrContext = matSystem->GetRenderContext(); 306 | rndrContext->SetRenderTarget(NULL); 307 | rndrContext->Release(); 308 | 309 | /*rndrContext = matSystem->GetRenderContext(); 310 | 311 | ITexture* fullscreenTxt = rndrContext->GetRenderTarget(); 312 | 313 | Rect_t srcRect; 314 | srcRect.x = setup.x; 315 | srcRect.y = setup.y; 316 | srcRect.width = 1920; 317 | srcRect.height = 1080; 318 | 319 | rndrContext->SetRenderTarget(m_VR->m_RightEyeTexture); 320 | rndrContext->CopyRenderTargetToTextureEx(fullscreenTxt, 0, &srcRect, &srcRect); 321 | 322 | rndrContext->SetRenderTarget(NULL); 323 | rndrContext->Release();*/ 324 | 325 | if (m_VR->m_RenderWindow) { 326 | setup.m_flAspectRatio = aspect; 327 | 328 | //setup.width, setup.height 329 | hkRenderView.fOriginal(ecx, setup, hudViewSetup, nClearFlags, whatToDraw); 330 | } 331 | 332 | 333 | m_VR->m_RenderedNewFrame = true; 334 | } 335 | 336 | bool __fastcall Hooks::dCreateMove(void *ecx, void *edx, float flInputSampleTime, CUserCmd *cmd) 337 | { 338 | if (!cmd->command_number) 339 | return hkCreateMove.fOriginal(ecx, flInputSampleTime, cmd); 340 | 341 | if (m_VR->m_IsVREnabled) 342 | { 343 | cmd->viewangles = m_VR->m_HmdAngAbs; 344 | 345 | vr::InputAnalogActionData_t analogActionData; 346 | if (m_VR->GetAnalogActionData(m_VR->m_ActionWalk, analogActionData)) { 347 | // Run toward other guy 348 | cmd->buttons &= ~(IN_FORWARD | IN_BACK | IN_MOVELEFT | IN_MOVERIGHT); 349 | 350 | cmd->forwardmove += analogActionData.y * MAX_LINEAR_SPEED; 351 | cmd->sidemove += analogActionData.x * MAX_LINEAR_SPEED; 352 | 353 | // We'll only be moving fwd or sideways 354 | cmd->upmove = 0.0f; 355 | 356 | if (cmd->forwardmove > 0.0f) 357 | { 358 | cmd->buttons |= IN_FORWARD; 359 | } 360 | else if (cmd->forwardmove < 0.0f) 361 | { 362 | cmd->buttons |= IN_BACK; 363 | } 364 | 365 | if (cmd->sidemove > 0.0f) 366 | { 367 | cmd->buttons |= IN_MOVELEFT; 368 | } 369 | else if (cmd->sidemove < 0.0f) 370 | { 371 | cmd->buttons |= IN_MOVERIGHT; 372 | } 373 | 374 | } 375 | 376 | if (m_VR->m_RoomscaleActive) 377 | { 378 | // How much have we moved since last CreateMove? 379 | Vector setupOriginToHMD = (m_VR->m_HmdPosRelativeRaw - m_VR->m_HmdPosRelativeRawPrev) * m_VR->m_VRScale; //m_VR->m_HmdPosRelative - m_VR->m_HmdPosRelativePrev; 380 | m_VR->m_HmdPosRelativeRawPrev = m_VR->m_HmdPosRelativeRaw; 381 | 382 | setupOriginToHMD.z = 0; 383 | float distance = VectorLength(setupOriginToHMD); 384 | if (distance > 0) 385 | { 386 | float forwardSpeed = DotProduct2D(setupOriginToHMD, m_VR->m_HmdForward); 387 | float sideSpeed = DotProduct2D(setupOriginToHMD, m_VR->m_HmdRight); 388 | cmd->forwardmove += distance * forwardSpeed; 389 | cmd->sidemove += distance * sideSpeed; 390 | 391 | // Let's update the position and the previous too 392 | /*m_VR->m_HmdPosRelative -= setupOriginToHMD; 393 | m_VR->m_HmdPosRelativePrev = m_VR->m_HmdPosRelative;*/ 394 | 395 | /*m_VR->m_Center += m_VR->m_HmdPosRelativeRaw - m_VR->m_HmdPosRelativeRawPrev; 396 | m_VR->m_HmdPosRelativeRawPrev = m_VR->m_HmdPosRelativeRaw;*/ 397 | 398 | //m_VR->ResetPosition(); 399 | } 400 | } 401 | } 402 | 403 | return false; 404 | } 405 | 406 | void __fastcall Hooks::dEndFrame(void *ecx, void *edx) 407 | { 408 | return hkEndFrame.fOriginal(ecx); 409 | } 410 | 411 | void __fastcall Hooks::dCalcViewModelView(void *ecx, void *edx, const Vector &eyePosition, const QAngle &eyeAngles) 412 | { 413 | Vector vecNewOrigin = eyePosition; 414 | QAngle vecNewAngles = eyeAngles; 415 | 416 | //std::cout << "dCalcViewModelView: (" << m_VR->m_IsVREnabled << ")\n"; 417 | 418 | if (m_VR->m_IsVREnabled) 419 | { 420 | vecNewOrigin = m_VR->GetRecommendedViewmodelAbsPos(eyePosition); 421 | vecNewAngles = m_VR->GetRecommendedViewmodelAbsAngle(); 422 | } 423 | 424 | 425 | return hkCalcViewModelView.fOriginal(ecx, vecNewOrigin, vecNewAngles); 426 | } 427 | 428 | float __fastcall Hooks::dProcessUsercmds(void *ecx, void *edx, edict_t *player, void *buf, int numcmds, int totalcmds, int dropped_packets, bool ignore, bool paused) 429 | { 430 | Server_BaseEntity *pPlayer = (Server_BaseEntity*)player->m_pUnk->GetBaseEntity(); 431 | 432 | int index = EntityIndex(pPlayer); 433 | m_Game->m_CurrentUsercmdID = index; 434 | 435 | return hkProcessUsercmds.fOriginal(ecx, player, buf, numcmds, totalcmds, dropped_packets, ignore, paused); 436 | } 437 | 438 | int Hooks::dWriteUsercmd(bf_write *buf, CUserCmd *to, CUserCmd *from) 439 | { 440 | auto result = hkWriteUsercmd.fOriginal(buf, to, from); 441 | 442 | // Let's write our stuff into the buffer 443 | if (m_VR->m_IsVREnabled) 444 | { 445 | Vector controllerPos = m_VR->GetRightControllerAbsPos(); 446 | QAngle controllerAngles = m_VR->GetRightControllerAbsAngle(); 447 | 448 | buf->WriteChar(-2); 449 | buf->WriteBitVec3Coord(controllerPos); 450 | buf->WriteBitAngles(controllerAngles); 451 | } 452 | 453 | return result; 454 | } 455 | 456 | int Hooks::dReadUsercmd(bf_read *buf, CUserCmd* move, CUserCmd* from) 457 | { 458 | auto result = hkReadUsercmd.fOriginal(buf, move, from); 459 | 460 | int i = m_Game->m_CurrentUsercmdID; 461 | auto& vrPlayer = m_Game->m_PlayersVRInfo[i]; 462 | 463 | auto pos = buf->Tell(); 464 | int res = buf->ReadChar(); 465 | 466 | // This means we got a VR player on the other side 467 | if (res == -2) 468 | { 469 | vrPlayer.isUsingVR = true; 470 | buf->ReadBitVec3Coord(vrPlayer.controllerPos); 471 | buf->ReadBitAngles(vrPlayer.controllerAngle); 472 | } 473 | else { 474 | vrPlayer.isUsingVR = false; 475 | buf->Seek(pos); 476 | } 477 | 478 | return result; 479 | } 480 | 481 | 482 | void Hooks::dAdjustEngineViewport(int &x, int &y, int &width, int &height) 483 | { 484 | width = m_VR->m_RenderWidth; 485 | height = m_VR->m_RenderHeight; 486 | 487 | hkAdjustEngineViewport.fOriginal(x, y, width, height); 488 | } 489 | 490 | void Hooks::dGetViewport(void *ecx, void *edx, int &x, int &y, int &width, int &height) 491 | { 492 | hkGetViewport.fOriginal(ecx, x, y, width, height); 493 | 494 | width = m_VR->m_RenderWidth; 495 | height = m_VR->m_RenderHeight; 496 | } 497 | 498 | int Hooks::dGetPrimaryAttackActivity(void *ecx, void *edx, void *meleeInfo) 499 | { 500 | return hkGetPrimaryAttackActivity.fOriginal(ecx, meleeInfo); 501 | } 502 | 503 | Vector *Hooks::dEyePosition(void *ecx, void *edx, Vector *eyePos) 504 | { 505 | Vector *result = hkEyePosition.fOriginal(ecx, eyePos); 506 | return result; 507 | } 508 | 509 | // We'll keep this for... future reference! 510 | void Hooks::dDrawModelExecute(void *ecx, void *edx, void *state, const ModelRenderInfo_t &info, void *pCustomBoneToWorld) 511 | { 512 | if (info.pModel) 513 | { 514 | std::string modelName = m_Game->m_ModelInfo->GetModelName(info.pModel); 515 | if (modelName.find("/arms/") != std::string::npos) 516 | { 517 | m_Game->m_ArmsMaterial = m_Game->m_MaterialSystem->FindMaterial(modelName.c_str(), "Model textures"); 518 | m_Game->m_ArmsModel = info.pModel; 519 | m_Game->m_CachedArmsModel = true; 520 | } 521 | } 522 | 523 | if (info.pModel && info.pModel == m_Game->m_ArmsModel) 524 | { 525 | m_Game->m_ArmsMaterial->SetMaterialVarFlag(MATERIAL_VAR_NO_DRAW, true); 526 | m_Game->m_ModelRender->ForcedMaterialOverride(m_Game->m_ArmsMaterial); 527 | hkDrawModelExecute.fOriginal(ecx, state, info, pCustomBoneToWorld); 528 | m_Game->m_ModelRender->ForcedMaterialOverride(NULL); 529 | return; 530 | } 531 | 532 | hkDrawModelExecute.fOriginal(ecx, state, info, pCustomBoneToWorld); 533 | } 534 | 535 | void Hooks::dPushRenderTargetAndViewport(void *ecx, void *edx, ITexture *pTexture, ITexture *pDepthTexture, int nViewX, int nViewY, int nViewW, int nViewH) 536 | { 537 | if (m_VR->m_CreatedVRTextures && !m_PushedHud) 538 | { 539 | pTexture = m_VR->m_HUDTexture; 540 | 541 | //pTexture = m_VR->m_RightEyeTexture; 542 | 543 | IMatRenderContext *renderContext = m_Game->m_MaterialSystem->GetRenderContext(); 544 | renderContext->ClearBuffers(false, true, true); 545 | renderContext->Release(); 546 | 547 | hkPushRenderTargetAndViewport.fOriginal(ecx, pTexture, pDepthTexture, nViewX, nViewY, nViewW, nViewH); 548 | 549 | renderContext = m_Game->m_MaterialSystem->GetRenderContext(); 550 | renderContext->OverrideAlphaWriteEnable(true, true); 551 | renderContext->ClearColor4ub(0, 0, 0, 0); 552 | renderContext->ClearBuffers(true, false); 553 | renderContext->Release(); 554 | 555 | m_VR->m_RenderedHud = true; 556 | m_PushedHud = true; 557 | } 558 | else 559 | { 560 | hkPushRenderTargetAndViewport.fOriginal(ecx, pTexture, pDepthTexture, nViewX, nViewY, nViewW, nViewH); 561 | } 562 | } 563 | 564 | void Hooks::dPopRenderTargetAndViewport(void *ecx, void *edx) 565 | { 566 | if (!m_VR->m_CreatedVRTextures) 567 | return hkPopRenderTargetAndViewport.fOriginal(ecx); 568 | 569 | //std::cout << "dPopRenderTargetAndViewport: " << m_PushHUDStep << "\n"; 570 | 571 | m_PushHUDStep = 0; 572 | 573 | if (m_PushedHud) 574 | { 575 | IMatRenderContext* renderContext = m_Game->m_MaterialSystem->GetRenderContext(); 576 | renderContext->OverrideAlphaWriteEnable(false, true); 577 | renderContext->ClearColor4ub(0, 0, 0, 255); 578 | renderContext->Release(); 579 | } 580 | 581 | hkPopRenderTargetAndViewport.fOriginal(ecx); 582 | } 583 | 584 | void Hooks::dVGui_Paint(void *ecx, void *edx, int mode) 585 | { 586 | if (!m_VR->m_CreatedVRTextures || m_VR->m_Game->m_VguiSurface->IsCursorVisible()) 587 | return hkVgui_Paint.fOriginal(ecx, mode); 588 | 589 | //std::cout << "dVGui_Paint\n"; 590 | 591 | if (m_PushedHud) 592 | mode = PAINT_UIPANELS | PAINT_INGAMEPANELS; 593 | 594 | hkVgui_Paint.fOriginal(ecx, mode); 595 | } 596 | 597 | int Hooks::dIsSplitScreen() 598 | { 599 | //std::cout << "dIsSplitScreen: " << m_PushHUDStep << "\n"; 600 | 601 | if (m_PushHUDStep == 0) 602 | ++m_PushHUDStep; 603 | else 604 | m_PushHUDStep = -999; 605 | 606 | return hkIsSplitScreen.fOriginal(); 607 | } 608 | 609 | DWORD *Hooks::dPrePushRenderTarget(void *ecx, void *edx, int a2) 610 | { 611 | //std::cout << "dPrePushRenderTarget: " << m_PushHUDStep << "\n"; 612 | 613 | if (m_PushHUDStep == 1) 614 | ++m_PushHUDStep; 615 | else 616 | m_PushHUDStep = -999; 617 | 618 | return hkPrePushRenderTarget.fOriginal(ecx, a2); 619 | } 620 | 621 | Vector* Hooks::dWeapon_ShootPosition(void* ecx, void* edx, Vector* eyePos) 622 | { 623 | Vector* result = hkWeapon_ShootPosition.fOriginal(ecx, eyePos); 624 | 625 | int localIndex = m_Game->m_EngineClient->GetLocalPlayer(); 626 | int index = EntityIndex(ecx); 627 | 628 | auto vrPlayer = m_Game->m_PlayersVRInfo[index]; 629 | 630 | if (m_VR->m_IsVREnabled && localIndex == index) { 631 | *result = m_VR->GetRightControllerAbsPos(); 632 | } 633 | else if (vrPlayer.isUsingVR) 634 | { 635 | *result = vrPlayer.controllerPos; 636 | } 637 | 638 | return result; 639 | } 640 | 641 | void* Hooks::dCWeaponPortalgun_FirePortal(void* ecx, void* edx, bool bPortal2, Vector* pVector) { 642 | bool wasTrue = m_VR->m_OverrideEyeAngles; 643 | 644 | m_VR->m_OverrideEyeAngles = true; 645 | 646 | auto result = hkCWeaponPortalgun_FirePortal.fOriginal(ecx, bPortal2, pVector); 647 | 648 | if (!wasTrue) 649 | m_VR->m_OverrideEyeAngles = false; 650 | 651 | return result; 652 | } 653 | 654 | bool __fastcall Hooks::dTraceFirePortal(void* ecx, void* edx, const Vector& vTraceStart, const Vector& vDirection, bool bPortal2, int iPlacedBy, void* tr) //trace_tx& tr, Vector& vFinalPosition // , Vector& vFinalPosition, QAngle& qFinalAngles, int iPlacedBy, bool bTest /*= false*/ 655 | { 656 | Vector vNewTraceStart = vTraceStart; 657 | Vector vNewDirection = vDirection; 658 | 659 | if (iPlacedBy == 2) { 660 | int localIndex = m_Game->m_EngineClient->GetLocalPlayer(); 661 | 662 | auto owner = GetOwner(ecx); 663 | 664 | if (owner) { 665 | int index = EntityIndex(owner); 666 | 667 | auto vrPlayer = m_Game->m_PlayersVRInfo[index]; 668 | 669 | if (m_VR->m_IsVREnabled && localIndex == index) { 670 | vNewTraceStart = m_VR->GetRightControllerAbsPos(); 671 | vNewDirection = m_VR->m_RightControllerForward; 672 | } 673 | else if (vrPlayer.isUsingVR) 674 | { 675 | vNewTraceStart = vrPlayer.controllerPos; 676 | Vector fwd, rt, up; 677 | QAngle::AngleVectors(vrPlayer.controllerAngle, &fwd, &rt, &up); 678 | vNewDirection = fwd; 679 | } 680 | } 681 | } 682 | 683 | return hkTraceFirePortal.fOriginal(ecx, vNewTraceStart, vNewDirection, bPortal2, iPlacedBy, tr); 684 | } 685 | 686 | void __fastcall Hooks::dPlayerPortalled(void* ecx, void* edx, void* a2, __int64 a3) 687 | { 688 | CBaseEntity* pBaseEntity = (CBaseEntity*)ecx; 689 | 690 | QAngle angAbsRotationBefore; 691 | m_Game->m_EngineClient->GetViewAngles(angAbsRotationBefore); 692 | 693 | hkPlayerPortalled.fOriginal(ecx, a2, a3); 694 | 695 | QAngle angAbsRotationAfter; 696 | m_Game->m_EngineClient->GetViewAngles(angAbsRotationAfter); 697 | 698 | if (angAbsRotationBefore != angAbsRotationAfter) { 699 | m_VR->m_PortalRotationOffset = angAbsRotationAfter - angAbsRotationBefore; 700 | m_VR->m_ApplyPortalRotationOffset = true; 701 | } 702 | 703 | return; 704 | } 705 | 706 | int Hooks::dGetModeHeight(void* ecx, void* edx) { 707 | //std::cout << "dGetModeHeight\n"; 708 | return m_VR->m_RenderHeight; 709 | } 710 | 711 | bool Hooks::dClipTransform(const Vector& point, Vector* pScreen) 712 | { 713 | return hkClipTransform.fOriginal(point, pScreen); 714 | } 715 | 716 | bool Hooks::ScreenTransform(const Vector& point, Vector* pScreen, int width, int height) 717 | { 718 | bool retval = hkClipTransform.fOriginal(point, pScreen); 719 | 720 | pScreen->x = 0.5f * (pScreen->x + 1.0f) * width; 721 | pScreen->y = 0.5f * (-pScreen->y + 1.0f) * height; 722 | 723 | return retval; 724 | } 725 | 726 | int __fastcall Hooks::dDrawSelf(void* ecx, void* edx, int x, int y, int w, int h, const void* clr, float flApparentZ) { 727 | //std::cout << "dDrawSelf - X: " << x << ", Y: " << y << ", W: " << w << ", H: " << h << ", Z: " << flApparentZ << "\n"; 728 | 729 | //int playerIndex = m_Game->m_EngineClient->GetLocalPlayer(); 730 | 731 | //auto viewport = m_Game->m_ClientMode->GetViewport(); 732 | 733 | int newX = x; 734 | int newY = y; 735 | 736 | if (m_VR->m_IsVREnabled) 737 | { 738 | int windowWidth, windowHeight; 739 | m_Game->m_MaterialSystem->GetRenderContext()->GetWindowSize(windowWidth, windowHeight); 740 | 741 | Vector screen = { 0, 0, 0 }; 742 | 743 | //Vector vec = m_VR->m_AimPos - m_VR->GetRightControllerAbsPos(); 744 | 745 | //newZ = 1.0 / sqrt(vec.x * vec.x + vec.y * vec.y + vec.z * vec.z); 746 | 747 | ScreenTransform(m_VR->m_AimPos, &screen, m_VR->m_RenderWidth, m_VR->m_RenderHeight); 748 | 749 | int offsetX = x - (windowWidth * 0.5f); 750 | int offsetY = y - (windowHeight * 0.5f); 751 | 752 | newX = screen.x + offsetX; 753 | newY = screen.y + offsetY; 754 | } 755 | 756 | return hkDrawSelf.fOriginal(ecx, newX, newY, w, h, clr, flApparentZ); 757 | } 758 | 759 | void __cdecl Hooks::dVGui_GetHudBounds(int slot, int& x, int& y, int& w, int& h) { 760 | if (m_VR->m_IsVREnabled && !m_Game->m_VguiSurface->IsCursorVisible()) 761 | { 762 | x = y = 0; 763 | w = m_VR->m_RenderWidth; 764 | h = m_VR->m_RenderHeight; 765 | } else { 766 | hkVGui_GetHudBounds.fOriginal(slot, x, y, w, h); 767 | } 768 | 769 | //std::cout << "dVGui_GetHudBounds - X: " << x << ", Y: " << y << ", W: " << w << ", H: " << h << "\n"; 770 | } 771 | 772 | void __cdecl Hooks::dVGui_GetPanelBounds(int slot, int& x, int& y, int& w, int& h) { 773 | if (m_VR->m_IsVREnabled && !m_Game->m_VguiSurface->IsCursorVisible()) 774 | { 775 | x = y = 0; 776 | w = m_VR->m_RenderWidth; 777 | h = m_VR->m_RenderHeight; 778 | } 779 | else { 780 | hkVGui_GetPanelBounds.fOriginal(slot, x, y, w, h); 781 | } 782 | 783 | //std::cout << "dVGui_GetPanelBounds - X: " << x << ", Y: " << y << ", W: " << w << ", H: " << h << "\n"; 784 | } 785 | 786 | void __cdecl Hooks::dVGUI_UpdateScreenSpaceBounds(int nNumSplits, int sx, int sy, int sw, int sh) { 787 | hkVGUI_UpdateScreenSpaceBounds.fOriginal(nNumSplits, sx, sy, m_VR->m_RenderWidth, m_VR->m_RenderHeight); 788 | } 789 | 790 | void __cdecl Hooks::dVGui_GetTrueScreenSize(int &w, int &h) { 791 | w = m_VR->m_RenderWidth; 792 | h = m_VR->m_RenderHeight; 793 | } 794 | 795 | void __fastcall Hooks::dGetScreenSize(void* ecx, void* edx, int& wide, int& tall) { 796 | //hkGetScreenSize.fOriginal(ecx, wide, tall); 797 | wide = m_VR->m_RenderWidth; 798 | tall = m_VR->m_RenderHeight; 799 | } 800 | 801 | void __cdecl Hooks::dGetHudSize(int& w, int& h) { 802 | w = m_VR->m_RenderWidth; 803 | h = m_VR->m_RenderHeight; 804 | } 805 | 806 | void __fastcall Hooks::dPush2DView(void* ecx, void* edx, IMatRenderContext* pRenderContext, const CViewSetup& view, int nFlags, ITexture* pRenderTarget, void* frustumPlanes) { 807 | m_PushedHud = false; 808 | 809 | return hkPush2DView.fOriginal(ecx, pRenderContext, view, nFlags, pRenderTarget, frustumPlanes); 810 | } 811 | 812 | void __fastcall Hooks::dRender(void* ecx, void* edx, vrect_t* rect) { 813 | //std::cout << "dRender - X: " << rect->x << ", Y: " << rect->y << ", W: " << rect->width << ", H: " << rect->height << "\n"; 814 | 815 | return hkRender.fOriginal(ecx, rect); 816 | } 817 | 818 | void __fastcall Hooks::dSetBounds(void* ecx, void* edx, int x, int y, int w, int h) { 819 | std::cout << "dSetBounds - X: " << x << ", Y: " << y << ", W: " << w << ", H: " << h << "\n"; 820 | 821 | hkSetBounds.fOriginal(ecx, x, y, m_VR->m_RenderWidth, m_VR->m_RenderHeight); 822 | } 823 | 824 | void __fastcall Hooks::dSetSize(void* ecx, void* edx, int wide, int tall) { 825 | hkSetSize.fOriginal(ecx, wide, tall); 826 | 827 | //std::cout << "dSetSize - Wide: " << wide << ", Tall: " << tall << "\n"; 828 | } 829 | 830 | void __fastcall Hooks::dGetClipRect(void* ecx, void* edx, int& x0, int& y0, int& x1, int& y1) { 831 | hkGetClipRect.fOriginal(ecx, x0, y0, x1, y1); 832 | 833 | //std::cout << "dGetClipRect - X: " << x0 << ", Y: " << y0 << ", W: " << x1 << ", H: " << y1 << "\n"; 834 | } 835 | 836 | double __fastcall Hooks::dComputeError(void* ecx, void* edx) { 837 | bool wasTrue = m_VR->m_OverrideEyeAngles; 838 | 839 | m_VR->m_OverrideEyeAngles = true; 840 | 841 | double computedError = hkComputeError.fOriginal(edx); 842 | 843 | if (!wasTrue) 844 | m_VR->m_OverrideEyeAngles = false; 845 | 846 | return computedError; 847 | } 848 | 849 | bool __fastcall Hooks::dUpdateObject(void* ecx, void* edx, void* pPlayer, float flError, bool bIsTeleport) { 850 | bool wasTrue = m_VR->m_OverrideEyeAngles; 851 | 852 | m_VR->m_OverrideEyeAngles = true; 853 | 854 | bool value = hkUpdateObject.fOriginal(ecx, pPlayer, flError, bIsTeleport); 855 | 856 | if (!wasTrue) 857 | m_VR->m_OverrideEyeAngles = false; 858 | 859 | return value; 860 | } 861 | 862 | bool __fastcall Hooks::dUpdateObjectVM(void* ecx, void* edx, void* pPlayer, float flError) { 863 | bool wasTrue = m_VR->m_OverrideEyeAngles; 864 | 865 | m_VR->m_OverrideEyeAngles = true; 866 | 867 | bool value = hkUpdateObjectVM.fOriginal(ecx, pPlayer, flError); 868 | 869 | if (!wasTrue) 870 | m_VR->m_OverrideEyeAngles = false; 871 | 872 | return value; 873 | } 874 | 875 | // This function is apparently not used by Portal 2, remove? 876 | void __fastcall Hooks::dRotateObject(void* ecx, void* edx, void* pPlayer, float fRotAboutUp, float fRotAboutRight, bool bUseWorldUpInsteadOfPlayerUp) { 877 | bool wasTrue = m_VR->m_OverrideEyeAngles; 878 | 879 | m_VR->m_OverrideEyeAngles = true; 880 | 881 | hkRotateObject.fOriginal(ecx, pPlayer, fRotAboutUp, fRotAboutRight, bUseWorldUpInsteadOfPlayerUp); 882 | 883 | if (!wasTrue) 884 | m_VR->m_OverrideEyeAngles = false; 885 | } 886 | 887 | // This is CPlayerBase, do we also need to hook CPortalPlayer? can the same function be used by both? 888 | // This works for release, but why was it crashing before??? TODO: buy a c++ book... 889 | QAngle& __fastcall Hooks::dEyeAngles(void* ecx, void* edx) { 890 | if (m_VR->m_OverrideEyeAngles) { 891 | int localIndex = m_Game->m_EngineClient->GetLocalPlayer(); 892 | int index = EntityIndex(ecx); 893 | 894 | auto& vrPlayer = m_Game->m_PlayersVRInfo[index]; 895 | 896 | if (m_VR->m_IsVREnabled && localIndex == index) { 897 | return m_VR->GetRightControllerAbsAngleConst(); 898 | } 899 | else if (vrPlayer.isUsingVR) 900 | { 901 | return vrPlayer.controllerAngle; 902 | } 903 | } 904 | 905 | return hkEyeAngles.fOriginal(ecx); 906 | } 907 | 908 | int __fastcall Hooks::dGetDefaultFOV(void* ecx, void* edx) { 909 | return m_VR->m_Fov; 910 | } 911 | 912 | double __fastcall Hooks::dGetFOV(void* ecx, void* edx) { 913 | return m_VR->m_Fov; 914 | } 915 | 916 | double __fastcall Hooks::dGetViewModelFOV(void* ecx, void* edx) { 917 | return m_VR->m_Fov; 918 | } -------------------------------------------------------------------------------- /L4D2VR/hooks.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "MinHook.h" 4 | #include "bitbuf.h" 5 | 6 | class Game; 7 | class VR; 8 | class ITexture; 9 | class CViewSetup; 10 | class CUserCmd; 11 | class QAngle; 12 | class Vector; 13 | class edict_t; 14 | class ModelRenderInfo_t; 15 | struct trace_tx; 16 | class IMatRenderContext; 17 | struct vrect_t; 18 | struct Ray_t; 19 | struct VMatrix; 20 | struct Rect_t; 21 | class bf_write; 22 | class bf_read; 23 | 24 | 25 | template 26 | struct Hook { 27 | T fOriginal; 28 | LPVOID pTarget; 29 | bool isEnabled; 30 | 31 | int createHook(LPVOID targetFunc, LPVOID detourFunc) 32 | { 33 | if (MH_CreateHook(targetFunc, detourFunc, reinterpret_cast(&fOriginal)) != MH_OK) 34 | { 35 | char errorString[512]; 36 | sprintf_s(errorString, 512, "Failed to create hook with this signature: %s", typeid(T).name()); 37 | Game::errorMsg(errorString); 38 | return 1; 39 | } 40 | pTarget = targetFunc; 41 | } 42 | 43 | int enableHook() 44 | { 45 | if (!pTarget) 46 | throw std::invalid_argument("pTarget is empty, did you miss a call to createHook?"); 47 | 48 | MH_STATUS status = MH_EnableHook(pTarget); 49 | if (status != MH_OK) 50 | { 51 | char errorString[256]; 52 | sprintf_s(errorString, 256, "Failed to enable hook: %i", status); 53 | Game::errorMsg(errorString); 54 | return 1; 55 | } 56 | isEnabled = true; 57 | } 58 | 59 | int disableHook() 60 | { 61 | if (MH_DisableHook(pTarget) != MH_OK) 62 | { 63 | Game::errorMsg("Failed to disable hook"); 64 | return 1; 65 | } 66 | isEnabled = false; 67 | } 68 | }; 69 | 70 | 71 | // Source Engine functions 72 | typedef ITexture *(__thiscall *tGetRenderTarget)(void *thisptr); 73 | typedef void(__thiscall *tRenderView)(void *thisptr, CViewSetup &setup, CViewSetup &hudViewSetup, int nClearFlags, int whatToDraw); 74 | typedef bool(__thiscall *tCreateMove)(void *thisptr, float flInputSampleTime, CUserCmd *cmd); 75 | typedef void(__thiscall *tEndFrame)(PVOID); 76 | typedef void(__thiscall *tCalcViewModelView)(void *thisptr, const Vector &eyePosition, const QAngle &eyeAngles); 77 | typedef float(__thiscall *tProcessUsercmds)(void *thisptr, edict_t *player, void *buf, int numcmds, int totalcmds, int dropped_packets, bool ignore, bool paused); 78 | typedef int(__cdecl *tReadUsercmd)(void *buf, CUserCmd *move, CUserCmd *from); 79 | typedef void(__thiscall *tWriteUsercmdDeltaToBuffer)(void *thisptr, int a1, void *buf, int from, int to, bool isnewcommand); 80 | typedef int(__cdecl *tWriteUsercmd)(void *buf, CUserCmd *to, CUserCmd *from); 81 | typedef int(__cdecl *tAdjustEngineViewport)(int &x, int &y, int &width, int &height); 82 | typedef void(__thiscall *tViewport)(void *thisptr, int x, int y, int width, int height); 83 | typedef void(__thiscall *tGetViewport)(void *thisptr, int &x, int &y, int &width, int &height); 84 | typedef int(__thiscall *tGetPrimaryAttackActivity)(void *thisptr, void *meleeInfo); 85 | typedef Vector *(__thiscall *tEyePosition)(void *thisptr, Vector *eyePos); 86 | typedef void(__thiscall *tDrawModelExecute)(void *thisptr, void *state, const ModelRenderInfo_t &info, void *pCustomBoneToWorld); 87 | typedef void(__thiscall *tPushRenderTargetAndViewport)(void *thisptr, ITexture *pTexture, ITexture *pDepthTexture, int nViewX, int nViewY, int nViewW, int nViewH); 88 | typedef void(__thiscall *tPopRenderTargetAndViewport)(void *thisptr); 89 | typedef void(__thiscall *tVgui_Paint)(void *thisptr, int mode); 90 | typedef int(__cdecl *tIsSplitScreen)(); 91 | typedef DWORD *(__thiscall *tPrePushRenderTarget)(void *thisptr, int a2); 92 | typedef ITexture* (__thiscall* tGetFullScreenTexture)(); 93 | 94 | typedef bool(__thiscall* tTraceFirePortal)(void* thisptr, const Vector& vTraceStart, const Vector& vDirection, bool bPortal2, int iPlacedBy, void* tr); 95 | 96 | typedef void(__thiscall* tPlayerPortalled)(void* thisptr, void* a2, __int64 a3); 97 | 98 | typedef int(__thiscall* tGetModeHeight)(void* thisptr); 99 | typedef int(__thiscall* tDrawSelf)(void* thisptr, int x, int y, int w, int h, const void* clr, float flApparentZ); 100 | typedef bool(__cdecl* tClipTransform)(const Vector& point, Vector* pClip); 101 | typedef void(__cdecl* tVGui_GetHudBounds)(int slot, int& x, int& y, int& w, int& h); 102 | typedef void(__cdecl* tVGui_GetPanelBounds)(int slot, int& x, int& y, int& w, int& h); 103 | 104 | // HUD 105 | typedef void(__cdecl* tVGUI_UpdateScreenSpaceBounds)(int nNumSplits, int sx, int sy, int sw, int sh); 106 | typedef void(__cdecl* tVGui_GetTrueScreenSize)(int &w, int &h); 107 | 108 | typedef void(__cdecl* tGetHudSize)(int& w, int& h); 109 | 110 | typedef void(__thiscall* tSetBounds)(void* thisptr, int x, int y, int w, int h); 111 | typedef void(__thiscall* tSetSize)(void* thisptr, int wide, int tall); 112 | typedef void(__thiscall* tGetScreenSize)(void* thisptr, int& wide, int& tall); 113 | typedef void(__thiscall* tPush2DView)(void* thisptr, IMatRenderContext* pRenderContext, const CViewSetup& view, int nFlags, ITexture* pRenderTarget, void* frustumPlanes); 114 | typedef void(__thiscall* tRender)(void* thisptr, vrect_t* rect); 115 | typedef void(__thiscall* tGetClipRect)(void* thisptr, int& x0, int& y0, int& x1, int& y1); 116 | 117 | typedef Vector* (__thiscall* tWeapon_ShootPosition)(void* thisptr, Vector* shootPos); 118 | typedef double(__thiscall* tComputeError)(void* thisptr); 119 | typedef bool(__thiscall* tUpdateObject)(void* thisptr, void* pPlayer, float flError, bool bIsTeleport); 120 | typedef bool(__thiscall* tUpdateObjectVM)(void* thisptr, void* pPlayer, float flError); 121 | typedef void(__thiscall* tRotateObject)(void* thisptr, void* pPlayer, float fRotAboutUp, float fRotAboutRight, bool bUseWorldUpInsteadOfPlayerUp); 122 | typedef QAngle&(__thiscall* tEyeAngles)(void* thisptr); 123 | 124 | typedef void(__cdecl* tMatrixBuildPerspectiveX)(void*& dst, double flFovX, double flAspect, double flZNear, double flZFar); 125 | 126 | typedef int(__cdecl* tGetDefaultFOV)(void*& thisptr); 127 | typedef double(__cdecl* tGetFOV)(void*& thisptr); 128 | typedef double(__cdecl* tGetViewModelFOV)(void*& thisptr); 129 | 130 | typedef void(__thiscall* tCreatePingPointer)(void* thisptr, Vector vecDestintaion); 131 | typedef void(__thiscall* tSetDrawOnlyForSplitScreenUser)(void* thisptr, int nSlot); 132 | typedef void(__thiscall* tClientThink)(void* thisptr); 133 | typedef void*(__cdecl* tGetPortalPlayer)(int index); 134 | typedef int(__cdecl* tPrecacheParticleSystem)(const char* pParticleSystemName); 135 | typedef void(__thiscall* tPrecache)(void* thisptr); 136 | typedef bool(__thiscall* tCHudCrosshair_ShouldDraw)(void* thisptr); 137 | 138 | typedef void*(__cdecl* tUTIL_Portal_FirstAlongRay)(const Ray_t& ray, float& fMustBeCloserThan); 139 | typedef float(__cdecl* tUTIL_IntersectRayWithPortal)(const Ray_t& ray, const void* pPortal); 140 | typedef void(__cdecl* tUTIL_Portal_AngleTransform)(const VMatrix& matThisToLinked, const QAngle& qSource, QAngle& qTransformed); 141 | typedef int(__thiscall* tEntindex)(void* thisptr); 142 | typedef void*(__thiscall* tGetOwner)(void* thisptr); 143 | typedef void* (__thiscall* tCWeaponPortalgun_FirePortal)(void* thisptr, bool bPortal2, Vector* pVector); 144 | 145 | class Hooks 146 | { 147 | public: 148 | static inline Game *m_Game; 149 | static inline VR *m_VR; 150 | 151 | static inline Hook hkGetRenderTarget; 152 | static inline Hook hkRenderView; 153 | static inline Hook hkCreateMove; 154 | static inline Hook hkEndFrame; 155 | static inline Hook hkCalcViewModelView; 156 | static inline Hook hkProcessUsercmds; 157 | static inline Hook hkReadUsercmd; 158 | static inline Hook hkWriteUsercmdDeltaToBuffer; 159 | static inline Hook hkWriteUsercmd; 160 | static inline Hook hkAdjustEngineViewport; 161 | static inline Hook hkViewport; 162 | static inline Hook hkGetViewport; 163 | static inline Hook hkGetPrimaryAttackActivity; 164 | static inline Hook hkEyePosition; 165 | static inline Hook hkDrawModelExecute; 166 | static inline Hook hkPushRenderTargetAndViewport; 167 | static inline Hook hkPopRenderTargetAndViewport; 168 | static inline Hook hkVgui_Paint; 169 | static inline Hook hkIsSplitScreen; 170 | static inline Hook hkPrePushRenderTarget; 171 | static inline Hook hkGetFullScreenTexture; 172 | static inline Hook hkWeapon_ShootPosition; 173 | static inline Hook hkTraceFirePortal; 174 | 175 | static inline Hook hkGetModeHeight; 176 | static inline Hook hkDrawSelf; 177 | static inline Hook hkClipTransform; 178 | static inline Hook hkPlayerPortalled; 179 | static inline Hook hkVGui_GetHudBounds; 180 | static inline Hook hkVGui_GetPanelBounds; 181 | 182 | static inline Hook hkVGUI_UpdateScreenSpaceBounds; 183 | static inline Hook hkVGui_GetTrueScreenSize; 184 | 185 | static inline Hook hkSetBounds; 186 | static inline Hook hkGetScreenSize; 187 | static inline Hook hkPush2DView; 188 | static inline Hook hkRender; 189 | static inline Hook hkGetClipRect; 190 | static inline Hook hkGetHudSize; 191 | static inline Hook hkSetSize; 192 | 193 | static inline Hook hkComputeError; 194 | static inline Hook hkUpdateObject; 195 | static inline Hook hkUpdateObjectVM; 196 | static inline Hook hkRotateObject; 197 | static inline Hook hkEyeAngles; 198 | 199 | static inline Hook hkMatrixBuildPerspectiveX; 200 | 201 | static inline Hook hkGetDefaultFOV; 202 | static inline Hook hkGetFOV; 203 | static inline Hook hkGetViewModelFOV; 204 | 205 | static inline Hook hkSetDrawOnlyForSplitScreenUser; 206 | static inline Hook hkClientThink; 207 | static inline Hook hkPrecache; 208 | static inline Hook hkCHudCrosshair_ShouldDraw; 209 | static inline Hook hkCWeaponPortalgun_FirePortal; 210 | 211 | //Precache 212 | 213 | Hooks() {}; 214 | Hooks(Game *game); 215 | 216 | ~Hooks(); 217 | 218 | int initSourceHooks(); 219 | 220 | // Detour functions 221 | static ITexture *__fastcall dGetRenderTarget(void *ecx, void *edx); 222 | static void __fastcall dRenderView(void *ecx, void *edx, CViewSetup &setup, CViewSetup &hudViewSetup, int nClearFlags, int whatToDraw); 223 | static bool __fastcall dCreateMove(void *ecx, void *edx, float flInputSampleTime, CUserCmd *cmd); 224 | static void __fastcall dEndFrame(void *ecx, void *edx); 225 | static void __fastcall dCalcViewModelView(void *ecx, void *edx, const Vector &eyePosition, const QAngle &eyeAngles); 226 | static int dServerFireTerrorBullets(int playerId, const Vector &vecOrigin, const QAngle &vecAngles, int a4, int a5, int a6, float a7); 227 | static int dClientFireTerrorBullets(int playerId, const Vector &vecOrigin, const QAngle &vecAngles, int a4, int a5, int a6, float a7); 228 | static float __fastcall dProcessUsercmds(void *ecx, void *edx, edict_t *player, void *buf, int numcmds, int totalcmds, int dropped_packets, bool ignore, bool paused); 229 | static int dReadUsercmd(bf_read *buf, CUserCmd *move, CUserCmd *from); 230 | static int dWriteUsercmd(bf_write *buf, CUserCmd *to, CUserCmd *from); 231 | static void dAdjustEngineViewport(int &x, int &y, int &width, int &height); 232 | static void __fastcall dViewport(void *ecx, void *edx, int x, int y, int width, int height); 233 | static void __fastcall dGetViewport(void *ecx, void *edx, int &x, int &y, int &width, int &height); 234 | static int __fastcall dTestMeleeSwingCollisionClient(void *ecx, void *edx, Vector const &vec); 235 | static int __fastcall dTestMeleeSwingCollisionServer(void *ecx, void *edx, Vector const &vec); 236 | static void __fastcall dDoMeleeSwingServer(void *ecx, void *edx); 237 | static void __fastcall dStartMeleeSwingServer(void *ecx, void *edx, void *player, bool a3); 238 | static int __fastcall dPrimaryAttackServer(void *ecx, void *edx); 239 | static void __fastcall dItemPostFrameServer(void *ecx, void *edx); 240 | static int __fastcall dGetPrimaryAttackActivity(void *ecx, void *edx, void* meleeInfo); 241 | static Vector *__fastcall dEyePosition(void *ecx, void *edx, Vector *eyePos); 242 | static void __fastcall dDrawModelExecute(void *ecx, void* edx, void *state, const ModelRenderInfo_t &info, void *pCustomBoneToWorld); 243 | static void __fastcall dPushRenderTargetAndViewport(void *ecx, void *edx, ITexture *pTexture, ITexture *pDepthTexture, int nViewX, int nViewY, int nViewW, int nViewH); 244 | static void __fastcall dPopRenderTargetAndViewport(void *ecx, void *edx); 245 | static void __fastcall dVGui_Paint(void *ecx, void *edx, int mode); 246 | static int __fastcall dIsSplitScreen(); 247 | static DWORD *__fastcall dPrePushRenderTarget(void *ecx, void *edx, int a2); 248 | static ITexture *__fastcall dGetFullScreenTexture(); 249 | 250 | // Fire portals from right controller 251 | static bool __fastcall dTraceFirePortal(void* ecx, void* edx, const Vector& vTraceStart, const Vector& vDirection, bool bPortal2, int iPlacedBy, void* tr); 252 | 253 | // Portalling angle fix 254 | static void __fastcall dPlayerPortalled(void* ecx, void* edx, void* a2, __int64 a3); 255 | 256 | // Crosshair 257 | static int __fastcall dGetModeHeight(void* ecx, void* edx); 258 | static int __fastcall dDrawSelf(void* ecx, void* edx, int x, int y, int w, int h, const void* clr, float flApparentZ); 259 | static bool dClipTransform(const Vector& point, Vector* pScreen); 260 | static void __fastcall dSetBounds(void* ecx, void* edx, int x, int y, int w, int h); 261 | static void __fastcall dSetSize(void* ecx, void* edx, int wide, int tall); 262 | static void __fastcall dGetScreenSize(void* ecx, void* edx, int& wide, int& tall); 263 | static void dGetHudSize(int& w, int& h); 264 | static void dVGui_GetHudBounds(int slot, int& x, int& y, int& w, int& h); 265 | static void dVGui_GetPanelBounds(int slot, int& x, int& y, int& w, int& h); 266 | 267 | static void dVGUI_UpdateScreenSpaceBounds(int nNumSplits, int sx, int sy, int sw, int sh); 268 | static void dVGui_GetTrueScreenSize(int &w, int &h); 269 | 270 | static void __fastcall dPush2DView(void* ecx, void* edx, IMatRenderContext* pRenderContext, const CViewSetup& view, int nFlags, ITexture* pRenderTarget, void* frustumPlanes); 271 | static void __fastcall dRender(void* ecx, void* edx, vrect_t* rect); 272 | static bool ScreenTransform(const Vector& point, Vector* pScreen, int width, int height); 273 | static void __fastcall dGetClipRect(void* ecx, void* edx, int& x0, int& y0, int& x1, int& y1); 274 | 275 | // Grabbable objects 276 | static Vector* __fastcall dWeapon_ShootPosition(void* ecx, void* edx, Vector* shootPos); 277 | static double __fastcall dComputeError(void* ecx, void* edx); 278 | static bool __fastcall dUpdateObject(void* ecx, void* edx, void* pPlayer, float flError, bool bIsTeleport = false); 279 | static bool __fastcall dUpdateObjectVM(void* ecx, void* edx, void* pPlayer, float flError); 280 | static void __fastcall dRotateObject(void* ecx, void* edx, void* pPlayer, float fRotAboutUp, float fRotAboutRight, bool bUseWorldUpInsteadOfPlayerUp); 281 | static QAngle& __fastcall dEyeAngles(void* ecx, void* edx); 282 | 283 | static int __fastcall dGetDefaultFOV(void* ecx, void* edx); 284 | static double __fastcall dGetFOV(void* ecx, void* edx); 285 | static double __fastcall dGetViewModelFOV(void* ecx, void* edx); 286 | 287 | static void __fastcall dSetDrawOnlyForSplitScreenUser(void* ecx, void* edx, int nSlot); 288 | static void __fastcall dClientThink(void* ecx, void* edx); 289 | static void __fastcall dPrecache(void* ecx, void* edx); 290 | static bool __fastcall dCHudCrosshair_ShouldDraw(void* ecx, void* edx); 291 | 292 | static void* __fastcall dCWeaponPortalgun_FirePortal(void* ecx, void* edx, bool bPortal2, Vector* pVector = 0); 293 | 294 | static inline int m_PushHUDStep; 295 | static inline bool m_PushedHud; 296 | 297 | static inline tCreatePingPointer CreatePingPointer; 298 | static inline tGetPortalPlayer GetPortalPlayer; 299 | static inline tPrecacheParticleSystem PrecacheParticleSystem; 300 | 301 | static inline tUTIL_Portal_FirstAlongRay UTIL_Portal_FirstAlongRay; 302 | static inline tUTIL_IntersectRayWithPortal UTIL_IntersectRayWithPortal; 303 | static inline tUTIL_Portal_AngleTransform UTIL_Portal_AngleTransform; 304 | static inline tEntindex EntityIndex; 305 | static inline tGetOwner GetOwner; 306 | static inline tGetFullScreenTexture GetFullScreenTexture; 307 | }; -------------------------------------------------------------------------------- /L4D2VR/manifest.vrmanifest: -------------------------------------------------------------------------------- 1 | { 2 | "source" : "builtin", 3 | "applications": [{ 4 | "app_key": "steam.app.620", 5 | 6 | "launch_type": "url", 7 | "url": "steam://launch/620/VR", 8 | "action_manifest_path" : "SteamVRActionManifest/action_manifest.json", 9 | "image_path" : "portal2vr_capsule_main.png", 10 | 11 | "strings": { 12 | "en_us": { 13 | "name": "Portal 2 VR", 14 | "description": "Portal 2 VR Mod" 15 | } 16 | } 17 | }] 18 | } 19 | -------------------------------------------------------------------------------- /L4D2VR/offsets.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "sigscanner.h" 3 | #include "game.h" 4 | 5 | 6 | struct Offset 7 | { 8 | std::string moduleName; 9 | int offset; 10 | int address; 11 | std::string signature; 12 | int sigOffset; 13 | 14 | Offset(std::string moduleName, int currentOffset, std::string signature, int sigOffset = 0) 15 | { 16 | this->moduleName = moduleName; 17 | this->offset = currentOffset; 18 | this->signature = signature; 19 | this->sigOffset = sigOffset; 20 | 21 | int newOffset = SigScanner::VerifyOffset(moduleName, currentOffset, signature, sigOffset); 22 | if (newOffset > 0) 23 | { 24 | this->offset = newOffset; 25 | } 26 | 27 | if (newOffset == -1) 28 | { 29 | Game::errorMsg(("Signature not found: " + signature).c_str()); 30 | return; 31 | } 32 | 33 | this->address = (uintptr_t)GetModuleHandle(moduleName.c_str()) + this->offset; 34 | } 35 | }; 36 | 37 | class Offsets 38 | { 39 | public: 40 | Offset GetFullScreenTexture = { "client.dll", 0x1A83F0, "A1 ? ? ? ? 85 C0 75 53 8B 0D ? ? ? ? 8B 01 8B 90 ? ? ? ? 6A 00 6A 01 68 ? ? ? ? 68 ? ? ? ? FF D2 50 B9 ? ? ? ? E8 ? ? ? ? 80 3D ? ? ? ? ? 75 1C 8B 0D ? ? ? ? 8B 01 8B 90 ? ? ? ? 68 ? ? ? ? C6 05 ? ? ? ? ? FF D2 A1 ? ? ? ? C3" }; 41 | Offset RenderView = { "client.dll", 0x1F2120, "55 8B EC 83 EC 2C 53 56 8B F1 6A 00 8D 8E ? ? ? ? E8 ? ? ? ?" }; 42 | Offset g_pClientMode = { "client.dll", 0x28A600, "8B 0D ? ? ? ? 8B", 2 }; 43 | Offset CalcViewModelView = { "client.dll", 0x27D750, "55 8B EC 83 EC 34 53 8B D9 80 BB" }; 44 | Offset CreateMove = { "client.dll", 0x27A440, "55 8B EC A1 ? ? ? ? 83 EC 0C 83 78 30 00 56 8B 75 0C 57 8B F9 74 43" }; 45 | 46 | //Offset WriteUsercmdDeltaToBuffer = { "client.dll", 0x134790, "55 8B EC 83 EC 60 0F 57 C0 8B 55 0C" }; // 47 | Offset WriteUsercmd = { "client.dll", 0x1C2060, "55 8B EC A1 ? ? ? ? 83 78 30 00 53 8B 5D 0C 56 57" }; 48 | Offset g_pppInput = { "client.dll", 0xD12A0, "8B 0D ? ? ? ? 8B 01 8B 50 68 FF E2", 2 }; 49 | /*Offset AdjustEngineViewport = { "client.dll", 0x41AD10, "55 8B EC 8B 0D ? ? ? ? 85 C9 74 17" }; 50 | Offset IsSplitScreen = { "client.dll", 0x1B2A60, "33 C0 83 3D ? ? ? ? ? 0F 9D C0" };*/ 51 | Offset PrePushRenderTarget = { "client.dll", 0xA8C80, "55 8B EC 8B C1 56 8B 75 08 8B 0E 89 08 8B 56 04 89" }; 52 | 53 | Offset ReadUserCmd = { "server.dll", 0x205100, "55 8B EC 53 8B 5D 10 56 57 8B 7D 0C 53" }; 54 | Offset ProcessUsercmds = { "server.dll", 0x170300, "55 8B EC B8 ? ? ? ? E8 ? ? ? ? 0F 57 C0 53 56 57 B9 ? ? ? ? 8D 85 ? ? ? ? 33 DB" }; //? 55 | Offset CBaseEntity_entindex = { "server.dll", 0x39F00, "8B 41 1C 85 C0 75 01 C3 8B 0D ? ? ? ? 2B 41 58 C1 F8 04 C3 CC"}; 56 | Offset EyePosition = { "server.dll", 0xF40E0, "55 8B EC 56 8B F1 8B 86 ? ? ? ? C1 E8 0B A8 01 74 05 E8 ? ? ? ? 8B 45 08 F3" }; 57 | 58 | /*Offset GetRenderTarget = { "materialsystem.dll", 0x2CD30, "83 79 4C 00" }; 59 | Offset Viewport = { "materialsystem.dll", 0x2E010, "55 8B EC 8B 45 0C 53 8B 5D" }; 60 | Offset GetViewport = { "materialsystem.dll", 0x2CAF0, "55 8B EC 8B 41 4C 8B 49 40 8D 04 C0 83 7C 81 ? ?" };*/ 61 | Offset PushRenderTargetAndViewport = { "materialsystem.dll", 0x2D5F0, "55 8B EC 83 EC 24 8B 45 08 8B 55 10 89" }; 62 | Offset PopRenderTargetAndViewport = { "materialsystem.dll", 0x2CE80, "56 8B F1 83 7E 4C 00" }; 63 | 64 | //Offset TraceFirePortalClient = { "client.dll", 0x3E0980, "53 8B DC 83 EC 08 83 E4 F0 83 C4 04 55 8B 6B 04 89 6C 24 04 8B EC 81 EC ? ? ? ? 56 57 8B F1 6A" }; 65 | // Firing Portals 66 | Offset TraceFirePortalServer = { "server.dll", 0x400D50, "53 8B DC 83 EC 08 83 E4 F0 83 C4 04 55 8B 6B 04 89 6C 24 04 8B EC 81 EC ? ? ? ? 56 57 8B F1 6A" }; 67 | Offset CWeaponPortalgun_FirePortal = { "server.dll", 0x401370, "53 8B DC 83 EC 08 83 E4 F0 83 C4 04 55 8B 6B 04 89 6C 24 04 8B EC 81 EC ? ? ? ? 56 57 8B F9 89 7D EC E8 ? ? ? ?" }; 68 | 69 | //53 8B DC 83 EC 08 83 E4 F0 83 C4 04 55 8B 6B 04 89 6C 24 04 8B EC 81 EC ? ? ? ? 56 57 8B F1 6A 00 56 8D 4D C0 89 75 F8 E8 70 | //Offset DrawModelExecute = { "engine.dll", 0xE05E0, "55 8B EC 81 EC ? ? ? ? A1 ? ? ? ? 33 C5 89 45 FC 8B 45 10 56 8B 75 08 57 8B" }; // 71 | Offset VGui_Paint = { "engine.dll", 0x115CE0, "55 8B EC E8 ? ? ? ? 8B 10 8B C8 8B 52 38" }; 72 | 73 | Offset PlayerPortalled = { "client.dll", 0x27C9D0, "55 8B EC 83 EC 78 53 56 8B D9 8B 0D ? ? ? ? 8B 01 8B 90 ? ? ? ? 57 33 FF 57 FF D2" }; 74 | 75 | // Ingame UI 76 | Offset DrawSelf = { "client.dll", 0x12CC90, "55 8B EC 56 8B F1 80 BE ? ? ? ? ? 0F 84 ? ? ? ? 8B 0D" }; 77 | Offset ClipTransform = { "client.dll", 0x1DD130, "55 8B EC 8B 0D ? ? ? ? 8B 01 8B 90 ? ? ? ? FF D2 8B 4D" }; 78 | /*Offset VGui_GetHudBounds = { "client.dll", 0x1CC550, "55 8B EC 51 56 8B 75 08 8B CE" }; 79 | Offset VGui_GetPanelBounds = { "client.dll", 0x1CC350, "55 8B EC 8B 45 08 8B C8 83 E1 1F BA ? ? ? ?" }; 80 | 81 | Offset VGUI_UpdateScreenSpaceBounds = { "client.dll", 0x1CC8C0, "55 8B EC 83 EC 14 8B 45 0C 8B 4D 10 53 8B 5D 18 56 A3 ? ? ? ? 33 C0" }; 82 | Offset VGui_GetTrueScreenSize = { "client.dll", 0x1CBCF0, "55 8B EC 8B 45 08 8B 0D ? ? ? ? 8B 55 0C 89 08 A1 ? ? ? ? 89 02 5D C3" };*/ 83 | 84 | Offset VGui_GetClientDLLRootPanel = { "client.dll", 0x26EDF0, "8B 0D ? ? ? ? 8B 01 8B 90 ? ? ? ? FF D2 8B 04 85 ? ? ? ? 8B 48 04" }; 85 | Offset g_pFullscreenRootPanel = { "client.dll", 0x26EE20, "A1 ? ? ? ? C3", 2 }; 86 | 87 | // Pointer laser 88 | Offset CreatePingPointer = { "client.dll", 0x280660, "55 8B EC 83 EC 14 53 56 8B F1 8B 8E ? ? ? ? 57 85 C9 74 30" }; 89 | //Offset ClientThink = { "client.dll", 0x27EA30, "53 8B DC 83 EC 08 83 E4 F0 83 C4 04 55 8B 6B 04 89 6C 24 04 8B EC 81 EC ? ? ? ?" }; 90 | Offset GetPortalPlayer = { "client.dll", 0x8DCA0, "55 8B EC 8B 45 08 83 F8 FF 75 10 8B 0D ? ? ? ? 8B 01 8B 90 ? ? ? ? FF D2" }; 91 | Offset PrecacheParticleSystem = { "server.dll", 0x16DF40, "55 8B EC 8B 0D ? ? ? ? 8B 55 08 8B 01 8B 40 20 6A 00 6A FF" }; 92 | Offset Precache = { "server.dll", 0x35A2C0, "E8 ? ? ? ? 68 ? ? ? ? E8 ? ? ? ?" }; 93 | //Offset GetActivePortalWeapon = { "client.dll", 0x2A8910, "8B 89 ? ? ? ? 83 F9 FF 74 1F 8B 15 ? ? ? ?" }; 94 | 95 | Offset SetControlPoint = { "client.dll", 0x17BD30, "55 8B EC 53 56 8B 75 0C 57 8B F9 BB ? ? ? ? 84 9F ? ? ? ?" }; 96 | Offset SetDrawOnlyForSplitScreenUser = { "client.dll", 0x17B9E0, "55 8B EC 8B 45 08 53 8B D9 3B 83 ? ? ? ? 74 55" }; 97 | Offset StopEmission = { "client.dll", 0x17B6A0, "55 8B EC 53 8B 5D 08 57 8B F9 F6 87 ? ? ? ? ? 74 7F" }; 98 | 99 | // Aim related 100 | Offset CHudCrosshair_ShouldDraw = { "client.dll", 0x141BE0, "57 8B F9 80 BF ? ? ? ? ? 74 04 32 C0 5F C3" }; 101 | 102 | // VR Eyes 103 | Offset UTIL_Portal_FirstAlongRay = { "server.dll", 0x377200, "55 8B EC 8B 0D ? ? ? ? 85 C9 74 19 A1 ? ? ? ?" }; 104 | Offset UTIL_IntersectRayWithPortal = { "server.dll", 0x376730, "55 8B EC 83 EC 48 56 8B 75 0C 85 F6 0F 84 ? ? ? ?" }; 105 | Offset UTIL_Portal_AngleTransform = { "server.dll", 0x375CA0, "55 8B EC 8B 45 08 8B 4D 0C 83 EC 0C 50 51 8D 55 F4" }; 106 | 107 | /*Offset GetScreenSize = { "vguimatsurface.dll", 0xB8C0, "55 8B EC 83 EC 08 80 B9 ? ? ? ? ? 74 1C" }; 108 | Offset GetHudSize = { "client.dll", 0x1CBCD0, "55 8B EC 8B 55 0C 8B 0D ? ? ? ? 8B 01 8B 80 ? ? ? ? 52 8B 55 08 52 FF D0 5D C3" }; 109 | 110 | Offset SetSizeC = { "client.dll", 0x63FB70, "55 8B EC 8B 41 04 8B 50 04 8B 45 0C 56 8B 35 ? ? ? ?" }; 111 | Offset SetSizeE = { "engine.dll", 0x298620, "55 8B EC 8B 41 04 8B 50 04 8B 45 0C 56 8B 35 ? ? ? ?" }; 112 | Offset SetSizeV = { "vguimatsurface.dll", 0x4B6D0, "55 8B EC 8B 41 04 8B 50 04 8B 45 0C 56 8B 35 ? ? ? ?" }; 113 | 114 | //Offset SetBoundsC = { "client.dll", 0x63FBF0, "55 8B EC 8B 55 0C 53 56 8B F1 8B 46 04 8B 48 04 8B 45 08 57 8B 3D ? ? ? ?" }; 115 | Offset SetBoundsE = { "engine.dll", 0x2986A0, "55 8B EC 8B 55 0C 53 56 8B F1 8B 46 04 8B 48 04 8B 45 08 57 8B 3D ? ? ? ? 8B 1F 8D 4C 31 04 52 8B 11 50 8B 02 FF D0 8B 53 08 50 8B CF FF D2" };*/ 116 | 117 | 118 | /*Offset Push2DView = { "engine.dll", 0xDF980, "55 8B EC 51 53 8B D9 8B 83 ? ? ? ? 56 8D B3 ? ? ? ? 57 89 5D FC 3B 46 04 7C 09" }; 119 | Offset Render = { "client.dll", 0x1D6800, "55 8B EC 81 EC ? ? ? ? 53 56 57 8B F9 8B 0D ? ? ? ? 89 7D F4 FF 15 ? ? ? ?" }; 120 | Offset GetClipRect = { "vguimatsurface.dll", 0x4C700, "55 8B EC 8B 81 ? ? ? ? 8B 50 04 8B 45 14 56 8B 35 ? ? ? ? 57 8B 3E 8D 8C 0A ? ? ? ? 8B 55 10 50" }; 121 | //Offset GetWeaponCrosshairScale = {} 122 | Offset GetModeHeight = { "engine.dll", 0x1F9F10, "8B 81 ? ? ? ? C3" };*/ 123 | 124 | //Grababbles 125 | //Offset Weapon_ShootPosition = { "client.dll", 0x2A8A60, "55 8B EC 8B 01 8B 90 ? ? ? ? 56 8B 75 08 56 FF D2 8B C6 5E 5D C2 04 00" }; 126 | Offset Weapon_ShootPosition = { "server.dll", 0x1033C0, "55 8B EC 8B 01 8B 90 ? ? ? ? 56 8B 75 08 56 FF D2 8B C6 5E 5D C2 04 00" }; 127 | Offset ComputeError = { "server.dll", 0x3C8140, "53 8B DC 83 EC 08 83 E4 F0 83 C4 04 55 8B 6B 04 89 6C 24 04 8B EC 81 EC ? ? ? ? 56 8B F1 8B 86 ? ? ? ? 57 83 F8 FF 74 2A" }; 128 | Offset UpdateObject = { "server.dll", 0x3CA010, "53 8B DC 83 EC 08 83 E4 F0 83 C4 04 55 8B 6B 04 89 6C 24 04 8B EC 81 EC ? ? ? ? 56 57 8B F9 8B 87 ? ? ? ? 89 BD" }; 129 | Offset UpdateObjectVM = { "server.dll", 0x3CBB10, "53 8B DC 83 EC 08 83 E4 F0 83 C4 04 55 8B 6B 04 89 6C 24 04 8B EC 81 EC ? ? ? ? 56 57 8B F9 8B 87 ? ? ? ? 83 F8" }; 130 | Offset RotateObject = { "server.dll", 0x3C7890, "55 8B EC 0F 57 C0 F3 0F 10 4D ? 81 EC ? ? ? ? 0F 2E C8 9F 57 8B F9 F6 C4 44 7A 12" }; 131 | Offset EyeAngles = { "server.dll", 0x103A50, "55 8B EC 8B 81 ? ? ? ? 83 EC 60 56 57 8B 3D ? ? ? ? 83 F8 FF 74 1D" }; 132 | 133 | // For Portal gun VFX (do we really need all three??) 134 | Offset MatrixBuildPerspectiveX = { "engine.dll", 0x2737E0, "55 8B EC 83 EC 08 F2 0F 10 45 ? F2 0F 59 05 ? ? ? ?" }; 135 | Offset GetFOV = { "client.dll", 0x2772B0, "55 8B EC 51 56 8B F1 E8 ? ? ? ? D9 5D FC 8B 06 8B 90 ? ? ? ? 8B CE FF D2" }; 136 | Offset GetDefaultFOV = { "client.dll", 0x279020, "A1 ? ? ? ? F3 0F 2C 40 ? C3" }; 137 | Offset GetViewModelFOV = { "client.dll", 0x28AB80, "A1 ? ? ? ? D9 40 2C C3" }; 138 | 139 | // Multiplayer 140 | Offset GetOwner = { "server.dll", 0xD7550, "8B 81 ? ? ? ? 83 F8 FF 74 23 8B 15 ? ? ? ?" }; 141 | //Offset GetActiveWeapon = { "server.dll", 0xD3FD0, "8B 89 ? ? ? ? 83 F9 FF 74 1F 8B 15 ? ? ? ?" }; 142 | }; -------------------------------------------------------------------------------- /L4D2VR/portal2vr_capsule_main.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Gistix/portal2vr/4abc0217fbbebae7f978c9f6758ef5dad118dadb/L4D2VR/portal2vr_capsule_main.png -------------------------------------------------------------------------------- /L4D2VR/portal2vr_portrait_main.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Gistix/portal2vr/4abc0217fbbebae7f978c9f6758ef5dad118dadb/L4D2VR/portal2vr_portrait_main.png -------------------------------------------------------------------------------- /L4D2VR/sdk/LICENSE.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Gistix/portal2vr/4abc0217fbbebae7f978c9f6758ef5dad118dadb/L4D2VR/sdk/LICENSE.txt -------------------------------------------------------------------------------- /L4D2VR/sdk/bitbuf.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Gistix/portal2vr/4abc0217fbbebae7f978c9f6758ef5dad118dadb/L4D2VR/sdk/bitbuf.cpp -------------------------------------------------------------------------------- /L4D2VR/sdk/checksum_crc.cpp: -------------------------------------------------------------------------------- 1 | //========= Copyright Valve Corporation, All rights reserved. ============// 2 | // 3 | // Purpose: Generic CRC functions 4 | // 5 | //=============================================================================// 6 | 7 | #include "checksum_crc.h" 8 | 9 | #define CRC32_INIT_VALUE 0xFFFFFFFFUL 10 | #define CRC32_XOR_VALUE 0xFFFFFFFFUL 11 | 12 | #define NUM_BYTES 256 13 | 14 | #define LittleLong( val ) ( val ) 15 | 16 | static const CRC32_t pulCRCTable[NUM_BYTES] = 17 | { 18 | 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 19 | 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 20 | 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 21 | 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 22 | 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 23 | 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 24 | 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 25 | 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 26 | 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 27 | 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 28 | 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 29 | 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 30 | 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 31 | 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, 32 | 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 33 | 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 34 | 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 35 | 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, 36 | 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 37 | 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, 38 | 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 39 | 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 40 | 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 41 | 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 42 | 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 43 | 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 44 | 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 45 | 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 46 | 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 47 | 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 48 | 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 49 | 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 50 | 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 51 | 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 52 | 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 53 | 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 54 | 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 55 | 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 56 | 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 57 | 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 58 | 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 59 | 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 60 | 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 61 | 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, 62 | 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 63 | 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 64 | 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 65 | 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 66 | 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 67 | 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, 68 | 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 69 | 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 70 | 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 71 | 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 72 | 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 73 | 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 74 | 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 75 | 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 76 | 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 77 | 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 78 | 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 79 | 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 80 | 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 81 | 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d 82 | }; 83 | 84 | void CRC32_Init(CRC32_t *pulCRC) 85 | { 86 | *pulCRC = CRC32_INIT_VALUE; 87 | } 88 | 89 | void CRC32_Final(CRC32_t *pulCRC) 90 | { 91 | *pulCRC ^= CRC32_XOR_VALUE; 92 | } 93 | 94 | CRC32_t CRC32_GetTableEntry( unsigned int slot ) 95 | { 96 | return pulCRCTable[(unsigned char)slot]; 97 | } 98 | 99 | void CRC32_ProcessBuffer(CRC32_t *pulCRC, const void *pBuffer, int nBuffer) 100 | { 101 | CRC32_t ulCrc = *pulCRC; 102 | unsigned char *pb = (unsigned char *)pBuffer; 103 | unsigned int nFront; 104 | int nMain; 105 | 106 | JustAfew: 107 | 108 | switch (nBuffer) 109 | { 110 | case 7: 111 | ulCrc = pulCRCTable[*pb++ ^ (unsigned char)ulCrc] ^ (ulCrc >> 8); 112 | 113 | case 6: 114 | ulCrc = pulCRCTable[*pb++ ^ (unsigned char)ulCrc] ^ (ulCrc >> 8); 115 | 116 | case 5: 117 | ulCrc = pulCRCTable[*pb++ ^ (unsigned char)ulCrc] ^ (ulCrc >> 8); 118 | 119 | case 4: 120 | ulCrc ^= LittleLong( *(CRC32_t *)pb ); 121 | ulCrc = pulCRCTable[(unsigned char)ulCrc] ^ (ulCrc >> 8); 122 | ulCrc = pulCRCTable[(unsigned char)ulCrc] ^ (ulCrc >> 8); 123 | ulCrc = pulCRCTable[(unsigned char)ulCrc] ^ (ulCrc >> 8); 124 | ulCrc = pulCRCTable[(unsigned char)ulCrc] ^ (ulCrc >> 8); 125 | *pulCRC = ulCrc; 126 | return; 127 | 128 | case 3: 129 | ulCrc = pulCRCTable[*pb++ ^ (unsigned char)ulCrc] ^ (ulCrc >> 8); 130 | 131 | case 2: 132 | ulCrc = pulCRCTable[*pb++ ^ (unsigned char)ulCrc] ^ (ulCrc >> 8); 133 | 134 | case 1: 135 | ulCrc = pulCRCTable[*pb++ ^ (unsigned char)ulCrc] ^ (ulCrc >> 8); 136 | 137 | case 0: 138 | *pulCRC = ulCrc; 139 | return; 140 | } 141 | 142 | // We may need to do some alignment work up front, and at the end, so that 143 | // the main loop is aligned and only has to worry about 8 byte at a time. 144 | // 145 | // The low-order two bits of pb and nBuffer in total control the 146 | // upfront work. 147 | // 148 | nFront = ((unsigned int)pb) & 3; 149 | nBuffer -= nFront; 150 | switch (nFront) 151 | { 152 | case 3: 153 | ulCrc = pulCRCTable[*pb++ ^ (unsigned char)ulCrc] ^ (ulCrc >> 8); 154 | case 2: 155 | ulCrc = pulCRCTable[*pb++ ^ (unsigned char)ulCrc] ^ (ulCrc >> 8); 156 | case 1: 157 | ulCrc = pulCRCTable[*pb++ ^ (unsigned char)ulCrc] ^ (ulCrc >> 8); 158 | } 159 | 160 | nMain = nBuffer >> 3; 161 | while (nMain--) 162 | { 163 | ulCrc ^= LittleLong( *(CRC32_t *)pb ); 164 | ulCrc = pulCRCTable[(unsigned char)ulCrc] ^ (ulCrc >> 8); 165 | ulCrc = pulCRCTable[(unsigned char)ulCrc] ^ (ulCrc >> 8); 166 | ulCrc = pulCRCTable[(unsigned char)ulCrc] ^ (ulCrc >> 8); 167 | ulCrc = pulCRCTable[(unsigned char)ulCrc] ^ (ulCrc >> 8); 168 | ulCrc ^= LittleLong( *(CRC32_t *)(pb + 4) ); 169 | ulCrc = pulCRCTable[(unsigned char)ulCrc] ^ (ulCrc >> 8); 170 | ulCrc = pulCRCTable[(unsigned char)ulCrc] ^ (ulCrc >> 8); 171 | ulCrc = pulCRCTable[(unsigned char)ulCrc] ^ (ulCrc >> 8); 172 | ulCrc = pulCRCTable[(unsigned char)ulCrc] ^ (ulCrc >> 8); 173 | pb += 8; 174 | } 175 | 176 | nBuffer &= 7; 177 | goto JustAfew; 178 | } 179 | -------------------------------------------------------------------------------- /L4D2VR/sdk/checksum_crc.h: -------------------------------------------------------------------------------- 1 | //========= Copyright Valve Corporation, All rights reserved. ============// 2 | // 3 | // Purpose: Generic CRC functions 4 | // 5 | // $NoKeywords: $ 6 | //=============================================================================// 7 | #ifndef CHECKSUM_CRC_H 8 | #define CHECKSUM_CRC_H 9 | #ifdef _WIN32 10 | #pragma once 11 | #endif 12 | 13 | typedef unsigned int CRC32_t; 14 | 15 | void CRC32_Init( CRC32_t *pulCRC ); 16 | void CRC32_ProcessBuffer( CRC32_t *pulCRC, const void *p, int len ); 17 | void CRC32_Final( CRC32_t *pulCRC ); 18 | CRC32_t CRC32_GetTableEntry( unsigned int slot ); 19 | 20 | inline CRC32_t CRC32_ProcessSingleBuffer( const void *p, int len ) 21 | { 22 | CRC32_t crc; 23 | 24 | CRC32_Init( &crc ); 25 | CRC32_ProcessBuffer( &crc, p, len ); 26 | CRC32_Final( &crc ); 27 | 28 | return crc; 29 | } 30 | 31 | #endif -------------------------------------------------------------------------------- /L4D2VR/sdk/cnewparticleeffect.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "game.h" 5 | #include "offsets.h" 6 | 7 | class Game; 8 | 9 | class CNewParticleEffect 10 | { 11 | public: 12 | inline void SetControlPoint(int nWhichPoint, const Vector& v) { 13 | typedef int(__thiscall* tSetControlPoint)(void* thisptr, int nWhichPoint, const Vector& v); 14 | static tSetControlPoint oSetControlPoint = (tSetControlPoint)(g_Game->m_Offsets->SetControlPoint.address); 15 | 16 | oSetControlPoint(this, nWhichPoint, v); 17 | }; 18 | 19 | inline void StopEmission(bool bInfiniteOnly = false, bool bRemoveAllParticles = false, bool bWakeOnStop = false, bool bPlayEndCap = false) { 20 | typedef int(__thiscall* tStopEmission)(void* thisptr, bool bInfiniteOnly, bool bRemoveAllParticles, bool bWakeOnStop, bool bPlayEndCap); 21 | static tStopEmission oStopEmission = (tStopEmission)(g_Game->m_Offsets->StopEmission.address); 22 | 23 | oStopEmission(this, bInfiniteOnly, bRemoveAllParticles, bWakeOnStop, bPlayEndCap); 24 | }; 25 | }; 26 | 27 | class CPortal_Base2D 28 | { 29 | public: 30 | inline VMatrix MatrixThisToLinked() { 31 | return *(VMatrix*)((uintptr_t)this + 0x4C4); 32 | }; 33 | }; -------------------------------------------------------------------------------- /L4D2VR/sdk/common_defs.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "coordsize.h" 4 | 5 | #define LOG2_BITS_PER_INT 5 6 | #define BITS_PER_INT 32 7 | 8 | #ifdef _X360 9 | #define BitVec_Bit( bitNum ) GetBitForBitnum( bitNum ) 10 | #define BitVec_BitInByte( bitNum ) GetBitForBitnumByte( bitNum ) 11 | #else 12 | #define BitVec_Bit( bitNum ) ( 1 << ( (bitNum) & (BITS_PER_INT-1) ) ) 13 | #define BitVec_BitInByte( bitNum ) ( 1 << ( (bitNum) & 7 ) ) 14 | #endif 15 | #define BitVec_Int( bitNum ) ( (bitNum) >> LOG2_BITS_PER_INT ) 16 | 17 | inline void Q_memcpy(void* dest, void* src, int count) 18 | { 19 | int i; 20 | 21 | if ((((long)dest | (long)src | count) & 3) == 0) 22 | { 23 | count >>= 2; 24 | for (i = 0; i < count; i++) 25 | ((int*)dest)[i] = ((int*)src)[i]; 26 | } 27 | else 28 | for (i = 0; i < count; i++) 29 | ((byte*)dest)[i] = ((byte*)src)[i]; 30 | } 31 | 32 | typedef unsigned short wchar; 33 | 34 | inline int GetBitForBitnum(int bitNum) 35 | { 36 | static int bitsForBitnum[] = 37 | { 38 | (1 << 0), 39 | (1 << 1), 40 | (1 << 2), 41 | (1 << 3), 42 | (1 << 4), 43 | (1 << 5), 44 | (1 << 6), 45 | (1 << 7), 46 | (1 << 8), 47 | (1 << 9), 48 | (1 << 10), 49 | (1 << 11), 50 | (1 << 12), 51 | (1 << 13), 52 | (1 << 14), 53 | (1 << 15), 54 | (1 << 16), 55 | (1 << 17), 56 | (1 << 18), 57 | (1 << 19), 58 | (1 << 20), 59 | (1 << 21), 60 | (1 << 22), 61 | (1 << 23), 62 | (1 << 24), 63 | (1 << 25), 64 | (1 << 26), 65 | (1 << 27), 66 | (1 << 28), 67 | (1 << 29), 68 | (1 << 30), 69 | (1 << 31), 70 | }; 71 | 72 | return bitsForBitnum[(bitNum) & (BITS_PER_INT - 1)]; 73 | } -------------------------------------------------------------------------------- /L4D2VR/sdk/coordsize.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Gistix/portal2vr/4abc0217fbbebae7f978c9f6758ef5dad118dadb/L4D2VR/sdk/coordsize.h -------------------------------------------------------------------------------- /L4D2VR/sdk/material.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "texture.h" 4 | 5 | enum MaterialRenderTargetDepth_t 6 | { 7 | MATERIAL_RT_DEPTH_SHARED = 0x0, 8 | MATERIAL_RT_DEPTH_SEPARATE = 0x1, 9 | MATERIAL_RT_DEPTH_NONE = 0x2, 10 | MATERIAL_RT_DEPTH_ONLY = 0x3, 11 | }; 12 | 13 | enum MaterialVarFlags_t 14 | { 15 | MATERIAL_VAR_DEBUG = (1 << 0), 16 | MATERIAL_VAR_NO_DEBUG_OVERRIDE = (1 << 1), 17 | MATERIAL_VAR_NO_DRAW = (1 << 2), 18 | MATERIAL_VAR_USE_IN_FILLRATE_MODE = (1 << 3), 19 | 20 | MATERIAL_VAR_VERTEXCOLOR = (1 << 4), 21 | MATERIAL_VAR_VERTEXALPHA = (1 << 5), 22 | MATERIAL_VAR_SELFILLUM = (1 << 6), 23 | MATERIAL_VAR_ADDITIVE = (1 << 7), 24 | MATERIAL_VAR_ALPHATEST = (1 << 8), 25 | MATERIAL_VAR_MULTIPASS = (1 << 9), 26 | MATERIAL_VAR_ZNEARER = (1 << 10), 27 | MATERIAL_VAR_MODEL = (1 << 11), 28 | MATERIAL_VAR_FLAT = (1 << 12), 29 | MATERIAL_VAR_NOCULL = (1 << 13), 30 | MATERIAL_VAR_NOFOG = (1 << 14), 31 | MATERIAL_VAR_IGNOREZ = (1 << 15), 32 | MATERIAL_VAR_DECAL = (1 << 16), 33 | MATERIAL_VAR_ENVMAPSPHERE = (1 << 17), 34 | MATERIAL_VAR_NOALPHAMOD = (1 << 18), 35 | MATERIAL_VAR_ENVMAPCAMERASPACE = (1 << 19), 36 | MATERIAL_VAR_BASEALPHAENVMAPMASK = (1 << 20), 37 | MATERIAL_VAR_TRANSLUCENT = (1 << 21), 38 | MATERIAL_VAR_NORMALMAPALPHAENVMAPMASK = (1 << 22), 39 | MATERIAL_VAR_NEEDS_SOFTWARE_SKINNING = (1 << 23), 40 | MATERIAL_VAR_OPAQUETEXTURE = (1 << 24), 41 | MATERIAL_VAR_ENVMAPMODE = (1 << 25), 42 | MATERIAL_VAR_SUPPRESS_DECALS = (1 << 26), 43 | MATERIAL_VAR_HALFLAMBERT = (1 << 27), 44 | MATERIAL_VAR_WIREFRAME = (1 << 28), 45 | MATERIAL_VAR_ALLOWALPHATOCOVERAGE = (1 << 29), 46 | MATERIAL_VAR_IGNORE_ALPHA_MODULATION = (1 << 30) 47 | }; 48 | 49 | 50 | enum CompiledVtfFlags 51 | { 52 | // flags from the *.txt config file 53 | TEXTUREFLAGS_POINTSAMPLE = 0x00000001, 54 | TEXTUREFLAGS_TRILINEAR = 0x00000002, 55 | TEXTUREFLAGS_CLAMPS = 0x00000004, 56 | TEXTUREFLAGS_CLAMPT = 0x00000008, 57 | TEXTUREFLAGS_ANISOTROPIC = 0x00000010, 58 | TEXTUREFLAGS_HINT_DXT5 = 0x00000020, 59 | TEXTUREFLAGS_SRGB = 0x00000040, 60 | TEXTUREFLAGS_NORMAL = 0x00000080, 61 | TEXTUREFLAGS_NOMIP = 0x00000100, 62 | TEXTUREFLAGS_NOLOD = 0x00000200, 63 | TEXTUREFLAGS_ALL_MIPS = 0x00000400, 64 | TEXTUREFLAGS_PROCEDURAL = 0x00000800, 65 | 66 | // These are automatically generated by vtex from the texture data. 67 | TEXTUREFLAGS_ONEBITALPHA = 0x00001000, 68 | TEXTUREFLAGS_EIGHTBITALPHA = 0x00002000, 69 | 70 | // newer flags from the *.txt config file 71 | TEXTUREFLAGS_ENVMAP = 0x00004000, 72 | TEXTUREFLAGS_RENDERTARGET = 0x00008000, 73 | TEXTUREFLAGS_DEPTHRENDERTARGET = 0x00010000, 74 | TEXTUREFLAGS_NODEBUGOVERRIDE = 0x00020000, 75 | TEXTUREFLAGS_SINGLECOPY = 0x00040000, 76 | 77 | TEXTUREFLAGS_STAGING_MEMORY = 0x00080000, 78 | TEXTUREFLAGS_IMMEDIATE_CLEANUP = 0x00100000, 79 | TEXTUREFLAGS_IGNORE_PICMIP = 0x00200000, 80 | TEXTUREFLAGS_UNUSED_00400000 = 0x00400000, 81 | 82 | TEXTUREFLAGS_NODEPTHBUFFER = 0x00800000, 83 | 84 | TEXTUREFLAGS_UNUSED_01000000 = 0x01000000, 85 | 86 | TEXTUREFLAGS_CLAMPU = 0x02000000, 87 | 88 | TEXTUREFLAGS_VERTEXTEXTURE = 0x04000000, // Useable as a vertex texture 89 | 90 | TEXTUREFLAGS_SSBUMP = 0x08000000, 91 | 92 | TEXTUREFLAGS_UNUSED_10000000 = 0x10000000, 93 | 94 | // Clamp to border color on all texture coordinates 95 | TEXTUREFLAGS_BORDER = 0x20000000, 96 | 97 | TEXTUREFLAGS_UNUSED_40000000 = 0x40000000, 98 | TEXTUREFLAGS_UNUSED_80000000 = 0x80000000, 99 | }; 100 | 101 | enum RenderTargetSizeMode_t 102 | { 103 | RT_SIZE_NO_CHANGE = 0, // Only allowed for render targets that don't want a depth buffer 104 | // (because if they have a depth buffer, the render target must be less than or equal to the size of the framebuffer). 105 | RT_SIZE_DEFAULT = 1, // Don't play with the specified width and height other than making sure it fits in the framebuffer. 106 | RT_SIZE_PICMIP = 2, // Apply picmip to the render target's width and height. 107 | RT_SIZE_HDR = 3, // frame_buffer_width / 4 108 | RT_SIZE_FULL_FRAME_BUFFER = 4, // Same size as frame buffer, or next lower power of 2 if we can't do that. 109 | RT_SIZE_OFFSCREEN = 5, // Target of specified size, don't mess with dimensions 110 | RT_SIZE_FULL_FRAME_BUFFER_ROUNDED_UP = 6, // Same size as the frame buffer, rounded up if necessary for systems that can't do non-power of two textures. 111 | RT_SIZE_REPLAY_SCREENSHOT = 7, // Rounded down to power of 2, essentially... 112 | RT_SIZE_LITERAL = 8, // Use the size passed in. Don't clamp it to the frame buffer size. Really. 113 | RT_SIZE_LITERAL_PICMIP = 9 // Use the size passed in, don't clamp to the frame buffer size, but do apply picmip restrictions. 114 | 115 | }; 116 | 117 | enum PaintMode_t 118 | { 119 | PAINT_UIPANELS = (1 << 0), 120 | PAINT_INGAMEPANELS = (1 << 1), 121 | PAINT_CURSOR = (1 << 2), // software cursor, if appropriate 122 | }; 123 | 124 | class IMatRenderContext; 125 | class IMaterial; 126 | 127 | class IMaterialSystem 128 | { 129 | public: 130 | virtual void ConnectEPFPvPKcPiE() = 0; //CMaterialSystem::Connect(void * (*)(char const*,int *)) 131 | virtual void DisconnectEv() = 0; //CMaterialSystem::Disconnect(void) 132 | virtual void QueryInterfaceEPKc() = 0; //CMaterialSystem::QueryInterface(char const*) 133 | virtual void InitEv() = 0; //CMaterialSystem::Init(void) 134 | virtual void ShutdownEv() = 0; //CMaterialSystem::Shutdown(void) 135 | virtual void GetDependencies() = 0; //CMaterialSystem::GetDependencies(void) 136 | virtual void GetTier() = 0; //CMaterialSystem::GetTier(void) 137 | virtual void Reconnect() = 0; //CMaterialSystem::Reconnect(void* (*)(char const*, int*), char const*) 138 | virtual void InitEPKcP21IMaterialProxyFactoryPFPvS1_PiES7_() = 0; //CMaterialSystem::Init(char const*,IMaterialProxyFactory *,void * (*)(char const*,int *),void * (*)(char const*,int *)) 139 | virtual void SetShaderAPIEPKc() = 0; //CMaterialSystem::SetShaderAPI(char const*) 140 | virtual void SetAdapterEii() = 0; //CMaterialSystem::SetAdapter(int,int) 141 | virtual void ModInitEv() = 0; //CMaterialSystem::ModInit(void) 142 | virtual void ModShutdownEv() = 0; //CMaterialSystem::ModShutdown(void) 143 | virtual void SetThreadModeE20MaterialThreadMode_ti() = 0; //CMaterialSystem::SetThreadMode(MaterialThreadMode_t,int) 144 | virtual void GetThreadModeEv() = 0; //CMaterialSystem::GetThreadMode(void) 145 | virtual void IsRenderThreadSafeEv() = 0; //CMaterialSystem::IsRenderThreadSafe(void) 146 | virtual void ExecuteQueuedEv() = 0; //CMaterialSystem::ExecuteQueued(void) 147 | virtual void OnDebugEvent() = 0; //CMaterialSystem::OnDebugEvent(char const*) 148 | virtual void GetHardwareConfigEPKcPi() = 0; //CMaterialSystem::GetHardwareConfig(char const*,int *) 149 | virtual void UpdateConfigEb() = 0; //CMaterialSystem::UpdateConfig(bool) 150 | virtual void OverrideConfigERK23MaterialSystem_Config_tb() = 0; //CMaterialSystem::OverrideConfig(MaterialSystem_Config_t const&,bool) 151 | virtual void GetCurrentConfigForVideoCardEv() = 0; //CMaterialSystem::GetCurrentConfigForVideoCard(void) 152 | virtual void GetRecommendedConfigurationInfoEiP9KeyValues() = 0; //CMaterialSystem::GetRecommendedConfigurationInfo(int,KeyValues *) 153 | virtual void GetDisplayAdapterCountEv() = 0; //CMaterialSystem::GetDisplayAdapterCount(void) 154 | virtual void GetCurrentAdapterEv() = 0; //CMaterialSystem::GetCurrentAdapter(void) 155 | virtual void GetDisplayAdapterInfoEiR21MaterialAdapterInfo_t() = 0; //CMaterialSystem::GetDisplayAdapterInfo(int,MaterialAdapterInfo_t &) 156 | virtual void GetModeCountEi() = 0; //CMaterialSystem::GetModeCount(int) 157 | virtual void GetModeInfoEiiR19MaterialVideoMode_t() = 0; //CMaterialSystem::GetModeInfo(int,int,MaterialVideoMode_t &) 158 | virtual void AddModeChangeCallBackEPFvvE() = 0; //CMaterialSystem::AddModeChangeCallBack(void (*)(void)) 159 | virtual void GetDisplayModeER19MaterialVideoMode_t() = 0; //CMaterialSystem::GetDisplayMode(MaterialVideoMode_t &) 160 | virtual void SetModeEPvRK23MaterialSystem_Config_t() = 0; //CMaterialSystem::SetMode(void *,MaterialSystem_Config_t const&) 161 | virtual void SupportsMSAAModeEi() = 0; //CMaterialSystem::SupportsMSAAMode(int) 162 | virtual void GetVideoCardIdentifierEv() = 0; //CMaterialSystem::GetVideoCardIdentifier(void) 163 | virtual void SpewDriverInfoEv() = 0; //CMaterialSystem::SpewDriverInfo(void) 164 | virtual void GetBackBufferDimensions(int &, int &) = 0; //CMaterialSystem::GetBackBufferDimensions(int &,int &) 165 | virtual ImageFormat GetBackBufferFormat() = 0; //CMaterialSystem::GetBackBufferFormat(void) 166 | virtual void GetAspectRatioInfo() = 0; //CMaterialSystem::GetAspectRatioInfo(void)const 167 | virtual void SupportsHDRModeE9HDRType_t() = 0; //CMaterialSystem::SupportsHDRMode(HDRType_t) 168 | virtual void AddViewEPv() = 0; //CMaterialSystem::AddView(void *) 169 | virtual void RemoveViewEPv() = 0; //CMaterialSystem::RemoveView(void *) 170 | virtual void SetViewEPv() = 0; //CMaterialSystem::SetView(void *) 171 | virtual void BeginFrameEf() = 0; //CMaterialSystem::BeginFrame(float) 172 | virtual void EndFrameEv() = 0; //CMaterialSystem::EndFrame(void) 173 | virtual void FlushEb() = 0; //CMaterialSystem::Flush(bool) 174 | virtual void GetCurrentFrameCount() = 0; //CMaterialSystem::GetCurrentFrameCount(void) 175 | virtual void SwapBuffersEv() = 0; //CMaterialSystem::SwapBuffers(void) 176 | virtual void EvictManagedResourcesEv() = 0; //CMaterialSystem::EvictManagedResources(void) 177 | virtual void ReleaseResourcesEv() = 0; //CMaterialSystem::ReleaseResources(void) 178 | virtual void ReacquireResourcesEv() = 0; //CMaterialSystem::ReacquireResources(void) 179 | virtual void AddReleaseFuncEPFviE() = 0; //CMaterialSystem::AddReleaseFunc(void (*)(int)) 180 | virtual void RemoveReleaseFuncEPFviE() = 0; //CMaterialSystem::RemoveReleaseFunc(void (*)(int)) 181 | virtual void AddRestoreFuncEPFviE() = 0; //CMaterialSystem::AddRestoreFunc(void (*)(int)) 182 | virtual void RemoveRestoreFuncEPFviE() = 0; //CMaterialSystem::RemoveRestoreFunc(void (*)(int)) 183 | virtual void AddEndFrameCleanupFunc() = 0; //CMaterialSystem::AddEndFrameCleanupFunc(void (*)(void)) 184 | virtual void RemoveEndFrameCleanupFunc() = 0; // CMaterialSystem::RemoveEndFrameCleanupFunc(void (*)(void)) 185 | virtual void OnLevelShutdown() = 0; // CMaterialSystem::OnLevelShutdown(void) 186 | virtual void AddOnLevelShutdownFunc() = 0; // CMaterialSystem::AddOnLevelShutdownFunc(void (*)(void *),void *) 187 | virtual void RemoveOnLevelShutdownFunc() = 0; // CMaterialSystem::RemoveOnLevelShutdownFunc(void (*)(void *),void *) 188 | virtual void ResetTempHWMemoryEb() = 0; //CMaterialSystem::ResetTempHWMemory(bool) 189 | virtual void HandleDeviceLostEv() = 0; //CMaterialSystem::HandleDeviceLost(void) 190 | virtual void ShaderCountEv() = 0; //CMaterialSystem::ShaderCount(void) 191 | virtual void GetShadersEiiPP7IShader() = 0; //CMaterialSystem::GetShaders(int,int,IShader **) 192 | virtual void ShaderFlagCountEv() = 0; //CMaterialSystem::ShaderFlagCount(void) 193 | virtual void ShaderFlagNameEi() = 0; //CMaterialSystem::ShaderFlagName(int) 194 | virtual void GetShaderFallbackEPKcPci() = 0; //CMaterialSystem::GetShaderFallback(char const*,char *,int) 195 | virtual void GetMaterialProxyFactoryEv() = 0; //CMaterialSystem::GetMaterialProxyFactory(void) 196 | virtual void SetMaterialProxyFactoryEP21IMaterialProxyFactory() = 0; //CMaterialSystem::SetMaterialProxyFactory(IMaterialProxyFactory *) 197 | virtual void EnableEditorMaterialsEv() = 0; //CMaterialSystem::EnableEditorMaterials(void) 198 | virtual void EnableGBuffersEv() = 0; //CMaterialSystem::EnableGBuffers(void) 199 | virtual void SetInStubModeEb() = 0; //CMaterialSystem::SetInStubMode(bool) 200 | virtual void DebugPrintUsedMaterialsEPKcb() = 0; //CMaterialSystem::DebugPrintUsedMaterials(char const*,bool) 201 | virtual void DebugPrintUsedTexturesEv() = 0; //CMaterialSystem::DebugPrintUsedTextures(void) 202 | virtual void ToggleSuppressMaterialEPKc() = 0; //CMaterialSystem::ToggleSuppressMaterial(char const*) 203 | virtual void ToggleDebugMaterialEPKc() = 0; //CMaterialSystem::ToggleDebugMaterial(char const*) 204 | virtual void UsingFastClippingEv() = 0; //CMaterialSystem::UsingFastClipping(void) 205 | virtual void StencilBufferBitsEv() = 0; //CMaterialSystem::StencilBufferBits(void) 206 | virtual void UncacheAllMaterialsEv() = 0; //CMaterialSystem::UncacheAllMaterials(void) 207 | virtual void UncacheUnusedMaterialsEb() = 0; //CMaterialSystem::UncacheUnusedMaterials(bool) 208 | virtual void CacheUsedMaterialsEv() = 0; //CMaterialSystem::CacheUsedMaterials(void) 209 | virtual void ReloadTexturesEv() = 0; //CMaterialSystem::ReloadTextures(void) 210 | virtual void ReloadMaterialsEPKc() = 0; //CMaterialSystem::ReloadMaterials(char const*) 211 | virtual void CreateMaterialEPKcP9KeyValues() = 0; //CMaterialSystem::CreateMaterial(char const*,KeyValues *) 212 | virtual IMaterial *FindMaterial(char const *pMaterialName, const char *pTextureGroupName, bool complain = true, const char *pComplainPrefix = NULL) = 0; //CMaterialSystem::FindMaterial(char const*,char const*,bool,char const*) 213 | virtual void IsMaterialLoaded() = 0; //CMaterialSystem::IsMaterialLoaded(char const*) 214 | virtual void FirstMaterialEv() = 0; //CMaterialSystem::FirstMaterial(void) 215 | virtual void NextMaterialEt() = 0; //CMaterialSystem::NextMaterial(ushort) 216 | virtual void InvalidMaterialEv() = 0; //CMaterialSystem::InvalidMaterial(void) 217 | virtual void GetMaterialEt() = 0; //CMaterialSystem::GetMaterial(ushort) 218 | virtual void GetNumMaterialsEv() = 0; //CMaterialSystem::GetNumMaterials(void) 219 | virtual ITexture *FindTexture(char const* pTextureName, const char* pTextureGroupName, bool complain = true, int nAdditionalCreationFlags = 0) = 0; //CMaterialSystem::FindTexture(char const*,char const*,bool,int) 220 | virtual void IsTextureLoadedEPKc() = 0; //CMaterialSystem::IsTextureLoaded(char const*) 221 | virtual void CreateProceduralTextureEPKcS1_ii11ImageFormati() = 0; //CMaterialSystem::CreateProceduralTexture(char const*,char const*,int,int,ImageFormat,int) 222 | virtual void BeginRenderTargetAllocation() = 0; //CMaterialSystem::BeginRenderTargetAllocation(void) 223 | virtual void EndRenderTargetAllocation() = 0; //CMaterialSystem::EndRenderTargetAllocation(void) 224 | virtual void *CreateRenderTargetTexture(int, int, RenderTargetSizeMode_t, ImageFormat, MaterialRenderTargetDepth_t) = 0; //CMaterialSystem::CreateRenderTargetTexture(int,int,RenderTargetSizeMode_t,ImageFormat,MaterialRenderTargetDepth_t) 225 | virtual ITexture *CreateNamedRenderTargetTextureEx(const char *pRTName, // Pass in NULL here for an unnamed render target. 226 | int w, 227 | int h, 228 | RenderTargetSizeMode_t sizeMode, // Controls how size is generated (and regenerated on video mode change). 229 | ImageFormat format, 230 | MaterialRenderTargetDepth_t depth = MATERIAL_RT_DEPTH_SHARED, 231 | unsigned int textureFlags = TEXTUREFLAGS_CLAMPS | TEXTUREFLAGS_CLAMPT, 232 | unsigned int renderTargetFlags = 0) = 0; //CMaterialSystem::CreateNamedRenderTargetTextureEx(char const*,int,int,RenderTargetSizeMode_t,ImageFormat,MaterialRenderTargetDepth_t,uint,uint) 233 | virtual void *CreateNamedRenderTargetTexture(char const *, int, int, RenderTargetSizeMode_t, ImageFormat, MaterialRenderTargetDepth_t, bool, bool) = 0; //CMaterialSystem::CreateNamedRenderTargetTexture(char const*,int,int,RenderTargetSizeMode_t,ImageFormat,MaterialRenderTargetDepth_t,bool,bool) 234 | virtual ITexture *CreateNamedRenderTargetTextureEx2(const char *pRTName, // Pass in NULL here for an unnamed render target. 235 | int w, 236 | int h, 237 | RenderTargetSizeMode_t sizeMode, // Controls how size is generated (and regenerated on video mode change). 238 | ImageFormat format, 239 | MaterialRenderTargetDepth_t depth = MATERIAL_RT_DEPTH_SHARED, 240 | unsigned int textureFlags = TEXTUREFLAGS_CLAMPS | TEXTUREFLAGS_CLAMPT, 241 | unsigned int renderTargetFlags = 0) = 0; //CMaterialSystem::CreateNamedRenderTargetTextureEx2(char const*,int,int,RenderTargetSizeMode_t,ImageFormat,MaterialRenderTargetDepth_t,uint,uint) 242 | virtual void BeginLightmapAllocationEv() = 0; //CMaterialSystem::BeginLightmapAllocation(void) 243 | virtual void EndLightmapAllocationEv() = 0; //CMaterialSystem::EndLightmapAllocation(void) 244 | virtual void CleanupLightmaps() = 0; //CMaterialSystem::CleanupLightmaps(void) 245 | virtual void AllocateLightmapEiiPiP9IMaterial() = 0; //CMaterialSystem::AllocateLightmap(int,int,int *,IMaterial *) 246 | virtual void AllocateWhiteLightmapEP9IMaterial() = 0; //CMaterialSystem::AllocateWhiteLightmap(IMaterial *) 247 | virtual void UpdateLightmapEiPiS0_PfS1_S1_S1_() = 0; //CMaterialSystem::UpdateLightmap(int,int *,int *,float *,float *,float *,float *) 248 | virtual void GetNumSortIDsEv() = 0; //CMaterialSystem::GetNumSortIDs(void) 249 | virtual void GetSortInfoEP25MaterialSystem_SortInfo_t() = 0; //CMaterialSystem::GetSortInfo(MaterialSystem_SortInfo_t *) 250 | virtual void GetLightmapPageSizeEiPiS0_() = 0; //CMaterialSystem::GetLightmapPageSize(int,int *,int *) 251 | virtual void ResetMaterialLightmapPageInfoEv() = 0; //CMaterialSystem::ResetMaterialLightmapPageInfo(void) 252 | virtual void IsStereoSupported() = 0; //CMaterialSystem::IsStereoSupported(void) 253 | virtual void IsStereoActiveThisFrame() = 0; //CMaterialSystem::IsStereoActiveThisFrame(void)const 254 | virtual void NVStereoUpdate() = 0;//CMaterialSystem::NVStereoUpdate(void) 255 | virtual void ClearBuffersEbbb() = 0; //CMaterialSystem::ClearBuffers(bool,bool,bool) 256 | virtual void SpinPresent() = 0; //CMaterialSystem::SpinPresent(unsigned int) 257 | virtual IMatRenderContext *GetRenderContext() = 0; //CMaterialSystem::GetRenderContext(void) 258 | 259 | char pad_0004[11180]; //0x0004 260 | bool isGameRunning; //0x2AB8 -> 0x2BB0 261 | }; //Size: 0x2ABC 262 | static_assert(sizeof(IMaterialSystem) == 0x2BB4); 263 | 264 | -------------------------------------------------------------------------------- /L4D2VR/sdk/newbitbuf.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Gistix/portal2vr/4abc0217fbbebae7f978c9f6758ef5dad118dadb/L4D2VR/sdk/newbitbuf.cpp -------------------------------------------------------------------------------- /L4D2VR/sdk/sdk_server.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class Server_WeaponCSBase 4 | { 5 | public: 6 | virtual void sub_1024E9C0() = 0; 7 | virtual void sub_100575D0() = 0; 8 | virtual void sub_1002C080() = 0; 9 | virtual void sub_1002C000() = 0; 10 | virtual void sub_1002C010() = 0; 11 | virtual void sub_1002C020() = 0; 12 | virtual void sub_1002C210() = 0; 13 | virtual void sub_1002C040() = 0; 14 | virtual void sub_1002C960() = 0; 15 | virtual void sub_1024DBE0() = 0; 16 | virtual void sub_1024DBF0() = 0; 17 | virtual void sub_1024DC00() = 0; 18 | virtual void sub_10039710() = 0; 19 | virtual void sub_1002C030() = 0; 20 | virtual void sub_1002C060() = 0; 21 | virtual void sub_100334A0() = 0; 22 | virtual void sub_10033590() = 0; 23 | virtual void nullsub_118() = 0; 24 | virtual void sub_1006D720() = 0; 25 | virtual void sub_10062F60() = 0; 26 | virtual void sub_10056BB0() = 0; 27 | virtual void sub_100498E0() = 0; 28 | virtual void sub_10031920() = 0; 29 | virtual void sub_1006D300() = 0; 30 | virtual void sub_1024EF60() = 0; 31 | virtual void sub_1002BA90() = 0; 32 | virtual void sub_1024DCD0() = 0; 33 | virtual void sub_10038980() = 0; 34 | virtual void nullsub_120() = 0; 35 | virtual void sub_100556A0() = 0; 36 | virtual void nullsub_80() = 0; 37 | virtual void sub_10052F60() = 0; 38 | virtual void sub_1006D160() = 0; 39 | virtual void sub_1006D0F0() = 0; 40 | virtual void sub_1024E0F0() = 0; 41 | virtual void sub_1006DED0() = 0; 42 | virtual void sub_1004B220() = 0; 43 | virtual void sub_10065540() = 0; 44 | virtual void sub_10066160() = 0; 45 | virtual void sub_1002BAC0() = 0; 46 | virtual void sub_1004A670() = 0; 47 | virtual void sub_1002C0A0() = 0; 48 | virtual void sub_1002BAD0() = 0; 49 | virtual void sub_1002BAE0() = 0; 50 | virtual void sub_1005EEA0() = 0; 51 | virtual void sub_1002BAF0() = 0; 52 | virtual void sub_1005D5F0() = 0; 53 | virtual void sub_100337A0() = 0; 54 | virtual void sub_10052F40() = 0; 55 | virtual void sub_100319D0() = 0; 56 | virtual void sub_100514C0() = 0; 57 | virtual void sub_1005EDA0() = 0; 58 | virtual void sub_10036670() = 0; 59 | virtual void sub_100345E0() = 0; 60 | virtual void sub_1002BB00() = 0; 61 | virtual void sub_1002BB10() = 0; 62 | virtual void sub_1002BB20() = 0; 63 | virtual void sub_10050A30() = 0; 64 | virtual void sub_10050A60() = 0; 65 | virtual void sub_10036530() = 0; 66 | virtual void sub_1002BB60() = 0; 67 | virtual void sub_10051D90() = 0; 68 | virtual void sub_10063B80() = 0; 69 | virtual void sub_10051330() = 0; 70 | virtual void nullsub_123() = 0; 71 | virtual void sub_1002C6B0() = 0; 72 | virtual void sub_10051340() = 0; 73 | virtual void sub_1002BB80() = 0; 74 | virtual void sub_1006D260() = 0; 75 | virtual void sub_10052D90() = 0; 76 | virtual void sub_1006F9D0() = 0; 77 | virtual void sub_1002BBB0() = 0; 78 | virtual void sub_10059AB0() = 0; 79 | virtual void sub_10059A10() = 0; 80 | virtual void sub_1002C220() = 0; 81 | virtual void sub_10059F80() = 0; 82 | virtual void nullsub_124() = 0; 83 | virtual void sub_1006D2F0() = 0; 84 | virtual void sub_1002BBD0() = 0; 85 | virtual void sub_1002BBE0() = 0; 86 | virtual void sub_1002BBF0() = 0; 87 | virtual void sub_1002BC00() = 0; 88 | virtual void sub_1002BC10() = 0; 89 | virtual void sub_1002BC20() = 0; 90 | virtual void sub_10051630() = 0; 91 | virtual void sub_1006D8C0() = 0; 92 | virtual void sub_1006D740() = 0; 93 | virtual void sub_1006D7C0() = 0; 94 | virtual void sub_1002BC30() = 0; 95 | virtual void sub_10052AF0() = 0; 96 | virtual void sub_1002BC40() = 0; 97 | virtual void sub_1002BC50() = 0; 98 | virtual void sub_1002BC60() = 0; 99 | virtual void sub_1002BC70() = 0; 100 | virtual void sub_1002BC80() = 0; 101 | virtual void sub_1002BC90() = 0; 102 | virtual void sub_10050750() = 0; 103 | virtual void sub_10050760() = 0; 104 | virtual void sub_1002BCC0() = 0; 105 | virtual void sub_10056A30() = 0; 106 | virtual void sub_10060EF0() = 0; 107 | virtual void sub_1005EDC0() = 0; 108 | virtual void sub_1002C1A0() = 0; 109 | virtual void sub_1002BCD0() = 0; 110 | virtual void sub_1002BD00() = 0; 111 | virtual void sub_1002BCF0() = 0; 112 | virtual void sub_1024E420() = 0; 113 | virtual void sub_100562B0() = 0; 114 | virtual void sub_10056310() = 0; 115 | virtual void sub_10056390() = 0; 116 | virtual void nullsub_125() = 0; 117 | virtual void sub_100563F0() = 0; 118 | virtual void nullsub_126() = 0; 119 | virtual void sub_1014E070() = 0; 120 | virtual void nullsub_127() = 0; 121 | virtual void sub_10065A20() = 0; 122 | virtual void nullsub_128() = 0; 123 | virtual void sub_10054850() = 0; 124 | virtual void sub_10031090() = 0; 125 | virtual void nullsub_7() = 0; 126 | virtual void sub_1004B380() = 0; 127 | virtual void sub_1006D2D0() = 0; 128 | virtual void sub_10070AE0() = 0; 129 | virtual void sub_1006D2B0() = 0; 130 | virtual void sub_1024E330() = 0; 131 | virtual void sub_1002BD60() = 0; 132 | virtual void sub_1002C1F0() = 0; 133 | virtual void sub_100306C0() = 0; 134 | virtual void nullsub_129() = 0; 135 | virtual void nullsub_130() = 0; 136 | virtual void nullsub_131() = 0; 137 | virtual void nullsub_132() = 0; 138 | virtual void nullsub_133() = 0; 139 | virtual void nullsub_134() = 0; 140 | virtual void nullsub_135() = 0; 141 | virtual void nullsub_136() = 0; 142 | virtual void nullsub_137() = 0; 143 | virtual void sub_10051740() = 0; 144 | virtual void sub_1002BE00() = 0; 145 | virtual void nullsub_138() = 0; 146 | virtual void sub_1006D610() = 0; 147 | virtual void sub_1006D670() = 0; 148 | virtual void sub_1006DEC0() = 0; 149 | virtual void sub_1006D040() = 0; 150 | virtual void sub_10050D50() = 0; 151 | virtual void sub_10050D80() = 0; 152 | virtual void sub_1005F6F0() = 0; 153 | virtual void sub_1006D690() = 0; 154 | virtual void sub_1006F7F0() = 0; 155 | virtual void sub_1002BFE0() = 0; 156 | virtual void sub_100336D0() = 0; 157 | virtual void sub_1002C200() = 0; 158 | virtual void sub_100568D0() = 0; 159 | virtual void sub_10056790() = 0; 160 | virtual void sub_1002BE20() = 0; 161 | virtual void sub_10059EA0() = 0; 162 | virtual void sub_10059F10() = 0; 163 | virtual void nullsub_139() = 0; 164 | virtual void sub_1002BE40() = 0; 165 | virtual void sub_1024E470() = 0; 166 | virtual void nullsub_140() = 0; 167 | virtual void sub_1006F360() = 0; 168 | virtual void sub_10051490() = 0; 169 | virtual void sub_1006D230() = 0; 170 | virtual void sub_1002BE90() = 0; 171 | virtual void sub_1006D200() = 0; 172 | virtual void sub_100708A0() = 0; 173 | virtual void sub_10052910() = 0; 174 | virtual void nullsub_141() = 0; 175 | virtual void nullsub_142() = 0; 176 | virtual void sub_10056610() = 0; 177 | virtual void sub_10051230() = 0; 178 | virtual void sub_1005EB40() = 0; 179 | virtual void sub_10052D60() = 0; 180 | virtual void sub_100512B0() = 0; 181 | virtual void sub_1002BEB0() = 0; 182 | virtual void sub_1002BEC0() = 0; 183 | virtual void sub_10147360() = 0; 184 | virtual void sub_1014C220() = 0; 185 | virtual void nullsub_143() = 0; 186 | virtual void sub_100325A0() = 0; 187 | virtual void sub_100325E0() = 0; 188 | virtual void sub_1002BED0() = 0; 189 | virtual void nullsub_144() = 0; 190 | virtual void nullsub_145() = 0; 191 | virtual void nullsub_146() = 0; 192 | virtual void nullsub_147() = 0; 193 | virtual void nullsub_148() = 0; 194 | virtual void nullsub_149() = 0; 195 | virtual void nullsub_150() = 0; 196 | virtual void nullsub_151() = 0; 197 | virtual void nullsub_152() = 0; 198 | virtual void nullsub_153() = 0; 199 | virtual void nullsub_154() = 0; 200 | virtual void nullsub_155() = 0; 201 | virtual void nullsub_156() = 0; 202 | virtual void nullsub_157() = 0; 203 | virtual void nullsub_158() = 0; 204 | virtual void nullsub_159() = 0; 205 | virtual void sub_10063F90() = 0; 206 | virtual void sub_10030580() = 0; 207 | virtual void sub_10030590() = 0; 208 | virtual void sub_10038450() = 0; 209 | virtual void nullsub_171() = 0; 210 | virtual void nullsub_172() = 0; 211 | virtual void sub_10036560() = 0; 212 | virtual void sub_10031F40() = 0; 213 | virtual void sub_10031A00() = 0; 214 | virtual void sub_10036570() = 0; 215 | virtual void sub_100368B0() = 0; 216 | virtual void sub_10030F50() = 0; 217 | virtual void sub_10031DE0() = 0; 218 | virtual void sub_10039720() = 0; 219 | virtual void sub_100351F0() = 0; 220 | virtual void sub_10036B20() = 0; 221 | virtual void sub_10035A40() = 0; 222 | virtual void sub_10034F20() = 0; 223 | virtual void sub_10049E30() = 0; 224 | virtual void nullsub_87() = 0; 225 | virtual void sub_10032840() = 0; 226 | virtual void sub_10035F80() = 0; 227 | virtual void sub_100331B0() = 0; 228 | virtual void sub_10036590() = 0; 229 | virtual void sub_10034420() = 0; 230 | virtual void sub_100344C0() = 0; 231 | virtual void sub_10034550() = 0; 232 | virtual void sub_100365A0() = 0; 233 | virtual void sub_100365B0() = 0; 234 | virtual void nullsub_173() = 0; 235 | virtual void sub_10037600() = 0; 236 | virtual void sub_100374E0() = 0; 237 | virtual void sub_10036660() = 0; 238 | virtual void sub_1024DC10() = 0; 239 | virtual void sub_10050780() = 0; 240 | virtual void sub_10050790() = 0; 241 | virtual void sub_1004F160() = 0; 242 | virtual void sub_1024F840() = 0; 243 | virtual void sub_1004D4D0() = 0; 244 | virtual void sub_1004AB70() = 0; 245 | virtual void sub_1004AB80() = 0; 246 | virtual void sub_1004ABA0() = 0; 247 | virtual void sub_1004B2C0() = 0; 248 | virtual void sub_1004B880() = 0; 249 | virtual void sub_1024DDC0() = 0; 250 | virtual void sub_1004B560() = 0; 251 | virtual void sub_1004B5B0() = 0; 252 | virtual void sub_1004B690() = 0; 253 | virtual void sub_1004B6F0() = 0; 254 | virtual void sub_1004B7A0() = 0; 255 | virtual void sub_1004B820() = 0; 256 | virtual void sub_1004D540() = 0; 257 | virtual void sub_1024DC40() = 0; 258 | virtual void sub_1004B8E0() = 0; 259 | virtual void sub_100507A0() = 0; 260 | virtual void sub_1004B9E0() = 0; 261 | virtual void sub_1004AE80() = 0; 262 | virtual void sub_1004D280() = 0; 263 | virtual void sub_1004AEA0() = 0; 264 | virtual void sub_1004BA80() = 0; 265 | virtual void sub_1004BAD0() = 0; 266 | virtual void sub_1004BB50() = 0; 267 | virtual void sub_100507B0() = 0; 268 | virtual void sub_1024EB40() = 0; 269 | virtual void sub_1024E160() = 0; 270 | virtual void sub_1024EE40() = 0; 271 | virtual void sub_1024DD60() = 0; 272 | virtual void sub_100507D0() = 0; 273 | virtual void sub_1004F3E0() = 0; 274 | virtual void sub_1004BBD0() = 0; 275 | virtual void sub_1004D590() = 0; 276 | virtual void sub_1004ABB0() = 0; 277 | virtual void sub_1004C850() = 0; 278 | virtual void sub_1024F220() = 0; 279 | virtual void sub_1004DC90() = 0; 280 | virtual void nullsub_192() = 0; 281 | virtual void sub_1004ACA0() = 0; 282 | virtual void sub_1004ABD0() = 0; 283 | virtual void sub_100507F0() = 0; 284 | virtual void sub_1004E0C0() = 0; 285 | virtual void sub_1004E3F0() = 0; 286 | virtual void sub_1004E600() = 0; 287 | virtual void sub_1024EEE0() = 0; 288 | virtual void sub_1004E640() = 0; 289 | virtual void sub_1024EA00() = 0; 290 | virtual void sub_1004C0F0() = 0; 291 | virtual void sub_1004F960() = 0; 292 | virtual void sub_1004ACD0() = 0; 293 | virtual void sub_1004ACE0() = 0; 294 | virtual void sub_1004ABC0() = 0; 295 | virtual void sub_1004AC90() = 0; 296 | virtual void sub_1024DEA0() = 0; 297 | virtual void sub_1004AC40() = 0; 298 | virtual void sub_10050820() = 0; 299 | virtual void sub_1024DE60() = 0; 300 | virtual void sub_10050850() = 0; 301 | virtual void sub_1004AC60() = 0; 302 | virtual void sub_10050860() = 0; 303 | virtual void sub_10050870() = 0; 304 | virtual void sub_10050880() = 0; 305 | virtual void sub_10050890() = 0; 306 | virtual void sub_100508A0() = 0; 307 | virtual void sub_1004BDA0() = 0; 308 | virtual void sub_1004C000() = 0; 309 | virtual void sub_1004AC50() = 0; 310 | virtual void sub_100508E0() = 0; 311 | virtual void sub_100508F0() = 0; 312 | virtual void sub_10050900() = 0; 313 | virtual void sub_10050910() = 0; 314 | virtual void sub_10050920() = 0; 315 | virtual void sub_1004D2E0() = 0; 316 | virtual void nullsub_194() = 0; 317 | virtual void sub_1004AF80() = 0; 318 | virtual void sub_1024FB00() = 0; 319 | virtual void nullsub_411() = 0; 320 | virtual void sub_1024E000() = 0; 321 | virtual void sub_1004AD00() = 0; 322 | virtual void sub_1004AD10() = 0; 323 | virtual void sub_10050950() = 0; 324 | virtual void sub_10050960() = 0; 325 | virtual void sub_10050970() = 0; 326 | virtual void sub_1024DC60() = 0; 327 | virtual void sub_1004A7B0() = 0; 328 | virtual void sub_1004A7D0() = 0; 329 | virtual void sub_1004A810() = 0; 330 | virtual void sub_1004A830() = 0; 331 | virtual void sub_1004A850() = 0; 332 | virtual void sub_1004A870() = 0; 333 | virtual void sub_1004A8E0() = 0; 334 | virtual void sub_1004A900() = 0; 335 | virtual void sub_1004A920() = 0; 336 | virtual void sub_1004A940() = 0; 337 | virtual void sub_1004A960() = 0; 338 | virtual void sub_1004A980() = 0; 339 | virtual void sub_1004A9A0() = 0; 340 | virtual void sub_1004A7F0() = 0; 341 | virtual void sub_1004AB20() = 0; 342 | virtual void sub_1004AB50() = 0; 343 | virtual void sub_1004A890() = 0; 344 | virtual void sub_1004A8C0() = 0; 345 | virtual void sub_1004A8B0() = 0; 346 | virtual void nullsub_196() = 0; 347 | virtual void sub_1004A760() = 0; 348 | virtual void sub_10050A10() = 0; 349 | virtual void sub_10050A20() = 0; 350 | virtual void sub_1004A9C0() = 0; 351 | virtual void sub_1004A9E0() = 0; 352 | virtual void sub_1004AA00() = 0; 353 | virtual void sub_1004AA20() = 0; 354 | virtual void sub_1004AA40() = 0; 355 | virtual void sub_1004AAA0() = 0; 356 | virtual void sub_1004AAC0() = 0; 357 | virtual void sub_1004AAE0() = 0; 358 | virtual void sub_1004AB00() = 0; 359 | virtual void sub_1004AA60() = 0; 360 | virtual void sub_1004AA80() = 0; 361 | virtual void sub_1004AD20() = 0; 362 | virtual void sub_10050990() = 0; 363 | virtual void sub_100509A0() = 0; 364 | virtual void sub_1004AC70() = 0; 365 | virtual void sub_1004AC80() = 0; 366 | virtual void sub_1004A450() = 0; 367 | virtual void sub_1004A5D0() = 0; 368 | virtual void sub_1024FA60() = 0; 369 | virtual void nullsub_412() = 0; 370 | virtual void sub_100499A0() = 0; 371 | virtual void sub_100499F0() = 0; 372 | virtual void sub_100509B0() = 0; 373 | virtual void sub_1004A0F0() = 0; 374 | virtual void sub_10049900() = 0; 375 | virtual void sub_10049E70() = 0; 376 | virtual void sub_10049980() = 0; 377 | virtual void sub_10049990() = 0; 378 | virtual void sub_10049C00() = 0; 379 | virtual void sub_10049D80() = 0; 380 | virtual void nullsub_197() = 0; 381 | virtual void sub_100509D0() = 0; 382 | virtual void sub_100509E0() = 0; 383 | virtual void sub_100509F0() = 0; 384 | virtual void sub_10050A00() = 0; 385 | virtual void sub_1004BD00() = 0; 386 | virtual void nullsub_413() = 0; 387 | virtual void sub_1024DEC0() = 0; 388 | virtual void sub_1024E6D0() = 0; 389 | virtual void sub_1024E1B0() = 0; 390 | virtual void sub_1024E8C0() = 0; 391 | virtual void sub_1024E1E0() = 0; 392 | virtual void sub_1024C4E0() = 0; 393 | virtual void sub_1024E8D0() = 0; 394 | virtual void unknown_libname_15() = 0; 395 | virtual void sub_1024D9B0() = 0; 396 | virtual void sub_1024C4F0() = 0; 397 | virtual void sub_1024E8F0() = 0; 398 | virtual void sub_1024DC20() = 0; 399 | virtual void sub_1024C500() = 0; 400 | virtual void sub_1024C510() = 0; 401 | virtual void nullsub_414() = 0; 402 | virtual void sub_1024E150() = 0; 403 | virtual int GetWeaponID() = 0; 404 | virtual void sub_1024C540() = 0; 405 | virtual void sub_1024EDE0() = 0; 406 | virtual void sub_1024C550() = 0; 407 | virtual void sub_1024C560() = 0; 408 | virtual void sub_1024E5D0() = 0; 409 | virtual void sub_1024C570() = 0; 410 | virtual void sub_1024DD20() = 0; 411 | virtual void sub_1024C5C0() = 0; 412 | virtual void sub_1024DD10() = 0; 413 | virtual void sub_1024EFF0() = 0; 414 | virtual void sub_1024C580() = 0; 415 | virtual void sub_1024C590() = 0; 416 | virtual void sub_1024C5A0() = 0; 417 | virtual void sub_1024C5B0() = 0; 418 | 419 | char pad_0000[6124]; //0x0000 420 | int entitiesHitThisSwing; //0x17F0 421 | }; //Size: 0x17F4 422 | static_assert(sizeof(Server_WeaponCSBase) == 0x17F4); 423 | 424 | class Server_BaseEntity 425 | { 426 | public: 427 | virtual void sub_10060B30() = 0; 428 | virtual void sub_100575D0() = 0; 429 | virtual void sub_1002C080() = 0; 430 | virtual void sub_1002C000() = 0; 431 | virtual void sub_1002C010() = 0; 432 | virtual void sub_1002C020() = 0; 433 | virtual void sub_1002C210() = 0; 434 | virtual void sub_1002C040() = 0; 435 | virtual void sub_1002C960() = 0; 436 | virtual void sub_10050CF0() = 0; 437 | virtual void sub_10050D00() = 0; 438 | virtual void sub_100510D0() = 0; 439 | virtual void sub_1006D010() = 0; 440 | virtual void sub_1002C030() = 0; 441 | virtual void sub_1002C060() = 0; 442 | virtual void sub_10051500() = 0; 443 | virtual void sub_10051510() = 0; 444 | virtual void nullsub_118() = 0; 445 | virtual void sub_1006D720() = 0; 446 | virtual void sub_10062F60() = 0; 447 | virtual void sub_10056BB0() = 0; 448 | virtual void sub_10056AC0() = 0; 449 | virtual void sub_10056C60() = 0; 450 | virtual void sub_1006D300() = 0; 451 | virtual void sub_1005A230() = 0; 452 | virtual void sub_1002BA90() = 0; 453 | virtual void nullsub_119() = 0; 454 | virtual void sub_10051690() = 0; 455 | virtual void nullsub_120() = 0; 456 | virtual void sub_100556A0() = 0; 457 | virtual void nullsub_80() = 0; 458 | virtual void sub_10052F60() = 0; 459 | virtual void sub_1006D160() = 0; 460 | virtual void sub_1006D0F0() = 0; 461 | virtual void sub_10070300() = 0; 462 | virtual void sub_1006DED0() = 0; 463 | virtual void sub_100659B0() = 0; 464 | virtual void sub_10065540() = 0; 465 | virtual void sub_10066160() = 0; 466 | virtual void sub_1002BAC0() = 0; 467 | virtual void sub_100561E0() = 0; 468 | virtual void sub_1002C0A0() = 0; 469 | virtual void sub_1002BAD0() = 0; 470 | virtual void sub_1002BAE0() = 0; 471 | virtual void sub_1005EEA0() = 0; 472 | virtual void sub_1002BAF0() = 0; 473 | virtual void sub_1005D5F0() = 0; 474 | virtual void sub_1005DB60() = 0; 475 | virtual void sub_10052F40() = 0; 476 | virtual void sub_1006B950() = 0; 477 | virtual void sub_100514C0() = 0; 478 | virtual void sub_1005EDA0() = 0; 479 | virtual void sub_10060C70() = 0; 480 | virtual void sub_100601B0() = 0; 481 | virtual void sub_1002BB00() = 0; 482 | virtual void sub_1002BB10() = 0; 483 | virtual void sub_1002BB20() = 0; 484 | virtual void nullsub_121() = 0; 485 | virtual void nullsub_122() = 0; 486 | virtual void sub_1002BB50() = 0; 487 | virtual void sub_1002BB60() = 0; 488 | virtual void sub_10051D90() = 0; 489 | virtual void sub_10063B80() = 0; 490 | virtual void sub_10051330() = 0; 491 | virtual void nullsub_123() = 0; 492 | virtual void sub_1002C6B0() = 0; 493 | virtual void sub_10051340() = 0; 494 | virtual void sub_1002BB80() = 0; 495 | virtual void sub_1006D260() = 0; 496 | virtual void sub_10052D90() = 0; 497 | virtual void sub_1006F9D0() = 0; 498 | virtual void sub_1002BBB0() = 0; 499 | virtual void sub_10059AB0() = 0; 500 | virtual void sub_10059A10() = 0; 501 | virtual void sub_1002C220() = 0; 502 | virtual void sub_10059F80() = 0; 503 | virtual void nullsub_124() = 0; 504 | virtual void sub_1006D2F0() = 0; 505 | virtual void sub_1002BBD0() = 0; 506 | virtual void sub_1002BBE0() = 0; 507 | virtual void sub_1002BBF0() = 0; 508 | virtual void sub_1002BC00() = 0; 509 | virtual void sub_1002BC10() = 0; 510 | virtual void sub_1002BC20() = 0; 511 | virtual void sub_10051630() = 0; 512 | virtual void sub_1006D8C0() = 0; 513 | virtual void sub_1006D740() = 0; 514 | virtual void sub_1006D7C0() = 0; 515 | virtual void sub_1002BC30() = 0; 516 | virtual void sub_10052AF0() = 0; 517 | virtual void sub_1002BC40() = 0; 518 | virtual void sub_1002BC50() = 0; 519 | virtual void sub_1002BC60() = 0; 520 | virtual void sub_1002BC70() = 0; 521 | virtual void sub_1002BC80() = 0; 522 | virtual void sub_1002BC90() = 0; 523 | virtual void sub_1002BCA0() = 0; 524 | virtual void sub_1002BCB0() = 0; 525 | virtual void sub_1002BCC0() = 0; 526 | virtual void sub_10056A30() = 0; 527 | virtual void sub_10060EF0() = 0; 528 | virtual void sub_1005EDC0() = 0; 529 | virtual void sub_1002C1A0() = 0; 530 | virtual void sub_1002BCD0() = 0; 531 | virtual void sub_1002BD00() = 0; 532 | virtual void sub_1002BCF0() = 0; 533 | virtual void sub_10056470() = 0; 534 | virtual void sub_100562B0() = 0; 535 | virtual void sub_10056310() = 0; 536 | virtual void sub_10056390() = 0; 537 | virtual void nullsub_125() = 0; 538 | virtual void sub_100563F0() = 0; 539 | virtual void nullsub_126() = 0; 540 | virtual void sub_1014E070() = 0; 541 | virtual void nullsub_127() = 0; 542 | virtual void sub_10065A20() = 0; 543 | virtual void nullsub_128() = 0; 544 | virtual void sub_10054850() = 0; 545 | virtual void sub_10066620() = 0; 546 | virtual void nullsub_7() = 0; 547 | virtual void sub_1006DB90() = 0; 548 | virtual void sub_1006D2D0() = 0; 549 | virtual void sub_10070AE0() = 0; 550 | virtual void sub_1006D2B0() = 0; 551 | virtual void sub_1002BD50() = 0; 552 | virtual void sub_1002BD60() = 0; 553 | virtual void sub_1002C1F0() = 0; 554 | virtual void sub_10061150() = 0; 555 | virtual void nullsub_129() = 0; 556 | virtual void nullsub_130() = 0; 557 | virtual void nullsub_131() = 0; 558 | virtual void nullsub_132() = 0; 559 | virtual void nullsub_133() = 0; 560 | virtual void nullsub_134() = 0; 561 | virtual void nullsub_135() = 0; 562 | virtual void nullsub_136() = 0; 563 | virtual void nullsub_137() = 0; 564 | virtual void sub_10051740() = 0; 565 | virtual void sub_1002BE00() = 0; 566 | virtual void nullsub_138() = 0; 567 | virtual Vector EyePosition() = 0; 568 | virtual void sub_1006D670() = 0; 569 | virtual void sub_1006DEC0() = 0; 570 | virtual void sub_1006D040() = 0; 571 | virtual void sub_10050D50() = 0; 572 | virtual void sub_10050D80() = 0; 573 | virtual void sub_1005F6F0() = 0; 574 | virtual void sub_1006D690() = 0; 575 | virtual void sub_1006F7F0() = 0; 576 | virtual void sub_1002BFE0() = 0; 577 | virtual void sub_1005F630() = 0; 578 | virtual void sub_1002C200() = 0; 579 | virtual void sub_100568D0() = 0; 580 | virtual void sub_10056790() = 0; 581 | virtual void sub_1002BE20() = 0; 582 | virtual void sub_10059EA0() = 0; 583 | virtual void sub_10059F10() = 0; 584 | virtual void nullsub_139() = 0; 585 | virtual void sub_1002BE40() = 0; 586 | virtual void sub_1002BE70() = 0; 587 | virtual void nullsub_140() = 0; 588 | virtual void sub_1006F360() = 0; 589 | virtual void sub_10051490() = 0; 590 | virtual void sub_1006D230() = 0; 591 | virtual void sub_1002BE90() = 0; 592 | virtual void sub_1006D200() = 0; 593 | virtual void sub_100708A0() = 0; 594 | virtual void sub_10052910() = 0; 595 | virtual void nullsub_141() = 0; 596 | virtual void nullsub_142() = 0; 597 | virtual void sub_10056610() = 0; 598 | virtual void sub_10051230() = 0; 599 | virtual void sub_1005EB40() = 0; 600 | virtual void sub_10052D60() = 0; 601 | virtual void sub_100512B0() = 0; 602 | virtual void sub_1002BEB0() = 0; 603 | virtual void sub_1002BEC0() = 0; 604 | virtual void sub_10147360() = 0; 605 | virtual void sub_1014C220() = 0; 606 | virtual void nullsub_143() = 0; 607 | virtual void sub_10057570() = 0; 608 | virtual void sub_100575A0() = 0; 609 | virtual void sub_1002BED0() = 0; 610 | virtual void nullsub_144() = 0; 611 | virtual void nullsub_145() = 0; 612 | virtual void nullsub_146() = 0; 613 | virtual void nullsub_147() = 0; 614 | virtual void nullsub_148() = 0; 615 | virtual void nullsub_149() = 0; 616 | virtual void nullsub_150() = 0; 617 | virtual void nullsub_151() = 0; 618 | virtual void nullsub_152() = 0; 619 | virtual void nullsub_153() = 0; 620 | virtual void nullsub_154() = 0; 621 | virtual void nullsub_155() = 0; 622 | virtual void nullsub_156() = 0; 623 | virtual void nullsub_157() = 0; 624 | virtual void nullsub_158() = 0; 625 | virtual void nullsub_159() = 0; 626 | virtual void sub_10063F90() = 0; 627 | 628 | }; 629 | 630 | class CPortalGameMovement 631 | { 632 | public: 633 | virtual ~CPortalGameMovement() = 0; 634 | C_BasePlayer* player; //0x0004 635 | }; //Size: 0x8 636 | static_assert(sizeof(CPortalGameMovement) == 0x8); 637 | 638 | class CBaseEntity 639 | { 640 | public: 641 | virtual ~CBaseEntity() = 0; 642 | char pad_0004[20]; //0x0004 643 | CBaseEntity* m_hOwnerEntity; //0x0018 644 | char pad_001C[68]; //0x001C 645 | char* EntityClass; //0x0060 646 | char pad_0064[72]; //0x0064 647 | char* ModelName; //0x00AC 648 | char pad_00B0[168]; //0x00B0 649 | void* m_hGroundEntity; //0x0158 650 | float m_flGroundChangeTime; //0x015C 651 | Vector m_vecBaseVelocity; //0x0160 652 | Vector m_vecAbsVelocity; //0x016C 653 | Vector m_vecAngVelocity; //0x0178 654 | char pad_0184[48]; //0x0184 // matrix3x4_t m_rgflCoordinateFrame; 655 | float m_flFriction; //0x01B4 656 | float m_flElasticity; //0x01B8 657 | float m_flLocalTime; //0x01BC 658 | float m_flVPhysicsUpdateLocalTime; //0x01C0 659 | float m_flMoveDoneTime; //0x01C4 660 | int32_t m_nPushEnumCount; //0x01C8 661 | Vector m_vecAbsOrigin; //0x01CC 662 | QAngle m_angAbsRotation; //0x01D8 663 | Vector m_vecVelocity; //0x01E4 664 | void* m_pBlocker; //0x01F0 665 | char pad_01F4[300]; //0x01F4 666 | char* m_iGlobalname; //0x0320 667 | char* m_iParent; //0x0324 668 | char pad_0328[44]; //0x0328 669 | char* m_iszDamageFilterName; //0x0354 670 | }; //Size: 0x0358 671 | static_assert(sizeof(CBaseEntity) == 0x0358); -------------------------------------------------------------------------------- /L4D2VR/sdk/texture.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | typedef unsigned int uint32; 4 | 5 | class IVTFTexture; 6 | class ITexture; 7 | struct Rect_t; 8 | 9 | enum NormalDecodeMode_t 10 | { 11 | NORMAL_DECODE_NONE = 0, 12 | NORMAL_DECODE_ATI2N = 1, 13 | NORMAL_DECODE_ATI2N_ALPHA = 2 14 | }; 15 | 16 | enum ImageFormat 17 | { 18 | IMAGE_FORMAT_UNKNOWN = -1, 19 | IMAGE_FORMAT_RGBA8888 = 0, 20 | IMAGE_FORMAT_ABGR8888, 21 | IMAGE_FORMAT_RGB888, 22 | IMAGE_FORMAT_BGR888, 23 | IMAGE_FORMAT_RGB565, 24 | IMAGE_FORMAT_I8, 25 | IMAGE_FORMAT_IA88, 26 | IMAGE_FORMAT_P8, 27 | IMAGE_FORMAT_A8, 28 | IMAGE_FORMAT_RGB888_BLUESCREEN, 29 | IMAGE_FORMAT_BGR888_BLUESCREEN, 30 | IMAGE_FORMAT_ARGB8888, 31 | IMAGE_FORMAT_BGRA8888, 32 | IMAGE_FORMAT_DXT1, 33 | IMAGE_FORMAT_DXT3, 34 | IMAGE_FORMAT_DXT5, 35 | IMAGE_FORMAT_BGRX8888, 36 | IMAGE_FORMAT_BGR565, 37 | IMAGE_FORMAT_BGRX5551, 38 | IMAGE_FORMAT_BGRA4444, 39 | IMAGE_FORMAT_DXT1_ONEBITALPHA, 40 | IMAGE_FORMAT_BGRA5551, 41 | IMAGE_FORMAT_UV88, 42 | IMAGE_FORMAT_UVWQ8888, 43 | IMAGE_FORMAT_RGBA16161616F, 44 | IMAGE_FORMAT_RGBA16161616, 45 | IMAGE_FORMAT_UVLX8888, 46 | IMAGE_FORMAT_R32F, // Single-channel 32-bit floating point 47 | IMAGE_FORMAT_RGB323232F, 48 | IMAGE_FORMAT_RGBA32323232F, 49 | 50 | // Depth-stencil texture formats for shadow depth mapping 51 | IMAGE_FORMAT_NV_DST16, // 52 | IMAGE_FORMAT_NV_DST24, // 53 | IMAGE_FORMAT_NV_INTZ, // Vendor-specific depth-stencil texture 54 | IMAGE_FORMAT_NV_RAWZ, // formats for shadow depth mapping 55 | IMAGE_FORMAT_ATI_DST16, // 56 | IMAGE_FORMAT_ATI_DST24, // 57 | IMAGE_FORMAT_NV_NULL, // Dummy format which takes no video memory 58 | 59 | // Compressed normal map formats 60 | IMAGE_FORMAT_ATI2N, // One-surface ATI2N / DXN format 61 | IMAGE_FORMAT_ATI1N, // Two-surface ATI1N format 62 | 63 | #if defined( _X360 ) 64 | // Depth-stencil texture formats 65 | IMAGE_FORMAT_X360_DST16, 66 | IMAGE_FORMAT_X360_DST24, 67 | IMAGE_FORMAT_X360_DST24F, 68 | // supporting these specific formats as non-tiled for procedural cpu access 69 | IMAGE_FORMAT_LINEAR_BGRX8888, 70 | IMAGE_FORMAT_LINEAR_RGBA8888, 71 | IMAGE_FORMAT_LINEAR_ABGR8888, 72 | IMAGE_FORMAT_LINEAR_ARGB8888, 73 | IMAGE_FORMAT_LINEAR_BGRA8888, 74 | IMAGE_FORMAT_LINEAR_RGB888, 75 | IMAGE_FORMAT_LINEAR_BGR888, 76 | IMAGE_FORMAT_LINEAR_BGRX5551, 77 | IMAGE_FORMAT_LINEAR_I8, 78 | IMAGE_FORMAT_LINEAR_RGBA16161616, 79 | 80 | IMAGE_FORMAT_LE_BGRX8888, 81 | IMAGE_FORMAT_LE_BGRA8888, 82 | #endif 83 | 84 | IMAGE_FORMAT_DXT1_RUNTIME, 85 | IMAGE_FORMAT_DXT5_RUNTIME, 86 | 87 | NUM_IMAGE_FORMATS 88 | }; 89 | 90 | //----------------------------------------------------------------------------- 91 | // This will get called on procedural textures to re-fill the textures 92 | // with the appropriate bit pattern. Calling Download() will also 93 | // cause this interface to be called. It will also be called upon 94 | // mode switch, or on other occasions where the bits are discarded. 95 | //----------------------------------------------------------------------------- 96 | class ITextureRegenerator 97 | { 98 | public: 99 | // This will be called when the texture bits need to be regenerated. 100 | // Use the VTFTexture interface, which has been set up with the 101 | // appropriate texture size + format 102 | // The rect specifies which part of the texture needs to be updated 103 | // You can choose to update all of the bits if you prefer 104 | virtual void RegenerateTextureBits(ITexture * pTexture, IVTFTexture * pVTFTexture, Rect_t * pRect) = 0; 105 | 106 | // This will be called when the regenerator needs to be deleted 107 | // which will happen when the texture is destroyed 108 | virtual void Release() = 0; 109 | 110 | // (erics): This should have a virtual destructor, but would be ABI breaking (non-versioned interface implemented 111 | // by the game) 112 | // virtual ~ITextureRegenerator(){} 113 | }; 114 | 115 | class ITexture 116 | { 117 | public: 118 | // Various texture polling methods 119 | virtual const char *GetName(void) const = 0; 120 | virtual int GetMappingWidth() const = 0; 121 | virtual int GetMappingHeight() const = 0; 122 | virtual int GetActualWidth() const = 0; 123 | virtual int GetActualHeight() const = 0; 124 | virtual int GetNumAnimationFrames() const = 0; 125 | virtual bool IsTranslucent() const = 0; 126 | virtual bool IsMipmapped() const = 0; 127 | 128 | virtual void GetLowResColorSample(float s, float t, float *color) const = 0; 129 | 130 | // Gets texture resource data of the specified type. 131 | // Params: 132 | // eDataType type of resource to retrieve. 133 | // pnumBytes on return is the number of bytes available in the read-only data buffer or is undefined 134 | // Returns: 135 | // pointer to the resource data, or NULL 136 | virtual void *GetResourceData(uint32 eDataType, size_t *pNumBytes) const = 0; 137 | 138 | // Methods associated with reference count 139 | virtual void IncrementReferenceCount(void) = 0; 140 | virtual void DecrementReferenceCount(void) = 0; 141 | 142 | inline void AddRef() { IncrementReferenceCount(); } 143 | inline void Release() { DecrementReferenceCount(); } 144 | 145 | // Used to modify the texture bits (procedural textures only) 146 | virtual void SetTextureRegenerator(ITextureRegenerator *pTextureRegen) = 0; 147 | 148 | // Reconstruct the texture bits in HW memory 149 | 150 | // If rect is not specified, reconstruct all bits, otherwise just 151 | // reconstruct a subrect. 152 | virtual void Download(Rect_t *pRect = 0, int nAdditionalCreationFlags = 0) = 0; 153 | 154 | // Uses for stats. . .get the approximate size of the texture in it's current format. 155 | virtual int GetApproximateVidMemBytes(void) const = 0; 156 | 157 | // Returns true if the texture data couldn't be loaded. 158 | virtual bool IsError() const = 0; 159 | 160 | // NOTE: Stuff after this is added after shipping HL2. 161 | 162 | // For volume textures 163 | virtual bool IsVolumeTexture() const = 0; 164 | virtual int GetMappingDepth() const = 0; 165 | virtual int GetActualDepth() const = 0; 166 | 167 | virtual ImageFormat GetImageFormat() const = 0; 168 | virtual NormalDecodeMode_t GetNormalDecodeMode() const = 0; 169 | 170 | // Various information about the texture 171 | virtual bool IsRenderTarget() const = 0; 172 | virtual bool IsCubeMap() const = 0; 173 | virtual bool IsNormalMap() const = 0; 174 | virtual bool IsProcedural() const = 0; 175 | 176 | virtual void DeleteIfUnreferenced() = 0; 177 | 178 | #if defined( _X360 ) 179 | virtual bool ClearTexture(int r, int g, int b, int a) = 0; 180 | virtual bool CreateRenderTargetSurface(int width, int height, ImageFormat format, bool bSameAsTexture) = 0; 181 | #endif 182 | 183 | // swap everything except the name with another texture 184 | virtual void SwapContents(ITexture *pOther) = 0; 185 | 186 | // Retrieve the vtf flags mask 187 | virtual unsigned int GetFlags(void) const = 0; 188 | 189 | // Force LOD override (automatically downloads the texture) 190 | virtual void ForceLODOverride(int iNumLodsOverrideUpOrDown) = 0; 191 | 192 | // Save texture to a file. 193 | virtual bool SaveToFile(const char *fileName) = 0; 194 | 195 | // Copy this texture, which must be a render target or a renderable texture, to the destination texture, 196 | // which must have been created with the STAGING bit. 197 | virtual void CopyToStagingTexture(ITexture *pDstTex) = 0; 198 | 199 | // Set that this texture should return true for the call "IsError" 200 | virtual void SetErrorTexture(bool bIsErrorTexture) = 0; 201 | }; 202 | 203 | 204 | inline bool IsErrorTexture(ITexture *pTex) 205 | { 206 | return !pTex || pTex->IsError(); 207 | } -------------------------------------------------------------------------------- /L4D2VR/sdk/trace.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "vector.h" 4 | 5 | 6 | 7 | struct cplane_t 8 | { 9 | Vector normal; 10 | float dist; 11 | unsigned char type; // for fast side tests 12 | unsigned char signbits; // signx + (signy<<1) + (signz<<1) 13 | unsigned char pad[2]; 14 | }; 15 | 16 | struct csurface_t 17 | { 18 | const char *name; 19 | short surfaceProps; 20 | unsigned short flags; // BUGBUG: These are declared per surface, not per material, but this database is per-material now 21 | }; 22 | 23 | #define CONTENTS_SOLID 0x1 // an eye is never valid in a solid 24 | #define CONTENTS_WINDOW 0x2 // translucent, but not watery (glass) 25 | #define CONTENTS_GRATE 0x8 // alpha-tested "grate" textures. Bullets/sight pass through, but solids don't 26 | #define CONTENTS_MOVEABLE 0x4000 27 | #define CONTENTS_PLAYERCLIP 0x10000 28 | #define CONTENTS_MONSTERCLIP 0x20000 29 | #define CONTENTS_MONSTER 0x2000000 30 | #define CONTENTS_DEBRIS 0x4000000 31 | #define CONTENTS_HITBOX 0x40000000 // use accurate hitboxes on trace 32 | 33 | #define MASK_NPCWORLDSTATIC (CONTENTS_SOLID|CONTENTS_WINDOW|CONTENTS_MONSTERCLIP|CONTENTS_GRATE) 34 | #define STANDARD_TRACE_MASK ( MASK_NPCWORLDSTATIC | CONTENTS_MOVEABLE | CONTENTS_MONSTER | CONTENTS_DEBRIS | CONTENTS_HITBOX ) 35 | #define MASK_SHOT (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_MONSTER|CONTENTS_WINDOW|CONTENTS_DEBRIS|CONTENTS_HITBOX) 36 | #define MASK_SHOT_HULL (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_MONSTER|CONTENTS_WINDOW|CONTENTS_DEBRIS|CONTENTS_GRATE) 37 | #define MASK_STATICWORLD (CONTENTS_SOLID|CONTENTS_WINDOW|CONTENTS_GRATE) 38 | 39 | #define DISPSURF_FLAG_SURFACE (1<<0) 40 | #define DISPSURF_FLAG_WALKABLE (1<<1) 41 | #define DISPSURF_FLAG_BUILDABLE (1<<2) 42 | #define DISPSURF_FLAG_SURFPROP1 (1<<3) 43 | #define DISPSURF_FLAG_SURFPROP2 (1<<4) 44 | 45 | enum SpewType_t 46 | { 47 | SPEW_MESSAGE = 0, 48 | SPEW_WARNING, 49 | SPEW_ASSERT, 50 | SPEW_ERROR, 51 | SPEW_LOG, 52 | 53 | SPEW_TYPE_COUNT 54 | }; 55 | 56 | #define __T(x) L ## x 57 | #define _T(x) __T(x) 58 | #define Assert( _exp ) _AssertMsg( _exp, _T("Assertion Failed: ") _T(#_exp), ((void)0), false ) 59 | 60 | #define FLT_MAX 3.402823466e+38F // max value 61 | 62 | #define _AssertMsg( _exp, _msg, _executeExp, _bFatal ) \ 63 | do { \ 64 | if (!(_exp)) \ 65 | { \ 66 | _SpewInfo( SPEW_ASSERT, __TFILE__, __LINE__ ); \ 67 | SpewRetval_t ret = _SpewMessage("%s", static_cast( _msg )); \ 68 | CallAssertFailedNotifyFunc( __TFILE__, __LINE__, _msg ); \ 69 | _executeExp; \ 70 | if ( ret == SPEW_DEBUGGER) \ 71 | { \ 72 | if ( !ShouldUseNewAssertDialog() || DoNewAssertDialog( __TFILE__, __LINE__, _msg ) ) \ 73 | { \ 74 | DebuggerBreak(); \ 75 | } \ 76 | if ( _bFatal ) \ 77 | { \ 78 | _ExitOnFatalAssert( __TFILE__, __LINE__ ); \ 79 | } \ 80 | } \ 81 | } \ 82 | } while (0) 83 | 84 | class CBaseTrace 85 | { 86 | public: 87 | 88 | // Displacement flags tests. 89 | bool IsDispSurface(void) { return ((dispFlags & DISPSURF_FLAG_SURFACE) != 0); } 90 | bool IsDispSurfaceWalkable(void) { return ((dispFlags & DISPSURF_FLAG_WALKABLE) != 0); } 91 | bool IsDispSurfaceBuildable(void) { return ((dispFlags & DISPSURF_FLAG_BUILDABLE) != 0); } 92 | bool IsDispSurfaceProp1(void) { return ((dispFlags & DISPSURF_FLAG_SURFPROP1) != 0); } 93 | bool IsDispSurfaceProp2(void) { return ((dispFlags & DISPSURF_FLAG_SURFPROP2) != 0); } 94 | 95 | public: 96 | 97 | // these members are aligned!! 98 | Vector startpos; // start position 99 | Vector endpos; // final position 100 | cplane_t plane; // surface normal at impact 101 | 102 | float fraction; // time completed, 1.0 = didn't hit anything 103 | 104 | int contents; // contents on other side of surface hit 105 | unsigned short dispFlags; // displacement flags for marking surfaces with data 106 | 107 | bool allsolid; // if true, plane is not valid 108 | bool startsolid; // if true, the initial point was in a solid area 109 | 110 | CBaseTrace() {} 111 | }; 112 | 113 | class CGameTrace : public CBaseTrace 114 | { 115 | public: 116 | 117 | bool DidHitWorld() const; 118 | bool DidHitNonWorldEntity() const; 119 | int GetEntityIndex() const; 120 | inline bool DidHit() const { return fraction < 1 || allsolid || startsolid; }; 121 | // bool isVisible() const; 122 | // The engine doesn't know what a CBaseEntity is, so it has a backdoor to 123 | // let it get at the edict. 124 | 125 | public: 126 | 127 | float fractionleftsolid; 128 | csurface_t surface; 129 | int hitgroup; 130 | short physicsbone; 131 | void *m_pEnt; 132 | int hitbox; 133 | 134 | CGameTrace() {} 135 | 136 | private: 137 | // No copy constructors allowed 138 | CGameTrace(const CGameTrace &vOther); 139 | }; 140 | 141 | enum TraceType_t 142 | { 143 | TRACE_EVERYTHING = 0, 144 | TRACE_WORLD_ONLY, // NOTE: This does *not* test static props!!! 145 | TRACE_ENTITIES_ONLY, // NOTE: This version will *not* test static props 146 | TRACE_EVERYTHING_FILTER_PROPS, // NOTE: This version will pass the IHandleEntity for props through the filter, unlike all other filters 147 | }; 148 | 149 | enum class TraceType 150 | { 151 | TRACE_EVERYTHING = 0, 152 | TRACE_WORLD_ONLY, 153 | TRACE_ENTITIES_ONLY, 154 | TRACE_EVERYTHING_FILTER_PROPS, 155 | }; 156 | 157 | class ITraceFilter 158 | { 159 | public: 160 | virtual bool ShouldHitEntity(IHandleEntity * pEntity, int contentsMask) = 0; 161 | virtual TraceType GetTraceType() const = 0; 162 | }; 163 | 164 | class CTraceFilter : public ITraceFilter 165 | { 166 | public: 167 | CTraceFilter(IHandleEntity *passentity, int collisionGroup, void *pExtraShouldHitCheckFn = NULL) 168 | { 169 | m_pPassEnt = passentity; 170 | m_collisionGroup = collisionGroup; 171 | m_pExtraShouldHitCheckFunction = pExtraShouldHitCheckFn; 172 | } 173 | virtual TraceType GetTraceType() const 174 | { 175 | return TraceType::TRACE_EVERYTHING; 176 | } 177 | 178 | IHandleEntity *m_pPassEnt; 179 | int m_collisionGroup; 180 | void *m_pExtraShouldHitCheckFunction; 181 | }; 182 | 183 | 184 | class CTraceFilterSkipNPCsAndPlayers : public CTraceFilter 185 | { 186 | public: 187 | CTraceFilterSkipNPCsAndPlayers(IHandleEntity *passentity, int collisionGroup) 188 | : CTraceFilter(passentity, collisionGroup) 189 | { 190 | } 191 | 192 | virtual bool ShouldHitEntity(IHandleEntity *pServerEntity, int contentsMask) 193 | { 194 | C_BasePlayer *pEntity = (C_BasePlayer *)pServerEntity; 195 | if (!pEntity) 196 | return true; 197 | 198 | if (m_pPassEnt == pServerEntity) 199 | return false; 200 | 201 | if (pEntity->IsNPC() || pEntity->IsPlayer()) 202 | { 203 | return false; 204 | } 205 | 206 | return true; 207 | } 208 | }; 209 | 210 | 211 | 212 | struct Ray_t 213 | { 214 | VectorAligned m_Start; // starting point, centered within the extents 215 | VectorAligned m_Delta; // direction + length of the ray 216 | VectorAligned m_StartOffset; // Add this to m_Start to get the actual ray start 217 | VectorAligned m_Extents; // Describes an axis aligned box extruded along a ray 218 | const matrix3x4_t *m_pWorldAxisTransform; 219 | bool m_IsRay; // are the extents zero? 220 | bool m_IsSwept; // is delta != 0? 221 | 222 | void Init(Vector const &start, Vector const &end) 223 | { 224 | //Assert(&end); 225 | VectorSubtract(end, start, m_Delta); 226 | 227 | m_IsSwept = (m_Delta.LengthSqr() != 0); 228 | 229 | VectorClear(m_Extents); 230 | m_IsRay = true; 231 | 232 | m_pWorldAxisTransform = 0; 233 | 234 | // Offset m_Start to be in the center of the box... 235 | VectorClear(m_StartOffset); 236 | VectorCopy(start, m_Start); 237 | } 238 | 239 | void Init(Vector const &start, Vector const &end, Vector const &mins, Vector const &maxs) 240 | { 241 | //Assert(&end); 242 | VectorSubtract(end, start, m_Delta); 243 | 244 | m_IsSwept = (m_Delta.LengthSqr() != 0); 245 | 246 | VectorSubtract(maxs, mins, m_Extents); 247 | m_Extents *= 0.5f; 248 | m_IsRay = (m_Extents.LengthSqr() < 1e-6); 249 | 250 | // Offset m_Start to be in the center of the box... 251 | VectorAdd(mins, maxs, m_StartOffset); 252 | m_StartOffset *= 0.5f; 253 | VectorAdd(start, m_StartOffset, m_Start); 254 | m_StartOffset *= -1.0f; 255 | } 256 | 257 | // compute inverse delta 258 | Vector InvDelta() const 259 | { 260 | Vector vecInvDelta; 261 | for (int iAxis = 0; iAxis < 3; ++iAxis) 262 | { 263 | if (m_Delta[iAxis] != 0.0f) 264 | { 265 | vecInvDelta[iAxis] = 1.0f / m_Delta[iAxis]; 266 | } 267 | else 268 | { 269 | vecInvDelta[iAxis] = FLT_MAX; 270 | } 271 | } 272 | return vecInvDelta; 273 | } 274 | 275 | private: 276 | }; 277 | 278 | typedef CGameTrace trace_t; 279 | class IEngineTrace 280 | { 281 | public: 282 | 283 | virtual void GetPointContents() = 0; 284 | virtual void GetPointContents_WorldOnly() = 0; 285 | virtual void GetPointContents_Collideable() = 0; 286 | virtual void ClipRayToEntity() = 0; 287 | virtual void ClipRayToCollideable() = 0; 288 | virtual void TraceRay(const Ray_t &ray, unsigned int fMask, CTraceFilter *pTraceFilter, trace_t *pTrace) = 0; 289 | }; 290 | 291 | 292 | typedef void(__fastcall *tTraceRay)(void *thisptr, void *not_edx, Ray_t &ray, unsigned int fMask, CTraceFilter *pTraceFilter, CGameTrace *pTrace); -------------------------------------------------------------------------------- /L4D2VR/sdk/usercmd.h: -------------------------------------------------------------------------------- 1 | //========= Copyright Valve Corporation, All rights reserved. ============// 2 | #pragma once 3 | #include "vector.h" 4 | #include "checksum_crc.h" 5 | 6 | typedef unsigned int CRC32_t; 7 | typedef unsigned char byte; 8 | 9 | class CUserCmd 10 | { 11 | public: 12 | CUserCmd() 13 | { 14 | Reset(); 15 | } 16 | 17 | virtual ~CUserCmd() { }; 18 | 19 | void Reset() 20 | { 21 | command_number = 0; 22 | tick_count = 0; 23 | viewangles.Init(); 24 | forwardmove = 0.0f; 25 | sidemove = 0.0f; 26 | upmove = 0.0f; 27 | buttons = 0; 28 | impulse = 0; 29 | weaponselect = 0; 30 | weaponsubtype = 0; 31 | random_seed = 0; 32 | mousedx = 0; 33 | mousedy = 0; 34 | hasbeenpredicted = false; 35 | } 36 | 37 | CUserCmd &operator =(const CUserCmd &src) 38 | { 39 | if (this == &src) 40 | return *this; 41 | 42 | command_number = src.command_number; 43 | tick_count = src.tick_count; 44 | viewangles = src.viewangles; 45 | forwardmove = src.forwardmove; 46 | sidemove = src.sidemove; 47 | upmove = src.upmove; 48 | buttons = src.buttons; 49 | impulse = src.impulse; 50 | weaponselect = src.weaponselect; 51 | weaponsubtype = src.weaponsubtype; 52 | random_seed = src.random_seed; 53 | mousedx = src.mousedx; 54 | mousedy = src.mousedy; 55 | 56 | hasbeenpredicted = src.hasbeenpredicted; 57 | 58 | return *this; 59 | } 60 | 61 | CUserCmd(const CUserCmd &src) 62 | { 63 | *this = src; 64 | } 65 | 66 | CRC32_t GetChecksum(void) const 67 | { 68 | CRC32_t crc; 69 | 70 | CRC32_Init(&crc); 71 | CRC32_ProcessBuffer(&crc, &command_number, sizeof(command_number)); 72 | CRC32_ProcessBuffer(&crc, &tick_count, sizeof(tick_count)); 73 | CRC32_ProcessBuffer(&crc, &viewangles, sizeof(viewangles)); 74 | CRC32_ProcessBuffer(&crc, &forwardmove, sizeof(forwardmove)); 75 | CRC32_ProcessBuffer(&crc, &sidemove, sizeof(sidemove)); 76 | CRC32_ProcessBuffer(&crc, &upmove, sizeof(upmove)); 77 | CRC32_ProcessBuffer(&crc, &buttons, sizeof(buttons)); 78 | CRC32_ProcessBuffer(&crc, &impulse, sizeof(impulse)); 79 | CRC32_ProcessBuffer(&crc, &weaponselect, sizeof(weaponselect)); 80 | CRC32_ProcessBuffer(&crc, &weaponsubtype, sizeof(weaponsubtype)); 81 | CRC32_ProcessBuffer(&crc, &random_seed, sizeof(random_seed)); 82 | CRC32_ProcessBuffer(&crc, &mousedx, sizeof(mousedx)); 83 | CRC32_ProcessBuffer(&crc, &mousedy, sizeof(mousedy)); 84 | CRC32_Final(&crc); 85 | 86 | return crc; 87 | } 88 | 89 | // Allow command, but negate gameplay-affecting values 90 | void MakeInert(void) 91 | { 92 | //viewangles = vec3_angle; 93 | forwardmove = 0.f; 94 | sidemove = 0.f; 95 | upmove = 0.f; 96 | buttons = 0; 97 | impulse = 0; 98 | } 99 | 100 | int command_number; 101 | int tick_count; 102 | QAngle viewangles; 103 | float forwardmove; 104 | float sidemove; 105 | float upmove; 106 | int buttons; 107 | byte impulse; 108 | int weaponselect; 109 | int weaponsubtype; 110 | int random_seed; 111 | short mousedx; 112 | short mousedy; 113 | bool hasbeenpredicted; 114 | char pad[25]; 115 | }; 116 | static_assert(sizeof(CUserCmd) == 0x58); 117 | 118 | class CVerifiedUserCmd 119 | { 120 | public: 121 | CUserCmd m_cmd; 122 | CRC32_t m_crc; 123 | }; 124 | 125 | class CInput 126 | { 127 | public: 128 | virtual void Init_All(void); 129 | virtual void Shutdown_All(void); 130 | virtual int GetButtonBits(int); 131 | virtual void CreateMove(int sequence_number, float input_sample_frametime, bool active); 132 | virtual void ExtraMouseSample(float frametime, bool active); 133 | virtual bool WriteUsercmdDeltaToBuffer(int *buf, int from, int to, bool isnewcommand); 134 | virtual void EncodeUserCmdToBuffer(int buf, int slot); 135 | virtual void DecodeUserCmdFromBuffer(int buf, int slot); 136 | virtual CUserCmd *GetUserCmd(int uk, int sequence_number); 137 | virtual void func0(void); 138 | virtual void func1(void); 139 | virtual void KeyEvent(int x, int y, char const * z); 140 | virtual void func3(void); 141 | virtual void func4(void); 142 | virtual void Joystick_Advanced(void); 143 | virtual void func5(void); 144 | virtual void func6(void); 145 | virtual void func7(void); 146 | virtual void func8(void); 147 | virtual void func9(void); 148 | virtual void func10(void); 149 | virtual void ActivateMouse(void); 150 | virtual void DeactivateMouse(void); 151 | }; -------------------------------------------------------------------------------- /L4D2VR/sdk/worldsize.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Gistix/portal2vr/4abc0217fbbebae7f978c9f6758ef5dad118dadb/L4D2VR/sdk/worldsize.h -------------------------------------------------------------------------------- /L4D2VR/sigscanner.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | class SigScanner 8 | { 9 | public: 10 | // Returns 0 if current offset matches, -1 if no matches found. 11 | // A value > 0 is the new offset. 12 | static int VerifyOffset(std::string moduleName, int currentOffset, std::string signature, int sigOffset = 0) 13 | { 14 | HMODULE hModule = GetModuleHandle(moduleName.c_str()); 15 | MODULEINFO moduleInfo; 16 | GetModuleInformation(GetCurrentProcess(), hModule, &moduleInfo, sizeof(moduleInfo)); 17 | 18 | uint8_t *bytes = (uint8_t *)moduleInfo.lpBaseOfDll; 19 | 20 | std::vector pattern; 21 | 22 | std::stringstream ss(signature); 23 | std::string sigByte; 24 | while (ss >> sigByte) 25 | { 26 | if (sigByte == "?" || sigByte == "??") 27 | pattern.push_back(-1); 28 | else 29 | pattern.push_back(strtoul(sigByte.c_str(), NULL, 16)); 30 | } 31 | 32 | int patternLen = pattern.size(); 33 | 34 | // Check if current offset is good 35 | bool offsetMatchesSig = true; 36 | for (int i = 0; i < patternLen; ++i) 37 | { 38 | if ( (bytes[currentOffset - sigOffset + i] != pattern[i]) && (pattern[i] != -1) ) 39 | { 40 | offsetMatchesSig = false; 41 | break; 42 | } 43 | } 44 | 45 | if (offsetMatchesSig) 46 | return 0; 47 | 48 | // Scan the dll for new offset 49 | for (int i = 0; i < moduleInfo.SizeOfImage; ++i) 50 | { 51 | bool found = true; 52 | for (int j = 0; j < patternLen; ++j) 53 | { 54 | if ((bytes[i + j] != pattern[j]) && (pattern[j] != -1)) 55 | { 56 | found = false; 57 | break; 58 | } 59 | } 60 | if (found) 61 | { 62 | return i + sigOffset; 63 | } 64 | } 65 | return -1; 66 | 67 | } 68 | }; -------------------------------------------------------------------------------- /L4D2VR/vr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "openvr.h" 3 | #include "vector.h" 4 | #include 5 | 6 | #define MAX_STR_LEN 256 7 | 8 | class Game; 9 | class IDirect3DTexture9; 10 | class IDirect3DSurface9; 11 | class ITexture; 12 | 13 | 14 | struct TrackedDevicePoseData 15 | { 16 | std::string TrackedDeviceName; 17 | Vector TrackedDevicePos; 18 | Vector TrackedDeviceVel; 19 | QAngle TrackedDeviceAng; 20 | QAngle TrackedDeviceAngVel; 21 | }; 22 | 23 | struct SharedTextureHolder 24 | { 25 | vr::VRVulkanTextureData_t m_VulkanData; 26 | vr::Texture_t m_VRTexture; 27 | }; 28 | 29 | class VR 30 | { 31 | public: 32 | Game *m_Game = nullptr; 33 | 34 | vr::IVRSystem *m_System = nullptr; 35 | vr::IVRInput *m_Input = nullptr; 36 | vr::IVROverlay *m_Overlay = nullptr; 37 | 38 | vr::VROverlayHandle_t m_MainMenuHandle; 39 | //vr::VROverlayHandle_t m_HUDHandle; 40 | 41 | float m_HorizontalOffsetLeft; 42 | float m_VerticalOffsetLeft; 43 | float m_HorizontalOffsetRight; 44 | float m_VerticalOffsetRight; 45 | 46 | uint32_t m_RenderWidth; 47 | uint32_t m_RenderHeight; 48 | uint32_t m_AntiAliasing; 49 | uint32_t m_RenderWindow; 50 | float m_Aspect; 51 | float m_Fov; 52 | 53 | vr::VRTextureBounds_t m_TextureBounds[2]; 54 | vr::TrackedDevicePose_t m_Poses[vr::k_unMaxTrackedDeviceCount]; 55 | 56 | Vector m_EyeToHeadTransformPosLeft = { 0,0,0 }; 57 | Vector m_EyeToHeadTransformPosRight = { 0,0,0 }; 58 | 59 | Vector m_HmdForward; 60 | Vector m_HmdRight; 61 | Vector m_HmdUp; 62 | 63 | Vector m_HmdPosLocalInWorld = { 0,0,0 }; 64 | 65 | Vector m_LeftControllerForward; 66 | Vector m_LeftControllerRight; 67 | Vector m_LeftControllerUp; 68 | 69 | Vector m_RightControllerForward; 70 | Vector m_RightControllerRight; 71 | Vector m_RightControllerUp; 72 | 73 | Vector m_ViewmodelForward; 74 | Vector m_ViewmodelRight; 75 | Vector m_ViewmodelUp; 76 | 77 | QAngle m_HmdAngAbs; 78 | 79 | Vector m_HmdPosRelativeRaw = { 0,0,0 }; 80 | Vector m_HmdPosRelativeRawPrev = { 0,0,0 }; 81 | 82 | Vector m_HmdPosRelative = { 0,0,0 }; 83 | Vector m_HmdPosRelativePrev = { 0,0,0 }; 84 | 85 | Vector m_AimPos = { 0, 0, 0 }; 86 | bool m_Traced = false; 87 | 88 | Vector m_Center = { 0,0,0 }; 89 | Vector m_SetupOrigin = { 0,0,0 }; 90 | 91 | float m_HeightOffset = 0.0; 92 | bool m_RoomscaleActive = false; 93 | 94 | Vector m_LeftControllerPosAbs; 95 | QAngle m_LeftControllerAngAbs; 96 | Vector m_RightControllerPosRel; 97 | QAngle m_RightControllerAngAbs; 98 | 99 | Vector m_ViewmodelPosOffset; 100 | QAngle m_ViewmodelAngOffset; 101 | 102 | Vector m_ViewmodelPosCustomOffset; // Custom (from config) viewmodel position offset applied on top of hardcoded ones 103 | QAngle m_ViewmodelAngCustomOffset; // Custom (from config) viewmodel angle offset applied on top of hardcoded ones 104 | 105 | float m_Ipd; 106 | float m_EyeZ; 107 | 108 | Vector m_IntendedPositionOffset = { 0,0,0 }; 109 | 110 | enum TextureID 111 | { 112 | Texture_None = -1, 113 | Texture_LeftEye, 114 | Texture_RightEye, 115 | Texture_HUD, 116 | Texture_Blank 117 | }; 118 | 119 | ITexture *m_LeftEyeTexture; 120 | ITexture *m_RightEyeTexture; 121 | ITexture *m_HUDTexture; 122 | ITexture *m_BlankTexture = nullptr; 123 | 124 | IDirect3DSurface9 *m_D9LeftEyeSurface; 125 | IDirect3DSurface9 *m_D9RightEyeSurface; 126 | IDirect3DSurface9 *m_D9HUDSurface; 127 | IDirect3DSurface9 *m_D9BlankSurface; 128 | 129 | SharedTextureHolder m_VKLeftEye; 130 | SharedTextureHolder m_VKRightEye; 131 | SharedTextureHolder m_VKBackBuffer; 132 | SharedTextureHolder m_VKHUD; 133 | SharedTextureHolder m_VKBlankTexture; 134 | 135 | bool m_IsVREnabled = false; 136 | bool m_IsInitialized = false; 137 | bool m_RenderedNewFrame = false; 138 | bool m_RenderedHud = false; 139 | bool m_CreatedVRTextures = false; 140 | bool m_DrawCrosshair = false; 141 | TextureID m_CreatingTextureID = Texture_None; 142 | 143 | bool m_PressedTurn = false; 144 | bool m_PushingThumbstick = false; 145 | bool m_PointerCreated = false; 146 | 147 | // action set 148 | vr::VRActionSetHandle_t m_ActionSet; 149 | vr::VRActiveActionSet_t m_ActiveActionSet; 150 | 151 | // actions 152 | vr::VRActionHandle_t m_ActionJump; 153 | vr::VRActionHandle_t m_ActionPrimaryAttack; 154 | vr::VRActionHandle_t m_ActionSecondaryAttack; 155 | vr::VRActionHandle_t m_ActionReload; 156 | vr::VRActionHandle_t m_ActionWalk; 157 | vr::VRActionHandle_t m_ActionTurn; 158 | vr::VRActionHandle_t m_ActionUse; 159 | vr::VRActionHandle_t m_ActionNextItem; 160 | vr::VRActionHandle_t m_ActionPrevItem; 161 | vr::VRActionHandle_t m_ActionResetPosition; 162 | vr::VRActionHandle_t m_ActionCrouch; 163 | vr::VRActionHandle_t m_ActionFlashlight; 164 | vr::VRActionHandle_t m_ActionActivateVR; 165 | vr::VRActionHandle_t m_MenuSelect; 166 | vr::VRActionHandle_t m_MenuBack; 167 | vr::VRActionHandle_t m_MenuUp; 168 | vr::VRActionHandle_t m_MenuDown; 169 | vr::VRActionHandle_t m_MenuLeft; 170 | vr::VRActionHandle_t m_MenuRight; 171 | vr::VRActionHandle_t m_Spray; 172 | vr::VRActionHandle_t m_Scoreboard; 173 | vr::VRActionHandle_t m_ShowHUD; 174 | vr::VRActionHandle_t m_Pause; 175 | 176 | TrackedDevicePoseData m_HmdPose; 177 | TrackedDevicePoseData m_LeftControllerPose; 178 | TrackedDevicePoseData m_RightControllerPose; 179 | 180 | bool m_ApplyPortalRotationOffset = false; 181 | QAngle m_PortalRotationOffset = {0, 0, 0}; 182 | QAngle m_RotationOffset = { 0, 0, 0 }; 183 | bool m_OverrideEyeAngles = false; 184 | std::chrono::steady_clock::time_point m_PrevFrameTime; 185 | 186 | float m_TurnSpeed = 0.15; 187 | bool m_SnapTurning = false; 188 | float m_SnapTurnAngle = 45.0; 189 | bool m_LeftHanded = false; 190 | float m_VRScale = 43.2; 191 | float m_IpdScale = 1.0; 192 | bool m_6DOF = true; 193 | float m_HudDistance = 1.3; 194 | float m_HudSize = 4.0; 195 | bool m_HudAlwaysVisible = false; 196 | int m_AimMode = 2; 197 | 198 | VR() {}; 199 | VR(Game *game); 200 | int SetActionManifest(const char *fileName); 201 | void InstallApplicationManifest(const char *fileName); 202 | void Update(); 203 | void SetScreenSizeOverride(bool bState); 204 | void CreateVRTextures(); 205 | void SubmitVRTextures(); 206 | void RepositionOverlays(); 207 | void GetPoses(); 208 | void UpdatePosesAndActions(); 209 | void GetViewParameters(); 210 | void ProcessMenuInput(); 211 | void ProcessInput(); 212 | VMatrix VMatrixFromHmdMatrix(const vr::HmdMatrix34_t &hmdMat); 213 | vr::HmdMatrix34_t VMatrixToHmdMatrix(const VMatrix &vMat); 214 | vr::HmdMatrix34_t GetControllerTipMatrix(vr::ETrackedControllerRole controllerRole); 215 | bool CheckOverlayIntersectionForController(vr::VROverlayHandle_t overlayHandle, vr::ETrackedControllerRole controllerRole); 216 | QAngle GetRightControllerAbsAngle(); 217 | QAngle& GetRightControllerAbsAngleConst(); 218 | Vector GetRightControllerAbsPos(Vector eyePosition = {0, 0, 0}); 219 | Vector GetRecommendedViewmodelAbsPos(Vector eyePosition); 220 | QAngle GetRecommendedViewmodelAbsAngle(); 221 | void UpdateHMDAngles(); 222 | void UpdateTracking(); 223 | Vector GetViewAngle(); 224 | Vector GetViewOrigin(Vector setupOrigin); 225 | Vector GetViewOriginLeft(Vector setupOrigin); 226 | Vector GetViewOriginRight(Vector setupOrigin); 227 | bool PressedDigitalAction(vr::VRActionHandle_t &actionHandle, bool checkIfActionChanged = false); 228 | bool GetAnalogActionData(vr::VRActionHandle_t &actionHandle, vr::InputAnalogActionData_t &analogDataOut); 229 | void ResetPosition(); 230 | void GetPoseData(vr::TrackedDevicePose_t &poseRaw, TrackedDevicePoseData &poseOut); 231 | void ParseConfigFile(); 232 | void WaitForConfigUpdate(); 233 | Vector Trace(uint32_t* localPlayer); 234 | Vector TraceEye(uint32_t* localPlayer, Vector cameraPos, Vector eyePos, QAngle& eyeAngle); 235 | }; -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 |

3 | 4 | 5 |

6 |
7 | 8 | # ![Portal 2 icon](imgs/icon.jpg "Portal 2 icon") Portal 2 VR 9 | ### ~~Use this mod at your own risk of getting VAC banned. Use the -insecure launch option to help protect yourself.~~ 10 | ### Apparently Portal 2 doesn't have VAC, but just to be safe you should still run the game with the `insecure` flag. 11 | This game contains flashing lights and fast motion sequences. 12 | 13 | ## Portal 2 VR Mod First 20 Minutes (Youtube Video) 14 | [![IMAGE ALT TEXT HERE](https://img.youtube.com/vi/nQZ601kEDFI/0.jpg)](https://www.youtube.com/watch?v=nQZ601kEDFI) 15 | 16 | ## Things that work 17 | * Singleplayer 18 | * 6DoF VR view 19 | * Motion controls for portal gun and grabbable objects 20 | * Workshop content 21 | 22 | ## Things that need fixing 23 | * Use the game's own haptic feedback 24 | * In-game UI and pause menu are broken 25 | * 6DoF and Roomscale needs to be reimplemented 26 | * CPU is underutilized 27 | 28 | ## How to use 29 | 1. Download [Portal2VR.zip](https://github.com/Gistix/portal2vr/releases) and extract the files to your Portal 2 directory (steamapps\common\Portal 2) 30 | 2. Connect your headset, then launch Portal 2 with these launch options: 31 | 32 | ``` -insecure -window -novid +mat_motion_blur_percent_of_screen_max 0 +mat_queue_mode 0 +mat_vsync 0 +mat_antialias 0 +mat_grain_scale_override 0 -width 1280 -height 720 ``` 33 | 34 | 3. At the menu, feel free to change [these video settings](https://i.imgur.com/yYQMXs6.jpg). 35 | 4. Load into a chapter. 36 | 5. To recenter the camera height, press down on the left stick. To see the HUD, aim the controller up or down. 37 | 38 | ## Troubleshooting 39 | If you have no audio: 40 | * Go to ```steamapps\common\Portal 2\portal2_dlc3``` and execute ```UpdateSoundCache.cmd``` 41 | 42 | If the game isn't loading in VR: 43 | * Try opening SteamVR before the game 44 | * Disable SteamVR theater in [Steam settings](https://external-preview.redd.it/1WdLExouo_YKhTGT6C5GGrOjeWO7qNdIdDRvIRBhw-0.png?auto=webp&s=0d4447a9d954e1ec15b2c010cf50eeabd51f4197) 45 | 46 | If the game is stuttering, try: 47 | * Steam Settings -> Shader Pre-Caching -> Allow background processing of Vulkan shaders 48 | 49 | If the game is crashing, try: 50 | * Lowering video settings 51 | * Disabling all add-ons then verifying integrity of game files 52 | * Re-installing the game 53 | 54 | ## Build instructions 55 | 1. ``` git clone --recurse-submodules https://github.com/Gistix/portal2vr.git ``` 56 | 2. Open l4d2vr.sln 57 | 3. Set to x86 Debug or Release 58 | 4. Build -> Build Solution 59 | 60 | Note: After building, it will attempt to copy the new d3d9.dll to your Portal 2/bin directory. 61 | 62 | ## Based on 63 | * [l4d2vr](https://github.com/sd805/l4d2vr) 64 | 65 | ## Utilizes code from 66 | * [VirtualFortress2](https://github.com/PinkMilkProductions/VirtualFortress2) 67 | * [gmcl_openvr](https://github.com/Planimeter/gmcl_openvr/) 68 | * [dxvk](https://github.com/TheIronWolfModding/dxvk/tree/vr-dx9-rel) 69 | * [source-sdk-2013](https://github.com/ValveSoftware/source-sdk-2013/) 70 | 71 | ## Support me 72 | Donate Button 73 | 74 | -------------------------------------------------------------------------------- /imgs/icon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Gistix/portal2vr/4abc0217fbbebae7f978c9f6758ef5dad118dadb/imgs/icon.jpg -------------------------------------------------------------------------------- /imgs/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Gistix/portal2vr/4abc0217fbbebae7f978c9f6758ef5dad118dadb/imgs/logo.png -------------------------------------------------------------------------------- /l4d2vr.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.31727.386 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "L4D2VR", "L4D2VR\l4d2vr.vcxproj", "{C81EA18A-A8D0-40D2-900C-A91F736802D4}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {C81EA18A-A8D0-40D2-900C-A91F736802D4}.Debug|x64.ActiveCfg = Debug|x64 17 | {C81EA18A-A8D0-40D2-900C-A91F736802D4}.Debug|x64.Build.0 = Debug|x64 18 | {C81EA18A-A8D0-40D2-900C-A91F736802D4}.Debug|x86.ActiveCfg = Debug|Win32 19 | {C81EA18A-A8D0-40D2-900C-A91F736802D4}.Debug|x86.Build.0 = Debug|Win32 20 | {C81EA18A-A8D0-40D2-900C-A91F736802D4}.Release|x64.ActiveCfg = Release|x64 21 | {C81EA18A-A8D0-40D2-900C-A91F736802D4}.Release|x64.Build.0 = Release|x64 22 | {C81EA18A-A8D0-40D2-900C-A91F736802D4}.Release|x86.ActiveCfg = Release|Win32 23 | {C81EA18A-A8D0-40D2-900C-A91F736802D4}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {9B18203D-EC63-469E-AE19-7B93F44EAF0B} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /thirdparty/minhook/include/MinHook.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MinHook - The Minimalistic API Hooking Library for x64/x86 3 | * Copyright (C) 2009-2017 Tsuda Kageyu. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 19 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 20 | * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 23 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #pragma once 30 | 31 | #if !(defined _M_IX86) && !(defined _M_X64) && !(defined __i386__) && !(defined __x86_64__) 32 | #error MinHook supports only x86 and x64 systems. 33 | #endif 34 | 35 | #include 36 | 37 | // MinHook Error Codes. 38 | typedef enum MH_STATUS 39 | { 40 | // Unknown error. Should not be returned. 41 | MH_UNKNOWN = -1, 42 | 43 | // Successful. 44 | MH_OK = 0, 45 | 46 | // MinHook is already initialized. 47 | MH_ERROR_ALREADY_INITIALIZED, 48 | 49 | // MinHook is not initialized yet, or already uninitialized. 50 | MH_ERROR_NOT_INITIALIZED, 51 | 52 | // The hook for the specified target function is already created. 53 | MH_ERROR_ALREADY_CREATED, 54 | 55 | // The hook for the specified target function is not created yet. 56 | MH_ERROR_NOT_CREATED, 57 | 58 | // The hook for the specified target function is already enabled. 59 | MH_ERROR_ENABLED, 60 | 61 | // The hook for the specified target function is not enabled yet, or already 62 | // disabled. 63 | MH_ERROR_DISABLED, 64 | 65 | // The specified pointer is invalid. It points the address of non-allocated 66 | // and/or non-executable region. 67 | MH_ERROR_NOT_EXECUTABLE, 68 | 69 | // The specified target function cannot be hooked. 70 | MH_ERROR_UNSUPPORTED_FUNCTION, 71 | 72 | // Failed to allocate memory. 73 | MH_ERROR_MEMORY_ALLOC, 74 | 75 | // Failed to change the memory protection. 76 | MH_ERROR_MEMORY_PROTECT, 77 | 78 | // The specified module is not loaded. 79 | MH_ERROR_MODULE_NOT_FOUND, 80 | 81 | // The specified function is not found. 82 | MH_ERROR_FUNCTION_NOT_FOUND 83 | } 84 | MH_STATUS; 85 | 86 | // Can be passed as a parameter to MH_EnableHook, MH_DisableHook, 87 | // MH_QueueEnableHook or MH_QueueDisableHook. 88 | #define MH_ALL_HOOKS NULL 89 | 90 | #ifdef __cplusplus 91 | extern "C" { 92 | #endif 93 | 94 | // Initialize the MinHook library. You must call this function EXACTLY ONCE 95 | // at the beginning of your program. 96 | MH_STATUS WINAPI MH_Initialize(VOID); 97 | 98 | // Uninitialize the MinHook library. You must call this function EXACTLY 99 | // ONCE at the end of your program. 100 | MH_STATUS WINAPI MH_Uninitialize(VOID); 101 | 102 | // Creates a Hook for the specified target function, in disabled state. 103 | // Parameters: 104 | // pTarget [in] A pointer to the target function, which will be 105 | // overridden by the detour function. 106 | // pDetour [in] A pointer to the detour function, which will override 107 | // the target function. 108 | // ppOriginal [out] A pointer to the trampoline function, which will be 109 | // used to call the original target function. 110 | // This parameter can be NULL. 111 | MH_STATUS WINAPI MH_CreateHook(LPVOID pTarget, LPVOID pDetour, LPVOID *ppOriginal); 112 | 113 | // Creates a Hook for the specified API function, in disabled state. 114 | // Parameters: 115 | // pszModule [in] A pointer to the loaded module name which contains the 116 | // target function. 117 | // pszTarget [in] A pointer to the target function name, which will be 118 | // overridden by the detour function. 119 | // pDetour [in] A pointer to the detour function, which will override 120 | // the target function. 121 | // ppOriginal [out] A pointer to the trampoline function, which will be 122 | // used to call the original target function. 123 | // This parameter can be NULL. 124 | MH_STATUS WINAPI MH_CreateHookApi( 125 | LPCWSTR pszModule, LPCSTR pszProcName, LPVOID pDetour, LPVOID *ppOriginal); 126 | 127 | // Creates a Hook for the specified API function, in disabled state. 128 | // Parameters: 129 | // pszModule [in] A pointer to the loaded module name which contains the 130 | // target function. 131 | // pszTarget [in] A pointer to the target function name, which will be 132 | // overridden by the detour function. 133 | // pDetour [in] A pointer to the detour function, which will override 134 | // the target function. 135 | // ppOriginal [out] A pointer to the trampoline function, which will be 136 | // used to call the original target function. 137 | // This parameter can be NULL. 138 | // ppTarget [out] A pointer to the target function, which will be used 139 | // with other functions. 140 | // This parameter can be NULL. 141 | MH_STATUS WINAPI MH_CreateHookApiEx( 142 | LPCWSTR pszModule, LPCSTR pszProcName, LPVOID pDetour, LPVOID *ppOriginal, LPVOID *ppTarget); 143 | 144 | // Removes an already created hook. 145 | // Parameters: 146 | // pTarget [in] A pointer to the target function. 147 | MH_STATUS WINAPI MH_RemoveHook(LPVOID pTarget); 148 | 149 | // Enables an already created hook. 150 | // Parameters: 151 | // pTarget [in] A pointer to the target function. 152 | // If this parameter is MH_ALL_HOOKS, all created hooks are 153 | // enabled in one go. 154 | MH_STATUS WINAPI MH_EnableHook(LPVOID pTarget); 155 | 156 | // Disables an already created hook. 157 | // Parameters: 158 | // pTarget [in] A pointer to the target function. 159 | // If this parameter is MH_ALL_HOOKS, all created hooks are 160 | // disabled in one go. 161 | MH_STATUS WINAPI MH_DisableHook(LPVOID pTarget); 162 | 163 | // Queues to enable an already created hook. 164 | // Parameters: 165 | // pTarget [in] A pointer to the target function. 166 | // If this parameter is MH_ALL_HOOKS, all created hooks are 167 | // queued to be enabled. 168 | MH_STATUS WINAPI MH_QueueEnableHook(LPVOID pTarget); 169 | 170 | // Queues to disable an already created hook. 171 | // Parameters: 172 | // pTarget [in] A pointer to the target function. 173 | // If this parameter is MH_ALL_HOOKS, all created hooks are 174 | // queued to be disabled. 175 | MH_STATUS WINAPI MH_QueueDisableHook(LPVOID pTarget); 176 | 177 | // Applies all queued changes in one go. 178 | MH_STATUS WINAPI MH_ApplyQueued(VOID); 179 | 180 | // Translates the MH_STATUS to its name as a string. 181 | const char * WINAPI MH_StatusToString(MH_STATUS status); 182 | 183 | #ifdef __cplusplus 184 | } 185 | #endif 186 | 187 | -------------------------------------------------------------------------------- /thirdparty/minhook/lib/Debug/libMinHook.x86.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Gistix/portal2vr/4abc0217fbbebae7f978c9f6758ef5dad118dadb/thirdparty/minhook/lib/Debug/libMinHook.x86.lib -------------------------------------------------------------------------------- /thirdparty/minhook/lib/Release/libMinHook.x86.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Gistix/portal2vr/4abc0217fbbebae7f978c9f6758ef5dad118dadb/thirdparty/minhook/lib/Release/libMinHook.x86.lib -------------------------------------------------------------------------------- /thirdparty/openvr/bin/win32/openvr_api.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Gistix/portal2vr/4abc0217fbbebae7f978c9f6758ef5dad118dadb/thirdparty/openvr/bin/win32/openvr_api.dll -------------------------------------------------------------------------------- /thirdparty/openvr/lib/win32/openvr_api.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Gistix/portal2vr/4abc0217fbbebae7f978c9f6758ef5dad118dadb/thirdparty/openvr/lib/win32/openvr_api.lib --------------------------------------------------------------------------------