├── .gitignore ├── README.md ├── config ├── actions.json ├── index-marulu-230324.json └── touch-marulu-230324.json ├── dip17build.sh ├── images └── icon.png ├── xivr.sln ├── xivr ├── Configuration.cs ├── EnumList.cs ├── IK.cs ├── Imports.cs ├── PluginUI.cs ├── Structures │ ├── ActionData.cs │ ├── Bone.cs │ ├── CharCustData.cs │ ├── CharEquipData.cs │ ├── ControlSystemCameraManager.cs │ ├── LanguageOptions.cs │ ├── Misc.cs │ ├── RawGameCamera.cs │ ├── RenderQueueCommands.cs │ ├── SceneCameraManager.cs │ ├── XBoxLayout.cs │ ├── ffxivRenderTargetManager.cs │ └── ffxivTexture.cs ├── VRCursor.cs ├── images │ ├── audio_off.png │ ├── audio_on.png │ ├── blank.png │ ├── dalamud_off.png │ ├── dalamud_on.png │ ├── hide_ui_off.png │ ├── hide_ui_on.png │ ├── keyboard_off.png │ ├── keyboard_on.png │ ├── occlusion_off.png │ ├── occlusion_on.png │ ├── recenter_off.png │ ├── recenter_on.png │ ├── weapon_off.png │ ├── weapon_on.png │ ├── xivr_off.png │ └── xivr_on.png ├── packages.lock.json ├── xivr.cs ├── xivr.csproj ├── xivr.json ├── xivr.png └── xivr_hooks.cs └── xivr_main ├── BasicRenderer.cpp ├── BasicRenderer.h ├── Configuration.h ├── OSK.cpp ├── OSK.h ├── RenderObject.cpp ├── RenderObject.h ├── SteamVRInput.cpp ├── SteamVRInput.h ├── dllmain.cpp ├── ffxivCameraManager.h ├── ffxivDevice.h ├── ffxivRenderTargetManager.h ├── ffxivSwapChain.h ├── ffxivTexture.h ├── framework.h ├── simpleVR.cpp ├── simpleVR.h ├── simpleXR.h ├── stBasicTexture.h ├── stButtonList.h ├── stCommon.h ├── stMonitorLayout.h ├── xivr_main.vcxproj ├── xivr_main.vcxproj.filters └── xivr_main.vcxproj.user /.gitignore: -------------------------------------------------------------------------------- 1 | .git/ 2 | .vs/ 3 | bin 4 | obj 5 | x64 6 | packages 7 | openvr 8 | minitrace 9 | sym_openvr.bat 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | *Throw wide the gates, that we may pass!* 2 | 3 | **XIVR** is an open-source project that aims to add VR support to the critically acclaimed Japanese MMORPG which has an expanded free trial with no restrictions on playtime. This open-source mod is purely based on original code, and does not include any copyrighted materials. While, to our knowledge, the mod is undetectable and fully usable on live servers, using this mod is against the TOS. Use at your own risk; we are not liable for damages caused. 4 | 5 | XIVR is currently in an **alpha state**. It will be released as a minimum viable product to gauge user interest and attract other developers interested in working with us. The code is open-source, and we are willing to merge in new features! If you're interested, please let us know! 6 | 7 | 8 | **• List of chat/macro commands •** 9 | 10 | `/xivr` opens the VR settings 11 | 12 | `/xivr on` enables VR 13 | 14 | `/xivr off` disables VR 15 | 16 | `/xivr recenter` recenters the camera 17 | 18 | `/xivr screen` renders the game in 2D on a floating screen whenever you need it (sniping minigame, etc) 19 | 20 | `/xivr uiz [amount]` sets the distance from the floating screen, where [amount] is a positive or negative value. The default is a value of 0. 21 | 22 | `/xivr uiscale [amount]` sets the sets the size of the floating screen, where [amount] is a positive or negative value. The default is a value of 1. 23 | 24 | `/xivr uireset` resets the distance and size of the floating screen 25 | 26 | `/xivr conloc` enables controller locomotion (aka onward locomotion) for first person 27 | 28 | `/xivr horizon` makes it so the camera angle is corrected if rotated vertically so the horizon never changes, preventing vr sickness 29 | 30 | `/xivr hsnap` enables horizontal snap turning via analogue sticks 31 | 32 | `/xivr vsnap` enables vertical snap turning via analogue sticks 33 | 34 | `/xivr snapanglex [degrees]` sets the amount of degrees for horizontal snap turning using the analogue stick, where [degrees] is a positive number 35 | 36 | `/xivr snapangley [degrees]` sets the amount of degrees for vertical snap turning using the analogue stick, where [degrees] is a positive number 37 | 38 | `/xivr rotatex [degrees]` immediate X axis snap turning, where [degrees] is a positive or negative number 39 | 40 | `/xivr rotatey [degrees]` immediate Y axis snap turning, where [degrees] is a positive or negative number 41 | 42 | `/xivr offsetx [amount]` moves the camera directly along the X axis, where [amount] is a positive or negative value. This can be used for an over-the-shoulder view. 43 | 44 | `/xivr offsety [amount]` moves the camera directly along the Y axis, where [amount] is a positive or negative value. This can be used for an over-the-shoulder view. 45 | 46 | 47 | **• Changelog •** 48 | 49 | **v0.0.0.2** released now installing via the repo should work again 50 | 51 | 52 | **v0.0.0.3** released now the UI should no longer hide randomly, if you have downloaded a previous version please delete \AppData\Roaming\XIVLauncher\pluginConfigs\ xivr.json should the error have been saved in the file 53 | 54 | 55 | **v0.0.0.4** released, "band aid edition" Fix cross-eyed world via `/xivr swapeyes` and ui via `/xivr swapeyesui` If your normal (non vr) controller isnt working please try `/xivr motcontoggle` 56 | 57 | 58 | **v0.0.0.5** experimental release 59 | 60 | Fixed floating UI scaling curvature bug 61 | 62 | Fixed shadow glitching at edge of vision 63 | 64 | Changes to loading order if it crashed previously please try this and report back 65 | 66 | If started from the title screen settings will auto apply if started from the game please run `/xivr loadcon` after starting vr 67 | 68 | 69 | **v0.0.0.6** 70 | 71 | Fixed controller zoom not working 72 | 73 | Updated to new game version 74 | 75 | 76 | **v0.0.0.8** 77 | 78 | Implemented automatic resolution resize (wont work on first load because it needs to fetch headset data once from Steam VR eye resolution) 79 | 80 | Fixed certain UI elements displaying differently in each eye 81 | 82 | Added multiple new menu entries for existing chat commands 83 | 84 | Changed loading order, might crash more or less please report back 85 | 86 | 87 | **v0.0.0.9** 88 | 89 | Fixed Dresser Camera 90 | 91 | Added IPD slider 92 | 93 | New VR settings menu 94 | 95 | Added verbose logging, logs are saved to dalamud.log in the XIVLauncher folder 96 | 97 | Less Crashing 98 | 99 | 100 | **v0.0.0.10** 101 | 102 | Support for 6.3 103 | 104 | Added first person locomotion based on head tracking, look in the direction you want to go 105 | 106 | Added vertical support for first person locomotion, point or look in the direction you want to fly/swim 107 | 108 | Fixed unintended first person camera behavior 109 | 110 | 111 | **v0.0.1.0** HANDTRACKING UPDATE 112 | 113 | Disabled culling in first person 114 | 115 | Mounts now are visible in first person 116 | 117 | All combat effects now are visible in first person 118 | 119 | Added toggle to show player body in first person without head 120 | 121 | Added hand tracking in first person (if controllers and body is enabled) 122 | 123 | Added Z-Offset slider 124 | 125 | Removed flickering UI target arrow 126 | 127 | Added in world target arrow (by @AJBats) 128 | 129 | Added size slider for target arrow (by @AJBats) 130 | 131 | 132 | Known Issues 133 | 134 | First person camera location might be off, please use the offset sliders 135 | 136 | If headgear is hidden using the toggle in the menu then the player head wont hide 137 | 138 | While in first person with tracking the arms of some NPCs might randomly break 139 | 140 | Gear polygon stretching from hand 141 | 142 | Its hard to target the exits of player houses in first person 143 | 144 | 145 | **v0.0.3.0** Now actually playable edition 146 | 147 | UI 148 | 149 | →added toggle to render UI inside the game world with occlusion /xivr uidepth 150 | 151 | →added UI z-offset and scale sliders 152 | 153 | →fixed UI z-offset and scale chat commands 154 | 155 | →while VR is active the mouse will be locked to the game window, you can alt tab to click on other windows 156 | 157 | →added ability to click on UI elements that are off screen because the game resolution is too high for the users display (up to 3x the res) 158 | 159 | →Dalamud (imgUI) is now visible in the headset 160 | 161 | 162 | 163 | controls 164 | 165 | →added ability to point at UI using motion controls to click on UI elements 166 | 167 | →added ability to point into the game world using motion controllers to target, interact and place AOE attacks 168 | 169 | →added ability to target, interact with objects and place AOE attacks via head tracking when using xbox controllers or kbm 170 | 171 | →added ability to move housing furniture via motion controls 172 | 173 | →added ability to click the mouse via the right trigger on both normal and motion controllers 174 | 175 | →the outline of targets you are looking or pointing at will highlight 176 | 177 | →added native two button controller mappings (WMR, Vive Focus3/XR, Pico, Touch, Quest etc.) 178 | 179 | →long pressing a stick down on motion controllers now changes its mode, the left stick switches from movement to dpad while the right stick it switches to a scroll wheel 180 | 181 | →fixed being unable to zoom in on the map using controllers in first person 182 | 183 | →added option to display weapons in the hands in first person 184 | 185 | →added controller haptics for stick mode switching and highlighting potential targets with motion controllers 186 | 187 | →fixed being unable to target certain things like housing doors in first person 188 | 189 | →pressing the right stick while holding the right bumper switches into a mode for controlling Dalamud, in this mode the face buttons are replaced by esc, F10-12 so you can remap them freely 190 | 191 | 192 | 193 | tracking 194 | 195 | →in first person mode the camera now gets recentered to the head location of the player model 196 | 197 | →in first person mode there no longer is a gap in the neck 198 | 199 | →the upper body of the player model is now tracked in accordance to head movement when unmounted 200 | 201 | →fixed a issue with the arms of certain NPCs breaking when using motion controls 202 | 203 | →removed option to hide body in first person 204 | 205 | →added Y- & Z-Offset slider for first person 206 | 207 | →reenabled head tracking in cutscenes (still as buggy as before) 208 | 209 | →fixed player head not hiding correctly when headgear is set to invisible 210 | 211 | →upper torso tracking is disabled when using controller or head turning and instead the torso is turning to counteract the turning of the player model 212 | 213 | Note: for now all tracking code is disable when mounted 214 | 215 | 216 | 217 | rendering 218 | 219 | →added 2D mode /xivr mode2d , recommended if you are unable to get double the FPS (not compatible with asymmetric projection) 220 | 221 | →added asymmetric projection toggle, enabling this will improve the performance (requires XIVR restart) 222 | 223 | →fixed a DirectX bug that stopped SteamVR from initializing (Thanks to @joko for helping us debug) 224 | 225 | →the desktop screen no longer flickers and instead displays black 226 | 227 | →implemented ASW 2.0 228 | 229 | →optimized shadow map for 100°FOV headsets 230 | 231 | →added ultra wide shadow map toggle, for use with widescreen headsets such as the Pimax and Xtal 232 | 233 | →fixed internal render resolution slightly decreasing every time you turn VR on and off 234 | 235 | →fixed a stereo mismatch in the rendering of the UI 236 | 237 | →removed broken post processing effects 238 | 239 | Note: changing resolution in SteamVR now requiers a full game restart 240 | 241 | 242 | 243 | other 244 | 245 | →the refresh rate limit now gets set to unlimited automatically but requires a restart of the game to take effect 246 | 247 | →fixed a bug with under water fx appearing above water 248 | 249 | →the mod now is available in 日本語 (Japanese) 250 | -------------------------------------------------------------------------------- /config/actions.json: -------------------------------------------------------------------------------- 1 | { 2 | "action_sets" : [ 3 | { 4 | "name" : "/actions/game", 5 | "usage" : "leftright" 6 | } 7 | ], 8 | "actions" : [ 9 | { 10 | "name" : "/actions/game/in/movement", 11 | "requirement" : "mandatory", 12 | "type" : "vector2" 13 | }, 14 | { 15 | "name" : "/actions/game/in/rotation", 16 | "requirement" : "mandatory", 17 | "type" : "vector2" 18 | }, 19 | { 20 | "name" : "/actions/game/in/lefthand_tip", 21 | "type" : "pose" 22 | }, 23 | { 24 | "name" : "/actions/game/in/righthand_tip", 25 | "type" : "pose" 26 | }, 27 | { 28 | "name" : "/actions/game/in/lefthand_palm", 29 | "type" : "pose" 30 | }, 31 | { 32 | "name" : "/actions/game/in/righthand_palm", 33 | "type" : "pose" 34 | }, 35 | { 36 | "name" : "/actions/game/in/leftclick", 37 | "type" : "boolean" 38 | }, 39 | { 40 | "name" : "/actions/game/in/rightclick", 41 | "type" : "boolean" 42 | }, 43 | { 44 | "name" : "/actions/game/in/recenter", 45 | "type" : "boolean" 46 | }, 47 | { 48 | "name" : "/actions/game/in/shift", 49 | "type" : "boolean" 50 | }, 51 | { 52 | "name" : "/actions/game/in/alt", 53 | "type" : "boolean" 54 | }, 55 | { 56 | "name" : "/actions/game/in/control", 57 | "type" : "boolean" 58 | }, 59 | { 60 | "name" : "/actions/game/in/escape", 61 | "type" : "boolean" 62 | }, 63 | { 64 | "name" : "/actions/game/in/scrollup", 65 | "type" : "boolean" 66 | }, 67 | { 68 | "name" : "/actions/game/in/scrolldown", 69 | "type" : "boolean" 70 | }, 71 | { 72 | "name" : "/actions/game/in/button01", 73 | "type" : "boolean" 74 | }, 75 | { 76 | "name" : "/actions/game/in/button02", 77 | "type" : "boolean" 78 | }, 79 | { 80 | "name" : "/actions/game/in/button03", 81 | "type" : "boolean" 82 | }, 83 | { 84 | "name" : "/actions/game/in/button04", 85 | "type" : "boolean" 86 | }, 87 | { 88 | "name" : "/actions/game/in/button05", 89 | "type" : "boolean" 90 | }, 91 | { 92 | "name" : "/actions/game/in/button06", 93 | "type" : "boolean" 94 | }, 95 | { 96 | "name" : "/actions/game/in/button07", 97 | "type" : "boolean" 98 | }, 99 | { 100 | "name" : "/actions/game/in/button08", 101 | "type" : "boolean" 102 | }, 103 | { 104 | "name" : "/actions/game/in/button09", 105 | "type" : "boolean" 106 | }, 107 | { 108 | "name" : "/actions/game/in/button10", 109 | "type" : "boolean" 110 | }, 111 | { 112 | "name" : "/actions/game/in/button11", 113 | "type" : "boolean" 114 | }, 115 | { 116 | "name" : "/actions/game/in/button12", 117 | "type" : "boolean" 118 | }, 119 | { 120 | "name" : "/actions/game/in/xbox_button_y", 121 | "type" : "boolean" 122 | }, 123 | { 124 | "name" : "/actions/game/in/xbox_button_x", 125 | "type" : "boolean" 126 | }, 127 | { 128 | "name" : "/actions/game/in/xbox_button_a", 129 | "type" : "boolean" 130 | }, 131 | { 132 | "name" : "/actions/game/in/xbox_button_b", 133 | "type" : "boolean" 134 | }, 135 | { 136 | "name" : "/actions/game/in/xbox_left_trigger", 137 | "type" : "vector1" 138 | }, 139 | { 140 | "name" : "/actions/game/in/xbox_left_bumper", 141 | "type" : "vector1" 142 | }, 143 | { 144 | "name" : "/actions/game/in/xbox_left_stick_click", 145 | "type" : "boolean" 146 | }, 147 | { 148 | "name" : "/actions/game/in/xbox_right_trigger", 149 | "type" : "vector1" 150 | }, 151 | { 152 | "name" : "/actions/game/in/xbox_right_bumper", 153 | "type" : "vector1" 154 | }, 155 | { 156 | "name" : "/actions/game/in/xbox_right_stick_click", 157 | "type" : "boolean" 158 | }, 159 | { 160 | "name" : "/actions/game/in/xbox_pad_up", 161 | "type" : "boolean" 162 | }, 163 | { 164 | "name" : "/actions/game/in/xbox_pad_down", 165 | "type" : "boolean" 166 | }, 167 | { 168 | "name" : "/actions/game/in/xbox_pad_left", 169 | "type" : "boolean" 170 | }, 171 | { 172 | "name" : "/actions/game/in/xbox_pad_right", 173 | "type" : "boolean" 174 | }, 175 | { 176 | "name" : "/actions/game/in/xbox_start", 177 | "type" : "boolean" 178 | }, 179 | { 180 | "name" : "/actions/game/in/xbox_pad_select", 181 | "type" : "boolean" 182 | }, 183 | { 184 | "name" : "/actions/game/in/thumbrest_left", 185 | "type" : "boolean" 186 | }, 187 | { 188 | "name" : "/actions/game/in/thumbrest_right", 189 | "type" : "boolean" 190 | }, 191 | { 192 | "name": "/actions/game/in/lefthand_anim", 193 | "type": "skeleton", 194 | "skeleton": "/skeleton/hand/left" 195 | }, 196 | { 197 | "name": "/actions/game/in/righthand_anim", 198 | "type": "skeleton", 199 | "skeleton": "/skeleton/hand/right" 200 | }, 201 | { 202 | "name" : "/actions/game/out/haptic_left", 203 | "type" : "vibration" 204 | }, 205 | { 206 | "name" : "/actions/game/out/haptic_right", 207 | "type" : "vibration" 208 | } 209 | ], 210 | "default_bindings" : [ 211 | { 212 | "binding_url" : "index-marulu-230324.json", 213 | "controller_type" : "knuckles" 214 | }, 215 | { 216 | "binding_url" : "touch-marulu-230324.json", 217 | "controller_type" : "oculus_touch" 218 | } 219 | ], 220 | "localization" : [ 221 | { 222 | "/actions/game" : "InGame", 223 | "/actions/game/in/movement" : "Movement", 224 | "/actions/game/in/rotation" : "Rotate", 225 | "/actions/game/in/lefthand_tip" : "Left Hand Pose", 226 | "/actions/game/in/righthand_tip" : "Right Hand Pose", 227 | "/actions/game/in/lefthand_palm" : "Left Hand Palm", 228 | "/actions/game/in/righthand_palm" : "Right Hand Palm", 229 | "/actions/game/in/leftclick" : "Left Click", 230 | "/actions/game/in/rightclick" : "Right Click", 231 | 232 | "/actions/game/in/recenter" : "Recenter", 233 | "/actions/game/in/shift" : "Shift", 234 | "/actions/game/in/alt" : "Alt", 235 | "/actions/game/in/control" : "Control", 236 | "/actions/game/in/escape" : "Escape", 237 | "/actions/game/in/scrollup" : "ScrollUp", 238 | "/actions/game/in/scrolldown" : "ScrollDown", 239 | "/actions/game/in/button01" : "F1", 240 | "/actions/game/in/button02" : "F2", 241 | "/actions/game/in/button03" : "F3", 242 | "/actions/game/in/button04" : "F4", 243 | "/actions/game/in/button05" : "F5", 244 | "/actions/game/in/button06" : "F6", 245 | "/actions/game/in/button07" : "F7", 246 | "/actions/game/in/button08" : "F8", 247 | "/actions/game/in/button09" : "F9", 248 | "/actions/game/in/button10" : "F10", 249 | "/actions/game/in/button11" : "F11", 250 | "/actions/game/in/button12" : "F12", 251 | 252 | "/actions/game/in/xbox_button_y" : "XBox Button Y", 253 | "/actions/game/in/xbox_button_x" : "XBox Button X", 254 | "/actions/game/in/xbox_button_a" : "XBox Button A", 255 | "/actions/game/in/xbox_button_b" : "XBox Button B", 256 | "/actions/game/in/xbox_left_trigger" : "XBox Left Trigger", 257 | "/actions/game/in/xbox_left_bumper" : "XBox Left Bumper", 258 | "/actions/game/in/xbox_left_stick_click" : "XBox Left Stick (Click)", 259 | "/actions/game/in/xbox_right_trigger" : "XBox Right Trigger", 260 | "/actions/game/in/xbox_right_bumper" : "XBox Right Bumper", 261 | "/actions/game/in/xbox_right_stick_click" : "XBox Right Stick (Click)", 262 | 263 | "/actions/game/in/xbox_start" : "XBox Start", 264 | "/actions/game/in/xbox_select" : "XBox Select", 265 | 266 | "/actions/game/in/thumbrest_left" : "Thumb Rest Left", 267 | "/actions/game/in/thumbrest_right" : "Thumb Rest Right", 268 | 269 | "language_tag" : "en" 270 | } 271 | ] 272 | } 273 | -------------------------------------------------------------------------------- /config/touch-marulu-230324.json: -------------------------------------------------------------------------------- 1 | { 2 | "action_manifest_version" : 0, 3 | "alias_info" : {}, 4 | "app_key" : "system.generated.ffxiv_dx11.exe", 5 | "bindings" : { 6 | "/actions/game" : { 7 | "chords" : [], 8 | "haptics" : [ 9 | { 10 | "output" : "/actions/game/out/haptic_left", 11 | "path" : "/user/hand/left/output/haptic" 12 | }, 13 | { 14 | "output" : "/actions/game/out/haptic_right", 15 | "path" : "/user/hand/right/output/haptic" 16 | } 17 | ], 18 | "poses" : [ 19 | { 20 | "output" : "none", 21 | "path" : "/user/hand/right/pose/base" 22 | }, 23 | { 24 | "output" : "none", 25 | "path" : "/user/hand/left/pose/base" 26 | }, 27 | { 28 | "output" : "/actions/game/in/lefthand_palm", 29 | "path" : "/user/hand/left/pose/openxr_aim" 30 | }, 31 | { 32 | "output" : "/actions/game/in/righthand_palm", 33 | "path" : "/user/hand/right/pose/openxr_aim" 34 | }, 35 | { 36 | "output" : "/actions/game/in/lefthand_tip", 37 | "path" : "/user/hand/left/pose/tip" 38 | }, 39 | { 40 | "output" : "/actions/game/in/righthand_tip", 41 | "path" : "/user/hand/right/pose/tip" 42 | } 43 | ], 44 | "skeleton" : [ 45 | { 46 | "output" : "/actions/game/in/lefthand_anim", 47 | "path" : "/user/hand/left/input/skeleton/left" 48 | }, 49 | { 50 | "output" : "/actions/game/in/righthand_anim", 51 | "path" : "/user/hand/right/input/skeleton/right" 52 | } 53 | ], 54 | "sources" : [ 55 | { 56 | "inputs" : { 57 | "pull" : { 58 | "output" : "/actions/game/in/xbox_left_trigger" 59 | } 60 | }, 61 | "mode" : "trigger", 62 | "path" : "/user/hand/left/input/trigger" 63 | }, 64 | { 65 | "inputs" : { 66 | "pull" : { 67 | "output" : "/actions/game/in/xbox_right_trigger" 68 | } 69 | }, 70 | "mode" : "trigger", 71 | "path" : "/user/hand/right/input/trigger" 72 | }, 73 | { 74 | "inputs" : { 75 | "click" : { 76 | "output" : "/actions/game/in/xbox_button_b" 77 | } 78 | }, 79 | "mode" : "button", 80 | "path" : "/user/hand/right/input/a" 81 | }, 82 | { 83 | "inputs" : { 84 | "click" : { 85 | "output" : "/actions/game/in/xbox_button_y" 86 | } 87 | }, 88 | "mode" : "button", 89 | "path" : "/user/hand/right/input/b" 90 | }, 91 | { 92 | "inputs" : { 93 | "click" : { 94 | "output" : "/actions/game/in/xbox_button_x" 95 | } 96 | }, 97 | "mode" : "button", 98 | "path" : "/user/hand/left/input/y" 99 | }, 100 | { 101 | "inputs" : { 102 | "click" : { 103 | "output" : "/actions/game/in/xbox_button_a" 104 | } 105 | }, 106 | "mode" : "button", 107 | "path" : "/user/hand/left/input/x" 108 | }, 109 | { 110 | "inputs" : { 111 | "click" : { 112 | "output" : "/actions/game/in/xbox_left_stick_click" 113 | }, 114 | "position" : { 115 | "output" : "/actions/game/in/movement" 116 | } 117 | }, 118 | "mode" : "joystick", 119 | "path" : "/user/hand/left/input/joystick" 120 | }, 121 | { 122 | "inputs" : { 123 | "click" : { 124 | "output" : "/actions/game/in/xbox_right_stick_click" 125 | }, 126 | "position" : { 127 | "output" : "/actions/game/in/rotation" 128 | } 129 | }, 130 | "mode" : "joystick", 131 | "path" : "/user/hand/right/input/joystick" 132 | }, 133 | { 134 | "inputs" : { 135 | "click" : { 136 | "output" : "/actions/game/in/xbox_pad_select" 137 | } 138 | }, 139 | "mode" : "button", 140 | "path" : "/user/hand/left/input/system" 141 | }, 142 | { 143 | "inputs" : { 144 | "pull" : { 145 | "output" : "/actions/game/in/xbox_right_bumper" 146 | } 147 | }, 148 | "mode" : "trigger", 149 | "path" : "/user/hand/right/input/grip" 150 | }, 151 | { 152 | "inputs" : { 153 | "pull" : { 154 | "output" : "/actions/game/in/xbox_left_bumper" 155 | } 156 | }, 157 | "mode" : "trigger", 158 | "path" : "/user/hand/left/input/grip" 159 | } 160 | ] 161 | }, 162 | "/actions/main" : { 163 | "chords" : [ {} ], 164 | "poses" : [ 165 | { 166 | "output" : "none", 167 | "path" : "/user/hand/left/pose/base" 168 | }, 169 | { 170 | "output" : "/actions/main/in/controllerleft", 171 | "path" : "/user/hand/left/pose/raw" 172 | }, 173 | { 174 | "output" : "/actions/main/in/controllerright", 175 | "path" : "/user/hand/right/pose/raw" 176 | }, 177 | { 178 | "output" : "none", 179 | "path" : "/user/hand/right/pose/base" 180 | }, 181 | { 182 | "output" : "none", 183 | "path" : "/user/hand/left/pose/handgrip" 184 | }, 185 | { 186 | "output" : "none", 187 | "path" : "/user/hand/right/pose/handgrip" 188 | } 189 | ], 190 | "skeleton" : [ 191 | { 192 | "output" : "/actions/main/in/skeletonleft", 193 | "path" : "/user/hand/left/input/skeleton/left" 194 | }, 195 | { 196 | "output" : "/actions/main/in/skeletonright", 197 | "path" : "/user/hand/right/input/skeleton/right" 198 | } 199 | ], 200 | "sources" : [ 201 | { 202 | "inputs" : { 203 | "click" : { 204 | "output" : "/actions/main/in/rightinteract axis" 205 | } 206 | }, 207 | "mode" : "button", 208 | "path" : "/user/hand/right/input/trigger" 209 | }, 210 | { 211 | "inputs" : { 212 | "click" : { 213 | "output" : "/actions/main/in/resethmd" 214 | }, 215 | "position" : { 216 | "output" : "/actions/main/in/configurableturnaxis_x,configurableturnaxis_y x y_axis2d" 217 | } 218 | }, 219 | "mode" : "joystick", 220 | "path" : "/user/hand/right/input/joystick" 221 | }, 222 | { 223 | "inputs" : { 224 | "click" : { 225 | "output" : "/actions/main/in/rightinteractsecondary axis" 226 | } 227 | }, 228 | "mode" : "button", 229 | "path" : "/user/hand/right/input/a" 230 | }, 231 | { 232 | "inputs" : { 233 | "click" : { 234 | "output" : "/actions/main/in/crouchtoggle" 235 | } 236 | }, 237 | "mode" : "button", 238 | "path" : "/user/hand/right/input/b" 239 | }, 240 | { 241 | "inputs" : { 242 | "click" : { 243 | "output" : "/actions/main/in/knucklesrightgrip axis" 244 | } 245 | }, 246 | "mode" : "button", 247 | "path" : "/user/hand/right/input/grip" 248 | }, 249 | { 250 | "inputs" : { 251 | "touch" : { 252 | "output" : "/actions/main/in/pause" 253 | } 254 | }, 255 | "mode" : "button", 256 | "path" : "/user/hand/left/input/system" 257 | }, 258 | { 259 | "inputs" : { 260 | "click" : { 261 | "output" : "/actions/main/in/sprinttoggle" 262 | }, 263 | "position" : { 264 | "output" : "/actions/main/in/moveforward_x,moveforward_y x y_axis2d" 265 | } 266 | }, 267 | "mode" : "joystick", 268 | "parameters" : { 269 | "invert" : "" 270 | }, 271 | "path" : "/user/hand/left/input/joystick" 272 | }, 273 | { 274 | "inputs" : { 275 | "click" : { 276 | "output" : "/actions/main/in/sprinttoggle" 277 | } 278 | }, 279 | "mode" : "button", 280 | "path" : "/user/hand/left/input/joystick" 281 | }, 282 | { 283 | "inputs" : { 284 | "click" : { 285 | "output" : "/actions/main/in/knucklesleftgrip axis" 286 | } 287 | }, 288 | "mode" : "button", 289 | "path" : "/user/hand/left/input/grip" 290 | }, 291 | { 292 | "inputs" : { 293 | "click" : { 294 | "output" : "/actions/main/in/selectdialogue" 295 | } 296 | }, 297 | "mode" : "button", 298 | "path" : "/user/hand/left/input/y" 299 | }, 300 | { 301 | "inputs" : { 302 | "click" : { 303 | "output" : "/actions/main/in/leftinteract axis" 304 | } 305 | }, 306 | "mode" : "trigger", 307 | "path" : "/user/hand/left/input/trigger" 308 | }, 309 | { 310 | "inputs" : { 311 | "click" : { 312 | "output" : "/actions/main/in/resethmd" 313 | } 314 | }, 315 | "mode" : "button", 316 | "path" : "/user/hand/right/input/joystick" 317 | }, 318 | { 319 | "inputs" : { 320 | "click" : { 321 | "output" : "/actions/main/in/leftinteractsecondary axis" 322 | } 323 | }, 324 | "mode" : "button", 325 | "path" : "/user/hand/left/input/x" 326 | }, 327 | { 328 | "inputs" : { 329 | "click" : { 330 | "output" : "/actions/main/in/rightinteract axis" 331 | } 332 | }, 333 | "mode" : "trigger", 334 | "path" : "/user/hand/right/input/trigger" 335 | }, 336 | { 337 | "inputs" : { 338 | "click" : { 339 | "output" : "/actions/main/in/leftinteract axis" 340 | } 341 | }, 342 | "mode" : "button", 343 | "path" : "/user/hand/left/input/trigger" 344 | } 345 | ] 346 | } 347 | }, 348 | "category" : "steamvr_input", 349 | "controller_type" : "oculus_touch", 350 | "description" : "\n\n", 351 | "interaction_profile" : "", 352 | "name" : "Oculus Touchコントローラー用に保存されたffxiv_dx11設定", 353 | "options" : {}, 354 | "simulated_actions" : [] 355 | } 356 | -------------------------------------------------------------------------------- /dip17build.sh: -------------------------------------------------------------------------------- 1 | # I don't want to talk about this 2 | 3 | set -e 4 | 5 | cd xivr_main 6 | 7 | mkdir x64 8 | mkdir x64/Release 9 | 10 | mkdir /scratch 11 | mkdir /scratch/openvr_local 12 | 7za x -y -o/scratch/openvr_local -tzip /needs/openvr.zip 13 | 14 | OPENVR_VERSION="1.23.7" 15 | OPENVR_LOCAL="/scratch/openvr_local/openvr-$OPENVR_VERSION" 16 | LINKER_OBJS="" 17 | 18 | compile () { 19 | /opt/msvc/bin/x64/cl /permissive- /ifcOutput "x64\Release\\" /GS /GL /W3 /Gy /Zc:wchar_t /Zi /Gm- /O2 /sdl /Fd"x64\Release\vc143.pdb" /Zc:inline \ 20 | /fp:precise /D "NDEBUG" /D "XIVRMAIN_EXPORTS" /D "_WINDOWS" /D "_USRDLL" /D "_WINDLL" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX- /Zc:forScope \ 21 | /Gd /Oi /MD /FC /Fa"x64\Release\\" /EHsc /nologo /Fo"x64\Release\\" /Fp"x64\Release\xivr_main.pch" /diagnostics:column /I"$OPENVR_LOCAL/headers" /c $1 22 | LINKER_OBJS="$LINKER_OBJS x64\Release\\${1/cpp/obj}" 23 | } 24 | 25 | for FILE in *.cpp; do compile $FILE; done 26 | 27 | echo $LINKER_OBJS 28 | 29 | # /PGD:"x64\Release\xivr_main.pgd" causes errors and I don't know what it does 30 | /opt/msvc/bin/x64/link /OUT:"x64\Release\xivr_main.dll" /MANIFEST /LTCG:incremental /NXCOMPAT /PDB:"x64\Release\xivr_main.pdb" \ 31 | /DYNAMICBASE "d3dcompiler.lib" "d3d11.lib" "dxgi.lib" "openvr_api.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" \ 32 | "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /IMPLIB:"x64\Release\xivr_main.lib" /DEBUG \ 33 | /DLL /MACHINE:X64 /OPT:REF /SUBSYSTEM:WINDOWS /MANIFESTUAC:NO /ManifestFile:"x64\Release\xivr_main.dll.intermediate.manifest" \ 34 | /LTCGOUT:"x64\Release\xivr_main.iobj" /OPT:ICF /ERRORREPORT:PROMPT /ILK:"x64\Release\xivr_main.ilk" /NOLOGO /LIBPATH:"$OPENVR_LOCAL/lib/win64" \ 35 | /TLBID:1 $LINKER_OBJS 36 | 37 | cp x64/Release/xivr_main.dll ../xivr 38 | cp x64/Release/xivr_main.pdb ../xivr 39 | cp $OPENVR_LOCAL/bin/win64/openvr_api.dll ../xivr 40 | -------------------------------------------------------------------------------- /images/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProjectMimer/xivr/cba8ab388c968ec558090dc14264d9a151bacf43/images/icon.png -------------------------------------------------------------------------------- /xivr.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.2.32616.157 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "xivr", "xivr\xivr.csproj", "{DDFD2241-5611-4220-B34E-E2880F573273}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xivr_main", "xivr_main\xivr_main.vcxproj", "{7E662908-03D1-4144-B4AF-73F1A925BFE4}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Debug|x64 = Debug|x64 14 | Debug|x86 = Debug|x86 15 | Release|Any CPU = Release|Any CPU 16 | Release|x64 = Release|x64 17 | Release|x86 = Release|x86 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {DDFD2241-5611-4220-B34E-E2880F573273}.Debug|Any CPU.ActiveCfg = Debug|x64 21 | {DDFD2241-5611-4220-B34E-E2880F573273}.Debug|Any CPU.Build.0 = Debug|x64 22 | {DDFD2241-5611-4220-B34E-E2880F573273}.Debug|x64.ActiveCfg = Debug|x64 23 | {DDFD2241-5611-4220-B34E-E2880F573273}.Debug|x64.Build.0 = Debug|x64 24 | {DDFD2241-5611-4220-B34E-E2880F573273}.Debug|x86.ActiveCfg = Debug|Any CPU 25 | {DDFD2241-5611-4220-B34E-E2880F573273}.Debug|x86.Build.0 = Debug|Any CPU 26 | {DDFD2241-5611-4220-B34E-E2880F573273}.Release|Any CPU.ActiveCfg = Release|x64 27 | {DDFD2241-5611-4220-B34E-E2880F573273}.Release|Any CPU.Build.0 = Release|x64 28 | {DDFD2241-5611-4220-B34E-E2880F573273}.Release|x64.ActiveCfg = Release|x64 29 | {DDFD2241-5611-4220-B34E-E2880F573273}.Release|x64.Build.0 = Release|x64 30 | {DDFD2241-5611-4220-B34E-E2880F573273}.Release|x86.ActiveCfg = Release|Any CPU 31 | {DDFD2241-5611-4220-B34E-E2880F573273}.Release|x86.Build.0 = Release|Any CPU 32 | {7E662908-03D1-4144-B4AF-73F1A925BFE4}.Debug|Any CPU.ActiveCfg = Debug|x64 33 | {7E662908-03D1-4144-B4AF-73F1A925BFE4}.Debug|Any CPU.Build.0 = Debug|x64 34 | {7E662908-03D1-4144-B4AF-73F1A925BFE4}.Debug|x64.ActiveCfg = Debug|x64 35 | {7E662908-03D1-4144-B4AF-73F1A925BFE4}.Debug|x64.Build.0 = Debug|x64 36 | {7E662908-03D1-4144-B4AF-73F1A925BFE4}.Debug|x86.ActiveCfg = Debug|Win32 37 | {7E662908-03D1-4144-B4AF-73F1A925BFE4}.Debug|x86.Build.0 = Debug|Win32 38 | {7E662908-03D1-4144-B4AF-73F1A925BFE4}.Release|Any CPU.ActiveCfg = Release|x64 39 | {7E662908-03D1-4144-B4AF-73F1A925BFE4}.Release|Any CPU.Build.0 = Release|x64 40 | {7E662908-03D1-4144-B4AF-73F1A925BFE4}.Release|x64.ActiveCfg = Release|x64 41 | {7E662908-03D1-4144-B4AF-73F1A925BFE4}.Release|x64.Build.0 = Release|x64 42 | {7E662908-03D1-4144-B4AF-73F1A925BFE4}.Release|x86.ActiveCfg = Release|Win32 43 | {7E662908-03D1-4144-B4AF-73F1A925BFE4}.Release|x86.Build.0 = Release|Win32 44 | EndGlobalSection 45 | GlobalSection(SolutionProperties) = preSolution 46 | HideSolutionNode = FALSE 47 | EndGlobalSection 48 | GlobalSection(ExtensibilityGlobals) = postSolution 49 | SolutionGuid = {ADDC7ED4-33D3-455C-ABB7-5632A8E9F7ED} 50 | EndGlobalSection 51 | EndGlobal 52 | -------------------------------------------------------------------------------- /xivr/Configuration.cs: -------------------------------------------------------------------------------- 1 | using Dalamud.Configuration; 2 | using Dalamud.Plugin; 3 | using System; 4 | using System.Runtime.InteropServices; 5 | 6 | namespace xivr 7 | { 8 | [Serializable] 9 | public class Configuration : IPluginConfiguration 10 | { 11 | [StructLayout(LayoutKind.Sequential)] 12 | public struct cfgData 13 | { 14 | // Bool: U1 15 | // Float: R4 16 | // Int: I4 17 | [MarshalAs(UnmanagedType.I4)] public int resetValue; 18 | [MarshalAs(UnmanagedType.I4)] public LanguageTypes languageType; 19 | [MarshalAs(UnmanagedType.U1)] public bool isEnabled; 20 | [MarshalAs(UnmanagedType.U1)] public bool isAutoEnabled; 21 | [MarshalAs(UnmanagedType.U1)] public bool autoResize; 22 | [MarshalAs(UnmanagedType.U1)] public bool autoMove; 23 | [MarshalAs(UnmanagedType.U1)] public bool runRecenter; 24 | [MarshalAs(UnmanagedType.U1)] public bool vLog; 25 | [MarshalAs(UnmanagedType.U1)] public bool hmdPointing; 26 | [MarshalAs(UnmanagedType.U1)] public bool forceFloatingScreen; 27 | [MarshalAs(UnmanagedType.U1)] public bool forceFloatingInCutscene; 28 | [MarshalAs(UnmanagedType.U1)] public bool horizontalLock; 29 | [MarshalAs(UnmanagedType.U1)] public bool verticalLock; 30 | [MarshalAs(UnmanagedType.U1)] public bool horizonLock; 31 | [MarshalAs(UnmanagedType.U1)] public bool conloc; 32 | [MarshalAs(UnmanagedType.U1)] public bool hmdloc; 33 | [MarshalAs(UnmanagedType.U1)] public bool vertloc; 34 | [MarshalAs(UnmanagedType.U1)] public bool motioncontrol; 35 | [MarshalAs(UnmanagedType.U1)] public bool showWeaponInHand; 36 | [MarshalAs(UnmanagedType.R4)] public float offsetAmountX; 37 | [MarshalAs(UnmanagedType.R4)] public float offsetAmountY; 38 | [MarshalAs(UnmanagedType.R4)] public float offsetAmountZ; 39 | [MarshalAs(UnmanagedType.R4)] public float offsetAmountYFPS; 40 | [MarshalAs(UnmanagedType.R4)] public float offsetAmountZFPS; 41 | [MarshalAs(UnmanagedType.R4)] public float offsetAmountYFPSMount; 42 | [MarshalAs(UnmanagedType.R4)] public float offsetAmountZFPSMount; 43 | [MarshalAs(UnmanagedType.R4)] public float snapRotateAmountX; 44 | [MarshalAs(UnmanagedType.R4)] public float snapRotateAmountY; 45 | [MarshalAs(UnmanagedType.U1)] public bool uiDepth; 46 | [MarshalAs(UnmanagedType.R4)] public float uiOffsetZ; 47 | [MarshalAs(UnmanagedType.R4)] public float uiOffsetScale; 48 | [MarshalAs(UnmanagedType.R4)] public float ipdOffset; 49 | [MarshalAs(UnmanagedType.U1)] public bool swapEyes; 50 | [MarshalAs(UnmanagedType.U1)] public bool swapEyesUI; 51 | [MarshalAs(UnmanagedType.I4)] public int hmdWidth; 52 | [MarshalAs(UnmanagedType.I4)] public int hmdHeight; 53 | [MarshalAs(UnmanagedType.I4)] public int targetCursorSize; 54 | [MarshalAs(UnmanagedType.U1)] public bool asymmetricProjection; 55 | [MarshalAs(UnmanagedType.U1)] public bool mode2d; 56 | [MarshalAs(UnmanagedType.U1)] public bool immersiveMovement; 57 | [MarshalAs(UnmanagedType.U1)] public bool immersiveFull; 58 | [MarshalAs(UnmanagedType.U1)] public bool ultrawideshadows; 59 | [MarshalAs(UnmanagedType.U1)] public bool osk; 60 | [MarshalAs(UnmanagedType.R4)] public float armMultiplier; 61 | 62 | public cfgData() 63 | { 64 | resetValue = 0; 65 | languageType = LanguageTypes.en; 66 | isEnabled = false; 67 | isAutoEnabled = true; 68 | autoResize = true; 69 | autoMove = true; 70 | runRecenter = false; 71 | vLog = false; 72 | hmdPointing = false; 73 | forceFloatingScreen = false; 74 | forceFloatingInCutscene = true; 75 | horizontalLock = false; 76 | verticalLock = true; 77 | horizonLock = true; 78 | conloc = false; 79 | hmdloc = false; 80 | vertloc = false; 81 | motioncontrol = true; 82 | showWeaponInHand = false; 83 | offsetAmountX = 0.0f; 84 | offsetAmountY = 0.0f; 85 | offsetAmountZ = 0.0f; 86 | offsetAmountYFPS = 0; 87 | offsetAmountZFPS = 0; 88 | offsetAmountYFPSMount = 0; 89 | offsetAmountZFPSMount = 0; 90 | snapRotateAmountX = 45.0f; 91 | snapRotateAmountY = 15.0f; 92 | uiDepth = true; 93 | uiOffsetZ = 50.0f; 94 | uiOffsetScale = 1.0f; 95 | ipdOffset = 0.0f; 96 | swapEyes = false; 97 | swapEyesUI = false; 98 | hmdWidth = 0; 99 | hmdHeight = 0; 100 | targetCursorSize = 100; 101 | asymmetricProjection = true; 102 | mode2d = false; 103 | immersiveMovement = false; 104 | immersiveFull = false; 105 | ultrawideshadows = false; 106 | osk = false; 107 | armMultiplier = 100.0f; 108 | } 109 | } 110 | 111 | public int Version { get; set; } = 0; 112 | public cfgData data = new cfgData(); 113 | 114 | [NonSerialized] 115 | private DalamudPluginInterface? pluginInterface; 116 | 117 | public void Initialize(DalamudPluginInterface pluginInterface) 118 | { 119 | this.pluginInterface = pluginInterface; 120 | } 121 | 122 | public void Save() 123 | { 124 | this.pluginInterface!.SavePluginConfig(this); 125 | } 126 | 127 | public void CheckVersion(int UpdateValue) 128 | { 129 | if (data.resetValue != UpdateValue) 130 | { 131 | int hmdWidth = data.hmdWidth; 132 | int hmdHeight = data.hmdHeight; 133 | data = new cfgData(); 134 | data.resetValue = UpdateValue; 135 | data.hmdWidth = hmdWidth; 136 | data.hmdHeight = hmdHeight; 137 | Save(); 138 | } 139 | } 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /xivr/IK.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | using FFXIVClientStructs.FFXIV.Client.Game.Character; 4 | using FFXIVClientStructs.FFXIV.Client.Graphics.Render; 5 | using FFXIVClientStructs.FFXIV.Common.Math; 6 | using FFXIVClientStructs.Havok; 7 | 8 | namespace xivr.Structures 9 | { 10 | [StructLayout(LayoutKind.Explicit)] 11 | public unsafe struct hkIKSetup 12 | { 13 | [FieldOffset(0x00)] public short m_firstJointIdx; 14 | [FieldOffset(0x02)] public short m_secondJointIdx; 15 | [FieldOffset(0x04)] public short m_endBoneIdx; 16 | [FieldOffset(0x06)] public short m_firstJointTwistIdx; 17 | [FieldOffset(0x08)] public short m_secondJointTwistIdx; 18 | [FieldOffset(0x0A)] public short m_spacer; 19 | [FieldOffset(0x0C)] public float m_spacer1; 20 | [FieldOffset(0x10)] public Vector4 m_hingeAxisLS; 21 | [FieldOffset(0x20)] public float m_cosineMaxHingeAngle; 22 | [FieldOffset(0x24)] public float m_cosineMinHingeAngle; 23 | [FieldOffset(0x28)] public float m_firstJointIkGain; 24 | [FieldOffset(0x2C)] public float m_secondJointIkGain; 25 | [FieldOffset(0x30)] public float m_endJointIkGain; 26 | [FieldOffset(0x34)] public float m_spacer2; 27 | [FieldOffset(0x38)] public float m_spacer3; 28 | [FieldOffset(0x3C)] public float m_spacer4; 29 | [FieldOffset(0x40)] public Vector4 m_endTargetMS; 30 | [FieldOffset(0x50)] public Quaternion m_endTargetRotationMS; 31 | [FieldOffset(0x60)] public Vector4 m_endBoneOffsetLS; 32 | [FieldOffset(0x70)] public Quaternion m_endBoneRotationOffsetLS; 33 | [FieldOffset(0x80)] public bool m_enforceEndPosition; 34 | [FieldOffset(0x81)] public bool m_enforceEndRotation; 35 | 36 | public hkIKSetup() 37 | { 38 | m_firstJointIdx = -1; 39 | m_secondJointIdx = -1; 40 | m_endBoneIdx = -1; 41 | m_firstJointTwistIdx = -1; 42 | m_secondJointTwistIdx = -1; 43 | m_spacer = 0; 44 | m_spacer1 = 0.0f; 45 | m_hingeAxisLS = Vector4.Zero; 46 | m_cosineMaxHingeAngle = -1.0f; 47 | m_cosineMinHingeAngle = 1.0f; 48 | m_firstJointIkGain = 1.0f; 49 | m_secondJointIkGain = 1.0f; 50 | m_endJointIkGain = 1.0f; 51 | m_spacer2 = 0.0f; 52 | m_spacer3 = 0.0f; 53 | m_spacer4 = 0.0f; 54 | m_endTargetMS = Vector4.Zero; 55 | m_endTargetRotationMS = Quaternion.Identity; 56 | m_endBoneOffsetLS = Vector4.Zero; 57 | m_endBoneRotationOffsetLS = Quaternion.Identity; 58 | m_enforceEndPosition = true; 59 | m_enforceEndRotation = false; 60 | } 61 | } 62 | 63 | 64 | public unsafe struct stMultiIK 65 | { 66 | public UInt32 worldId; 67 | public UInt32 objId; 68 | public Character* objCharacter; 69 | public Skeleton* objSkeleton; 70 | public bool isPlayer; 71 | public Matrix4x4 hmdMatrix; 72 | public Matrix4x4 lhcMatrix; 73 | public Matrix4x4 rhcMatrix; 74 | public bool doHandIK; 75 | public float armMultiplier; 76 | public UInt64 lastUpdate; 77 | public bool doUpdate; 78 | 79 | public stMultiIK(UInt32 wId, UInt32 id, Character* character, Skeleton* skeleton, bool player, Matrix4x4 hmd, Matrix4x4 lhc, Matrix4x4 rhc, bool runHandIK, float armMulti) 80 | { 81 | worldId = wId; 82 | objId = id; 83 | objCharacter = character; 84 | objSkeleton = skeleton; 85 | isPlayer = player; 86 | hmdMatrix = hmd; 87 | lhcMatrix = lhc; 88 | rhcMatrix = rhc; 89 | doHandIK = runHandIK; 90 | armMultiplier = armMulti; 91 | doUpdate = true; 92 | } 93 | 94 | public void SetTracking(bool player, Matrix4x4 hmd, Matrix4x4 lhc, Matrix4x4 rhc, bool runHandIK, float armMulti) 95 | { 96 | isPlayer = player; 97 | hmdMatrix = hmd; 98 | lhcMatrix = lhc; 99 | rhcMatrix = rhc; 100 | doHandIK = runHandIK; 101 | armMultiplier = armMulti; 102 | doUpdate = true; 103 | } 104 | } 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | public class IK 140 | { 141 | private float Deg2Rad = MathF.PI / 180.0f; 142 | private float Rad2Deg = 180.0f / MathF.PI; 143 | 144 | private Vector3 en; 145 | 146 | public Bone target, start, joint, end, pole; 147 | public hkQsTransformf upVector; 148 | //public Transform target, pole, upVector; 149 | public float blendPct = 1.0f; 150 | public float upperElbowRotation = 0; 151 | public float lowerElbowRotation = 0; 152 | 153 | public unsafe void Update(bool mirror = false) 154 | { 155 | float a = joint.transform.Translation.Magnitude(); 156 | float b = end.transform.Translation.Magnitude(); 157 | float c = Vector3.Distance(target.worldBase.Translation.Convert(), start.worldBase.Translation.Convert()); 158 | 159 | Vector3 targetStart = target.worldBase.Translation.Convert() - start.worldBase.Translation.Convert(); 160 | Vector3 poleStart = pole.worldBase.Translation.Convert() - start.worldBase.Translation.Convert(); 161 | Vector3 jointStart = joint.worldBase.Translation.Convert() - start.worldBase.Translation.Convert(); 162 | 163 | en = Vector3.Cross(targetStart, poleStart); 164 | 165 | //Set the rotation of the upper arm 166 | if (mirror) 167 | { 168 | start.worldBase.Rotation = LookRotation(-targetStart, -Transform(en, -AngleAxis(upperElbowRotation, jointStart))).Convert(); 169 | start.worldBase.Rotation = (start.worldBase.Rotation.Convert() * Inverse(FromToRotation(Vector3.Back, joint.transform.Translation.Convert()))).Convert(); 170 | } 171 | else 172 | { 173 | start.worldBase.Rotation = LookRotation(targetStart, Transform(en, AngleAxis(upperElbowRotation, jointStart))).Convert(); 174 | start.worldBase.Rotation = (start.worldBase.Rotation.Convert() * Inverse(FromToRotation(Vector3.Forward, joint.transform.Translation.Convert()))).Convert(); 175 | } 176 | start.worldBase.Rotation = (AngleAxis(CosAngle(a, c, b), en) * start.worldBase.Rotation.Convert()).Convert(); 177 | start.setLocal(false); 178 | start.CalculateMatrix(true); 179 | start.setUpdates(true, true, true); 180 | 181 | //set the rotation of the lower arm 182 | Vector3 targetJoint = target.worldBase.Translation.Convert() - joint.worldBase.Translation.Convert(); 183 | Vector3 endJoint = end.worldBase.Translation.Convert() - joint.worldBase.Translation.Convert(); 184 | 185 | if (mirror) 186 | { 187 | joint.worldBase.Rotation = LookRotation(-targetJoint, -Transform(en, -AngleAxis(lowerElbowRotation, endJoint))).Convert(); 188 | joint.worldBase.Rotation = (joint.worldBase.Rotation.Convert() * Inverse(FromToRotation(Vector3.Back, end.transform.Translation.Convert()))).Convert(); 189 | } 190 | else 191 | { 192 | joint.worldBase.Rotation = LookRotation(targetJoint, Transform(en, AngleAxis(lowerElbowRotation, endJoint))).Convert(); 193 | joint.worldBase.Rotation = (joint.worldBase.Rotation.Convert() * Inverse(FromToRotation(Vector3.Forward, end.transform.Translation.Convert()))).Convert(); 194 | } 195 | joint.setLocal(false); 196 | joint.CalculateMatrix(true); 197 | joint.setUpdates(true, true, true); 198 | 199 | //end.setLocal(false); 200 | //end.CalculateMatrix(true); 201 | //end.setUpdates(true, true, false); 202 | } 203 | 204 | float CosAngle(float a, float b, float c) 205 | { 206 | if (!float.IsNaN(MathF.Acos((-(c * c) + (a * a) + (b * b)) / (-2 * a * b)) * Rad2Deg)) 207 | { 208 | return MathF.Acos((-(c * c) + (a * a) + (b * b)) / (2 * a * b)) * Rad2Deg; 209 | } 210 | else 211 | { 212 | return 1; 213 | } 214 | } 215 | 216 | Quaternion LookRotation(Vector3 forward, Vector3 up) 217 | { 218 | Vector3 vector = Vector3.Normalize(forward); 219 | Vector3 vector2 = Vector3.Normalize(Vector3.Cross(up, vector)); 220 | Vector3 vector3 = Vector3.Cross(vector, vector2); 221 | var m00 = vector2.X; 222 | var m01 = vector2.Y; 223 | var m02 = vector2.Z; 224 | var m10 = vector3.X; 225 | var m11 = vector3.Y; 226 | var m12 = vector3.Z; 227 | var m20 = vector.X; 228 | var m21 = vector.Y; 229 | var m22 = vector.Z; 230 | 231 | float num8 = (m00 + m11) + m22; 232 | var quaternion = new Quaternion(); 233 | if (num8 > 0f) 234 | { 235 | var num = (float)MathF.Sqrt(num8 + 1f); 236 | quaternion.W = num * 0.5f; 237 | num = 0.5f / num; 238 | quaternion.X = (m12 - m21) * num; 239 | quaternion.Y = (m20 - m02) * num; 240 | quaternion.Z = (m01 - m10) * num; 241 | return quaternion; 242 | } 243 | if ((m00 >= m11) && (m00 >= m22)) 244 | { 245 | var num7 = (float)MathF.Sqrt(((1f + m00) - m11) - m22); 246 | var num4 = 0.5f / num7; 247 | quaternion.X = 0.5f * num7; 248 | quaternion.Y = (m01 + m10) * num4; 249 | quaternion.Z = (m02 + m20) * num4; 250 | quaternion.W = (m12 - m21) * num4; 251 | return quaternion; 252 | } 253 | if (m11 > m22) 254 | { 255 | var num6 = (float)MathF.Sqrt(((1f + m11) - m00) - m22); 256 | var num3 = 0.5f / num6; 257 | quaternion.X = (m10 + m01) * num3; 258 | quaternion.Y = 0.5f * num6; 259 | quaternion.Z = (m21 + m12) * num3; 260 | quaternion.W = (m20 - m02) * num3; 261 | return quaternion; 262 | } 263 | 264 | var num5 = (float)MathF.Sqrt(((1f + m22) - m00) - m11); 265 | var num2 = 0.5f / num5; 266 | quaternion.X = (m20 + m02) * num2; 267 | quaternion.Y = (m21 + m12) * num2; 268 | quaternion.Z = 0.5f * num5; 269 | quaternion.W = (m01 - m10) * num2; 270 | return quaternion; 271 | } 272 | 273 | System.Numerics.Quaternion FromToRotation(Vector3 aFrom, Vector3 aTo) 274 | { 275 | Vector3 axis = Vector3.Cross(aFrom, aTo); 276 | float angle = Vector3.Angle(aFrom, aTo) * Rad2Deg; 277 | //PluginLog.Log($"{angle} | {aFrom} | {aTo} | {axis}"); 278 | return AngleAxis(angle, Vector3.Normalize(axis)); 279 | } 280 | 281 | System.Numerics.Quaternion Inverse(Quaternion value) 282 | { 283 | Quaternion ans; 284 | 285 | float ls = value.X * value.X + value.Y * value.Y + value.Z * value.Z + value.W * value.W; 286 | float invNorm = 1.0f / ls; 287 | 288 | ans.X = -value.X * invNorm; 289 | ans.Y = -value.Y * invNorm; 290 | ans.Z = -value.Z * invNorm; 291 | ans.W = value.W * invNorm; 292 | 293 | return ans; 294 | } 295 | 296 | Vector3 Transform(Vector3 value, Quaternion rotation) 297 | { 298 | float x2 = rotation.X + rotation.X; 299 | float y2 = rotation.Y + rotation.Y; 300 | float z2 = rotation.Z + rotation.Z; 301 | 302 | float wx2 = rotation.W * x2; 303 | float wy2 = rotation.W * y2; 304 | float wz2 = rotation.W * z2; 305 | float xx2 = rotation.X * x2; 306 | float xy2 = rotation.X * y2; 307 | float xz2 = rotation.X * z2; 308 | float yy2 = rotation.Y * y2; 309 | float yz2 = rotation.Y * z2; 310 | float zz2 = rotation.Z * z2; 311 | 312 | return new Vector3( 313 | value.X * (1.0f - yy2 - zz2) + value.Y * (xy2 - wz2) + value.Z * (xz2 + wy2), 314 | value.X * (xy2 + wz2) + value.Y * (1.0f - xx2 - zz2) + value.Z * (yz2 - wx2), 315 | value.X * (xz2 - wy2) + value.Y * (yz2 + wx2) + value.Z * (1.0f - xx2 - yy2)); 316 | } 317 | 318 | System.Numerics.Quaternion AngleAxis(float aAngle, Vector3 aAxis) 319 | { 320 | aAxis = Vector3.Normalize(aAxis); 321 | float rad = aAngle * Deg2Rad * 0.5f; 322 | aAxis *= MathF.Sin(rad); 323 | return new Quaternion(aAxis.X, aAxis.Y, aAxis.Z, MathF.Cos(rad)); 324 | } 325 | } 326 | } 327 | -------------------------------------------------------------------------------- /xivr/Imports.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Drawing; 3 | using System.Numerics; 4 | using System.Runtime.InteropServices; 5 | using xivr.Structures; 6 | 7 | namespace xivr 8 | { 9 | public static unsafe class Imports 10 | { 11 | [DllImport("kernel32.dll")] 12 | public static extern bool VirtualProtectEx(IntPtr hProcess, IntPtr lpAddress, UIntPtr dwSize, uint flNewProtect, out uint lpflOldProtect); 13 | 14 | [DllImport("kernel32.dll")] 15 | public static extern bool FlushInstructionCache(IntPtr hProcess, IntPtr lpAddress, UIntPtr dwSize); 16 | 17 | [DllImport("user32.dll", SetLastError = true)] 18 | public static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string lclassName, string windowTitle); 19 | 20 | [DllImport("user32.dll")] 21 | public static extern uint GetWindowThreadProcessId(IntPtr hWnd, out int ProcessId); 22 | 23 | [DllImport("user32.dll")] 24 | public static extern bool IsWindowVisible(IntPtr hWnd); 25 | 26 | [DllImport("user32.dll")] 27 | public static extern bool GetCursorPos(out Point lpPoint); 28 | 29 | [DllImport("user32.dll")] 30 | public static extern bool SetCursorPos(Point lpPoint); 31 | 32 | [DllImport("user32.dll")] 33 | public static extern bool ScreenToClient(IntPtr hwnd, out Point lpPoint); 34 | 35 | [DllImport("user32.dll")] 36 | public static extern bool ClientToScreen(IntPtr hwnd, out Point lpPoint); 37 | 38 | [DllImport("user32.dll")] 39 | public static extern bool GetClientRect(IntPtr hwnd, out Rectangle lpRect); 40 | 41 | [DllImport("kernel32.dll", EntryPoint = "RtlZeroMemory")] 42 | public unsafe static extern bool ZeroMemory(byte* destination, int length); 43 | 44 | [DllImport("kernel32.dll", EntryPoint = "GetModuleHandle")] 45 | public static extern IntPtr GetModuleHandle([MarshalAs(UnmanagedType.LPStr)] string lpModuleName); 46 | 47 | [DllImport("kernel32.dll", EntryPoint = "GetProcAddress")] 48 | public static extern IntPtr GetProcAddress(IntPtr hModule, [MarshalAs(UnmanagedType.LPStr)] string lpProcName); 49 | 50 | 51 | 52 | [DllImport("xivr_main.dll", CallingConvention = CallingConvention.Cdecl)] 53 | public static extern void UpdateConfiguration(Configuration.cfgData config); 54 | 55 | [DllImport("xivr_main.dll", CallingConvention = CallingConvention.Cdecl)] 56 | public static extern bool SetDX11(IntPtr Device, IntPtr rtManager, [In, MarshalAs(UnmanagedType.LPUTF8Str)] string dllPath); 57 | 58 | [DllImport("xivr_main.dll", CallingConvention = CallingConvention.Cdecl)] 59 | public static extern void UnsetDX11(); 60 | 61 | [DllImport("xivr_main.dll", CallingConvention = CallingConvention.Cdecl)] 62 | public static extern Structures.Texture* GetRenderTexture(int eye); 63 | 64 | [DllImport("xivr_main.dll", CallingConvention = CallingConvention.Cdecl)] 65 | public static extern Structures.Texture* GetDepthTexture(int eye); 66 | 67 | [DllImport("xivr_main.dll", CallingConvention = CallingConvention.Cdecl)] 68 | public static extern Structures.Texture* GetUIRenderTexture(int eye); 69 | 70 | [DllImport("xivr_main.dll", CallingConvention = CallingConvention.Cdecl)] 71 | public static extern void Recenter(); 72 | 73 | [DllImport("xivr_main.dll", CallingConvention = CallingConvention.Cdecl)] 74 | public static extern void SetFramePose(); 75 | 76 | [DllImport("xivr_main.dll", CallingConvention = CallingConvention.Cdecl)] 77 | public static extern void WaitGetPoses(); 78 | 79 | [DllImport("xivr_main.dll", CallingConvention = CallingConvention.Cdecl)] 80 | public static extern Matrix4x4 GetFramePose(poseType posetype, int eye); 81 | 82 | [DllImport("xivr_main.dll", CallingConvention = CallingConvention.Cdecl)] 83 | public static extern fingerHandLayout GetSkeletalPose(poseType poseType); 84 | 85 | [DllImport("xivr_main.dll", CallingConvention = CallingConvention.Cdecl)] 86 | public static extern void SetThreadedEye(int eye); 87 | 88 | [DllImport("xivr_main.dll", CallingConvention = CallingConvention.Cdecl)] 89 | public static extern void RenderVR(Matrix4x4 curProjection, Matrix4x4 curViewMatrixWithoutHMD, Matrix4x4 rayMatrix, Matrix4x4 watchMatrix, Point virtualMouse, bool dalamudMode, bool floatingUI); 90 | 91 | [DllImport("xivr_main.dll", CallingConvention = CallingConvention.Cdecl)] 92 | public static extern void RenderUI(); 93 | 94 | [DllImport("xivr_main.dll", CallingConvention = CallingConvention.Cdecl)] 95 | public static extern void RenderUID(IntPtr Device, Matrix4x4 curProjection, Matrix4x4 curViewMatrixWithoutHMD); 96 | 97 | [DllImport("xivr_main.dll", CallingConvention = CallingConvention.Cdecl)] 98 | public static extern Point GetBufferSize(); 99 | 100 | [DllImport("xivr_main.dll", CallingConvention = CallingConvention.Cdecl)] 101 | public static extern void ResizeWindow(IntPtr hwnd, int width, int height); 102 | 103 | [DllImport("xivr_main.dll", CallingConvention = CallingConvention.Cdecl)] 104 | public static extern void MoveWindowPos(IntPtr hwnd, int adapterId, bool reset); 105 | 106 | [DllImport("xivr_main.dll", CallingConvention = CallingConvention.Cdecl)] 107 | public static extern bool SetActiveJSON([In, MarshalAs(UnmanagedType.LPUTF8Str)] string filePath, int size); 108 | 109 | [DllImport("xivr_main.dll", CallingConvention = CallingConvention.Cdecl)] 110 | public static extern void UpdateController(UpdateControllerInput controllerCallback); 111 | 112 | [DllImport("xivr_main.dll", CallingConvention = CallingConvention.Cdecl)] 113 | public static extern void HapticFeedback(ActionButtonLayout side, float time, float freq, float amp); 114 | 115 | [DllImport("xivr_main.dll", CallingConvention = CallingConvention.Cdecl)] 116 | public static extern void SetLogFunction(InternalLogging internalLogging); 117 | 118 | [DllImport("xivr_main.dll", CallingConvention = CallingConvention.Cdecl)] 119 | public static extern void SetRayCoordinate(float* posFrom, float* posTo); 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /xivr/PluginUI.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using System.Numerics; 3 | using Dalamud.Interface; 4 | using ImGuiNET; 5 | using xivr.Structures; 6 | 7 | namespace xivr 8 | { 9 | public static class PluginUI 10 | { 11 | public static bool isVisible = false; 12 | 13 | public static void Draw(uiOptionStrings lngOptions) 14 | { 15 | if (!isVisible) 16 | return; 17 | 18 | ImGui.SetNextWindowSize(new Vector2(750, 760) * ImGuiHelpers.GlobalScale, ImGuiCond.FirstUseEver); 19 | ImGui.SetNextWindowSizeConstraints(new Vector2(750, 770) * ImGuiHelpers.GlobalScale, new Vector2(9999)); 20 | //if (ImGui.Begin("Configuration", ref isVisible, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoScrollWithMouse)) 21 | 22 | 23 | if (ImGui.Begin("Configuration", ref isVisible, ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoScrollWithMouse)) 24 | { 25 | ImGui.BeginChild("Outer", new Vector2(730, 750) * ImGuiHelpers.GlobalScale, true); 26 | 27 | ShowKofi(lngOptions); 28 | 29 | ImGui.BeginChild("VR", new Vector2(350, 230) * ImGuiHelpers.GlobalScale, true); 30 | 31 | if (ImGui.Checkbox(lngOptions.isEnabled_Line1, ref xivr.cfg!.data.isEnabled)) 32 | xivr.Plugin.doUpdate = true; 33 | 34 | if (ImGui.Checkbox(lngOptions.isAutoEnabled_Line1, ref xivr.cfg!.data.isAutoEnabled)) 35 | xivr.Plugin.doUpdate = true; 36 | 37 | if (ImGui.Checkbox(lngOptions.autoResize_Line1, ref xivr.cfg!.data.autoResize)) 38 | xivr.Plugin.doUpdate = true; 39 | 40 | if (ImGui.Checkbox(lngOptions.autoMove_Line1, ref xivr.cfg!.data.autoMove)) 41 | xivr.Plugin.doUpdate = true; 42 | 43 | if (ImGui.Checkbox(lngOptions.enableOSK_Line1, ref xivr.cfg!.data.osk)) 44 | xivr.Plugin.doUpdate = true; 45 | 46 | if (ImGui.Button(lngOptions.runRecenter_Line1)) 47 | xivr.cfg.data.runRecenter = true; 48 | 49 | if (ImGui.Checkbox(lngOptions.vLog_Line1, ref xivr.cfg!.data.vLog)) 50 | xivr.Plugin.doUpdate = true; 51 | 52 | ImGui.EndChild(); 53 | 54 | ImGui.SameLine(); 55 | 56 | ImGui.BeginChild("Misc", new Vector2(350, 230) * ImGuiHelpers.GlobalScale, true); 57 | 58 | if (ImGui.Checkbox(lngOptions.motioncontrol_Line1, ref xivr.cfg!.data.motioncontrol)) 59 | { 60 | xivr.cfg!.data.hmdPointing = !xivr.cfg!.data.motioncontrol; 61 | xivr.Plugin.doUpdate = true; 62 | } 63 | 64 | if (ImGui.Checkbox(lngOptions.conloc_Line1, ref xivr.cfg!.data.conloc)) 65 | xivr.Plugin.doUpdate = true; 66 | 67 | if (ImGui.Checkbox(lngOptions.hmdloc_Line1, ref xivr.cfg!.data.hmdloc)) 68 | xivr.Plugin.doUpdate = true; 69 | 70 | if (ImGui.Checkbox(lngOptions.immersiveMovement_Line1, ref xivr.cfg!.data.immersiveMovement)) 71 | xivr.Plugin.doUpdate = true; 72 | 73 | if (ImGui.Checkbox(lngOptions.vertloc_Line1, ref xivr.cfg!.data.vertloc)) 74 | xivr.Plugin.doUpdate = true; 75 | 76 | if (ImGui.Checkbox(lngOptions.showWeaponInHand_Line1, ref xivr.cfg!.data.showWeaponInHand)) 77 | xivr.Plugin.doUpdate = true; 78 | 79 | if (ImGui.Checkbox(lngOptions.forceFloatingScreen_Line1, ref xivr.cfg!.data.forceFloatingScreen)) 80 | xivr.Plugin.doUpdate = true; 81 | 82 | if (ImGui.Checkbox(lngOptions.forceFloatingInCutscene_Line1, ref xivr.cfg!.data.forceFloatingInCutscene)) 83 | xivr.Plugin.doUpdate = true; 84 | 85 | ImGui.EndChild(); 86 | 87 | DrawLocks(lngOptions); 88 | ImGui.SameLine(); 89 | DrawUISetings(lngOptions); 90 | 91 | ImGui.EndChild(); 92 | 93 | if (xivr.Plugin.doUpdate == true) 94 | xivr.cfg!.Save(); 95 | 96 | ImGui.End(); 97 | } 98 | } 99 | 100 | public static void DrawLocks(uiOptionStrings lngOptions) 101 | { 102 | ImGui.BeginChild("Snap Turning", new Vector2(350, 200) * ImGuiHelpers.GlobalScale, true); 103 | 104 | if (ImGui.Checkbox(lngOptions.horizonLock_Line1, ref xivr.cfg!.data.horizonLock)) 105 | xivr.Plugin.doUpdate = true; 106 | 107 | if (ImGui.Checkbox(lngOptions.snapRotateAmountX_Line1, ref xivr.cfg!.data.horizontalLock)) 108 | xivr.Plugin.doUpdate = true; 109 | 110 | ImGui.Text(lngOptions.snapRotateAmountX_Line2); ImGui.SameLine(); 111 | if (ImGui.SliderFloat("##DrawLocks:hsa", ref xivr.cfg!.data.snapRotateAmountX, 0, 90, "%.0f")) 112 | xivr.Plugin.doUpdate = true; 113 | 114 | if (ImGui.Checkbox(lngOptions.snapRotateAmountY_Line1, ref xivr.cfg!.data.verticalLock)) 115 | xivr.Plugin.doUpdate = true; 116 | 117 | ImGui.Text(lngOptions.snapRotateAmountY_Line2); ImGui.SameLine(); 118 | if (ImGui.SliderFloat("##DrawLocks:vsa", ref xivr.cfg!.data.snapRotateAmountY, 0, 90, "%.0f")) 119 | xivr.Plugin.doUpdate = true; 120 | 121 | ImGui.EndChild(); 122 | } 123 | 124 | 125 | 126 | public static void DrawUISetings(uiOptionStrings lngOptions) 127 | { 128 | ImGui.BeginChild("UI", new Vector2(350, 440) * ImGuiHelpers.GlobalScale, true); 129 | 130 | ImGui.Text(lngOptions.uiOffsetZ_Line1); ImGui.SameLine(); 131 | if (ImGui.SliderFloat("##DrawUISetings:uizoff", ref xivr.cfg!.data.uiOffsetZ, 0, 100, "%.0f")) 132 | xivr.Plugin.doUpdate = true; 133 | 134 | ImGui.Text(lngOptions.uiOffsetScale_Line1); ImGui.SameLine(); 135 | if (ImGui.SliderFloat("##DrawUISetings:uizscale", ref xivr.cfg!.data.uiOffsetScale, 1, 5, "%.00f")) 136 | xivr.Plugin.doUpdate = true; 137 | 138 | if (ImGui.Checkbox(lngOptions.uiDepth_Line1, ref xivr.cfg!.data.uiDepth)) 139 | xivr.Plugin.doUpdate = true; 140 | 141 | ImGui.Text(lngOptions.ipdOffset_Line1); ImGui.SameLine(); 142 | if (ImGui.SliderFloat("##DrawUISetings:ipdoff", ref xivr.cfg!.data.ipdOffset, -10, 10, "%f")) 143 | xivr.Plugin.doUpdate = true; 144 | 145 | if (ImGui.Checkbox(lngOptions.swapEyes_Line1, ref xivr.cfg!.data.swapEyes)) 146 | xivr.Plugin.doUpdate = true; 147 | 148 | if (ImGui.Checkbox(lngOptions.swapEyesUI_Line1, ref xivr.cfg!.data.swapEyesUI)) 149 | xivr.Plugin.doUpdate = true; 150 | 151 | ImGui.Text(lngOptions.armMultiplier_Line1); ImGui.SameLine(); 152 | if (ImGui.SliderFloat("##DrawUISetings:armmultiplier", ref xivr.cfg!.data.armMultiplier, 0, 200, "%.f")) 153 | xivr.Plugin.doUpdate = true; 154 | 155 | ImGui.Text(lngOptions.offsetAmountX_Line1); ImGui.SameLine(); 156 | if (ImGui.SliderFloat("##DrawUISetings:xoff", ref xivr.cfg!.data.offsetAmountX, -100, 100, "%.f")) 157 | xivr.Plugin.doUpdate = true; 158 | 159 | ImGui.Text(lngOptions.offsetAmountY_Line1); ImGui.SameLine(); 160 | if (ImGui.SliderFloat("##DrawUISetings:yoff", ref xivr.cfg!.data.offsetAmountY, -100, 100, "%.f")) 161 | xivr.Plugin.doUpdate = true; 162 | 163 | ImGui.Text(lngOptions.offsetAmountZ_Line1); ImGui.SameLine(); 164 | if (ImGui.SliderFloat("##DrawUISetings:zoff", ref xivr.cfg!.data.offsetAmountZ, -100, 100, "%.f")) 165 | xivr.Plugin.doUpdate = true; 166 | 167 | ImGui.Text(lngOptions.offsetAmountYFPS_Line1); ImGui.SameLine(); 168 | if (ImGui.SliderFloat("##DrawUISetings:fpsyoff", ref xivr.cfg!.data.offsetAmountYFPS, -100, 100, "%.f")) 169 | xivr.Plugin.doUpdate = true; 170 | 171 | ImGui.Text(lngOptions.offsetAmountZFPS_Line1); ImGui.SameLine(); 172 | if (ImGui.SliderFloat("##DrawUISetings:fpszoff", ref xivr.cfg!.data.offsetAmountZFPS, -100, 100, "%.f")) 173 | xivr.Plugin.doUpdate = true; 174 | 175 | ImGui.Text(lngOptions.offsetAmountYFPSMount_Line1); ImGui.SameLine(); 176 | if (ImGui.SliderFloat("##DrawUISetings:mountyoff", ref xivr.cfg!.data.offsetAmountYFPSMount, -100, 100, "%.f")) 177 | xivr.Plugin.doUpdate = true; 178 | 179 | ImGui.Text(lngOptions.offsetAmountZFPSMount_Line1); ImGui.SameLine(); 180 | if (ImGui.SliderFloat("##DrawUISetings:mountzoff", ref xivr.cfg!.data.offsetAmountZFPSMount, -100, 100, "%.f")) 181 | xivr.Plugin.doUpdate = true; 182 | 183 | ImGui.Text(lngOptions.targetCursorSize_Line1); ImGui.SameLine(); 184 | if (ImGui.SliderInt("##DrawUISetings:targetcur", ref xivr.cfg!.data.targetCursorSize, 25, 255)) 185 | xivr.Plugin.doUpdate = true; 186 | 187 | if (ImGui.Checkbox(lngOptions.ultrawideshadows_Line1, ref xivr.cfg!.data.ultrawideshadows)) 188 | xivr.Plugin.doUpdate = true; 189 | 190 | ImGui.EndChild(); 191 | } 192 | 193 | 194 | public static void ShowKofi(uiOptionStrings lngOptions) 195 | { 196 | ImGui.BeginChild("Support", new Vector2(350, 50) * ImGuiHelpers.GlobalScale, true); 197 | 198 | ImGui.PushStyleColor(ImGuiCol.Button, 0xFF000000 | 0x005E5BFF); 199 | ImGui.PushStyleColor(ImGuiCol.ButtonActive, 0xDD000000 | 0x005E5BFF); 200 | ImGui.PushStyleColor(ImGuiCol.ButtonHovered, 0xAA000000 | 0x005E5BFF); 201 | if (ImGui.Button(lngOptions.support_Line1)) 202 | { 203 | Process.Start(new ProcessStartInfo { FileName = "https://ko-fi.com/projectmimer", UseShellExecute = true }); 204 | } 205 | ImGui.PopStyleColor(3); 206 | ImGui.EndChild(); 207 | } 208 | } 209 | } 210 | -------------------------------------------------------------------------------- /xivr/Structures/ActionData.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace xivr.Structures 4 | { 5 | public enum ActionButtonLayout 6 | { 7 | movement, 8 | rotation, 9 | leftHandTipPose, 10 | rightHandTipPose, 11 | lefthandPalmPose, 12 | righthandPalmPose, 13 | leftHandAnim, 14 | rightHandAnim, 15 | leftClick, 16 | rightClick, 17 | recenter, 18 | shift, 19 | alt, 20 | control, 21 | escape, 22 | button01, 23 | button02, 24 | button03, 25 | button04, 26 | button05, 27 | button06, 28 | button07, 29 | button08, 30 | button09, 31 | button10, 32 | button11, 33 | button12, 34 | xbox_button_y, 35 | xbox_button_x, 36 | xbox_button_a, 37 | xbox_button_b, 38 | xbox_left_trigger, 39 | xbox_left_bumper, 40 | xbox_left_stick_click, 41 | xbox_right_trigger, 42 | xbox_right_bumper, 43 | xbox_right_stick_click, 44 | xbox_pad_up, 45 | xbox_pad_down, 46 | xbox_pad_left, 47 | xbox_pad_right, 48 | xbox_start, 49 | xbox_select, 50 | thumbrest_left, 51 | thumbrest_right, 52 | haptics_left, 53 | haptics_right, 54 | watch_audio, 55 | watch_dalamud, 56 | watch_ui, 57 | watch_keyboard, 58 | watch_none, 59 | watch_occlusion, 60 | watch_recenter, 61 | watch_weapon, 62 | watch_xivr 63 | } 64 | 65 | 66 | public struct InputDigitalActionData 67 | { 68 | public bool bActive; 69 | public UInt64 activeOrigin; 70 | public bool bState; 71 | public bool bChanged; 72 | public float fUpdateTime; 73 | }; 74 | 75 | public struct InputAnalogActionData 76 | { 77 | public bool bActive; 78 | public UInt64 activeOrigin; 79 | public float x; 80 | public float y; 81 | public float z; 82 | public float deltaX; 83 | public float deltaY; 84 | public float deltaZ; 85 | public float fUpdateTime; 86 | }; 87 | } 88 | -------------------------------------------------------------------------------- /xivr/Structures/CharCustData.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | using Dalamud.Logging; 4 | using FFXIVClientStructs.FFXIV.Client.Game.Character; 5 | 6 | namespace xivr.Structures 7 | { 8 | [StructLayout(LayoutKind.Explicit, Size = 26)] 9 | public unsafe struct CharCustData 10 | { 11 | [FieldOffset(0x00)] public fixed byte Data[26]; 12 | [FieldOffset(0x00)] public byte Race; 13 | [FieldOffset(0x01)] public byte Gender; 14 | [FieldOffset(0x02)] public byte ModelType; 15 | [FieldOffset(0x03)] public byte Height; 16 | [FieldOffset(0x04)] public byte Tribe; 17 | [FieldOffset(0x05)] public byte FaceType; 18 | [FieldOffset(0x06)] public byte HairStyle; 19 | [FieldOffset(0x07)] public byte HasHighlights; 20 | [FieldOffset(0x08)] public byte SkinColor; 21 | [FieldOffset(0x09)] public byte EyeColor; 22 | [FieldOffset(0x0A)] public byte HairColor; 23 | [FieldOffset(0x0B)] public byte HairColor2; 24 | [FieldOffset(0x0C)] public byte FaceFeatures; 25 | [FieldOffset(0x0D)] public byte FaceFeaturesColor; 26 | [FieldOffset(0x0E)] public byte Eyebrows; 27 | [FieldOffset(0x0F)] public byte EyeColor2; 28 | [FieldOffset(0x10)] public byte EyeShape; 29 | [FieldOffset(0x11)] public byte NoseShape; 30 | [FieldOffset(0x12)] public byte JawShape; 31 | [FieldOffset(0x13)] public byte LipStyle; 32 | [FieldOffset(0x14)] public byte LipColor; 33 | [FieldOffset(0x15)] public byte RaceFeatureSize; 34 | [FieldOffset(0x16)] public byte RaceFeatureType; 35 | [FieldOffset(0x17)] public byte BustSize; 36 | [FieldOffset(0x18)] public byte Facepaint; 37 | [FieldOffset(0x19)] public byte FacepaintColor; 38 | 39 | public void Save(Character* character) 40 | { 41 | for (int i = 0; i < 26; i++) 42 | Data[i] = character->DrawData.CustomizeData[i]; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /xivr/Structures/CharEquipData.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | using FFXIVClientStructs.FFXIV.Client.Game.Character; 4 | 5 | namespace xivr.Structures 6 | { 7 | [StructLayout(LayoutKind.Explicit, Size = 40)] 8 | public unsafe struct CharEquipData 9 | { 10 | [FieldOffset(0x00)] public fixed uint Data[10]; 11 | [FieldOffset(0x00)] public CharEquipSlotData Head; 12 | [FieldOffset(0x04)] public CharEquipSlotData Body; 13 | [FieldOffset(0x08)] public CharEquipSlotData Hands; 14 | [FieldOffset(0x0C)] public CharEquipSlotData Legs; 15 | [FieldOffset(0x10)] public CharEquipSlotData Feet; 16 | [FieldOffset(0x14)] public CharEquipSlotData Ears; 17 | [FieldOffset(0x18)] public CharEquipSlotData Neck; 18 | [FieldOffset(0x1C)] public CharEquipSlotData Wrist; 19 | [FieldOffset(0x20)] public CharEquipSlotData RRing; 20 | [FieldOffset(0x24)] public CharEquipSlotData LRing; 21 | 22 | public void Save(Character* character) 23 | { 24 | Head.Save(character->DrawData.Head); 25 | Body.Save(character->DrawData.Top); 26 | Hands.Save(character->DrawData.Arms); 27 | Legs.Save(character->DrawData.Legs); 28 | Feet.Save(character->DrawData.Feet); 29 | Ears.Save(character->DrawData.Ear); 30 | Neck.Save(character->DrawData.Neck); 31 | Wrist.Save(character->DrawData.Wrist); 32 | RRing.Save(character->DrawData.RFinger); 33 | LRing.Save(character->DrawData.LFinger); 34 | } 35 | } 36 | 37 | [StructLayout(LayoutKind.Explicit, Size = 0x4)] 38 | public unsafe struct CharEquipSlotData 39 | { 40 | [FieldOffset(0)] public uint Data; 41 | [FieldOffset(0)] public ushort Id; 42 | [FieldOffset(2)] public byte Variant; 43 | [FieldOffset(3)] public byte Dye; 44 | public CharEquipSlotData(ushort id, byte variant, byte dye) 45 | { 46 | Id = id; 47 | Variant = variant; 48 | Dye = dye; 49 | } 50 | public void Save(EquipmentModelId data) 51 | { 52 | Id = data.Id; 53 | Variant = data.Variant; 54 | Dye = data.Stain; 55 | } 56 | } 57 | 58 | [StructLayout(LayoutKind.Explicit)] 59 | public unsafe struct CharWeaponData 60 | { 61 | [FieldOffset(0x00)] public fixed UInt64 Data[3]; 62 | [FieldOffset(0x00)] public CharWeaponSlotData MainHand; 63 | [FieldOffset(0x08)] public CharWeaponSlotData OffHand; 64 | [FieldOffset(0x0C)] public CharWeaponSlotData Uk3; 65 | 66 | public void Save(Character* character) 67 | { 68 | MainHand.Save(character->DrawData.MainHandModel); 69 | OffHand.Save(character->DrawData.OffHandModel); 70 | Uk3.Save(character->DrawData.UnkE0Model); 71 | } 72 | 73 | } 74 | 75 | [StructLayout(LayoutKind.Explicit, Size = 0x8)] 76 | public unsafe struct CharWeaponSlotData 77 | { 78 | [FieldOffset(0)] public UInt64 Data; 79 | [FieldOffset(0)] public ushort Type; 80 | [FieldOffset(2)] public ushort Id; 81 | [FieldOffset(4)] public ushort Variant; 82 | [FieldOffset(6)] public byte Dye; 83 | [FieldOffset(7)] public byte uk1; 84 | 85 | public CharWeaponSlotData(ushort type, ushort id, byte variant, byte dye) 86 | { 87 | Type = type; 88 | Id = id; 89 | Variant = variant; 90 | Dye = dye; 91 | } 92 | 93 | public void Save(WeaponModelId data) 94 | { 95 | Type = data.Type; 96 | Id = data.Id; 97 | Variant = data.Variant; 98 | Dye = data.Stain; 99 | } 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /xivr/Structures/ControlSystemCameraManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace xivr.Structures 5 | { 6 | [StructLayout(LayoutKind.Explicit, Size = 0x300)] 7 | public unsafe struct ControlSystemCameraManager 8 | { 9 | [FieldOffset(0x0)] public GameCamera* GameCamera; 10 | [FieldOffset(0x8)] public LowCutCamera* LowCutCamera; 11 | [FieldOffset(0x10)] public LobbyCamera* LobbyCamera; 12 | [FieldOffset(0x18)] public Camera3* Camera3; 13 | [FieldOffset(0x20)] public Camera4* Camera4; 14 | 15 | [FieldOffset(0x48)] public int ActiveCameraIndex; 16 | [FieldOffset(0x4C)] public int PreviousCameraIndex; 17 | 18 | [FieldOffset(0x60)] public UInt64 CameraBase; 19 | [FieldOffset(0x70)] public UInt64 ukn1; 20 | [FieldOffset(0x90)] public UInt64 ukn2; 21 | [FieldOffset(0x98)] public UInt64 ukn3; 22 | 23 | public RawGameCamera* GetActive(ControlSystemCameraManager* csCameraManager = null) 24 | { 25 | if (csCameraManager != null) 26 | { 27 | ActiveCameraIndex = csCameraManager->ActiveCameraIndex; 28 | PreviousCameraIndex = csCameraManager->PreviousCameraIndex; 29 | } 30 | 31 | if (ActiveCameraIndex == 1) 32 | return &LowCutCamera->Camera; 33 | else if (ActiveCameraIndex == 2) 34 | return &LobbyCamera->Camera; 35 | else if (ActiveCameraIndex == 3) 36 | return &Camera3->Camera; 37 | else if (ActiveCameraIndex == 4) 38 | return &Camera4->Camera; 39 | else 40 | return &GameCamera->Camera; 41 | } 42 | } 43 | 44 | 45 | [StructLayout(LayoutKind.Explicit, Size = 0x10)] 46 | public unsafe struct CameraBase 47 | { 48 | [FieldOffset(0x00)] public UInt64* vtbl; 49 | [FieldOffset(0x08)] public UInt64 uk1; 50 | } 51 | 52 | [StructLayout(LayoutKind.Explicit, Size = 0x2B0)] 53 | public unsafe struct GameCamera 54 | { 55 | [FieldOffset(0x00)] public CameraBase CameraBase; 56 | [FieldOffset(0x10)] public RawGameCamera Camera; 57 | } 58 | 59 | [StructLayout(LayoutKind.Explicit, Size = 0x2E0)] 60 | public struct LowCutCamera 61 | { 62 | [FieldOffset(0x00)] public CameraBase CameraBase; 63 | [FieldOffset(0x10)] public RawGameCamera Camera; 64 | } 65 | 66 | [StructLayout(LayoutKind.Explicit, Size = 0x300)] 67 | public unsafe struct LobbyCamera 68 | { 69 | [FieldOffset(0x00)] public CameraBase CameraBase; 70 | [FieldOffset(0x10)] public RawGameCamera Camera; 71 | [FieldOffset(0x2F8)] public void* LobbyExcelSheet; 72 | } 73 | 74 | [StructLayout(LayoutKind.Explicit, Size = 0x300)] 75 | public struct Camera3 76 | { 77 | [FieldOffset(0x00)] public CameraBase CameraBase; 78 | [FieldOffset(0x10)] public RawGameCamera Camera; 79 | } 80 | 81 | [StructLayout(LayoutKind.Explicit, Size = 0x350)] 82 | public struct Camera4 83 | { 84 | [FieldOffset(0x00)] public CameraBase CameraBase; 85 | [FieldOffset(0x10)] public RawGameCamera Camera; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /xivr/Structures/LanguageOptions.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace xivr.Structures 4 | { 5 | public struct uiOptionStrings 6 | { 7 | public string isEnabled_Line1; 8 | public string isAutoEnabled_Line1; 9 | public string forceFloatingScreen_Line1; 10 | public string forceFloatingInCutscene_Line1; 11 | public string horizontalLock_Line1; 12 | public string verticalLock_Line1; 13 | public string horizonLock_Line1; 14 | public string runRecenter_Line1; 15 | public string offsetAmountX_Line1; 16 | public string offsetAmountY_Line1; 17 | public string offsetAmountYFPS_Line1; 18 | public string offsetAmountZFPS_Line1; 19 | public string offsetAmountYFPSMount_Line1; 20 | public string offsetAmountZFPSMount_Line1; 21 | public string snapRotateAmountX_Line1; 22 | public string snapRotateAmountX_Line2; 23 | public string snapRotateAmountX_Line3; 24 | public string snapRotateAmountY_Line1; 25 | public string snapRotateAmountY_Line2; 26 | public string snapRotateAmountY_Line3; 27 | public string uiOffsetZ_Line1; 28 | public string uiOffsetScale_Line1; 29 | public string conloc_Line1; 30 | public string swapEyes_Line1; 31 | public string swapEyesUI_Line1; 32 | public string motioncontrol_Line1; 33 | public string hmdWidth_Line1; 34 | public string hmdHeight_Line1; 35 | public string autoResize_Line1; 36 | public string ipdOffset_Line1; 37 | public string vLog_Line1; 38 | public string hmdloc_Line1; 39 | public string vertloc_Line1; 40 | public string targetCursorSize_Line1; 41 | public string offsetAmountZ_Line1; 42 | public string uiDepth_Line1; 43 | public string hmdPointing_Line1; 44 | public string mode2d_Line1; 45 | public string asymmetricProjection_Line1; 46 | public string immersiveMovement_Line1; 47 | public string immersiveFull_Line1; 48 | public string languageType_Line1; 49 | public string ultrawideshadows_Line1; 50 | public string showWeaponInHand_Line1; 51 | public string support_Line1; 52 | public string autoMove_Line1; 53 | public string enableOSK_Line1; 54 | public string armMultiplier_Line1; 55 | } 56 | 57 | public static class Language 58 | { 59 | public static Dictionary rawLngData = new Dictionary() { 60 | { 61 | LanguageTypes.en, new uiOptionStrings 62 | { 63 | isEnabled_Line1 = "Enable", 64 | isAutoEnabled_Line1 = "Auto Enable if steamvr is active", 65 | mode2d_Line1 = "2D Mode", 66 | autoResize_Line1 = "Auto Resize when activated", 67 | runRecenter_Line1 = "Recenter", 68 | vLog_Line1 = "Verbose Logs", 69 | motioncontrol_Line1 = "Enable motion controllers", 70 | conloc_Line1 = "Enable 1st person controller locomotion", 71 | hmdloc_Line1 = "Enable 1st person headset locomotion", 72 | vertloc_Line1 = "1st person locomotion allow vertical movement", 73 | forceFloatingScreen_Line1 = "Flat mode", 74 | forceFloatingInCutscene_Line1 = "Flat mode in Cutscene", 75 | immersiveMovement_Line1 = "Immersive Mode", 76 | horizonLock_Line1 = "Keep headset level with horizon", 77 | snapRotateAmountX_Line1 = "Horizontal Snap", 78 | snapRotateAmountX_Line2 = "Amount", 79 | snapRotateAmountY_Line1 = "Vertical Snap", 80 | snapRotateAmountY_Line2 = "Amount", 81 | uiOffsetZ_Line1 = "UI Distance", 82 | uiOffsetScale_Line1 = "UI Size", 83 | uiDepth_Line1 = "Enable UI Depth", 84 | ipdOffset_Line1 = "IPD Offset", 85 | swapEyes_Line1 = "Swap Eyes", 86 | swapEyesUI_Line1 = "Swap Eyes UI", 87 | offsetAmountX_Line1 = "3rd Person X Offset", 88 | offsetAmountY_Line1 = "3rd Person Y Offset", 89 | offsetAmountZ_Line1 = "3rd Person Z Offset", 90 | offsetAmountYFPS_Line1 = "1st Person Y Offset", 91 | offsetAmountZFPS_Line1 = "1st Person Z Offset", 92 | offsetAmountYFPSMount_Line1 = "1st Person Mount Y Offset", 93 | offsetAmountZFPSMount_Line1 = "1st Person Mount Z Offset", 94 | targetCursorSize_Line1 = "Target Cursor Size", 95 | asymmetricProjection_Line1 = "Asymmetric Projection - Requires XIVR Restart", 96 | ultrawideshadows_Line1 = "Ultrawide Shadows", 97 | showWeaponInHand_Line1 = "Show Weapon In Hand", 98 | support_Line1 = "Support via Ko-fi", 99 | autoMove_Line1 = "Auto Move when activated", 100 | enableOSK_Line1 = "Virtual Keyboard (Requires Admin)", 101 | armMultiplier_Line1 = "IK Hand Distance Scale" 102 | } 103 | }, 104 | { 105 | LanguageTypes.jp, new uiOptionStrings 106 | { 107 | isEnabled_Line1 = "VR有効化", 108 | isAutoEnabled_Line1 = "SteamVR実行中の場合はVR自動有効化", 109 | mode2d_Line1 = "2Dモード", 110 | autoResize_Line1 = "自動ウインドウサイズ変更", 111 | runRecenter_Line1 = "頭位置リセット", 112 | vLog_Line1 = "詳細ログ生成", 113 | motioncontrol_Line1 = "モーションコントローラーを有効にする", 114 | conloc_Line1 = "一人称左手移動操作", 115 | hmdloc_Line1 = "一人称頭移動操作", 116 | vertloc_Line1 = "一人称移動上下操作を有効にする", 117 | forceFloatingScreen_Line1 = "平面モード", 118 | forceFloatingInCutscene_Line1 = "ムービー中平面モード", 119 | immersiveMovement_Line1 = "没入モード", 120 | horizonLock_Line1 = "地平線と水平を保つ", 121 | snapRotateAmountX_Line1 = "水平スナップ回転", 122 | snapRotateAmountX_Line2 = "度数", 123 | snapRotateAmountY_Line1 = "垂直スナップ回転", 124 | snapRotateAmountY_Line2 = "度数", 125 | uiOffsetZ_Line1 = "メニュー距離", 126 | uiOffsetScale_Line1 = "メニューサイズ", 127 | uiDepth_Line1 = "メニュー奥行き", 128 | ipdOffset_Line1 = "瞳孔間距離(IPD)補正", 129 | swapEyes_Line1 = "目を入れ替える 世界", 130 | swapEyesUI_Line1 = "目を入れ替える メニュー", 131 | offsetAmountX_Line1 = "三人称X軸補正", 132 | offsetAmountY_Line1 = "三人称Y軸補正", 133 | offsetAmountZ_Line1 = "三人称Z軸補正", 134 | offsetAmountYFPS_Line1 = "一人称Y軸補正", 135 | offsetAmountZFPS_Line1 = "一人称Z軸補正", 136 | offsetAmountYFPSMount_Line1 = "一人称マウントY軸補正", 137 | offsetAmountZFPSMount_Line1 = "一人称マウントZ軸補正", 138 | targetCursorSize_Line1 = "ターゲットカーソルサイズ", 139 | asymmetricProjection_Line1 = "非対称映写(2Dモード非対応)XIVR再起動必須", 140 | ultrawideshadows_Line1 = "ウルトラワイド影", 141 | showWeaponInHand_Line1 = "手の中の武器表示する", 142 | support_Line1 = "Ko-fiで支援", 143 | autoMove_Line1 = "自動ウィンドウ位置調整", 144 | enableOSK_Line1 = "バーチャルキーボード(管理者権限必要", 145 | armMultiplier_Line1 = "IK手距離スケール" 146 | } 147 | } 148 | }; 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /xivr/Structures/Misc.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Numerics; 3 | using System.Runtime.InteropServices; 4 | using FFXIVClientStructs.Havok; 5 | using FFXIVClientStructs.FFXIV.Client.Game.Object; 6 | using FFXIVClientStructs.FFXIV.Client.Graphics.Render; 7 | using FFXIVClientStructs.FFXIV.Client.Graphics; 8 | using System.Collections.Generic; 9 | 10 | namespace xivr.Structures 11 | { 12 | public class MovingAverage 13 | { 14 | private Queue dataList = new Queue(); 15 | private int sampleLength = 1; 16 | private float dataTotal = 0; 17 | public float Average => dataTotal / dataList.Count; 18 | 19 | public MovingAverage(int sampleAmount = 100) 20 | { 21 | sampleLength = sampleAmount; 22 | } 23 | 24 | public void AddNew(float newSample) 25 | { 26 | dataTotal += newSample; 27 | dataList.Enqueue(newSample); 28 | if (dataList.Count > sampleLength) 29 | dataTotal -= dataList.Dequeue(); 30 | } 31 | 32 | public void Reset() 33 | { 34 | dataList.Clear(); 35 | dataTotal = 0; 36 | } 37 | } 38 | 39 | [StructLayout(LayoutKind.Explicit)] 40 | public unsafe struct Model 41 | { 42 | [FieldOffset(0x18)] public GameObject* ParentObject; 43 | [FieldOffset(0x20)] public GameObject* PrevLinkedObject; 44 | [FieldOffset(0x28)] public GameObject* NextLinkedObject; 45 | [FieldOffset(0x50)] public hkQsTransformf basePosition; 46 | [FieldOffset(0x88)] public ModelCullTypes CullType; 47 | [FieldOffset(0x89)] public byte RenderStyle; 48 | [FieldOffset(0xA0)] public Skeleton* skeleton; 49 | [FieldOffset(0x120)] public int mountFlag1; 50 | [FieldOffset(0x124)] public int mountFlag2; 51 | [FieldOffset(0x128)] public Skeleton* mountedOwnerSkeleton; 52 | [FieldOffset(0x130)] public GameObject* mountedObject; 53 | [FieldOffset(0x138)] public int mountFlag3; 54 | } 55 | 56 | [StructLayout(LayoutKind.Explicit)] 57 | public struct ScreenSettings 58 | { 59 | [FieldOffset(0x18)] public UInt64 hWnd; 60 | [FieldOffset(0x20)] public int Width; 61 | [FieldOffset(0x24)] public int Height; 62 | [FieldOffset(0x30)] public int ScreenStatus; 63 | [FieldOffset(0x58)] public int MinWidth; 64 | [FieldOffset(0x5C)] public int MinHeight; 65 | [FieldOffset(0x70)] public int FullWidth; 66 | [FieldOffset(0x74)] public int FullHeight; 67 | } 68 | 69 | [StructLayout(LayoutKind.Explicit)] 70 | public unsafe struct CharSelectionCharList 71 | { 72 | [FieldOffset(0x00)] public GameObject* Character0; 73 | [FieldOffset(0x08)] public GameObject* Character1; 74 | [FieldOffset(0x10)] public GameObject* Character2; 75 | [FieldOffset(0x18)] public GameObject* Character3; 76 | [FieldOffset(0x20)] public GameObject* Character4; 77 | [FieldOffset(0x28)] public GameObject* Character5; 78 | [FieldOffset(0x30)] public GameObject* Character6; 79 | [FieldOffset(0x38)] public GameObject* Character7; 80 | } 81 | 82 | public static class ExtendedData 83 | { 84 | public unsafe static Vector3 GetScale(this Matrix4x4 matrix) 85 | { 86 | return new Vector3(matrix.M14, matrix.M24, matrix.M34); 87 | } 88 | 89 | public unsafe static void SetScale(this ref Matrix4x4 matrix, float x, float y, float z) 90 | { 91 | matrix.M14 = x; 92 | matrix.M24 = y; 93 | matrix.M34 = z; 94 | } 95 | 96 | public unsafe static void SetScale(this ref Matrix4x4 matrix, hkVector4f scale) 97 | { 98 | matrix.SetScale(scale.X, scale.Y, scale.X); 99 | } 100 | 101 | public unsafe static void SetScale(this ref Matrix4x4 matrix, Vector3 scale) 102 | { 103 | matrix.SetScale(scale.X, scale.Y, scale.X); 104 | } 105 | 106 | 107 | public unsafe static float Magnitude(this Vector3 vector) 108 | { 109 | return MathF.Sqrt(vector.X * vector.X + vector.Y * vector.Y + vector.Z * vector.Z); 110 | } 111 | 112 | public unsafe static float Magnitude(this hkVector4f vector) 113 | { 114 | return MathF.Sqrt(vector.X * vector.X + vector.Y * vector.Y + vector.Z * vector.Z); 115 | } 116 | 117 | 118 | public static Transform Convert(this hkQsTransformf transform) 119 | { 120 | Transform retVal = new Transform(); 121 | retVal.Position = transform.Translation.Convert(); 122 | retVal.Rotation = transform.Rotation.Convert(); 123 | retVal.Scale = transform.Scale.Convert(); 124 | return retVal; 125 | } 126 | 127 | public static hkQsTransformf Convert(this BoneData boneData) 128 | { 129 | hkQsTransformf retVal = new hkQsTransformf(); 130 | retVal.Translation = boneData.Position; 131 | retVal.Rotation = boneData.Rotation; 132 | retVal.Scale = new Vector3(1, 1, 1).Convert(); 133 | return retVal; 134 | } 135 | 136 | public static hkQsTransformf Convert(this Matrix4x4 matrix) 137 | { 138 | hkQsTransformf retVal = new hkQsTransformf(); 139 | retVal.Translation = matrix.Translation.Convert(); 140 | retVal.Rotation = Quaternion.CreateFromRotationMatrix(matrix).Convert(); 141 | retVal.Scale = matrix.GetScale().Convert(); 142 | return retVal; 143 | } 144 | 145 | public static hkQsTransformf Convert(this Transform transform) 146 | { 147 | hkQsTransformf retVal = new hkQsTransformf(); 148 | retVal.Translation = transform.Position.Convert(); 149 | retVal.Rotation = transform.Rotation.Convert(); 150 | retVal.Scale = transform.Scale.Convert(); 151 | return retVal; 152 | } 153 | 154 | public static Quaternion Convert(this hkQuaternionf quaternion) 155 | { 156 | return new Quaternion(quaternion.X, quaternion.Y, quaternion.Z, quaternion.W); 157 | } 158 | 159 | public static hkQuaternionf Convert(this Quaternion quaternion) 160 | { 161 | hkQuaternionf retVal = new hkQuaternionf(); 162 | retVal.X = quaternion.X; 163 | retVal.Y = quaternion.Y; 164 | retVal.Z = quaternion.Z; 165 | retVal.W = quaternion.W; 166 | return retVal; 167 | } 168 | 169 | public static hkQuaternionf Convert(this FFXIVClientStructs.FFXIV.Common.Math.Quaternion quaternion) 170 | { 171 | hkQuaternionf retVal = new hkQuaternionf(); 172 | retVal.X = quaternion.X; 173 | retVal.Y = quaternion.Y; 174 | retVal.Z = quaternion.Z; 175 | retVal.W = quaternion.W; 176 | return retVal; 177 | } 178 | 179 | public static Vector3 Convert(this hkVector4f vector) 180 | { 181 | return new Vector3(vector.X, vector.Y, vector.Z); 182 | } 183 | 184 | public static hkVector4f hkVector4f(this hkVector4f vector, float X, float Y, float Z, float W) 185 | { 186 | vector.X = X; 187 | vector.Y = Y; 188 | vector.Z = Z; 189 | vector.W = W; 190 | return vector; 191 | } 192 | 193 | public static hkVector4f Convert(this Vector3 vector) 194 | { 195 | hkVector4f retVal = new hkVector4f(); 196 | retVal.X = vector.X; 197 | retVal.Y = vector.Y; 198 | retVal.Z = vector.Z; 199 | retVal.W = 0.0f; 200 | return retVal; 201 | } 202 | 203 | public static hkVector4f Convert(this FFXIVClientStructs.FFXIV.Common.Math.Vector3 vector) 204 | { 205 | hkVector4f retVal = new hkVector4f(); 206 | retVal.X = vector.X; 207 | retVal.Y = vector.Y; 208 | retVal.Z = vector.Z; 209 | retVal.W = 0.0f; 210 | return retVal; 211 | } 212 | 213 | public static Matrix4x4 ToMatrix(this Transform transform) 214 | { 215 | Matrix4x4 toMatrix = Matrix4x4.CreateFromQuaternion(transform.Rotation); 216 | toMatrix.Translation = transform.Position; 217 | toMatrix.SetScale(transform.Scale); 218 | return toMatrix; 219 | } 220 | 221 | public static Matrix4x4 ToMatrix(this hkQsTransformf transform) 222 | { 223 | Matrix4x4 toMatrix = Matrix4x4.CreateFromQuaternion(transform.Rotation.Convert()); 224 | toMatrix.Translation = transform.Translation.Convert(); 225 | toMatrix.SetScale(transform.Scale); 226 | return toMatrix; 227 | } 228 | } 229 | } 230 | -------------------------------------------------------------------------------- /xivr/Structures/RawGameCamera.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Numerics; 3 | using System.Runtime.InteropServices; 4 | using FFXIVClientStructs.Attributes; 5 | using FFXIVClientStructs.Interop.Attributes; 6 | 7 | namespace xivr.Structures 8 | { 9 | [StructLayout(LayoutKind.Explicit)] 10 | public struct vtblRawGameCamera 11 | { 12 | [FieldOffset(0x78)] // 15*8=112 13 | public unsafe delegate* unmanaged[Stdcall] vf15; 14 | } 15 | 16 | [StructLayout(LayoutKind.Explicit)] 17 | public unsafe struct RawGameCamera 18 | { 19 | [FieldOffset(0x0)] public vtblRawGameCamera* vtbl; 20 | [FieldOffset(0x50)] public Vector3 Position; 21 | [FieldOffset(0x80)] public Vector3 LookAt; 22 | [FieldOffset(0x90)] public float uk1a; 23 | [FieldOffset(0x94)] public float uk1b; 24 | [FieldOffset(0x98)] public float uk1c; 25 | [FieldOffset(0xA0)] public Matrix4x4 ViewMatrix; 26 | [FieldOffset(0xE0)] public CameraConstantBuffer* BufferData; 27 | [FieldOffset(0xE8)] public float unk2; 28 | [FieldOffset(0xEC)] public byte unk3; 29 | [FieldOffset(0x104)] public float CurrentZoom; 30 | [FieldOffset(0x108)] public float MinZoom; 31 | [FieldOffset(0x10C)] public float MaxZoom; 32 | [FieldOffset(0x110)] public float CurrentFoV; 33 | [FieldOffset(0x114)] public float MinFoV; 34 | [FieldOffset(0x118)] public float MaxFoV; 35 | [FieldOffset(0x11C)] public float AddedFoV; 36 | [FieldOffset(0x120)] public float CurrentHRotation; 37 | [FieldOffset(0x124)] public float CurrentVRotation; 38 | [FieldOffset(0x128)] public float HRotationThisFrame1; 39 | [FieldOffset(0x12C)] public float VRotationThisFrame1; 40 | [FieldOffset(0x130)] public float HRotationThisFrame2; 41 | [FieldOffset(0x134)] public float VRotationThisFrame2; 42 | [FieldOffset(0x138)] public float MinVRotation; 43 | [FieldOffset(0x13C)] public float MaxVRotation; 44 | [FieldOffset(0x150)] public float Tilt; 45 | [FieldOffset(0x160)] public CameraModes Mode; // Camera mode? (0 = 1st person, 1 = 3rd person, 2+ = weird controller mode? cant look up/down) 46 | [FieldOffset(0x16C)] public float InterpolatedZoom; 47 | [FieldOffset(0x1A0)] public float ViewX; 48 | [FieldOffset(0x1A4)] public float ViewY; 49 | [FieldOffset(0x1A8)] public float ViewZ; 50 | [FieldOffset(0x214)] public float LookAtHeightOffset; 51 | [FieldOffset(0x218)] public byte ResetLookatHeightOffset; 52 | [FieldOffset(0x2A4)] public float LookAtZ2; 53 | 54 | 55 | /*[VirtualFunction(15)] 56 | public unsafe void vf15(IntPtr target, float* vectorPosition, bool swapPerson) 57 | { 58 | fixed (RawGameCamera* ptr = &this) 59 | { 60 | vtbl->vf15(ptr, target, vectorPosition, swapPerson); 61 | } 62 | }*/ 63 | } 64 | 65 | 66 | 67 | [StructLayout(LayoutKind.Explicit)] 68 | public struct vtblCameraConstantBuffer 69 | { 70 | } 71 | 72 | [StructLayout(LayoutKind.Explicit)] 73 | public unsafe struct CameraConstantBuffer 74 | { 75 | [FieldOffset(0x0)] public vtblCameraConstantBuffer* vtbl; 76 | [FieldOffset(0x10)] public Matrix4x4 ViewMatrix; 77 | [FieldOffset(0x50)] public Matrix4x4 ProjectionMatrix; 78 | [FieldOffset(0x90)] public float EyePosX; 79 | [FieldOffset(0x94)] public float EyePosY; 80 | [FieldOffset(0x98)] public float EyePosZ; 81 | [FieldOffset(0xA0)] public int OffsetIndex; 82 | [FieldOffset(0xA4)] public float FOV; 83 | [FieldOffset(0xA8)] public float MkProj1; 84 | [FieldOffset(0xAC)] public float Aspect; 85 | [FieldOffset(0xB0)] public float NearClip; 86 | [FieldOffset(0xB4)] public float FarClip; 87 | [FieldOffset(0xC0)] public Matrix4x4 CalculationMatrix; 88 | [FieldOffset(0x120)] public CameraThreadedData* ThreadedData; 89 | [FieldOffset(0x128)] public UInt64 unk1; 90 | } 91 | 92 | [StructLayout(LayoutKind.Explicit)] 93 | public unsafe struct CameraThreadedData 94 | { 95 | [FieldOffset(0x0)] public UInt64 unk1; 96 | [FieldOffset(0x8)] public int unk2; 97 | [FieldOffset(0x20)] public int BufferSize; 98 | [FieldOffset(0x24)] public int unk3; 99 | [FieldOffset(0x28)] public UInt64 NextThreadedBuffer; 100 | [FieldOffset(0x34)] public int BufferSizeA; 101 | [FieldOffset(0x50)] public UInt64 ThreadedOffsetA; 102 | [FieldOffset(0x58)] public UInt64 ThreadedOffsetB; 103 | [FieldOffset(0x60)] public UInt64 ThreadedOffsetC; 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /xivr/Structures/RenderQueueCommands.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Numerics; 3 | using System.Runtime.InteropServices; 4 | 5 | namespace xivr.Structures 6 | { 7 | [StructLayout(LayoutKind.Explicit)] 8 | struct stRenderQueueCommandClear 9 | { 10 | [FieldOffset(0x00)] public int SwitchType; 11 | [FieldOffset(0x04)] public int clearType; 12 | [FieldOffset(0x08)] public float colorR; 13 | [FieldOffset(0x0C)] public float colorG; 14 | [FieldOffset(0x10)] public float colorB; 15 | [FieldOffset(0x14)] public float colorA; 16 | [FieldOffset(0x18)] public float unkn1; 17 | [FieldOffset(0x1C)] public float unkn2; 18 | [FieldOffset(0x20)] public int clearCheck; 19 | [FieldOffset(0x24)] public float unkn4; 20 | [FieldOffset(0x28)] public float unkn5; 21 | [FieldOffset(0x2C)] public float unkn6; 22 | [FieldOffset(0x30)] public float unkn7; 23 | [FieldOffset(0x34)] public float unkn8; 24 | [FieldOffset(0x38)] public float unkn9; 25 | 26 | public void Clear() 27 | { 28 | SwitchType = 4; 29 | clearType = 0; 30 | colorR = 0; 31 | colorG = 0; 32 | colorB = 0; 33 | colorA = 0; 34 | unkn1 = 0; 35 | unkn2 = 0; 36 | clearCheck = 0; 37 | unkn4 = 0; 38 | unkn5 = 0; 39 | unkn6 = 0; 40 | unkn7 = 0; 41 | unkn8 = 0; 42 | unkn9 = 0; 43 | } 44 | }; 45 | 46 | [StructLayout(LayoutKind.Explicit)] 47 | public struct Matrix3x4 48 | { 49 | [FieldOffset(0x00)] public float M11; 50 | [FieldOffset(0x04)] public float M12; 51 | [FieldOffset(0x08)] public float M13; 52 | [FieldOffset(0x0C)] public float M14; 53 | [FieldOffset(0x10)] public float M21; 54 | [FieldOffset(0x14)] public float M22; 55 | [FieldOffset(0x18)] public float M23; 56 | [FieldOffset(0x1C)] public float M24; 57 | [FieldOffset(0x20)] public float M31; 58 | [FieldOffset(0x24)] public float M32; 59 | [FieldOffset(0x28)] public float M33; 60 | [FieldOffset(0x2C)] public float M34; 61 | 62 | public Matrix3x4(float n11, float n12, float n13, float n14, float n21, float n22, float n23, float n24, float n31, float n32, float n33, float n34) 63 | { 64 | M11 = n11; M12 = n12; M13 = n13; M14 = n14; 65 | M21 = n21; M22 = n22; M23 = n23; M24 = n24; 66 | M31 = n31; M32 = n32; M33 = n33; M34 = n34; 67 | } 68 | } 69 | 70 | [StructLayout(LayoutKind.Explicit)] 71 | public unsafe struct ptrShaderData 72 | { 73 | [FieldOffset(0x00)] public RawShaderData* ShaderData; 74 | }; 75 | 76 | [StructLayout(LayoutKind.Explicit)] 77 | public unsafe struct RawShaderData 78 | { 79 | [FieldOffset(0x00)] public Matrix3x4 ViewMatrix; 80 | [FieldOffset(0x30)] public Matrix3x4 InvViewMatrix; 81 | [FieldOffset(0x60)] public Matrix4x4 ViewProjectionMatrix; 82 | [FieldOffset(0xA0)] public Matrix4x4 InvViewProjectionMatrix; 83 | [FieldOffset(0xE0)] public Matrix4x4 InvProjectionMatrix; 84 | [FieldOffset(0x120)] public Matrix4x4 ProjectionMatrix; 85 | [FieldOffset(0x160)] public Matrix4x4 MainViewToProjectionMatrix; 86 | [FieldOffset(0x1A0)] public Vector4 EyePos; 87 | [FieldOffset(0x1A0)] public Vector4 LookAt; 88 | }; 89 | 90 | 91 | [StructLayout(LayoutKind.Explicit)] 92 | public unsafe struct cmdList 93 | { 94 | [FieldOffset(0x00)] public cmdGroup[] list; 95 | } 96 | 97 | [StructLayout(LayoutKind.Explicit, Pack = 0x10)] 98 | public unsafe struct cmdGroup 99 | { 100 | [FieldOffset(0x00)] public int unk1; 101 | [FieldOffset(0x04)] public int unk2; 102 | [FieldOffset(0x08)] public cmdType* Type; 103 | [FieldOffset(0x08)] public cmdType0* SetRenderTarget; 104 | [FieldOffset(0x08)] public cmdType1* Viewport; 105 | [FieldOffset(0x08)] public cmdType3* Scissors; 106 | [FieldOffset(0x08)] public cmdType4* Clear; 107 | [FieldOffset(0x08)] public cmdType5* Draw; 108 | [FieldOffset(0x08)] public cmdType6* DrawIndex; 109 | [FieldOffset(0x08)] public cmdType7* DrawIndexInstance; 110 | [FieldOffset(0x08)] public cmdType10* CopyResource; 111 | [FieldOffset(0x08)] public cmdUpdateVR* UpdateVR; 112 | }; 113 | 114 | [StructLayout(LayoutKind.Explicit)] 115 | public unsafe struct cmdUnion 116 | { 117 | [FieldOffset(0x00)] public cmdType Type; 118 | [FieldOffset(0x00)] public cmdType0 SetRenderTarget; 119 | [FieldOffset(0x00)] public cmdType1 Viewport; 120 | [FieldOffset(0x00)] public cmdType3 Scissors; 121 | [FieldOffset(0x00)] public cmdType4 Clear; 122 | [FieldOffset(0x00)] public cmdType5 Draw; 123 | [FieldOffset(0x00)] public cmdType6 DrawIndex; 124 | [FieldOffset(0x00)] public cmdType7 DrawIndexInstance; 125 | [FieldOffset(0x00)] public cmdType10 CopyResource; 126 | [FieldOffset(0x00)] public cmdUpdateVR UpdateVR; 127 | }; 128 | 129 | 130 | [StructLayout(LayoutKind.Explicit)] 131 | public unsafe struct cmdType 132 | { 133 | [FieldOffset(0x00)] public int SwitchType; 134 | }; 135 | 136 | [StructLayout(LayoutKind.Explicit)] 137 | public unsafe struct cmdType0 // SetRendTarget 138 | { 139 | [FieldOffset(0x00)] public int SwitchType; 140 | [FieldOffset(0x04)] public int numRenderTargets; 141 | [FieldOffset(0x08)] public Texture* RenderTarget0; 142 | [FieldOffset(0x10)] public Texture* RenderTarget1; 143 | [FieldOffset(0x18)] public Texture* RenderTarget2; 144 | [FieldOffset(0x20)] public Texture* RenderTarget3; 145 | [FieldOffset(0x28)] public Texture* DepthBuffer; 146 | [FieldOffset(0x38)] public float unk3; 147 | [FieldOffset(0x3C)] public float unk4; 148 | }; 149 | 150 | [StructLayout(LayoutKind.Explicit)] 151 | public unsafe struct cmdType1 // Viewport 152 | { 153 | [FieldOffset(0x00)] public int SwitchType; 154 | [FieldOffset(0x04)] public int TopLeftY; 155 | [FieldOffset(0x08)] public int TopLeftX; 156 | [FieldOffset(0x0C)] public int BottomRightY; 157 | [FieldOffset(0x10)] public int BottomRightX; 158 | [FieldOffset(0x14)] public float MinDepth; 159 | [FieldOffset(0x18)] public float MaxDepth; 160 | }; 161 | 162 | [StructLayout(LayoutKind.Explicit)] 163 | public unsafe struct cmdType3 // ScissorsRect 164 | { 165 | [FieldOffset(0x00)] public int SwitchType; 166 | [FieldOffset(0x04)] public uint left; 167 | [FieldOffset(0x08)] public uint top; 168 | [FieldOffset(0x0C)] public uint right; 169 | [FieldOffset(0x10)] public uint bottom; 170 | }; 171 | 172 | [StructLayout(LayoutKind.Explicit)] 173 | public unsafe struct cmdType4 // ClearRendDepth 174 | { 175 | [FieldOffset(0x00)] public int SwitchType; 176 | [FieldOffset(0x04)] public int clearType; 177 | [FieldOffset(0x08)] public float colorB; 178 | [FieldOffset(0x0C)] public float colorG; 179 | [FieldOffset(0x10)] public float colorR; 180 | [FieldOffset(0x14)] public float colorA; 181 | [FieldOffset(0x18)] public float clearDepth; 182 | [FieldOffset(0x1C)] public int clearStencil; 183 | [FieldOffset(0x20)] public int clearCheck; 184 | [FieldOffset(0x24)] public float Top; 185 | [FieldOffset(0x28)] public float Left; 186 | [FieldOffset(0x2C)] public float Width; 187 | [FieldOffset(0x30)] public float Height; 188 | [FieldOffset(0x34)] public float MinZ; 189 | [FieldOffset(0x38)] public float MaxZ; 190 | }; 191 | 192 | [StructLayout(LayoutKind.Explicit)] 193 | public unsafe struct cmdType5 // Draw 194 | { 195 | [FieldOffset(0x00)] public int SwitchType; 196 | [FieldOffset(0x1C)] public uint uk1; 197 | [FieldOffset(0x1F)] public byte uk4; 198 | [FieldOffset(0x6C)] public ptrShaderData* ptrCurrentShaderData; 199 | }; 200 | 201 | [StructLayout(LayoutKind.Explicit)] 202 | public unsafe struct cmdType6 // DrawIndexed 203 | { 204 | [FieldOffset(0x00)] public int SwitchType; 205 | [FieldOffset(0x1C)] public uint uk1; 206 | [FieldOffset(0x1F)] public byte uk4; 207 | [FieldOffset(0x6C)] public ptrShaderData* ptrCurrentShaderData; 208 | }; 209 | 210 | [StructLayout(LayoutKind.Explicit)] 211 | public unsafe struct cmdType7 // DrawIndexedInstance 212 | { 213 | [FieldOffset(0x00)] public int SwitchType; 214 | [FieldOffset(0x20)] public uint uk1; 215 | [FieldOffset(0x23)] public byte uk4; 216 | [FieldOffset(0x70)] public ptrShaderData* ptrCurrentShaderData; 217 | }; 218 | 219 | [StructLayout(LayoutKind.Explicit)] 220 | public unsafe struct cmdType10 // CopyResource 221 | { 222 | [FieldOffset(0x00)] public int SwitchType; 223 | [FieldOffset(0x04)] public int uk1; 224 | [FieldOffset(0x08)] public Texture* Destination; 225 | [FieldOffset(0x10)] public uint subResourceDestination; 226 | [FieldOffset(0x14)] public uint X; 227 | [FieldOffset(0x18)] public uint Y; 228 | [FieldOffset(0x1C)] public uint Z; 229 | [FieldOffset(0x20)] public Texture* Source; 230 | [FieldOffset(0x28)] public uint subResourceSource; 231 | [FieldOffset(0x30)] public float useRect; 232 | [FieldOffset(0x38)] public float rectTop; 233 | [FieldOffset(0x3C)] public float rectLeft; 234 | [FieldOffset(0x40)] public float rectBottom; 235 | [FieldOffset(0x44)] public float rectRight; 236 | }; 237 | 238 | 239 | [StructLayout(LayoutKind.Explicit)] 240 | public unsafe struct cmdUpdateVR 241 | { 242 | [FieldOffset(0x00)] public int SwitchType; 243 | [FieldOffset(0x04)] public int eye; 244 | [FieldOffset(0x08)] public UInt64 nextThreadedBuffer; 245 | [FieldOffset(0x10)] public UInt64 nextThreadedBufferL; 246 | [FieldOffset(0x18)] public UInt64 nextThreadedBufferR; 247 | }; 248 | } 249 | 250 | -------------------------------------------------------------------------------- /xivr/Structures/SceneCameraManager.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace xivr.Structures 4 | { 5 | [StructLayout(LayoutKind.Explicit, Size = 0xF0)] 6 | public unsafe struct SceneCameraManager 7 | { 8 | 9 | [FieldOffset(0x50)] public int CameraIndex; 10 | [FieldOffset(0x58)] public RawGameCamera* Camera0; 11 | [FieldOffset(0x60)] public RawGameCamera* Camera1; 12 | [FieldOffset(0x68)] public RawGameCamera* Camera2; 13 | [FieldOffset(0x70)] public RawGameCamera* Camera3; 14 | [FieldOffset(0x78)] public RawGameCamera* Camera4; 15 | 16 | public RawGameCamera* GetActive(SceneCameraManager* scCameraManager = null) 17 | { 18 | if (scCameraManager != null) 19 | { 20 | CameraIndex = scCameraManager->CameraIndex; 21 | } 22 | 23 | if (CameraIndex == 0) 24 | return Camera0; 25 | else if (CameraIndex == 1) 26 | return Camera1; 27 | else if (CameraIndex == 2) 28 | return Camera2; 29 | else if (CameraIndex == 3) 30 | return Camera3; 31 | else if (CameraIndex == 4) 32 | return Camera4; 33 | else 34 | return Camera0; 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /xivr/Structures/XBoxLayout.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace xivr.Structures 5 | { 6 | public struct XBoxButtonStatus 7 | { 8 | public bool active; 9 | public float value; 10 | public bool ChangedStatus; 11 | public bool ChangedValue; 12 | public void Set() 13 | { 14 | active = false; 15 | value = 0; 16 | ChangedStatus = false; 17 | ChangedValue = false; 18 | } 19 | 20 | public void Set(bool a, float v) 21 | { 22 | ChangedStatus = false; 23 | if (active != a) 24 | { 25 | active = a; 26 | ChangedStatus = true; 27 | } 28 | ChangedValue = false; 29 | if (value != v) 30 | { 31 | value = v; 32 | ChangedValue = true; 33 | } 34 | } 35 | } 36 | 37 | public struct XBoxStatus 38 | { 39 | public XBoxButtonStatus dpad_up; 40 | public XBoxButtonStatus dpad_down; 41 | public XBoxButtonStatus dpad_left; 42 | public XBoxButtonStatus dpad_right; 43 | 44 | public XBoxButtonStatus left_stick_down; 45 | public XBoxButtonStatus left_stick_up; 46 | public XBoxButtonStatus left_stick_left; 47 | public XBoxButtonStatus left_stick_right; 48 | 49 | public XBoxButtonStatus right_stick_down; 50 | public XBoxButtonStatus right_stick_up; 51 | public XBoxButtonStatus right_stick_left; 52 | public XBoxButtonStatus right_stick_right; 53 | 54 | public XBoxButtonStatus button_y; 55 | public XBoxButtonStatus button_b; 56 | public XBoxButtonStatus button_a; 57 | public XBoxButtonStatus button_x; 58 | public XBoxButtonStatus left_bumper; 59 | public XBoxButtonStatus left_trigger; 60 | public XBoxButtonStatus left_stick_click; 61 | public XBoxButtonStatus right_bumper; 62 | public XBoxButtonStatus right_trigger; 63 | public XBoxButtonStatus right_stick_click; 64 | public XBoxButtonStatus start; 65 | public XBoxButtonStatus select; 66 | } 67 | 68 | 69 | [StructLayout(LayoutKind.Explicit, Size = 0xD0)] 70 | public unsafe struct XBoxButtonOffsets 71 | { 72 | [FieldOffset(0x740)] public byte dpad_up; 73 | [FieldOffset(0x741)] public byte dpad_down; 74 | [FieldOffset(0x742)] public byte dpad_left; 75 | [FieldOffset(0x743)] public byte dpad_right; 76 | 77 | [FieldOffset(0x744)] public byte left_stick_down; 78 | [FieldOffset(0x745)] public byte left_stick_up; 79 | [FieldOffset(0x746)] public byte left_stick_left; 80 | [FieldOffset(0x747)] public byte left_stick_right; 81 | 82 | [FieldOffset(0x748)] public byte right_stick_down; 83 | [FieldOffset(0x749)] public byte right_stick_up; 84 | [FieldOffset(0x74A)] public byte right_stick_left; 85 | [FieldOffset(0x74B)] public byte right_stick_right; 86 | 87 | [FieldOffset(0x74C)] public byte button_y; 88 | [FieldOffset(0x74D)] public byte button_b; 89 | [FieldOffset(0x74E)] public byte button_a; 90 | [FieldOffset(0x74F)] public byte button_x; 91 | [FieldOffset(0x750)] public byte left_bumper; 92 | [FieldOffset(0x751)] public byte left_trigger; 93 | [FieldOffset(0x752)] public byte left_stick_click; 94 | [FieldOffset(0x753)] public byte right_bumper; 95 | [FieldOffset(0x754)] public byte right_trigger; 96 | [FieldOffset(0x755)] public byte right_stick_click; 97 | [FieldOffset(0x756)] public byte start; 98 | [FieldOffset(0x757)] public byte select; 99 | } 100 | 101 | 102 | [StructLayout(LayoutKind.Explicit, Size = 0xD0)] 103 | public unsafe struct XBoxLayout 104 | { 105 | [FieldOffset(0x00)] public float start; 106 | [FieldOffset(0x04)] public float select; 107 | [FieldOffset(0x08)] public float left_stick_click; 108 | [FieldOffset(0x0C)] public float right_stick_click; 109 | [FieldOffset(0x10)] public float left_bumper; 110 | [FieldOffset(0x14)] public float right_bumper; 111 | [FieldOffset(0x18)] public float button_a; 112 | [FieldOffset(0x1C)] public float button_b; 113 | [FieldOffset(0x20)] public float button_x; 114 | [FieldOffset(0x24)] public float button_y; 115 | 116 | [FieldOffset(0x80)] public float dpad_left; 117 | [FieldOffset(0x84)] public float dpad_right; 118 | [FieldOffset(0x88)] public float dpad_up; 119 | [FieldOffset(0x8C)] public float dpad_down; 120 | 121 | [FieldOffset(0x90)] public float left_stick_left; 122 | [FieldOffset(0x94)] public float left_stick_right; 123 | [FieldOffset(0x98)] public float left_stick_up; 124 | [FieldOffset(0x9C)] public float left_stick_down; 125 | 126 | [FieldOffset(0xA0)] public float right_stick_left; 127 | [FieldOffset(0xA4)] public float right_stick_right; 128 | [FieldOffset(0xA8)] public float right_stick_up; 129 | [FieldOffset(0xAC)] public float right_stick_down; 130 | 131 | [FieldOffset(0xB4)] public float left_trigger; 132 | [FieldOffset(0xB8)] public float right_trigger; 133 | } 134 | 135 | } 136 | -------------------------------------------------------------------------------- /xivr/Structures/ffxivRenderTargetManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | using FFXIVClientStructs.FFXIV.Client.Graphics.Render; 5 | using FFXIVClientStructs.Interop; 6 | using FFXIVClientStructs.Interop.Attributes; 7 | 8 | namespace xivr.Structures 9 | { 10 | [StructLayout(LayoutKind.Explicit, Size = 1152)] 11 | public struct RenderTargetManager 12 | { 13 | public static class Addresses 14 | { 15 | public static readonly Address Instance = new StaticAddress("RenderTargetManager.Instance", "48 8B 0D ?? ?? ?? ?? 48 8B B1 ?? ?? ?? ?? ?? ??", new ulong[2] { 5188146770731699016uL, 45451uL }, new ulong[2] { 18374686479688400895uL, 65535uL }, (nuint)0u, 3); 16 | } 17 | 18 | public static class StaticAddressPointers 19 | { 20 | public unsafe static RenderTargetManager** ppInstance => (RenderTargetManager**)Addresses.Instance.Value; 21 | } 22 | 23 | [FieldOffset(0)] 24 | public unsafe void* vtbl; 25 | 26 | [FieldOffset(8)] 27 | public Notifier Notifier; 28 | 29 | [FieldOffset(32)] 30 | [FixedSizeArray>(65)] 31 | public unsafe fixed byte RenderTargetArray[520]; 32 | 33 | [FieldOffset(96)] 34 | public unsafe Texture* MainDepthBuffer; 35 | 36 | [FieldOffset(480)] 37 | public unsafe Texture* OffscreenRenderTarget_1; 38 | 39 | [FieldOffset(488)] 40 | public unsafe Texture* OffscreenRenderTarget_2; 41 | 42 | [FieldOffset(496)] 43 | public unsafe Texture* OffscreenRenderTarget_3; 44 | 45 | [FieldOffset(504)] 46 | public unsafe Texture* OffscreenRenderTarget_4; 47 | 48 | [FieldOffset(512)] 49 | public unsafe Texture* OffscreenGBuffer; 50 | 51 | [FieldOffset(520)] 52 | public unsafe Texture* OffscreenDepthStencil; 53 | 54 | [FieldOffset(528)] 55 | public unsafe Texture* OffscreenRenderTarget_Unk1; 56 | 57 | [FieldOffset(536)] 58 | public unsafe Texture* OffscreenRenderTarget_Unk2; 59 | 60 | [FieldOffset(544)] 61 | public unsafe Texture* OffscreenRenderTarget_Unk3; 62 | 63 | [FieldOffset(584)] 64 | public unsafe Texture* MainRenderTarget; 65 | 66 | [FieldOffset(616)] 67 | public uint Resolution_Width; 68 | 69 | [FieldOffset(620)] 70 | public uint Resolution_Height; 71 | 72 | [FieldOffset(624)] 73 | public uint ShadowMap_Width; 74 | 75 | [FieldOffset(628)] 76 | public uint ShadowMap_Height; 77 | 78 | [FieldOffset(632)] 79 | public uint NearShadowMap_Width; 80 | 81 | [FieldOffset(636)] 82 | public uint NearShadowMap_Height; 83 | 84 | [FieldOffset(640)] 85 | public uint FarShadowMap_Width; 86 | 87 | [FieldOffset(644)] 88 | public uint FarShadowMap_Height; 89 | 90 | [FieldOffset(648)] 91 | public bool UnkBool_1; 92 | 93 | [FieldOffset(672)] 94 | [FixedSizeArray>(49)] 95 | public unsafe fixed byte RenderTargetArray2[392]; 96 | 97 | public unsafe Span> RenderTargetArraySpan => new Span>(Unsafe.AsPointer(ref RenderTargetArray[0]), 65); 98 | 99 | public unsafe Span> RenderTargetArray2Span => new Span>(Unsafe.AsPointer(ref RenderTargetArray2[0]), 49); 100 | 101 | [StaticAddress("48 8B 0D ?? ?? ?? ?? 48 8B B1 ?? ?? ?? ??", 3, true)] 102 | public unsafe static RenderTargetManager* Instance() 103 | { 104 | if (StaticAddressPointers.ppInstance == null) 105 | { 106 | throw new InvalidOperationException("Pointer for RenderTargetManager.Instance is null. The resolver was either uninitialized or failed to resolve address with signature 48 8B 0D ?? ?? ?? ?? 48 8B B1 ?? ?? ?? ?? ?? ??."); 107 | } 108 | 109 | return *StaticAddressPointers.ppInstance; 110 | } 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /xivr/Structures/ffxivTexture.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | using FFXIVClientStructs.FFXIV.Client.Graphics.Render; 4 | 5 | namespace xivr.Structures 6 | { 7 | [StructLayout(LayoutKind.Explicit, Size = 168)] 8 | public unsafe struct Texture 9 | { 10 | [FieldOffset(0x00)] public void* vtbl; 11 | [FieldOffset(0x08)] public int RefCount; 12 | [FieldOffset(0x18)] public long uk5; 13 | [FieldOffset(0x20)] public Notifier Notifier; 14 | [FieldOffset(0x38)] public uint Width; 15 | [FieldOffset(0x3C)] public uint Height; 16 | [FieldOffset(0x40)] public uint Width1; 17 | [FieldOffset(0x44)] public uint Height1; 18 | [FieldOffset(0x48)] public uint Width2; 19 | [FieldOffset(0x4C)] public uint Height2; 20 | [FieldOffset(0x50)] public uint Depth; 21 | [FieldOffset(0x54)] public byte MipLevel; 22 | [FieldOffset(0x58)] public TextureFormat TextureFormat; 23 | [FieldOffset(0x5C)] public uint Flags; 24 | [FieldOffset(0x68)] public unsafe void* D3D11Texture2D; 25 | [FieldOffset(0x70)] public unsafe void* D3D11ShaderResourceView; 26 | [FieldOffset(0x80)] public UInt64 D3D11RenderTargetPtr; 27 | } 28 | } -------------------------------------------------------------------------------- /xivr/VRCursor.cs: -------------------------------------------------------------------------------- 1 | using Dalamud.Logging; 2 | using FFXIVClientStructs.FFXIV.Client.System.Memory; 3 | using FFXIVClientStructs.FFXIV.Component.GUI; 4 | using static FFXIVClientStructs.FFXIV.Client.UI.AddonNamePlate; 5 | 6 | namespace xivr 7 | { 8 | 9 | public static unsafe class VRCursor 10 | { 11 | private static NamePlateObject* currentNPTarget = null; 12 | 13 | public static unsafe bool SetupVRTargetCursor(AtkTextNode** vrTrgCursor, int targetCursorSize) 14 | { 15 | if ((*vrTrgCursor) != null) 16 | { 17 | return true; 18 | } 19 | 20 | (*vrTrgCursor) = (AtkTextNode*)IMemorySpace.GetUISpace()->Malloc((ulong)sizeof(AtkTextNode), 8); 21 | if ((*vrTrgCursor) == null) 22 | { 23 | PluginLog.Debug("Failed to allocate memory for text node"); 24 | return false; 25 | } 26 | IMemorySpace.Memset((*vrTrgCursor), 0, (ulong)sizeof(AtkTextNode)); 27 | (*vrTrgCursor)->Ctor(); 28 | 29 | (*vrTrgCursor)->AtkResNode.Type = NodeType.Text; 30 | (*vrTrgCursor)->AtkResNode.Flags = (short)(NodeFlags.UseDepthBasedPriority); 31 | (*vrTrgCursor)->AtkResNode.DrawFlags = 12; 32 | 33 | (*vrTrgCursor)->LineSpacing = 12; 34 | (*vrTrgCursor)->AlignmentFontType = 4; 35 | (*vrTrgCursor)->FontSize = (byte)targetCursorSize; 36 | (*vrTrgCursor)->TextFlags = (byte)(TextFlags.AutoAdjustNodeSize | TextFlags.Edge); 37 | (*vrTrgCursor)->TextFlags2 = 0; 38 | 39 | (*vrTrgCursor)->SetText("↓"); 40 | 41 | (*vrTrgCursor)->AtkResNode.ToggleVisibility(true); 42 | 43 | (*vrTrgCursor)->AtkResNode.SetPositionShort(90, -23); 44 | ushort outWidth = 0; 45 | ushort outHeight = 0; 46 | (*vrTrgCursor)->GetTextDrawSize(&outWidth, &outHeight); 47 | (*vrTrgCursor)->AtkResNode.SetWidth((ushort)(outWidth)); 48 | (*vrTrgCursor)->AtkResNode.SetHeight((ushort)(outHeight)); 49 | 50 | // white fill 51 | (*vrTrgCursor)->TextColor.R = 255; 52 | (*vrTrgCursor)->TextColor.G = 255; 53 | (*vrTrgCursor)->TextColor.B = 255; 54 | (*vrTrgCursor)->TextColor.A = 255; 55 | 56 | // yellow/golden glow 57 | (*vrTrgCursor)->EdgeColor.R = 235; 58 | (*vrTrgCursor)->EdgeColor.G = 185; 59 | (*vrTrgCursor)->EdgeColor.B = 7; 60 | (*vrTrgCursor)->EdgeColor.A = 255; 61 | 62 | return true; 63 | } 64 | 65 | public static void FreeVRTargetCursor(AtkTextNode** vrTrgCursor) 66 | { 67 | if ((*vrTrgCursor) != null) 68 | { 69 | if (currentNPTarget != null) 70 | RemoveVRCursor(vrTrgCursor, currentNPTarget); 71 | 72 | currentNPTarget = null; 73 | 74 | (*vrTrgCursor)->AtkResNode.Destroy(true); 75 | (*vrTrgCursor) = null; 76 | } 77 | } 78 | 79 | public static void AddVRCursor(AtkTextNode** vrTrgCursor, NamePlateObject* nameplate) 80 | { 81 | if (nameplate != null && (*vrTrgCursor) != null) 82 | { 83 | var npComponent = nameplate->RootNode->Component; 84 | 85 | var lastChild = npComponent->UldManager.RootNode; 86 | while (lastChild->PrevSiblingNode != null) lastChild = lastChild->PrevSiblingNode; 87 | 88 | lastChild->PrevSiblingNode = (AtkResNode*)(*vrTrgCursor); 89 | (*vrTrgCursor)->AtkResNode.NextSiblingNode = lastChild; 90 | (*vrTrgCursor)->AtkResNode.ParentNode = (AtkResNode*)nameplate->RootNode; 91 | 92 | npComponent->UldManager.UpdateDrawNodeList(); 93 | } 94 | } 95 | 96 | public static void RemoveVRCursor(AtkTextNode** vrTrgCursor, NamePlateObject* nameplate) 97 | { 98 | if (nameplate != null && (*vrTrgCursor) != null) 99 | { 100 | var npComponent = nameplate->RootNode->Component; 101 | 102 | var lastChild = npComponent->UldManager.RootNode; 103 | while (lastChild->PrevSiblingNode != null) lastChild = lastChild->PrevSiblingNode; 104 | 105 | if (lastChild == (*vrTrgCursor)) 106 | { 107 | lastChild->NextSiblingNode->PrevSiblingNode = null; 108 | 109 | (*vrTrgCursor)->AtkResNode.NextSiblingNode = null; 110 | (*vrTrgCursor)->AtkResNode.ParentNode = null; 111 | 112 | npComponent->UldManager.UpdateDrawNodeList(); 113 | } 114 | else 115 | { 116 | PluginLog.Error("RemoveVRCursor: lastChild != vrTargetCursor"); 117 | } 118 | } 119 | } 120 | 121 | public static void UpdateVRCursorSize(AtkTextNode** vrTrgCursor, int targetCursorSize) 122 | { 123 | if ((*vrTrgCursor) == null) return; 124 | 125 | (*vrTrgCursor)->FontSize = (byte)targetCursorSize; 126 | ushort outWidth = 0; 127 | ushort outHeight = 0; 128 | (*vrTrgCursor)->GetTextDrawSize(&outWidth, &outHeight); 129 | (*vrTrgCursor)->AtkResNode.SetWidth(outWidth); 130 | (*vrTrgCursor)->AtkResNode.SetHeight(outHeight); 131 | 132 | // explanation of these numbers 133 | // Some setup info: 134 | // 1. The ↓ character output from GetTextDrawSize is always 1:1 with the 135 | // requested font. Font size 100 results in outWidth 100 and outHeight 100. 136 | // 2. The anchor point for text fields are the upper left corner of the frame. 137 | // 3. The hand-tuned position of the default font size 100 is x 90, y -23. 138 | // 139 | // Adding the inverted delta offset (and div by 2 for x) correctly moves the ancor 140 | // from upper left to bottom center. However I noticed that as the font scales 141 | // up and down, the point of the arrow drifts slightly along the x and y. This 142 | // is the reason for the * 1.10 and * 1.15. This corrects for the drift and keeps 143 | // the point of the arrow exactly where it should be. 144 | 145 | const float DriftOffset_X = 1.10f; 146 | const float DriftOffset_Y = 1.15f; 147 | 148 | short xpos = (short)(90 + ((100 - outWidth) / 2 * DriftOffset_X)); 149 | short ypos = (short)(-23 + (100 - outWidth) * DriftOffset_Y); 150 | (*vrTrgCursor)->AtkResNode.SetPositionShort(xpos, ypos); 151 | } 152 | 153 | public static void SetVRCursor(AtkTextNode** vrTrgCursor, NamePlateObject* nameplate) 154 | { 155 | // nothing to do! 156 | if (currentNPTarget == nameplate) 157 | return; 158 | 159 | if ((*vrTrgCursor) != null) 160 | { 161 | if (currentNPTarget != null) 162 | { 163 | RemoveVRCursor(vrTrgCursor, currentNPTarget); 164 | currentNPTarget = null; 165 | } 166 | 167 | if (nameplate != null) 168 | { 169 | AddVRCursor(vrTrgCursor, nameplate); 170 | currentNPTarget = nameplate; 171 | } 172 | } 173 | } 174 | } 175 | } 176 | -------------------------------------------------------------------------------- /xivr/images/audio_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProjectMimer/xivr/cba8ab388c968ec558090dc14264d9a151bacf43/xivr/images/audio_off.png -------------------------------------------------------------------------------- /xivr/images/audio_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProjectMimer/xivr/cba8ab388c968ec558090dc14264d9a151bacf43/xivr/images/audio_on.png -------------------------------------------------------------------------------- /xivr/images/blank.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProjectMimer/xivr/cba8ab388c968ec558090dc14264d9a151bacf43/xivr/images/blank.png -------------------------------------------------------------------------------- /xivr/images/dalamud_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProjectMimer/xivr/cba8ab388c968ec558090dc14264d9a151bacf43/xivr/images/dalamud_off.png -------------------------------------------------------------------------------- /xivr/images/dalamud_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProjectMimer/xivr/cba8ab388c968ec558090dc14264d9a151bacf43/xivr/images/dalamud_on.png -------------------------------------------------------------------------------- /xivr/images/hide_ui_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProjectMimer/xivr/cba8ab388c968ec558090dc14264d9a151bacf43/xivr/images/hide_ui_off.png -------------------------------------------------------------------------------- /xivr/images/hide_ui_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProjectMimer/xivr/cba8ab388c968ec558090dc14264d9a151bacf43/xivr/images/hide_ui_on.png -------------------------------------------------------------------------------- /xivr/images/keyboard_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProjectMimer/xivr/cba8ab388c968ec558090dc14264d9a151bacf43/xivr/images/keyboard_off.png -------------------------------------------------------------------------------- /xivr/images/keyboard_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProjectMimer/xivr/cba8ab388c968ec558090dc14264d9a151bacf43/xivr/images/keyboard_on.png -------------------------------------------------------------------------------- /xivr/images/occlusion_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProjectMimer/xivr/cba8ab388c968ec558090dc14264d9a151bacf43/xivr/images/occlusion_off.png -------------------------------------------------------------------------------- /xivr/images/occlusion_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProjectMimer/xivr/cba8ab388c968ec558090dc14264d9a151bacf43/xivr/images/occlusion_on.png -------------------------------------------------------------------------------- /xivr/images/recenter_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProjectMimer/xivr/cba8ab388c968ec558090dc14264d9a151bacf43/xivr/images/recenter_off.png -------------------------------------------------------------------------------- /xivr/images/recenter_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProjectMimer/xivr/cba8ab388c968ec558090dc14264d9a151bacf43/xivr/images/recenter_on.png -------------------------------------------------------------------------------- /xivr/images/weapon_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProjectMimer/xivr/cba8ab388c968ec558090dc14264d9a151bacf43/xivr/images/weapon_off.png -------------------------------------------------------------------------------- /xivr/images/weapon_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProjectMimer/xivr/cba8ab388c968ec558090dc14264d9a151bacf43/xivr/images/weapon_on.png -------------------------------------------------------------------------------- /xivr/images/xivr_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProjectMimer/xivr/cba8ab388c968ec558090dc14264d9a151bacf43/xivr/images/xivr_off.png -------------------------------------------------------------------------------- /xivr/images/xivr_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProjectMimer/xivr/cba8ab388c968ec558090dc14264d9a151bacf43/xivr/images/xivr_on.png -------------------------------------------------------------------------------- /xivr/packages.lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "dependencies": { 4 | "net7.0-windows7.0": { 5 | "DalamudPackager": { 6 | "type": "Direct", 7 | "requested": "[2.1.10, )", 8 | "resolved": "2.1.10", 9 | "contentHash": "S6NrvvOnLgT4GDdgwuKVJjbFo+8ZEj+JsEYk9ojjOR/MMfv1dIFpT8aRJQfI24rtDcw1uF+GnSSMN4WW1yt7fw==" 10 | } 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /xivr/xivr.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 0.0.5.3 7 | XIVR. 8 | 9 | 10 | 11 | 12 | 13 | net7.0-windows 14 | x64 15 | enable 16 | latest 17 | true 18 | false 19 | false 20 | true 21 | 22 | 23 | 24 | $(appdata)\XIVLauncher\addon\Hooks\dev\ 25 | True 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | PreserveNewest 44 | 45 | 46 | 47 | 48 | PreserveNewest 49 | 50 | 51 | 52 | 53 | PreserveNewest 54 | config/actions.json 55 | 56 | 57 | 58 | 59 | PreserveNewest 60 | config/index-marulu-230324.json 61 | 62 | 63 | 64 | 65 | PreserveNewest 66 | config/touch-marulu-230324.json 67 | 68 | 69 | 70 | 71 | 72 | PreserveNewest 73 | false 74 | 75 | 76 | PreserveNewest 77 | false 78 | 79 | 80 | PreserveNewest 81 | false 82 | 83 | 84 | PreserveNewest 85 | false 86 | 87 | 88 | PreserveNewest 89 | false 90 | 91 | 92 | PreserveNewest 93 | false 94 | 95 | 96 | PreserveNewest 97 | false 98 | 99 | 100 | PreserveNewest 101 | false 102 | 103 | 104 | PreserveNewest 105 | false 106 | 107 | 108 | PreserveNewest 109 | false 110 | 111 | 112 | PreserveNewest 113 | false 114 | 115 | 116 | PreserveNewest 117 | false 118 | 119 | 120 | PreserveNewest 121 | false 122 | 123 | 124 | PreserveNewest 125 | false 126 | 127 | 128 | PreserveNewest 129 | false 130 | 131 | 132 | PreserveNewest 133 | false 134 | 135 | 136 | PreserveNewest 137 | false 138 | 139 | 140 | 141 | 142 | 143 | 144 | $(DalamudLibPath)FFXIVClientStructs.dll 145 | false 146 | 147 | 148 | $(DalamudLibPath)Newtonsoft.Json.dll 149 | false 150 | 151 | 152 | $(DalamudLibPath)Dalamud.dll 153 | false 154 | 155 | 156 | $(DalamudLibPath)ImGui.NET.dll 157 | false 158 | 159 | 160 | $(DalamudLibPath)ImGuiScene.dll 161 | false 162 | 163 | 164 | $(DalamudLibPath)Lumina.dll 165 | false 166 | 167 | 168 | $(DalamudLibPath)Lumina.Excel.dll 169 | false 170 | 171 | 172 | 173 | -------------------------------------------------------------------------------- /xivr/xivr.json: -------------------------------------------------------------------------------- 1 | { 2 | "Author": "Marulu, StreetRat", 3 | "Name": "XIVR - VR Mod", 4 | "InternalName": "xivr", 5 | "AssemblyVersion": "0.0.5.3", 6 | "Description": "** Requires SteamVR **\nThe following Settings have to be enabled for the mod to operate:\nIn XIVLauncher: Choose how to load dalamud: New\nIn InGame Dalamud Settings: Wait for plugins before game loads\n\nPlease click the globe icon for detailed instructions.\nChat/FAQ: flat2vr.com", 7 | "ApplicableVersion": "any", 8 | "RepoUrl": "https://github.com/ProjectMimer/xivr", 9 | "Tags": [ 10 | "utility" 11 | ], 12 | "DalamudApiLevel": 8, 13 | "LoadPriority": 0, 14 | "LoadRequiredState": 2, 15 | "LoadSync": true, 16 | "Punchline": "Mod to allow VR", 17 | "AcceptsFeedback": true 18 | } 19 | -------------------------------------------------------------------------------- /xivr/xivr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProjectMimer/xivr/cba8ab388c968ec558090dc14264d9a151bacf43/xivr/xivr.png -------------------------------------------------------------------------------- /xivr_main/BasicRenderer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #define WIN32_LEAN_AND_MEAN 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "stCommon.h" 9 | #include "Configuration.h" 10 | #include "RenderObject.h" 11 | 12 | using namespace DirectX; 13 | 14 | struct stMatrixSet 15 | { 16 | XMMATRIX projectionMatrix; 17 | XMMATRIX gameWorldMatrixFloating; 18 | XMMATRIX gameWorldMatrix; 19 | XMMATRIX hmdMatrix; 20 | XMMATRIX eyeMatrix; 21 | XMMATRIX rhcMatrix; 22 | XMMATRIX lhcMatrix; 23 | Vector4 oskOffset; 24 | }; 25 | 26 | struct VertexType 27 | { 28 | float position[3]; 29 | float texture[2]; 30 | }; 31 | 32 | struct VertexTypeColor 33 | { 34 | float position[3]; 35 | float color[4]; 36 | }; 37 | 38 | struct stMatrixBuffer 39 | { 40 | XMMATRIX world; 41 | XMMATRIX view; 42 | XMMATRIX projection; 43 | }; 44 | 45 | struct stMouseBuffer 46 | { 47 | XMFLOAT2 radiusR; 48 | XMFLOAT2 coordsR; 49 | XMFLOAT2 radiusB; 50 | XMFLOAT2 coordsB; 51 | }; 52 | 53 | class BasicRenderer 54 | { 55 | ID3D11Device* dev; 56 | ID3D11DeviceContext* devcon; 57 | 58 | ID3D11VertexShader* pVS = nullptr; 59 | ID3D11PixelShader* pPS = nullptr; 60 | ID3D11PixelShader* pPS1 = nullptr; 61 | ID3D11VertexShader* pVSColor = nullptr; 62 | ID3D11PixelShader* pPSColor = nullptr; 63 | ID3D11InputLayout* pLayout = nullptr; 64 | ID3D11InputLayout* pLayoutColor = nullptr; 65 | ID3D11Buffer* pMatrixBuffer = nullptr; 66 | ID3D11Buffer* pMouseBuffer = nullptr; 67 | ID3D11SamplerState* pSampleState = nullptr; 68 | ID3D11BlendState* pBlendState[3] = { nullptr, nullptr, nullptr }; 69 | ID3D11DepthStencilState* pDepthStateOff = nullptr; 70 | ID3D11DepthStencilState* pDepthStateOn = nullptr; 71 | ID3D11RasterizerState* pRasterizerState = nullptr; 72 | 73 | stMatrixBuffer matrixBuffer = stMatrixBuffer(); 74 | stMouseBuffer mouseBuffer = stMouseBuffer(); 75 | std::stringstream logError; 76 | 77 | VertexType uiVertices[32][3] = {}; 78 | short uiIndices[32][3] = {}; 79 | float uiNormals[32][3] = {}; 80 | XMMATRIX uiMatrix = XMMatrixIdentity(); 81 | 82 | stConfiguration* cfg; 83 | bool disableBlend = false; 84 | int blendIndex = 0; 85 | RenderObject orthogSquare; 86 | RenderObject curvedUI; 87 | RenderObject osk; 88 | RenderObject colorCube; 89 | RenderObject rayLine; 90 | RenderObject handSquare[9]; 91 | RenderObject lineObj; 92 | 93 | bool curvedUIAtUI = false; 94 | bool oskAtUI = false; 95 | bool handSquareAtUI[9] = {}; 96 | int handSquareCount = sizeof(handSquare) / sizeof(RenderObject); 97 | bool needsRecenter = true; 98 | 99 | bool haveSaved = false; 100 | ID3D11BlendState* savedBlendState = nullptr; 101 | float savedBlendFactor[4] = { 0.f, 0.f, 0.f, 0.f }; 102 | UINT savedSampleMask = 0; 103 | ID3D11DepthStencilState* savedDepthStencilState = nullptr; 104 | UINT savedStencilRef = 0; 105 | ID3D11RenderTargetView* savedRenderTargetView = nullptr; 106 | ID3D11DepthStencilView* savedDepthStencilView = nullptr; 107 | ID3D11SamplerState* savedSampleState = nullptr; 108 | D3D_PRIMITIVE_TOPOLOGY savedPrimitiveTopology = D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST; 109 | UINT savedNumViewports; 110 | D3D11_VIEWPORT savedViewport; 111 | ID3D11InputLayout* savedInputLayout = nullptr; 112 | ID3D11VertexShader* savedVertexShader = nullptr; 113 | ID3D11ClassInstance* savedVertexClassInstance = nullptr; 114 | UINT savedVertexNumClassInstance = 0; 115 | ID3D11PixelShader* savedPixelShader = nullptr; 116 | ID3D11ClassInstance* savedPixelClassInstance = nullptr; 117 | UINT savedPixelNumClassInstance = 0; 118 | ID3D11Buffer* savedVSBuffer = nullptr; 119 | ID3D11Buffer* savedPSBuffer = nullptr; 120 | ID3D11Buffer* savedVertexBuffer = nullptr; 121 | UINT savedVertexStride = 0; 122 | UINT savedVertexOffset = 0; 123 | ID3D11Buffer* savedIndexBuffer = nullptr; 124 | DXGI_FORMAT savedIndexFormat = DXGI_FORMAT_R16_UINT; 125 | UINT savedIndexOffset = 0; 126 | 127 | bool CompileShaderFromString(std::string shaderSource, std::string shaderName, std::string target, ID3D10Blob** shader); 128 | bool CreateShaders(); 129 | void DestroyShaders(); 130 | bool CreateBuffers(); 131 | void DestroyBuffers(); 132 | void MapResource(ID3D11Buffer* buffer, void* data, int size); 133 | 134 | public: 135 | BasicRenderer(stConfiguration* config); 136 | BasicRenderer(ID3D11Device* tdev, ID3D11DeviceContext* tdevcon); 137 | ~BasicRenderer(); 138 | bool SetDevice(ID3D11Device* tdev, ID3D11DeviceContext* tdevcon); 139 | void SetMousePosition(HWND hwnd, int mouseX, int mouseY, bool forceMouse = false); 140 | void SetMouseBuffer(HWND hwnd, int width, int height, int mouseX, int mouseY, bool dalamudMode); 141 | void RunFrameUpdate(stScreenLayout* screenLayout, stScreenLayout* oskLayout, XMMATRIX rayMatrix, Vector4 oskOffset, poseType inputType, bool dalamudMode, bool showOSK); 142 | void RenderLines(std::vector> LineRender); 143 | void DoRender(D3D11_VIEWPORT viewport, ID3D11RenderTargetView* rtv, ID3D11ShaderResourceView* srv, ID3D11DepthStencilView* dsv, stMatrixSet* matrixSet, bool isOrthog = false); 144 | void SaveSettings(); 145 | void LoadSettings(); 146 | void SetRenderTarget(ID3D11RenderTargetView* rtv, ID3D11DepthStencilView* dsv); 147 | void SetClearColor(ID3D11RenderTargetView* rtv, ID3D11DepthStencilView* dsv, float color[], bool clearDepth = false); 148 | void SetBlendIndex(int index); 149 | void DoRenderRay(D3D11_VIEWPORT viewport, stMatrixSet* matrixSet); 150 | void DoRenderLine(D3D11_VIEWPORT viewport, stMatrixSet* matrixSet); 151 | void DoRender(D3D11_VIEWPORT viewport, ID3D11ShaderResourceView* srv, stMatrixSet* matrixSet, int blendIndex, bool useDepth, bool isOrthog = false, bool moveOrthog = false); 152 | void DoRenderOSK(D3D11_VIEWPORT viewport, ID3D11ShaderResourceView* srv, stMatrixSet* matrixSet, int blendIndex, bool useDepth); 153 | void DoRenderWatch(D3D11_VIEWPORT viewport, ID3D11ShaderResourceView* srv[], stMatrixSet* matrixSet, int blendIndex); 154 | void GetUIStatus(bool* status, int count); 155 | void Release(); 156 | bool HasErrors(); 157 | std::string GetErrors(); 158 | }; -------------------------------------------------------------------------------- /xivr_main/Configuration.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #define WIN32_LEAN_AND_MEAN 3 | #include 4 | 5 | struct stConfiguration 6 | { 7 | int resetValue; 8 | int languageType; 9 | bool isEnabled; 10 | bool isAutoEnabled; 11 | bool autoResize; 12 | bool autoMove; 13 | bool runRecenter; 14 | bool vLog; 15 | bool hmdPointing; 16 | bool forceFloatingScreen; 17 | bool forceFloatingInCutscene; 18 | bool horizontalLock; 19 | bool verticalLock; 20 | bool horizonLock; 21 | bool conloc; 22 | bool hmdloc; 23 | bool vertloc; 24 | bool motioncontrol; 25 | bool showWeaponInHand; 26 | float offsetAmountX; 27 | float offsetAmountY; 28 | float offsetAmountZ; 29 | float offsetAmountYFPS; 30 | float offsetAmountZFPS; 31 | float offsetAmountYFPSMount; 32 | float offsetAmountZFPSMount; 33 | float snapRotateAmountX; 34 | float snapRotateAmountY; 35 | bool uiDepth; 36 | float uiOffsetZ; 37 | float uiOffsetScale; 38 | float ipdOffset; 39 | bool swapEyes; 40 | bool swapEyesUI; 41 | int hmdWidth; 42 | int hmdHeight; 43 | int targetCursorSize; 44 | bool asymmetricProjection; 45 | bool mode2d; 46 | bool immersiveMovement; 47 | bool immersiveFull; 48 | bool ultrawideshadows; 49 | bool osk; 50 | }; -------------------------------------------------------------------------------- /xivr_main/OSK.cpp: -------------------------------------------------------------------------------- 1 | #include "OSK.h" 2 | 3 | typedef BOOL(WINAPI* DwmGetDxSharedSurface_td) ( 4 | __in HWND hwnd, 5 | __out_opt HANDLE* p1, 6 | __out_opt LUID* p2, 7 | __out_opt ULONG* p3, 8 | __out_opt ULONG* p4, 9 | __out_opt ULONGLONG* p5); 10 | 11 | DwmGetDxSharedSurface_td DwmGetSharedSurface = ((DwmGetDxSharedSurface_td)GetProcAddress(GetModuleHandle(TEXT("USER32")), "DwmGetDxSharedSurface")); 12 | 13 | 14 | 15 | PROCESSENTRY32 OSK::FindProcess(std::wstring toFind) 16 | { 17 | PROCESSENTRY32 entry; 18 | entry.dwSize = sizeof(PROCESSENTRY32); 19 | 20 | HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); 21 | if (snapshot == INVALID_HANDLE_VALUE) 22 | return PROCESSENTRY32(); 23 | if (!Process32First(snapshot, &entry)) 24 | return PROCESSENTRY32(); 25 | 26 | do 27 | { 28 | std::wstring fileName(entry.szExeFile); 29 | if (fileName == toFind) 30 | { 31 | CloseHandle(snapshot); 32 | return entry; 33 | } 34 | } while (Process32Next(snapshot, &entry)); 35 | CloseHandle(snapshot); 36 | return PROCESSENTRY32(); 37 | } 38 | 39 | void OSK::ToggleOSK() 40 | { 41 | INPUT input[6]; 42 | ZeroMemory(input, sizeof(INPUT) * 6); 43 | input[0].type = INPUT_KEYBOARD; 44 | input[0].ki.wVk = VK_LCONTROL; 45 | input[0].ki.dwFlags = 0; 46 | input[1].type = INPUT_KEYBOARD; 47 | input[1].ki.wVk = VK_LWIN; 48 | input[1].ki.dwFlags = 0; 49 | input[2].type = INPUT_KEYBOARD; 50 | input[2].ki.wVk = VkKeyScan('O'); 51 | input[2].ki.dwFlags = 0; 52 | 53 | input[3].type = INPUT_KEYBOARD; 54 | input[3].ki.wVk = VkKeyScan('O'); 55 | input[3].ki.dwFlags = KEYEVENTF_KEYUP; 56 | input[4].type = INPUT_KEYBOARD; 57 | input[4].ki.wVk = VK_LWIN; 58 | input[4].ki.dwFlags = KEYEVENTF_KEYUP; 59 | input[5].type = INPUT_KEYBOARD; 60 | input[5].ki.wVk = VK_LCONTROL; 61 | input[5].ki.dwFlags = KEYEVENTF_KEYUP; 62 | SendInput(6, input, sizeof(INPUT)); 63 | } 64 | 65 | void OSK::CreateOSKTexture(ID3D11Device* device, stBasicTexture* oskTexture) 66 | { 67 | //---- 68 | // Creates the given texture to be a copy of the onscreen keyboard 69 | //---- 70 | if (oskSharedTexture.pTexture) { oskSharedTexture.Release(); } 71 | if (oskTexture->pTexture) { oskTexture->Release(); } 72 | 73 | if (oskLayout.hwnd) 74 | { 75 | //---- 76 | // Get the position of the keyboard and get the very top left point of the keyboard window 77 | // to remove the top bar and border 78 | //---- 79 | RECT rect; 80 | GetWindowRect(oskLayout.hwnd, &rect); 81 | 82 | POINT point = { rect.left, rect.top }; 83 | ScreenToClient(oskLayout.hwnd, &point); 84 | displayRect.left = std::abs(point.x); 85 | displayRect.top = std::abs(point.y); 86 | 87 | //---- 88 | // Get the actual client size of the keyboard 89 | //---- 90 | GetClientRect(oskLayout.hwnd, &rect); 91 | displayRect.right = rect.right; 92 | displayRect.bottom = rect.bottom; 93 | } 94 | 95 | if (oskSharedTexture.Create(device, false, false, true)) 96 | { 97 | oskSharedTexture.pTexture->GetDesc(&oskSharedTexture.textureDesc); 98 | 99 | oskTexture->textureDesc = oskSharedTexture.textureDesc; 100 | oskTexture->textureDesc.Width = displayRect.right; 101 | oskTexture->textureDesc.Height = displayRect.bottom; 102 | oskTexture->Create(device, false, true, false); 103 | 104 | oskLayout.width = oskTexture->textureDesc.Width; 105 | oskLayout.height = oskTexture->textureDesc.Height; 106 | oskLayout.haveLayout = true; 107 | } 108 | } 109 | 110 | void OSK::CopyOSKTexture(ID3D11Device* device, ID3D11DeviceContext* devCon, stBasicTexture* oskTexture) 111 | { 112 | //---- 113 | // Copy the on screen keyboard to the given texture 114 | //---- 115 | if (oskLayout.hwnd) 116 | { 117 | LUID adapter = LUID(); 118 | ULONG pFmtWindow = 0; 119 | ULONG pPresentFlags = 0; 120 | ULONGLONG pWin32kUpdateId = 0; 121 | HANDLE toskSurface; 122 | 123 | DwmGetSharedSurface(oskLayout.hwnd, &toskSurface, &adapter, &pFmtWindow, &pPresentFlags, &pWin32kUpdateId); 124 | if (toskSurface != oskSharedTexture.pSharedHandle) 125 | { 126 | oskSharedTexture.pSharedHandle = toskSurface; 127 | CreateOSKTexture(device, oskTexture); 128 | } 129 | 130 | //devCon->CopyResource(oskTexture->pTexture, oskSharedTexture.pTexture); 131 | D3D11_BOX oskTextureCutout = { displayRect.left, displayRect.top, 0, displayRect.left + displayRect.right, displayRect.top + displayRect.bottom, 1 }; 132 | devCon->CopySubresourceRegion(oskTexture->pTexture, 0, 0, 0, 0, oskSharedTexture.pTexture, 0, &oskTextureCutout); 133 | } 134 | } 135 | 136 | bool OSK::LoadOSK(ID3D11Device* device, stBasicTexture* oskTexture, RECT position) 137 | { 138 | //---- 139 | // Find the on screen keyboard, if it isnt loaded, load it and wait for it to be found 140 | // otherwise resize it and create the texture 141 | //---- 142 | 143 | bool haveFoundKeyboard = false; 144 | int haveFoundKeyboardCount = 100; 145 | 146 | PROCESSENTRY32 osk = FindProcess(L"osk.exe"); 147 | if (osk.th32ProcessID != 0) 148 | { 149 | haveFoundKeyboard = true; 150 | } 151 | else if (osk.th32ProcessID == 0) 152 | { 153 | ToggleOSK(); 154 | while (!haveFoundKeyboard && haveFoundKeyboardCount > 0) 155 | { 156 | osk = FindProcess(L"osk.exe"); 157 | if (osk.th32ProcessID != 0) 158 | haveFoundKeyboard = true; 159 | haveFoundKeyboardCount--; 160 | } 161 | } 162 | 163 | if (haveFoundKeyboard) 164 | { 165 | oskLayout.hwnd = FindWindow(L"OSKMainClass", NULL); 166 | if (oskLayout.hwnd) { 167 | LUID adapter = LUID(); 168 | ULONG pFmtWindow = 0; 169 | ULONG pPresentFlags = 0; 170 | ULONGLONG pWin32kUpdateId = 0; 171 | 172 | DwmGetSharedSurface(oskLayout.hwnd, &oskSharedTexture.pSharedHandle, &adapter, &pFmtWindow, &pPresentFlags, &pWin32kUpdateId); 173 | 174 | if (oskSharedTexture.pSharedHandle != 0) 175 | { 176 | SetWindowPos(oskLayout.hwnd, 0, position.left, position.top, position.right, position.bottom, SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED); 177 | SendMessageA(oskLayout.hwnd, WM_EXITSIZEMOVE, WPARAM(0), LPARAM(0)); 178 | CreateOSKTexture(device, oskTexture); 179 | } 180 | } 181 | } 182 | return haveFoundKeyboard; 183 | } 184 | 185 | stScreenLayout* OSK::GetOSKLayout() 186 | { 187 | return &oskLayout; 188 | } 189 | 190 | void OSK::ShowHide(bool show) 191 | { 192 | HWND curActiveWin = GetActiveWindow(); 193 | SetActiveWindow(oskLayout.hwnd); 194 | if (show) 195 | ShowWindow(oskLayout.hwnd, SW_SHOW); 196 | else 197 | ShowWindow(oskLayout.hwnd, SW_HIDE); 198 | SetActiveWindow(curActiveWin); 199 | } 200 | 201 | void OSK::UnloadOSK() 202 | { 203 | if (oskLayout.hwnd != 0) 204 | { 205 | PROCESSENTRY32 osk = FindProcess(L"osk.exe"); 206 | if (osk.th32ProcessID != 0) 207 | ToggleOSK(); 208 | oskLayout = stScreenLayout(); 209 | oskSharedTexture.Release(); 210 | } 211 | } 212 | -------------------------------------------------------------------------------- /xivr_main/OSK.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #define WIN32_LEAN_AND_MEAN 3 | // Windows Header Files 4 | #include 5 | #include 6 | #include 7 | #include "stCommon.h" 8 | 9 | class OSK 10 | { 11 | stScreenLayout oskLayout = stScreenLayout(); 12 | stBasicTexture oskSharedTexture = stBasicTexture(); 13 | RECT displayRect = { 0, 0, 0, 0 }; 14 | PROCESSENTRY32 FindProcess(std::wstring toFind); 15 | 16 | public: 17 | void ToggleOSK(); 18 | void CreateOSKTexture(ID3D11Device* device, stBasicTexture* oskTexture); 19 | void CopyOSKTexture(ID3D11Device* device, ID3D11DeviceContext* devCon, stBasicTexture* oskTexture); 20 | bool LoadOSK(ID3D11Device* device, stBasicTexture* oskTexture, RECT position); 21 | stScreenLayout* GetOSKLayout(); 22 | void ShowHide(bool show); 23 | void UnloadOSK(); 24 | }; 25 | 26 | -------------------------------------------------------------------------------- /xivr_main/RenderObject.cpp: -------------------------------------------------------------------------------- 1 | #include "RenderObject.h" 2 | 3 | 4 | RenderObject::RenderObject() : dev(nullptr), devcon(nullptr) 5 | { 6 | } 7 | 8 | RenderObject::RenderObject(ID3D11Device* tdev, ID3D11DeviceContext* tdevcon) : dev(tdev), devcon(tdevcon) 9 | { 10 | } 11 | 12 | bool RenderObject::SetVertexBuffer(std::vector vertices, int itmStride, D3D11_USAGE usage) 13 | { 14 | vertexList = vertices; 15 | stride = itmStride; 16 | byteStride = stride * sizeof(float); 17 | vertexCount = (int)vertices.size() / stride; 18 | int byteWidth = vertexCount * byteStride; 19 | 20 | vertexSet = false; 21 | if (vertices.size() > 0) 22 | { 23 | D3D11_BUFFER_DESC vertexBufferDesc = D3D11_BUFFER_DESC(); 24 | vertexBufferDesc.Usage = D3D11_USAGE_DYNAMIC; 25 | vertexBufferDesc.ByteWidth = byteWidth; 26 | vertexBufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER; 27 | vertexBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; 28 | vertexBufferDesc.MiscFlags = 0; 29 | vertexBufferDesc.StructureByteStride = 0; 30 | 31 | D3D11_SUBRESOURCE_DATA initData = D3D11_SUBRESOURCE_DATA(); 32 | initData.pSysMem = &vertices[0]; 33 | 34 | HRESULT result = dev->CreateBuffer(&vertexBufferDesc, &initData, &vertexBuffer); 35 | if (FAILED(result)) { 36 | return false; 37 | } 38 | 39 | vertexSet = true; 40 | } 41 | return vertexSet; 42 | } 43 | 44 | int RenderObject::GetVertexCount() 45 | { 46 | return vertexCount; 47 | } 48 | 49 | bool RenderObject::SetIndexBuffer(std::vector indices, D3D11_USAGE usage) 50 | { 51 | indexList = indices; 52 | indexCount = (int)indices.size(); 53 | int byteWidth = indexCount * sizeof(short); 54 | 55 | indexSet = false; 56 | if (indices.size() > 0) 57 | { 58 | D3D11_BUFFER_DESC indexBufferDesc = D3D11_BUFFER_DESC(); 59 | indexBufferDesc.Usage = D3D11_USAGE_DYNAMIC; 60 | indexBufferDesc.ByteWidth = byteWidth; 61 | indexBufferDesc.BindFlags = D3D11_BIND_INDEX_BUFFER; 62 | indexBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; 63 | indexBufferDesc.MiscFlags = 0; 64 | indexBufferDesc.StructureByteStride = 0; 65 | 66 | D3D11_SUBRESOURCE_DATA initData = D3D11_SUBRESOURCE_DATA(); 67 | initData.pSysMem = &indices[0]; 68 | 69 | HRESULT result = dev->CreateBuffer(&indexBufferDesc, &initData, &indexBuffer); 70 | if (FAILED(result)) { 71 | return false; 72 | } 73 | 74 | indexSet = true; 75 | } 76 | return indexSet; 77 | } 78 | 79 | void RenderObject::SetShadersLayout(ID3D11InputLayout* layout, ID3D11VertexShader* vertex, ID3D11PixelShader* pixel) 80 | { 81 | structLayout = layout; 82 | vertexShader = vertex; 83 | pixelShader = pixel; 84 | } 85 | 86 | void RenderObject::MapResource(void* data, int size) 87 | { 88 | D3D11_MAPPED_SUBRESOURCE mappedResource = D3D11_MAPPED_SUBRESOURCE(); 89 | devcon->Map(vertexBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource); 90 | memcpy(mappedResource.pData, data, size); 91 | devcon->Unmap(vertexBuffer, 0); 92 | } 93 | 94 | 95 | bool RenderObject::RayIntersection(XMVECTOR origin, XMVECTOR direction, XMVECTOR *intersection, float *distance, std::stringstream* logError) 96 | { 97 | bool intersected = false; 98 | //XMMATRIX objMatrixI = XMMatrixInverse(0, objMatrix); 99 | for (int i = 0; i < indexCount; i += 3) 100 | { 101 | int i0 = indexList[i + 0]; 102 | int i1 = indexList[i + 1]; 103 | int i2 = indexList[i + 2]; 104 | 105 | XMVECTOR v0 = { vertexList[i0 * stride + 0], vertexList[i0 * stride + 1], vertexList[i0 * stride + 2] }; 106 | XMVECTOR v1 = { vertexList[i1 * stride + 0], vertexList[i1 * stride + 1], vertexList[i1 * stride + 2] }; 107 | XMVECTOR v2 = { vertexList[i2 * stride + 0], vertexList[i2 * stride + 1], vertexList[i2 * stride + 2] }; 108 | 109 | XMVECTOR v0uv = { vertexList[i0 * stride + 3], vertexList[i0 * stride + 4], 1.0f }; 110 | XMVECTOR v1uv = { vertexList[i1 * stride + 3], vertexList[i1 * stride + 4], 1.0f }; 111 | XMVECTOR v2uv = { vertexList[i2 * stride + 3], vertexList[i2 * stride + 4], 1.0f }; 112 | 113 | v0 = XMVector3Transform(v0, objMatrix); 114 | v1 = XMVector3Transform(v1, objMatrix); 115 | v2 = XMVector3Transform(v2, objMatrix); 116 | 117 | float pickU = 0.0f; 118 | float pickV = 0.0f; 119 | float pickW = 0.0f; 120 | 121 | bool rayHit = RayTest(origin, direction, v0, v1, v2, &pickU, &pickV, &pickW, distance, logError); 122 | if (rayHit) 123 | { 124 | intersected = true; 125 | *intersection = pickU * v1uv + pickV * v2uv + pickW * v0uv; 126 | //(*logError) << pickU << " : " << pickV << " : " << pickW << " : " << (*distance) << " -- " << intersection->m128_f32[0] << ", " <m128_f32[1] << ", " << intersection->m128_f32[2] << std::endl; 127 | } 128 | } 129 | return intersected; 130 | } 131 | 132 | bool RenderObject::RayTest(XMVECTOR origin, XMVECTOR direction, XMVECTOR v0, XMVECTOR v1, XMVECTOR v2, float* barycentricU, float* barycentricV, float* barycentricW, float* distance, std::stringstream* logError) 133 | { 134 | XMVECTOR v1v0 = v1 - v0; 135 | XMVECTOR v2v0 = v2 - v0; 136 | XMVECTOR vOv0 = origin - v0; 137 | 138 | // Begin calculating determinant - also used to calculate barycentricU parameter 139 | XMVECTOR pvec = XMVector3Cross(direction, v2v0); 140 | 141 | // If determinant is near zero, ray lies in plane of triangle 142 | float det = 0; 143 | DirectX::XMStoreFloat(&det, XMVector3Dot(v1v0, pvec)); 144 | if (det < 0.0001f && det > -0.0001f) 145 | return false; 146 | float fInvDet = 1.0f / det; 147 | 148 | // Calculate barycentricU parameter and test bounds 149 | DirectX::XMStoreFloat(barycentricU, XMVector3Dot(vOv0, pvec) * fInvDet); 150 | if (*barycentricU < 0.0f || *barycentricU > 1.0f) 151 | return false; 152 | 153 | // Prepare to test barycentricV parameter 154 | XMVECTOR qvec = XMVector3Cross(vOv0, v1v0); 155 | 156 | // Calculate barycentricV parameter and test bounds 157 | DirectX::XMStoreFloat(barycentricV, XMVector3Dot(direction, qvec) * fInvDet); 158 | if (*barycentricV < 0.0f || (*barycentricU + *barycentricV) > 1.0f) 159 | return false; 160 | 161 | // Calculate pickDistance 162 | DirectX::XMStoreFloat(distance, XMVector3Dot(v2v0, qvec) * fInvDet); 163 | if (*distance > 0) 164 | return false; 165 | (*barycentricW) = 1.f - (*barycentricU) - (*barycentricV); 166 | 167 | //(*logError) << det << " : " << fInvDet << " : " << (*barycentricU) << " : " << (*barycentricV) << " : " << (*distance) << std::endl; 168 | return true; 169 | 170 | } 171 | 172 | void RenderObject::Render() 173 | { 174 | unsigned int offset = 0; 175 | 176 | devcon->IASetInputLayout(structLayout); 177 | devcon->VSSetShader(vertexShader, 0, 0); 178 | devcon->PSSetShader(pixelShader, 0, 0); 179 | 180 | if(vertexSet) 181 | devcon->IASetVertexBuffers(0, 1, &vertexBuffer, &byteStride, &offset); 182 | 183 | if (indexSet) 184 | { 185 | devcon->IASetIndexBuffer(indexBuffer, DXGI_FORMAT_R16_UINT, 0); 186 | devcon->DrawIndexed(indexCount, 0, 0); 187 | } 188 | else 189 | { 190 | devcon->Draw(vertexCount, 0); 191 | } 192 | } 193 | 194 | 195 | void RenderObject::SetObjectMatrix(XMMATRIX matrix) 196 | { 197 | objMatrix = matrix; 198 | } 199 | 200 | XMMATRIX RenderObject::GetObjectMatrix(bool inverse, bool transpose) 201 | { 202 | if (transpose && inverse) 203 | return XMMatrixTranspose(XMMatrixInverse(0, objMatrix)); 204 | else if (transpose) 205 | return XMMatrixTranspose(objMatrix); 206 | else if (inverse) 207 | return XMMatrixInverse(0, objMatrix); 208 | else 209 | return objMatrix; 210 | } 211 | 212 | void RenderObject::Release() 213 | { 214 | if (vertexBuffer) { vertexBuffer->Release(); vertexBuffer = nullptr; } 215 | if (indexBuffer) { indexBuffer->Release(); indexBuffer = nullptr; } 216 | 217 | if (structLayout) { structLayout = nullptr; } 218 | if (vertexShader) { vertexShader = nullptr; } 219 | if (pixelShader) { pixelShader = nullptr; } 220 | 221 | vertexCount = 0; 222 | indexCount = 0; 223 | 224 | dev = nullptr; 225 | devcon = nullptr; 226 | } 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | RenderCurvedUI::RenderCurvedUI(ID3D11Device* tdev, ID3D11DeviceContext* tdevcon) : RenderObject(tdev, tdevcon) 240 | { 241 | // x,y,z, u,v 242 | std::vector vertices = 243 | { 244 | -0.5000000f, -0.5000000f, 0.1456540f, 0.000016f, 1.000000f, 245 | -0.5000000f, 0.5000000f, 0.1456540f, 0.000018f, 0.000000f, 246 | -0.4903928f, -0.5000000f, 0.0980761f, 0.040409f, 1.000000f, 247 | -0.4903928f, 0.5000000f, 0.0980761f, 0.040410f, 0.000000f, 248 | -0.4619398f, -0.5000000f, 0.0523266f, 0.085244f, 1.000000f, 249 | -0.4619398f, 0.5000000f, 0.0523266f, 0.085245f, 0.000000f, 250 | -0.4157348f, -0.5000000f, 0.0101635f, 0.137297f, 1.000000f, 251 | -0.4157348f, 0.5000000f, 0.0101635f, 0.137299f, 0.000000f, 252 | -0.3535534f, -0.5000000f, -0.0267926f, 0.197492f, 1.000000f, 253 | -0.3535534f, 0.5000000f, -0.0267926f, 0.197494f, 0.000000f, 254 | -0.2777852f, -0.5000000f, -0.0571218f, 0.265409f, 1.000000f, 255 | -0.2777852f, 0.5000000f, -0.0571218f, 0.265411f, 0.000000f, 256 | -0.1913418f, -0.5000000f, -0.0796584f, 0.339750f, 1.000000f, 257 | -0.1913418f, 0.5000000f, -0.0796584f, 0.339752f, 0.000000f, 258 | -0.0975452f, -0.5000000f, -0.0935364f, 0.418655f, 1.000000f, 259 | -0.0975452f, 0.5000000f, -0.0935364f, 0.418658f, 0.000000f, 260 | 0.0000000f, -0.5000000f, -0.0982224f, 0.499924f, 1.000000f, 261 | 0.0000000f, 0.5000000f, -0.0982224f, 0.499927f, 0.000000f, 262 | 0.0975452f, -0.5000000f, -0.0935363f, 0.581193f, 1.000000f, 263 | 0.0975452f, 0.5000000f, -0.0935363f, 0.581195f, 0.000000f, 264 | 0.1913418f, -0.5000000f, -0.0796584f, 0.660098f, 1.000000f, 265 | 0.1913418f, 0.5000000f, -0.0796584f, 0.660101f, 0.000000f, 266 | 0.2777851f, -0.5000000f, -0.0571218f, 0.734438f, 1.000000f, 267 | 0.2777851f, 0.5000000f, -0.0571218f, 0.734442f, 0.000000f, 268 | 0.3535533f, -0.5000000f, -0.0267926f, 0.802356f, 1.000000f, 269 | 0.3535533f, 0.5000000f, -0.0267926f, 0.802359f, 0.000000f, 270 | 0.4157349f, -0.5000000f, 0.0101636f, 0.862551f, 1.000000f, 271 | 0.4157349f, 0.5000000f, 0.0101636f, 0.862554f, 0.000000f, 272 | 0.4619398f, -0.5000000f, 0.0523266f, 0.914604f, 1.000000f, 273 | 0.4619398f, 0.5000000f, 0.0523266f, 0.914608f, 0.000000f, 274 | 0.4903927f, -0.5000000f, 0.0980762f, 0.959439f, 1.000000f, 275 | 0.4903927f, 0.5000000f, 0.0980762f, 0.959443f, 0.000000f, 276 | 0.5000000f, -0.5000000f, 0.1456541f, 0.999832f, 1.000000f, 277 | 0.5000000f, 0.5000000f, 0.1456541f, 0.999835f, 0.000000f, 278 | }; 279 | 280 | std::vector vertices1 = 281 | { 282 | -1, -1, 0, 1.0f, 0.0f, 0.0f, 1.0f, // 0, 1, 283 | -1, 1, 0, 0.0f, 0.0f, 1.0f, 1.0f, // 0, 0, 284 | 1, 1, 0, 0.0f, 1.0f, 0.0f, 1.0f, // 1, 0, 285 | 1, -1, 0, 1.0f, 1.0f, 1.0f, 1.0f, // 1, 1, 286 | }; 287 | 288 | std::vector vertices2 = 289 | { 290 | -1, -1, 0, 0, 1, 291 | -1, 1, 0, 0, 0, 292 | 1, 1, 0, 1, 0, 293 | 1, -1, 0, 1, 1, 294 | }; 295 | SetVertexBuffer(vertices, 5); 296 | //SetVertexBuffer(vertices1, 7); 297 | //SetVertexBuffer(vertices2, 5); 298 | 299 | 300 | std::vector indices = 301 | { 302 | 0, 1, 3, 303 | 3, 2, 0, 304 | 2, 3, 5, 305 | 5, 4, 2, 306 | 4, 5, 7, 307 | 7, 6, 4, 308 | 6, 7, 9, 309 | 9, 8, 6, 310 | 8, 9, 11, 311 | 11, 10, 8, 312 | 10, 11, 13, 313 | 13, 12, 10, 314 | 12, 13, 15, 315 | 15, 14, 12, 316 | 14, 15, 17, 317 | 17, 16, 14, 318 | 16, 17, 19, 319 | 19, 18, 16, 320 | 18, 19, 21, 321 | 21, 20, 18, 322 | 20, 21, 23, 323 | 23, 22, 20, 324 | 22, 23, 25, 325 | 25, 24, 22, 326 | 24, 25, 27, 327 | 27, 26, 24, 328 | 26, 27, 29, 329 | 29, 28, 26, 330 | 28, 29, 31, 331 | 31, 30, 28, 332 | 30, 31, 33, 333 | 33, 32, 30, 334 | }; 335 | 336 | std::vector indices1 = 337 | { 338 | 0, 1, 2, 339 | 2, 3, 0 340 | }; 341 | SetIndexBuffer(indices); 342 | } 343 | 344 | RenderOSK::RenderOSK(ID3D11Device* tdev, ID3D11DeviceContext* tdevcon) : RenderObject(tdev, tdevcon) 345 | { 346 | std::vector vertices = 347 | { 348 | -1, -1, 0, 0, 1, 349 | -1, 1, 0, 0, 0, 350 | 1, 1, 0, 1, 0, 351 | 1, -1, 0, 1, 1, 352 | }; 353 | SetVertexBuffer(vertices, 5); 354 | 355 | 356 | std::vector indices = 357 | { 358 | 0, 1, 2, 359 | 2, 3, 0 360 | }; 361 | SetIndexBuffer(indices); 362 | } 363 | 364 | RenderSquare::RenderSquare(ID3D11Device* tdev, ID3D11DeviceContext* tdevcon) : RenderObject(tdev, tdevcon) 365 | { 366 | std::vector vertices = 367 | { 368 | -1, -1, 0, 0, 1, 369 | -1, 1, 0, 0, 0, 370 | 1, 1, 0, 1, 0, 371 | 1, -1, 0, 1, 1, 372 | }; 373 | SetVertexBuffer(vertices, 5); 374 | 375 | 376 | std::vector indices = 377 | { 378 | 0, 1, 2, 379 | 2, 3, 0 380 | }; 381 | SetIndexBuffer(indices); 382 | } 383 | 384 | 385 | RenderCube::RenderCube(ID3D11Device* tdev, ID3D11DeviceContext* tdevcon) : RenderObject(tdev, tdevcon) 386 | { 387 | std::vector vertices = 388 | { 389 | -0.55f, -0.55f, -0.55f, 0.0f, 0.0f, 0.0f, 1.0f, 390 | -0.55f, 0.55f, -0.55f, 0.0f, 0.0f, 1.0f, 1.0f, 391 | 0.55f, 0.55f, -0.55f, 0.0f, 1.0f, 0.0f, 1.0f, 392 | 0.55f, -0.55f, -0.55f, 0.0f, 1.0f, 1.0f, 1.0f, 393 | -0.55f, -0.55f, 0.55f, 1.0f, 0.0f, 0.0f, 1.0f, 394 | -0.55f, 0.55f, 0.55f, 1.0f, 0.0f, 1.0f, 1.0f, 395 | 0.55f, 0.55f, 0.55f, 1.0f, 1.0f, 0.0f, 1.0f, 396 | 0.55f, -0.55f, 0.55f, 1.0f, 1.0f, 1.0f, 1.0f, 397 | }; 398 | SetVertexBuffer(vertices, 7); 399 | 400 | // 5----6 401 | // /| /| 402 | // 1----2 | 403 | // | 4--|-7 404 | // |/ |/ 405 | // 0----3 406 | // 407 | 408 | std::vector indices = 409 | { 410 | // front face 411 | 0, 1, 2, 412 | 0, 2, 3, 413 | 414 | // back face 415 | 4, 6, 5, 416 | 4, 7, 6, 417 | 418 | // left face 419 | 4, 5, 1, 420 | 4, 1, 0, 421 | 422 | // right face 423 | 3, 2, 6, 424 | 3, 6, 7, 425 | 426 | // top face 427 | 1, 5, 6, 428 | 1, 6, 2, 429 | 430 | // bottom face 431 | 4, 0, 3, 432 | 4, 3, 7 433 | }; 434 | SetIndexBuffer(indices); 435 | } 436 | 437 | 438 | RenderRayLine::RenderRayLine(ID3D11Device* tdev, ID3D11DeviceContext* tdevcon) : RenderObject(tdev, tdevcon) 439 | { 440 | std::vector vertices = 441 | { 442 | 0, 0, 1, 1.0f, 0.0f, 0.0f, 0.75f, 443 | 0, 0,-1, 0.0f, 0.0f, 1.0f, 0.25f 444 | }; 445 | SetVertexBuffer(vertices, 7, D3D11_USAGE_DYNAMIC); 446 | } -------------------------------------------------------------------------------- /xivr_main/RenderObject.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | using namespace DirectX; 9 | 10 | class RenderObject 11 | { 12 | ID3D11Device* dev; 13 | ID3D11DeviceContext* devcon; 14 | 15 | ID3D11InputLayout* structLayout = nullptr; 16 | ID3D11VertexShader* vertexShader = nullptr; 17 | ID3D11PixelShader* pixelShader = nullptr; 18 | 19 | 20 | ID3D11Buffer* vertexBuffer = nullptr; 21 | ID3D11Buffer* indexBuffer = nullptr; 22 | 23 | std::vector vertexList = std::vector(); 24 | std::vector indexList = std::vector(); 25 | 26 | XMMATRIX objMatrix = XMMatrixIdentity(); 27 | unsigned int stride = 0; 28 | unsigned int byteStride = 0; 29 | int vertexCount = 0; 30 | int indexCount = 0; 31 | 32 | bool vertexSet = false; 33 | bool indexSet = false; 34 | 35 | public: 36 | RenderObject(); 37 | RenderObject(ID3D11Device* tdev, ID3D11DeviceContext* tdevcon); 38 | 39 | bool SetVertexBuffer(std::vector vertices, int itmStride, D3D11_USAGE usage = D3D11_USAGE_DEFAULT); 40 | int GetVertexCount(); 41 | bool SetIndexBuffer(std::vector indices, D3D11_USAGE usage = D3D11_USAGE_DEFAULT); 42 | void SetShadersLayout(ID3D11InputLayout* layout, ID3D11VertexShader* vertex, ID3D11PixelShader* pixelShader); 43 | void MapResource(void* data, int size); 44 | 45 | void SetObjectMatrix(DirectX::XMMATRIX matrix); 46 | XMMATRIX GetObjectMatrix(bool inverse = false, bool transpose = false); 47 | 48 | bool RayIntersection(XMVECTOR origin, XMVECTOR direction, XMVECTOR* intersection, float* distance, std::stringstream *logError); 49 | bool RayTest(XMVECTOR origin, XMVECTOR direction, XMVECTOR v0, XMVECTOR v1, XMVECTOR v2, float* barycentricU, float* barycentricV, float* barycentricW, float* distance, std::stringstream* logError); 50 | 51 | void Render(); 52 | 53 | void Release(); 54 | }; 55 | 56 | 57 | 58 | 59 | 60 | 61 | class RenderCurvedUI : public RenderObject 62 | { 63 | 64 | public: 65 | RenderCurvedUI(ID3D11Device* tdev, ID3D11DeviceContext* tdevcon); 66 | }; 67 | 68 | class RenderOSK : public RenderObject 69 | { 70 | 71 | public: 72 | RenderOSK(ID3D11Device* tdev, ID3D11DeviceContext* tdevcon); 73 | }; 74 | 75 | class RenderSquare : public RenderObject 76 | { 77 | 78 | public: 79 | RenderSquare(ID3D11Device* tdev, ID3D11DeviceContext* tdevcon); 80 | }; 81 | 82 | class RenderCube : public RenderObject 83 | { 84 | 85 | public: 86 | RenderCube(ID3D11Device* tdev, ID3D11DeviceContext* tdevcon); 87 | }; 88 | 89 | class RenderRayLine : public RenderObject 90 | { 91 | 92 | public: 93 | RenderRayLine(ID3D11Device* tdev, ID3D11DeviceContext* tdevcon); 94 | }; 95 | -------------------------------------------------------------------------------- /xivr_main/SteamVRInput.cpp: -------------------------------------------------------------------------------- 1 | #include "SteamVRInput.h" 2 | 3 | void setActionHandlesGame(inputController* input) 4 | { 5 | vr::EVRInputError iError = vr::VRInputError_None; 6 | iError = vr::VRInput()->GetActionSetHandle("/actions/game", &input->game.setHandle); 7 | //if (iError != 0) 8 | //{ 9 | iError = vr::VRInput()->GetActionSetHandle("/actions/game/in/movement", &input->game.movement); 10 | iError = vr::VRInput()->GetActionSetHandle("/actions/game/in/rotation", &input->game.rotation); 11 | iError = vr::VRInput()->GetActionSetHandle("/actions/game/in/lefthand_tip", &input->game.lefthand_tip); 12 | iError = vr::VRInput()->GetActionSetHandle("/actions/game/in/righthand_tip", &input->game.righthand_tip); 13 | iError = vr::VRInput()->GetActionSetHandle("/actions/game/in/lefthand_palm", &input->game.lefthand_palm); 14 | iError = vr::VRInput()->GetActionSetHandle("/actions/game/in/righthand_palm", &input->game.righthand_palm); 15 | iError = vr::VRInput()->GetActionSetHandle("/actions/game/in/lefthand_anim", &input->game.lefthand_anim); 16 | iError = vr::VRInput()->GetActionSetHandle("/actions/game/in/righthand_anim", &input->game.righthand_anim); 17 | iError = vr::VRInput()->GetActionSetHandle("/actions/game/in/leftclick", &input->game.leftclick); 18 | iError = vr::VRInput()->GetActionSetHandle("/actions/game/in/rightclick", &input->game.rightclick); 19 | 20 | iError = vr::VRInput()->GetActionSetHandle("/actions/game/in/recenter", &input->game.recenter); 21 | iError = vr::VRInput()->GetActionSetHandle("/actions/game/in/shift", &input->game.shift); 22 | iError = vr::VRInput()->GetActionSetHandle("/actions/game/in/alt", &input->game.alt); 23 | iError = vr::VRInput()->GetActionSetHandle("/actions/game/in/control", &input->game.control); 24 | iError = vr::VRInput()->GetActionSetHandle("/actions/game/in/escape", &input->game.escape); 25 | iError = vr::VRInput()->GetActionSetHandle("/actions/game/in/scrollup", &input->game.scrollup); 26 | iError = vr::VRInput()->GetActionSetHandle("/actions/game/in/scrolldown", &input->game.scrolldown); 27 | iError = vr::VRInput()->GetActionSetHandle("/actions/game/in/button01", &input->game.button01); 28 | iError = vr::VRInput()->GetActionSetHandle("/actions/game/in/button02", &input->game.button02); 29 | iError = vr::VRInput()->GetActionSetHandle("/actions/game/in/button03", &input->game.button03); 30 | iError = vr::VRInput()->GetActionSetHandle("/actions/game/in/button04", &input->game.button04); 31 | iError = vr::VRInput()->GetActionSetHandle("/actions/game/in/button05", &input->game.button05); 32 | iError = vr::VRInput()->GetActionSetHandle("/actions/game/in/button06", &input->game.button06); 33 | iError = vr::VRInput()->GetActionSetHandle("/actions/game/in/button07", &input->game.button07); 34 | iError = vr::VRInput()->GetActionSetHandle("/actions/game/in/button08", &input->game.button08); 35 | iError = vr::VRInput()->GetActionSetHandle("/actions/game/in/button09", &input->game.button09); 36 | iError = vr::VRInput()->GetActionSetHandle("/actions/game/in/button10", &input->game.button10); 37 | iError = vr::VRInput()->GetActionSetHandle("/actions/game/in/button11", &input->game.button11); 38 | iError = vr::VRInput()->GetActionSetHandle("/actions/game/in/button12", &input->game.button12); 39 | 40 | iError = vr::VRInput()->GetActionSetHandle("/actions/game/in/xbox_button_y", &input->game.xbox_button_y); 41 | iError = vr::VRInput()->GetActionSetHandle("/actions/game/in/xbox_button_x", &input->game.xbox_button_x); 42 | iError = vr::VRInput()->GetActionSetHandle("/actions/game/in/xbox_button_a", &input->game.xbox_button_a); 43 | iError = vr::VRInput()->GetActionSetHandle("/actions/game/in/xbox_button_b", &input->game.xbox_button_b); 44 | 45 | iError = vr::VRInput()->GetActionSetHandle("/actions/game/in/xbox_left_trigger", &input->game.xbox_left_trigger); 46 | iError = vr::VRInput()->GetActionSetHandle("/actions/game/in/xbox_left_bumper", &input->game.xbox_left_bumper); 47 | iError = vr::VRInput()->GetActionSetHandle("/actions/game/in/xbox_left_stick_click", &input->game.xbox_left_stick_click); 48 | 49 | iError = vr::VRInput()->GetActionSetHandle("/actions/game/in/xbox_right_trigger", &input->game.xbox_right_trigger); 50 | iError = vr::VRInput()->GetActionSetHandle("/actions/game/in/xbox_right_bumper", &input->game.xbox_right_bumper); 51 | iError = vr::VRInput()->GetActionSetHandle("/actions/game/in/xbox_right_stick_click", &input->game.xbox_right_stick_click); 52 | 53 | iError = vr::VRInput()->GetActionSetHandle("/actions/game/in/xbox_pad_up", &input->game.xbox_pad_up); 54 | iError = vr::VRInput()->GetActionSetHandle("/actions/game/in/xbox_pad_down", &input->game.xbox_pad_down); 55 | iError = vr::VRInput()->GetActionSetHandle("/actions/game/in/xbox_pad_left", &input->game.xbox_pad_left); 56 | iError = vr::VRInput()->GetActionSetHandle("/actions/game/in/xbox_pad_right", &input->game.xbox_pad_right); 57 | 58 | iError = vr::VRInput()->GetActionSetHandle("/actions/game/in/xbox_start", &input->game.xbox_start); 59 | iError = vr::VRInput()->GetActionSetHandle("/actions/game/in/xbox_select", &input->game.xbox_select); 60 | 61 | iError = vr::VRInput()->GetActionSetHandle("/actions/game/in/thumbrest_left", &input->game.thumbrest_left); 62 | iError = vr::VRInput()->GetActionSetHandle("/actions/game/in/thumbrest_right", &input->game.thumbrest_right); 63 | 64 | iError = vr::VRInput()->GetActionSetHandle("/actions/game/out/haptic_left", &input->game.haptic_left); 65 | iError = vr::VRInput()->GetActionSetHandle("/actions/game/out/haptic_right", &input->game.haptic_right); 66 | 67 | //} 68 | } 69 | 70 | -------------------------------------------------------------------------------- /xivr_main/SteamVRInput.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #define WIN32_LEAN_AND_MEAN 3 | // Windows Header Files 4 | #include 5 | #include 6 | 7 | struct inputActionGame 8 | { 9 | vr::VRActionSetHandle_t setHandle; 10 | 11 | vr::VRActionHandle_t movement; 12 | vr::VRActionHandle_t rotation; 13 | vr::VRActionHandle_t lefthand_tip; 14 | vr::VRActionHandle_t righthand_tip; 15 | vr::VRActionHandle_t lefthand_palm; 16 | vr::VRActionHandle_t righthand_palm; 17 | vr::VRActionHandle_t lefthand_anim; 18 | vr::VRActionHandle_t righthand_anim; 19 | vr::VRActionHandle_t leftclick; 20 | vr::VRActionHandle_t rightclick; 21 | 22 | vr::VRActionHandle_t recenter; 23 | vr::VRActionHandle_t shift; 24 | vr::VRActionHandle_t alt; 25 | vr::VRActionHandle_t control; 26 | vr::VRActionHandle_t escape; 27 | vr::VRActionHandle_t scrollup; 28 | vr::VRActionHandle_t scrolldown; 29 | vr::VRActionHandle_t button01; 30 | vr::VRActionHandle_t button02; 31 | vr::VRActionHandle_t button03; 32 | vr::VRActionHandle_t button04; 33 | vr::VRActionHandle_t button05; 34 | vr::VRActionHandle_t button06; 35 | vr::VRActionHandle_t button07; 36 | vr::VRActionHandle_t button08; 37 | vr::VRActionHandle_t button09; 38 | vr::VRActionHandle_t button10; 39 | vr::VRActionHandle_t button11; 40 | vr::VRActionHandle_t button12; 41 | 42 | vr::VRActionHandle_t xbox_button_y; 43 | vr::VRActionHandle_t xbox_button_x; 44 | vr::VRActionHandle_t xbox_button_a; 45 | vr::VRActionHandle_t xbox_button_b; 46 | 47 | vr::VRActionHandle_t xbox_left_trigger; 48 | vr::VRActionHandle_t xbox_left_bumper; 49 | vr::VRActionHandle_t xbox_left_stick_click; 50 | 51 | vr::VRActionHandle_t xbox_right_trigger; 52 | vr::VRActionHandle_t xbox_right_bumper; 53 | vr::VRActionHandle_t xbox_right_stick_click; 54 | 55 | vr::VRActionHandle_t xbox_pad_up; 56 | vr::VRActionHandle_t xbox_pad_down; 57 | vr::VRActionHandle_t xbox_pad_left; 58 | vr::VRActionHandle_t xbox_pad_right; 59 | 60 | vr::VRActionHandle_t xbox_start; 61 | vr::VRActionHandle_t xbox_select; 62 | 63 | vr::VRActionHandle_t thumbrest_left; 64 | vr::VRActionHandle_t thumbrest_right; 65 | 66 | vr::VRActionHandle_t haptic_left; 67 | vr::VRActionHandle_t haptic_right; 68 | 69 | }; 70 | 71 | struct inputController 72 | { 73 | struct inputActionGame game; 74 | }; 75 | 76 | enum buttonLayout 77 | { 78 | movement, 79 | rotation, 80 | leftHandTipPose, 81 | rightHandTipPose, 82 | leftHandPalmPose, 83 | rightHandPalmPose, 84 | leftHandAnim, 85 | rightHandAnim, 86 | leftClick, 87 | rightClick, 88 | recenter, 89 | shift, 90 | alt, 91 | control, 92 | escape, 93 | button01, 94 | button02, 95 | button03, 96 | button04, 97 | button05, 98 | button06, 99 | button07, 100 | button08, 101 | button09, 102 | button10, 103 | button11, 104 | button12, 105 | xbox_button_y, 106 | xbox_button_x, 107 | xbox_button_a, 108 | xbox_button_b, 109 | xbox_left_trigger, 110 | xbox_left_bumper, 111 | xbox_left_stick_click, 112 | xbox_right_trigger, 113 | xbox_right_bumper, 114 | xbox_right_stick_click, 115 | xbox_pad_up, 116 | xbox_pad_down, 117 | xbox_pad_left, 118 | xbox_pad_right, 119 | xbox_start, 120 | xbox_select, 121 | thumbrest_left, 122 | thumbrest_right, 123 | haptic_left, 124 | haptic_right, 125 | watch_audio, 126 | watch_dalamud, 127 | watch_ui, 128 | watch_keyboard, 129 | watch_none, 130 | watch_occlusion, 131 | watch_recenter, 132 | watch_weapon, 133 | watch_xivr 134 | }; 135 | 136 | enum skeletalFingerLayout 137 | { 138 | root, 139 | wrist, 140 | thumbMetacarpal, 141 | thumbProximal, 142 | thumbMiddle, 143 | thumbDistal, 144 | thumbTip, 145 | indexMetacarpal, 146 | indexProximal, 147 | indexMiddle, 148 | indexDistal, 149 | indexTip, 150 | middleMetacarpal, 151 | middleProximal, 152 | middleMiddle, 153 | middleDistal, 154 | middleTip, 155 | ringMetacarpal, 156 | ringProximal, 157 | ringMiddle, 158 | ringDistal, 159 | ringTip, 160 | pinkyMetacarpal, 161 | pinkyProximal, 162 | pinkyMiddle, 163 | pinkyDistal, 164 | pinkyTip, 165 | thumbAux, 166 | indexAux, 167 | middleAux, 168 | ringAux, 169 | pinkyAux 170 | }; 171 | 172 | void setActionHandlesGame(inputController* input); 173 | -------------------------------------------------------------------------------- /xivr_main/ffxivCameraManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #define WIN32_LEAN_AND_MEAN 3 | #include 4 | #include 5 | #include 6 | 7 | struct stCameraBase 8 | { 9 | /* 0x000 */ unsigned long long* vtbl; 10 | /* 0x008 */ unsigned long long uk1; 11 | }; 12 | 13 | struct stRawGameCamera 14 | { 15 | /* 0x000 */ unsigned long long* vtbl; 16 | /* 0x008 */ byte spcr1[0x50 - 0x08]; 17 | /* 0x050 */ float X; 18 | /* 0x054 */ float Y; 19 | /* 0x058 */ float Z; 20 | /* 0x05C */ byte spr2[0x80 - 0x5C]; 21 | /* 0x080 */ float LookAtX; 22 | /* 0x084 */ float LookAtY; 23 | /* 0x088 */ float LookAtZ; 24 | /* 0x08C */ float uk1; 25 | /* 0x090 */ float RotateX; 26 | /* 0x094 */ float RotateY; 27 | /* 0x098 */ float RotateZ; 28 | /* 0x09C */ float uk2; 29 | /* 0x0A0 */ XMMATRIX ViewMatrix; 30 | /* 0x0E0 */ unsigned long long* BufferData; 31 | /* 0x0E8 */ byte spcr2[0x104 - 0xE8]; 32 | /* 0x104 */ float CurrentZoom; 33 | /* 0x108 */ float MinZoom; 34 | /* 0x10C */ float MaxZoom; 35 | /* 0x110 */ float CurrentFoV; 36 | /* 0x114 */ float MinFoV; 37 | /* 0x118 */ float MaxFoV; 38 | /* 0x11C */ float AddedFoV; 39 | /* 0x120 */ float CurrentHRotation; 40 | /* 0x124 */ float CurrentVRotation; 41 | /* 0x128 */ float HRotationThisFrame1; 42 | /* 0x12C */ float VRotationThisFrame1; 43 | /* 0x130 */ float HRotationThisFrame2; 44 | /* 0x134 */ float VRotationThisFrame2; 45 | /* 0x138 */ float MinVRotation; 46 | /* 0x13C */ float MaxVRotation; 47 | /* 0x150 */ float Tilt; 48 | /* 0x154 */ byte spcr3[0x160 - 0x154]; 49 | /* 0x160 */ int Mode; 50 | /* 0x164 */ byte spcr4[0x16C - 0x164]; 51 | /* 0x16C */ float InterpolatedZoom; 52 | /* 0x170 */ byte spcr5[0x1A0 - 0x170]; 53 | /* 0x1A0 */ float ViewX; 54 | /* 0x1A4 */ float ViewY; 55 | /* 0x1A8 */ float ViewZ; 56 | }; 57 | 58 | 59 | struct stGameCamera 60 | { 61 | /* 0x000 */ stCameraBase CameraBase; 62 | /* 0x010 */ stRawGameCamera Camera; 63 | }; 64 | 65 | struct stLowCutCamera 66 | { 67 | /* 0x000 */ stCameraBase CameraBase; 68 | /* 0x010 */ stRawGameCamera Camera; 69 | }; 70 | 71 | struct stLobbyCamera 72 | { 73 | /* 0x000 */ stCameraBase CameraBase; 74 | /* 0x010 */ stRawGameCamera Camera; 75 | /* 0x2F8 */ //void* LobbyExcelSheet; 76 | }; 77 | 78 | struct stCamera3 79 | { 80 | /* 0x000 */ stCameraBase CameraBase; 81 | /* 0x010 */ stRawGameCamera Camera; 82 | }; 83 | 84 | struct stCamera4 85 | { 86 | /* 0x000 */ stCameraBase CameraBase; 87 | /* 0x010 */ stRawGameCamera Camera; 88 | }; 89 | 90 | struct stCameraManager 91 | { 92 | /* 0x000 */ stGameCamera* GameCamera; 93 | /* 0x008 */ stLowCutCamera* LowCutCamera; 94 | /* 0x010 */ stLobbyCamera* LobbyCamera; 95 | /* 0x018 */ stCamera3* Camera3; 96 | /* 0x020 */ stCamera4* Camera4; 97 | /* 0x028 */ byte spcr1[0x48 - 0x28]; 98 | /* 0x048 */ int ActiveCameraIndex; 99 | /* 0x04C */ int PreviousCameraIndex; 100 | /* 0x050 */ byte spcr2[0x60 - 0x50]; 101 | /* 0x060 */ unsigned long long CameraBase; 102 | }; 103 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /xivr_main/ffxivDevice.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "ffxivSwapChain.h" 4 | 5 | struct stDevice 6 | { 7 | /* 0x000 */ byte spcr1[0x8]; 8 | /* 0x008 */ unsigned long long ContextArray; 9 | /* 0x010 */ unsigned long long RenderThread; 10 | /* 0x018 */ byte spcr2[0x70 - 0x18]; 11 | /* 0x070 */ stSwapChain* SwapChain; 12 | /* 0x078 */ byte spcr3[0x2]; 13 | /* 0x07A */ byte RequestResolutionChange; 14 | /* 0x07B */ byte spcr4[0x88 - 0x7B]; 15 | /* 0x088 */ unsigned int width; 16 | /* 0x08C */ unsigned int height; 17 | /* 0x090 */ byte spcr5[0xF0 - 0x90]; 18 | /* 0x0F0 */ unsigned long long ListOfCommands; 19 | /* 0x0F8 */ unsigned int NumCommands; 20 | /* 0x0FC */ byte spcr6[0x1C0 - 0xFC]; 21 | /* 0x1C0 */ unsigned int newWidth; 22 | /* 0x1C4 */ unsigned int newHeight; 23 | /* 0x1C8 */ byte spcr7[0x220 - 0x1C8]; 24 | /* 0x220 */ unsigned int D3DFeatureLevel; 25 | /* 0x224 */ unsigned int uk1; 26 | /* 0x228 */ IDXGIFactory4* IDXGIFactory; 27 | /* 0x230 */ IDXGIOutput4* IDXGIOutput; 28 | /* 0x238 */ ID3D11Device4* Device; 29 | /* 0x240 */ ID3D11DeviceContext4* DeviceContext; 30 | /* 0x248 */ unsigned long long uk2; 31 | /* 0x250 */ unsigned long long ImmediateContext; 32 | }; -------------------------------------------------------------------------------- /xivr_main/ffxivRenderTargetManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ffxivTexture.h" 3 | 4 | struct stRenderTargetManager 5 | { 6 | /* 0x000 */ void* vtbl; 7 | /* 0x008 */ unsigned long long Notifier; 8 | /* 0x010 */ byte spcr1[0x10]; 9 | /* 0x020 */ stTexture* RenderTextureArray1[74]; 10 | /* 0x270 */ unsigned int ResolutionWidth; 11 | /* 0x274 */ unsigned int ResolutionHeight; 12 | /* 0x278 */ unsigned int ShadowMapWidth; 13 | /* 0x27C */ unsigned int ShadowMapHeight; 14 | /* 0x280 */ unsigned int NearShadowMapWidth; 15 | /* 0x284 */ unsigned int NearShadowMapHeight; 16 | /* 0x288 */ unsigned int FarShadowMapWidth; 17 | /* 0x28C */ unsigned int FarShadowMapHeight; 18 | /* 0x290 */ byte spcr3[0x18]; 19 | /* 0x2A8 */ stTexture* RenderTextureArray2[49]; 20 | }; 21 | -------------------------------------------------------------------------------- /xivr_main/ffxivSwapChain.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "ffxivTexture.h" 4 | 5 | struct stSwapChain 6 | { 7 | /* 0x000 */ byte spcr1[0x38]; 8 | /* 0x038 */ unsigned int Width; 9 | /* 0x03C */ unsigned int Height; 10 | /* 0x040 */ byte spcr2[0x18]; 11 | /* 0x058 */ stTexture* BackBuffer; 12 | /* 0x060 */ stTexture* DepthStencil; 13 | /* 0x068 */ IDXGISwapChain4* DXGISwapChain; 14 | }; -------------------------------------------------------------------------------- /xivr_main/ffxivTexture.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | union unTexturePtr 5 | { 6 | ID3D11RenderTargetView* RenderTargetView; 7 | ID3D11DepthStencilView* DepthStencilView; 8 | }; 9 | 10 | struct stTexture 11 | { 12 | /* 0x000 */ unsigned long long uk1; 13 | /* 0x008 */ unsigned int RefCount; 14 | /* 0x00C */ unsigned int uk3; 15 | /* 0x010 */ unsigned long long uk4; 16 | /* 0x018 */ unsigned long long uk5; 17 | /* 0x020 */ unsigned long long Notifier; 18 | /* 0x028 */ unsigned long long uk7; 19 | /* 0x030 */ unsigned long long uk8; 20 | /* 0x038 */ unsigned int Width; 21 | /* 0x03C */ unsigned int Height; 22 | /* 0x040 */ unsigned int Width1; 23 | /* 0x044 */ unsigned int Height1; 24 | /* 0x048 */ unsigned int Width2; 25 | /* 0x04C */ unsigned int Height2; 26 | /* 0x050 */ unsigned int Depth; 27 | /* 0x054 */ unsigned int MipLevel; 28 | /* 0x058 */ unsigned int TextureFormat; 29 | /* 0x05C */ unsigned int Flags; 30 | /* 0x060 */ unsigned int uk9; 31 | /* 0x064 */ unsigned int ukA; 32 | /* 0x068 */ ID3D11Texture2D* Texture; 33 | /* 0x070 */ ID3D11ShaderResourceView* ShaderResourceView; 34 | /* 0x078 */ unsigned long long ukB; 35 | /* 0x080 */ unTexturePtr* itemPtr; 36 | /* 0x088 */ byte spcr5[0xF8 - 0x80]; 37 | }; -------------------------------------------------------------------------------- /xivr_main/framework.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define WIN32_LEAN_AND_MEAN 4 | // Windows Header Files 5 | #include 6 | #include 7 | #include "stCommon.h" 8 | #include "ffxivDevice.h" 9 | #include "ffxivRenderTargetManager.h" 10 | #include "SteamVRInput.h" 11 | #include "BasicRenderer.h" 12 | #include "simpleVR.h" 13 | #include "stMonitorLayout.h" 14 | void forceFlush(); 15 | 16 | #include "Configuration.h" 17 | #include "ffxivCameraManager.h" 18 | -------------------------------------------------------------------------------- /xivr_main/simpleVR.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #define WIN32_LEAN_AND_MEAN 3 | #define _USE_MATH_DEFINES 4 | // Windows Header Files 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "stCommon.h" 13 | #include "Configuration.h" 14 | 15 | class simpleVR 16 | { 17 | vr::IVRSystem* openVRSession = nullptr; 18 | vr::IVRChaperone* openVRChaperone = nullptr; 19 | vr::IVRRenderModels* openVRModels = nullptr; 20 | vr::TrackedDevicePose_t rTrackedDevicePose[vr::k_unMaxTrackedDeviceCount]; 21 | bool _isConnected = false; 22 | POINT bufferSize; 23 | POINT resolution; 24 | uMatrix projMatrixRaw[2]; 25 | uMatrix eyeViewMatrixRaw[2]; 26 | uMatrix eyeViewMatrix[2]; 27 | uMatrix identMatrix; 28 | uMatrix hmdMatrix; 29 | uMatrix controllerMatrix[4]; 30 | uMatrix genericMatrix[3]; 31 | int gTrackCount; 32 | float currentIPD; 33 | stConfiguration* cfg; 34 | std::stringstream logError; 35 | vr::HmdVector2_t depthRange; 36 | vr::VRTextureBounds_t textureBounds[2]; 37 | 38 | fingerHandLayout layoutFinger[2]; 39 | 40 | private: 41 | void InitalizeVR(); 42 | 43 | public: 44 | simpleVR(stConfiguration* config); 45 | ~simpleVR(); 46 | 47 | bool PreloadVR(); 48 | bool StartVR(); 49 | bool StopVR(); 50 | bool isEnabled(); 51 | void Recenter(); 52 | POINT GetBufferSize(); 53 | void SetActionPose(vr::HmdMatrix34_t matPose, poseType poseType); 54 | void SetSkeletalPose(vr::VRBoneTransform_t* boneArray, int boneCount, poseType poseType); 55 | void SetFramePose(); 56 | uMatrix GetFramePose(poseType poseType, int eye); 57 | fingerHandLayout GetSkeletalPose(poseType poseType); 58 | void Render(ID3D11Texture2D* leftEye, ID3D11Texture2D* leftDepth, ID3D11Texture2D* rightEye, ID3D11Texture2D* rightDepth); 59 | void WaitGetPoses(); 60 | void MakeIPDOffset(); 61 | bool HasErrors(); 62 | std::string GetErrors(); 63 | }; 64 | -------------------------------------------------------------------------------- /xivr_main/simpleXR.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #define WIN32_LEAN_AND_MEAN 3 | #define _USE_MATH_DEFINES 4 | // Windows Header Files 5 | #include 6 | #include 7 | #include "Configuration.h" 8 | #include 9 | #include 10 | #include "stCommon.h" 11 | #include 12 | 13 | // Tell OpenXR what platform code we'll be using 14 | #define XR_USE_PLATFORM_WIN32 15 | #define XR_USE_GRAPHICS_API_D3D11 16 | 17 | #include 18 | #include 19 | 20 | using namespace DirectX; 21 | 22 | struct swapchain_surfdata_t { 23 | ID3D11DepthStencilView* depth_view; 24 | ID3D11RenderTargetView* target_view; 25 | }; 26 | 27 | struct swapchain_t { 28 | XrSwapchain handle; 29 | int32_t width; 30 | int32_t height; 31 | std::vector surface_images; 32 | std::vector surface_data; 33 | }; 34 | 35 | struct input_state_t { 36 | XrActionSet actionSet; 37 | XrAction poseAction; 38 | XrAction selectAction; 39 | XrPath handSubactionPath[2]; 40 | XrSpace handSpace[2]; 41 | XrPosef handPose[2]; 42 | XrBool32 renderHand[2]; 43 | XrBool32 handSelect[2]; 44 | }; 45 | 46 | class simpleXR 47 | { 48 | XrInstance m_instance{ XR_NULL_HANDLE }; 49 | XrSession m_session{ XR_NULL_HANDLE }; 50 | XrSystemId m_system_id = XR_NULL_SYSTEM_ID; 51 | XrSpace m_app_space = {}; 52 | XrSessionState m_session_state = XR_SESSION_STATE_UNKNOWN; 53 | input_state_t m_input = { }; 54 | 55 | // Function pointers for some OpenXR extension methods we'll use. 56 | PFN_xrGetD3D11GraphicsRequirementsKHR ext_xrGetD3D11GraphicsRequirementsKHR = nullptr; 57 | PFN_xrCreateDebugUtilsMessengerEXT ext_xrCreateDebugUtilsMessengerEXT = nullptr; 58 | PFN_xrDestroyDebugUtilsMessengerEXT ext_xrDestroyDebugUtilsMessengerEXT = nullptr; 59 | 60 | XrFormFactor app_config_form = XR_FORM_FACTOR_HEAD_MOUNTED_DISPLAY; 61 | XrViewConfigurationType app_config_view = XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO; 62 | 63 | XrEnvironmentBlendMode m_blend = {}; 64 | XrDebugUtilsMessengerEXT m_debug = {}; 65 | 66 | const XrPosef m_pose_identity = { {0,0,0,1}, {0,0,0} }; 67 | std::vector m_views; 68 | std::vector m_config_views; 69 | std::vector m_swapchains; 70 | 71 | DXGI_FORMAT swapchain_format = DXGI_FORMAT_R8G8B8A8_UNORM_SRGB; 72 | 73 | bool _isConnected = false; 74 | POINT bufferSize; 75 | POINT resolution; 76 | uMatrix projMatrixRaw[2]; 77 | uMatrix eyeViewMatrixRaw[2]; 78 | uMatrix eyeViewMatrix[2]; 79 | uMatrix identMatrix; 80 | uMatrix hmdMatrix; 81 | uMatrix controllerLeftMatrix; 82 | uMatrix controllerRightMatrix; 83 | uMatrix genericMatrix[3]; 84 | 85 | stConfiguration* cfg; 86 | std::stringstream logError; 87 | 88 | private: 89 | void InitalizeVR(); 90 | swapchain_surfdata_t d3d_make_surface_data(ID3D11Device* device, XrBaseInStructure& swapchain_img); 91 | void d3d_swapchain_destroy(swapchain_t& swapchain); 92 | 93 | public: 94 | simpleXR(stConfiguration* config); 95 | ~simpleXR(); 96 | 97 | XrInstance GetInstance(); 98 | XrSession GetSession(); 99 | XrSpace GetSpace(); 100 | XrSessionState GetSessionState(); 101 | XrEnvironmentBlendMode GetBlend(); 102 | std::vector GetSwapChain(); 103 | std::vector GetViews(); 104 | input_state_t GetInput(); 105 | 106 | 107 | bool StartVR(ID3D11Device* device); 108 | bool StopVR(); 109 | bool isEnabled(); 110 | void Recenter(); 111 | POINT GetBufferSize(); 112 | uMatrix GetFramePose(poseType pose_type, int eye); 113 | void PollFrameEvents(bool& exit); 114 | void SetFramePose(); 115 | void Render(void (*callback)(int, XrCompositionLayerProjectionView&, swapchain_surfdata_t&)); 116 | void WaitGetPoses(XrTime predictedTime); 117 | void SetActions(); 118 | bool HasErrors(); 119 | std::string GetErrors(); 120 | 121 | 122 | /* 123 | bool StartVR(); 124 | bool StopVR(); 125 | bool isEnabled(); 126 | void Recenter(); 127 | POINT GetBufferSize(); 128 | void SetActionPose(vr::HmdMatrix34_t matPose, poseType pose); 129 | void SetFramePose(); 130 | uMatrix GetFramePose(poseType pose_type, int eye); 131 | void Render(ID3D11Texture2D* leftEye, ID3D11Texture2D* leftDepth, ID3D11Texture2D* rightEye, ID3D11Texture2D* rightDepth); 132 | void WaitGetPoses(); 133 | void MakeIPDOffset(); 134 | bool HasErrors(); 135 | std::string GetErrors(); 136 | */ 137 | }; 138 | -------------------------------------------------------------------------------- /xivr_main/stButtonList.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace ButtonsList 4 | { 5 | enum _ 6 | { 7 | left_Menu, 8 | left_Trigger, 9 | left_Bumper, 10 | left_ButtonA, 11 | left_ButtonB, 12 | left_Pad, 13 | left_PadXAxis, 14 | left_PadYAxis, 15 | left_DPad_Up, 16 | left_DPad_Down, 17 | left_DPad_Left, 18 | left_DPad_Right, 19 | 20 | right_Menu, 21 | right_Trigger, 22 | right_Bumper, 23 | right_ButtonA, 24 | right_ButtonB, 25 | right_Pad, 26 | right_PadXAxis, 27 | right_PadYAxis, 28 | right_DPad_Up, 29 | right_DPad_Down, 30 | right_DPad_Left, 31 | right_DPad_Right, 32 | 33 | left_GestureIndexPoint, 34 | left_GestureThumbUp, 35 | left_GestureFist, 36 | 37 | right_GestureIndexPoint, 38 | right_GestureThumbUp, 39 | right_GestureFist 40 | }; 41 | }; 42 | 43 | namespace ControllerTypes 44 | { 45 | enum _ 46 | { 47 | controllerType_NA = 0, 48 | controllerType_XBox = 1, 49 | controllerType_Virtual = 2, 50 | //controllerType_Both = 3 51 | }; 52 | }; 53 | 54 | namespace ControllerID 55 | { 56 | enum _ 57 | { 58 | NA = 0, 59 | openvrVive = 1, 60 | openvrTouch = 2, 61 | oculusTouch = 3, 62 | }; 63 | }; 64 | 65 | namespace HeadsetIDs 66 | { 67 | enum _ 68 | { 69 | NA = 0, 70 | vive = 1, 71 | rift = 2, 72 | }; 73 | }; 74 | 75 | namespace MouseButtons 76 | { 77 | enum _ 78 | { 79 | left, 80 | middle, 81 | right, 82 | }; 83 | }; 84 | 85 | const int ButtonsListCount = 30; 86 | typedef ButtonsList::_ ButtonList; 87 | typedef ControllerTypes::_ ControllerType; 88 | typedef ControllerID::_ ControllerList; 89 | typedef HeadsetIDs::_ HeadsetList; 90 | typedef MouseButtons::_ MouseButton; 91 | -------------------------------------------------------------------------------- /xivr_main/stCommon.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "stBasicTexture.h" 3 | 4 | union uMatrix 5 | { 6 | float matrix[4][4]; 7 | float _m[16]; 8 | }; 9 | 10 | enum poseType 11 | { 12 | None = 0, 13 | Projection = 1, 14 | EyeOffset = 5, 15 | hmdPosition = 10, 16 | LeftHand = 20, 17 | LeftHandPalm = 21, 18 | RightHand = 30, 19 | RightHandPalm = 31, 20 | }; 21 | 22 | struct stScreenLayout 23 | { 24 | UINT64 pid = 0; 25 | HWND hwnd = 0; 26 | int width = 0; 27 | int height = 0; 28 | bool haveLayout = false; 29 | 30 | void SetFromSwapchain(IDXGISwapChain4* swapchain) 31 | { 32 | DXGI_SWAP_CHAIN_DESC swapDesc; 33 | swapchain->GetDesc(&swapDesc); 34 | hwnd = swapDesc.OutputWindow; 35 | width = swapDesc.BufferDesc.Width; 36 | height = swapDesc.BufferDesc.Height; 37 | haveLayout = true; 38 | } 39 | }; 40 | 41 | struct Vector4 42 | { 43 | float x; 44 | float y; 45 | float z; 46 | float w; 47 | }; 48 | 49 | struct Quat4 50 | { 51 | float w; 52 | float x; 53 | float y; 54 | float z; 55 | }; 56 | 57 | struct BoneData 58 | { 59 | Vector4 Translation; 60 | Quat4 Rotation; 61 | }; 62 | 63 | struct fingerHandLayout 64 | { 65 | BoneData root; 66 | BoneData wrist; 67 | 68 | BoneData thumb0Metacarpal; 69 | union 70 | { 71 | BoneData thumb1Proximal; 72 | BoneData thumb2Middle; 73 | }; 74 | BoneData thumb3Distal; 75 | BoneData thumb4Tip; 76 | 77 | BoneData index0Metacarpal; 78 | BoneData index1Proximal; 79 | BoneData index2Middle; 80 | BoneData index3Distal; 81 | BoneData index4Tip; 82 | 83 | BoneData middle0Metacarpal; 84 | BoneData middle1Proximal; 85 | BoneData middle2Middle; 86 | BoneData middle3Distal; 87 | BoneData middle4Tip; 88 | 89 | BoneData ring0Metacarpal; 90 | BoneData ring1Proximal; 91 | BoneData ring2Middle; 92 | BoneData ring3Distal; 93 | BoneData ring4Tip; 94 | 95 | BoneData pinky0Metacarpal; 96 | BoneData pinky1Proximal; 97 | BoneData pinky2Middle; 98 | BoneData pinky3Distal; 99 | BoneData pinky4Tip; 100 | 101 | BoneData thumbAux; 102 | BoneData indexAux; 103 | BoneData middleAux; 104 | BoneData ringAux; 105 | BoneData pinkyAux; 106 | }; -------------------------------------------------------------------------------- /xivr_main/stMonitorLayout.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #define WIN32_LEAN_AND_MEAN 3 | // Windows Header Files 4 | #include 5 | #include 6 | 7 | struct stMonitorLayout 8 | { 9 | std::vector iMonitors; 10 | std::vector hMonitors; 11 | std::vector hdcMonitors; 12 | std::vector rcMonitors; 13 | 14 | static BOOL CALLBACK MonitorEnum(HMONITOR hMon, HDC hdc, LPRECT lprcMonitor, LPARAM pData) 15 | { 16 | stMonitorLayout* pThis = reinterpret_cast(pData); 17 | pThis->hMonitors.push_back(hMon); 18 | pThis->hdcMonitors.push_back(hdc); 19 | pThis->rcMonitors.push_back(*lprcMonitor); 20 | pThis->iMonitors.push_back((int)pThis->hdcMonitors.size()); 21 | return TRUE; 22 | } 23 | 24 | stMonitorLayout() 25 | { 26 | EnumDisplayMonitors(0, 0, MonitorEnum, (LPARAM)this); 27 | } 28 | }; 29 | -------------------------------------------------------------------------------- /xivr_main/xivr_main.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 16.0 23 | Win32Proj 24 | {7e662908-03d1-4144-b4af-73f1a925bfe4} 25 | xivrmain 26 | 10.0 27 | 28 | 29 | 30 | DynamicLibrary 31 | true 32 | v143 33 | Unicode 34 | 35 | 36 | DynamicLibrary 37 | false 38 | v143 39 | true 40 | Unicode 41 | 42 | 43 | DynamicLibrary 44 | true 45 | v143 46 | Unicode 47 | 48 | 49 | DynamicLibrary 50 | false 51 | v143 52 | true 53 | Unicode 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | $(SolutionDir)$(ProjectName)\bin\$(Platform)\$(Configuration)\ 75 | 76 | 77 | $(SolutionDir)$(ProjectName)\bin\$(Platform)\$(Configuration)\ 78 | 79 | 80 | 81 | Level3 82 | true 83 | WIN32;_DEBUG;XIVRMAIN_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) 84 | true 85 | Use 86 | pch.h 87 | 88 | 89 | Windows 90 | true 91 | false 92 | 93 | 94 | 95 | 96 | Level3 97 | true 98 | true 99 | true 100 | WIN32;NDEBUG;XIVRMAIN_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) 101 | true 102 | Use 103 | pch.h 104 | 105 | 106 | Windows 107 | true 108 | true 109 | true 110 | false 111 | 112 | 113 | 114 | 115 | Level3 116 | true 117 | _DEBUG;XIVRMAIN_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) 118 | true 119 | NotUsing 120 | 121 | 122 | $(SolutionDir)openvr\headers;%(AdditionalIncludeDirectories) 123 | 124 | 125 | Windows 126 | true 127 | false 128 | $(SolutionDir)openvr\lib\win64;%(AdditionalLibraryDirectories) 129 | d3dcompiler.lib;d3d11.lib;dxgi.lib;openvr_api.lib;$(CoreLibraryDependencies);%(AdditionalDependencies) 130 | 131 | 132 | xcopy /y $(SolutionDir)openvr\bin\win64\openvr_api.dll $(SolutionDir)xivr-Ex\bin\$(Platform)\$(Configuration)\ 133 | xcopy /y $(OutDir)xivr_main.dll $(SolutionDir)xivr-Ex\bin\$(Platform)\$(Configuration)\ 134 | xcopy /y /e $(SolutionDir)config $(SolutionDir)xivr-Ex\bin\$(Platform)\$(Configuration)\config\ 135 | 136 | 137 | 138 | 139 | Level3 140 | true 141 | true 142 | true 143 | NDEBUG;XIVRMAIN_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) 144 | true 145 | NotUsing 146 | 147 | 148 | $(SolutionDir)openvr\headers;%(AdditionalIncludeDirectories) 149 | 150 | 151 | Windows 152 | true 153 | true 154 | true 155 | false 156 | $(SolutionDir)openvr\lib\win64;%(AdditionalLibraryDirectories) 157 | d3dcompiler.lib;d3d11.lib;dxgi.lib;openvr_api.lib;$(CoreLibraryDependencies);%(AdditionalDependencies) 158 | 159 | 160 | 161 | xcopy /y $(SolutionDir)openvr\bin\win64\openvr_api.dll $(SolutionDir)xivr\bin\$(Platform)\$(Configuration)\ 162 | xcopy /y $(OutDir)xivr_main.dll $(SolutionDir)xivr\bin\$(Platform)\$(Configuration)\ 163 | xcopy /y /e $(SolutionDir)config $(SolutionDir)xivr\bin\$(Platform)\$(Configuration)\config\ 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | -------------------------------------------------------------------------------- /xivr_main/xivr_main.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | Header Files 29 | 30 | 31 | Header Files 32 | 33 | 34 | Header Files 35 | 36 | 37 | Header Files 38 | 39 | 40 | Header Files 41 | 42 | 43 | Header Files 44 | 45 | 46 | Header Files 47 | 48 | 49 | Header Files 50 | 51 | 52 | Header Files 53 | 54 | 55 | Header Files 56 | 57 | 58 | Header Files 59 | 60 | 61 | Header Files 62 | 63 | 64 | Header Files 65 | 66 | 67 | 68 | 69 | Source Files 70 | 71 | 72 | Source Files 73 | 74 | 75 | Source Files 76 | 77 | 78 | Source Files 79 | 80 | 81 | Source Files 82 | 83 | 84 | Source Files 85 | 86 | 87 | -------------------------------------------------------------------------------- /xivr_main/xivr_main.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | --------------------------------------------------------------------------------