Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: RE BSOpenVR #45

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions include/RE/B/BSOpenVR.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ namespace RE
void Unk_11(void) override; // 11 - { return 0; }
void Unk_12(void) override; // 12
void Unk_13() override; // 13
void Unk_14(void) override; // 14
NiPointer<NiNode>* GetControllerNode(RE::NiPointer<NiNode>& a_out, Hand a_hand) override; // 14
void Unk_15(void) override; // 15 - { return 0; }
HMDDeviceType GetHMDDeviceType() override; // 16 - { return hmdDeviceType; }
void Unk_17(void) override; // 17
NiPointer<NiNode>* CreateControllerNode(RE::NiPointer<NiNode>& a_out, Hand a_hand) override; // 17

static BSOpenVR* GetSingleton();

Expand All @@ -62,18 +62,18 @@ namespace RE
static vr::IVRSystem* GetIVRSystem();

// members
vr::IVRSystem* vrSystem; // 208
void* unk210; // 210
std::uint64_t unk218; // 218
std::uint64_t unk220; // 220
std::uint64_t unk228; // 228
RE::NiPointer<NiSourceTexture> unk230; // 230 - name is SIMPLE_NORMAL_MAP
Unk238 unk238[4]; // 238
std::uint64_t unk338; // 380
std::uint64_t unk340[9]; // 340
RE::NiPointer<NiNode> unk388[2]; // 388
HMDDeviceType hmdDeviceType; // 398 - Set by comparing TrackedSystemName to "lighthouse", "oculus" and "holographic". Defaults to "lighthouse" if none match
NiTransform eyeToHeadTransform[2]; // 39C - 0 is left eye, 1 is right eye
vr::IVRSystem* vrSystem; // 208
void* unk210; // 210
std::uint64_t unk218; // 218
std::uint64_t unk220; // 220
std::uint64_t unk228; // 228
NiPointer<NiSourceTexture> unk230; // 230 - name is SIMPLE_NORMAL_MAP
Unk238 unk238[4]; // 238
std::uint64_t unk338; // 380
std::uint64_t unk340[9]; // 340
NiPointer<NiNode> controllerNodes[Hand::kTotal]; // 388 - Cloned for PlayerCharacter's LeftValveIndexControllerNode/RightValveIndexControllerNode
HMDDeviceType hmdDeviceType; // 398 - Set by comparing TrackedSystemName to "lighthouse", "oculus" and "holographic". Defaults to "lighthouse" if none match
NiTransform eyeToHeadTransform[2]; // 39C - 0 is left eye, 1 is right eye
private:
KEEP_FOR_RE()
};
Expand Down
94 changes: 71 additions & 23 deletions include/RE/B/BSVRInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#ifdef SKYRIMVR

# include "RE/B/BSTEvent.h"
# include "RE/N/NiNode.h"
# include "RE/N/NiSmartPointer.h"
# include "RE/N/NiTransform.h"
# include "openvr.h"

Expand All @@ -27,6 +29,52 @@ namespace RE
kHolographics // used for sDriverWindowsMR:VR?
};

enum Hand : std::uint32_t
{
kLeft,
kRight,
kTotal
};

struct Unk118
{
# pragma pack(push, 4)
struct PoseTransform
{
// Status based on openvr's ETrackingResult. Calibrated/uninitialized = kNotRunning
enum class TrackingStatus : std::uint32_t
{
kNotRunning,
kRunningOk,
kOutOfRange
};

TrackingStatus poseStatus; // 00
NiTransform renderPoseTransform; // 04
NiTransform gamePoseTransform; // 38
};
static_assert(sizeof(PoseTransform) == 0x6C);
# pragma pack(pop)

// members
Unk118* unk00; // 00
Unk118* unk08; // 08
Unk118* unk10; // 10
std::uint8_t unk18; // 18
bool unk19; // 19
std::uint16_t unk1A; // 18
std::uint32_t poseIndex; // 1C
PoseTransform* poseTransform; // 20
std::uint64_t unk28; // 28
std::uint64_t unk30; // 30
std::uint64_t unk38; // 38
std::uint64_t unk40; // 40
std::uint64_t unk48; // 48
std::uint64_t unk50; // 50
NiTransform unk58; // 58
};
static_assert(sizeof(Unk118) == 0x90);

struct Unk190
{
// members
Expand Down Expand Up @@ -58,7 +106,7 @@ namespace RE
virtual void GetProjectionRaw(vr::EVREye eEye, float* pfLeft, float* pfRight, float* pfTop, float* pfBottom); // 08
virtual NiTransform* GetEyeToHeadTransform(NiTransform& a_out, bool getRightEye); // 09
virtual NiTransform* Unk_0A(NiTransform& a_out, bool getRightController, bool a_unk1); // 0A
virtual void Unk_0B(void); // 0B
virtual void Unk_0B(void); // 0B - Processes events?
virtual vr::TrackedDeviceIndex_t GetTrackedDeviceIndexForHMD(); // 0C
virtual vr::TrackedDeviceIndex_t GetTrackedDeviceIndexForHand(bool getRightHand); // 0D
virtual void TriggerHapticPulse(bool doRightController, float duration); // 0E
Expand All @@ -67,32 +115,32 @@ namespace RE
virtual void Unk_11(void); // 11
virtual void Unk_12(void); // 12
virtual void Unk_13(void); // 13
virtual void Unk_14(void); // 14
virtual RE::NiPointer<NiNode>* GetControllerNode(RE::NiPointer<NiNode>& a_out, Hand a_hand); // 14
virtual void Unk_15(void); // 15
virtual HMDDeviceType GetHMDDeviceType(); // 16
virtual void Unk_17(void); // 17
virtual RE::NiPointer<NiNode>* CreateControllerNode(RE::NiPointer<NiNode>& a_out, Hand a_hand); // 17

// members
std::uint8_t unk110; // 110
void* unk118; // 118
std::uint64_t unk120; // 120
NiTransform unk128; // 128
NiTransform unk15C; // 15C
Unk190* unk190; // 190
std::uint64_t unk198; // 198
std::uint64_t unk1A0; // 1A0
std::uint64_t unk1A8; // 1A8
vr::IVROverlay* ivrOverlay; // 1B0
std::uint64_t unk1B8; // 1B8
std::uint64_t unk1C0; // 1C0
std::uint64_t unk1C8; // 1C8
std::uint64_t unk1D0; // 1D0
std::uint64_t unk1D8; // 1D8
std::uint64_t unk1E0; // 1E0
std::uint64_t unk1E8; // 1E8
std::uint64_t unk1F0; // 1F0
vr::VROverlayHandle_t unk1F8; // 1F8 - current overlay handle? Used in 2D overlay menus like JournalMenu
std::byte unk200; // 200
std::uint8_t unk110; // 110
Unk118* unk118; // 118 - Possibily a data structure for storing pose data?
std::uint64_t unk120; // 120
NiTransform renderTransform; // 128 - Headset pose render transform
NiTransform gameTransform; // 15C - Headset pose game transform
Unk190* unk190; // 190
std::uint64_t unk198; // 198
std::uint64_t unk1A0; // 1A0
std::uint64_t unk1A8; // 1A8
vr::IVROverlay* ivrOverlay; // 1B0
std::uint64_t unk1B8; // 1B8
std::uint64_t unk1C0; // 1C0
std::uint64_t unk1C8; // 1C8
std::uint64_t unk1D0; // 1D0
std::uint64_t unk1D8; // 1D8
std::uint64_t unk1E0; // 1E0
std::uint64_t unk1E8; // 1E8
std::uint64_t unk1F0; // 1F0
vr::VROverlayHandle_t unk1F8; // 1F8 - current overlay handle? Used in 2D overlay menus like JournalMenu
bool isHeadsetTrackingOk; // 200 - Headset is active and skyrim is receiving tracking data
private:
KEEP_FOR_RE()
};
Expand Down
8 changes: 6 additions & 2 deletions include/RE/J/JournalMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,17 @@ namespace RE
Journal_SystemTab systemTab; // 98
std::uint64_t unkD0; // D0
std::uint64_t unkD8; // D8
std::uint64_t unkE0; // E0
bool unkE0; // E0
#ifdef SKYRIMVR
std::uint64_t unkF8; // F8
std::uint64_t unk100; // 100
#endif
private:
KEEP_FOR_RE()
};
#ifndef SKYRIMVR
static_assert(sizeof(JournalMenu) == 0xE8);
#else
//static_assert(sizeof(JournalMenu) == 0x108);
static_assert(sizeof(JournalMenu) == 0x108);
#endif
}
2 changes: 1 addition & 1 deletion include/RE/N/NiAVObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ namespace RE
// add
virtual void UpdateControllers(NiUpdateData& a_data); // 25
#ifdef SKYRIMVR
virtual void Unk_VRFunc(void);
virtual void ApplyLocalTransformToWorld();
#endif
virtual void PerformOp(PerformOpFunc& a_func); // 26
virtual void AttachProperty(NiAlphaProperty* a_property); // 27 - { return; }
Expand Down
8 changes: 5 additions & 3 deletions include/RE/P/PlayerCharacter.h
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,8 @@ namespace RE
NiPointer<NiNode> PrimaryMagicOffsetNode; // 538
NiPointer<NiNode> PrimaryMagicAimNode; // 540
NiPointer<NiNode> PrimaryStaffMagicOffsetNode; // 548
std::uint64_t unk550; // 550
std::uint32_t unk550; // 550 - left hand for something?
std::uint32_t unk554; // 554 - right hand for something?
NiPointer<NiBillboardNode> CrosshairParent; // 558
NiPointer<NiBillboardNode> CrosshairSecondaryParent; // 560
NiPointer<NiBillboardNode> TargetLockParent; // 568
Expand All @@ -699,7 +700,8 @@ namespace RE
std::uint32_t unk5B0; // 5B0
std::uint32_t unk5B4; // 5B4
std::uint64_t unk5B8; // 5B8
std::uint64_t unk5C0; // 5C0
std::uint32_t unk5C0; // 5C0
std::uint32_t unk5C4; // 5C4
NiPointer<NiNode> BowAimNode; // 5C8
NiPointer<NiNode> BowRotationNode; // 5D0
NiPointer<NiNode> ArrowSnapNode; // 5D8
Expand All @@ -708,7 +710,7 @@ namespace RE
std::uint64_t unk5F0; // 5F0
NiPointer<NiNode> ArrowHoldOffsetNode; // 5F8
NiPointer<NiNode> ArrowHoldNode; // 600
std::uint64_t unk608; // 608
NiPointer<NiNode> unk608; // 608
float unkFloat610; // 610
std::uint32_t unk614; // 614
std::uint64_t unk618; // 618
Expand Down
7 changes: 5 additions & 2 deletions include/RE/T/TESCameraState.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ namespace RE
virtual ~TESCameraState(); // 00

// add
virtual void Begin(); // 01 - { return; }
virtual void End(); // 02 - { return; }
virtual void Begin(); // 01 - { return; }
virtual void End(); // 02 - { return; }
#ifdef SKYRIMVR
virtual void Unk_03(); // 03 - Directly calls Update
#endif
virtual void Update(BSTSmartPointer<TESCameraState>& a_nextState); // 03
virtual void GetRotation(NiQuaternion& a_rotation); // 04
virtual void GetTranslation(NiPoint3& a_translation); // 05
Expand Down
6 changes: 6 additions & 0 deletions include/RE/U/UI.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,17 @@ namespace RE
bool closingAllMenus; // 1C1
std::uint16_t pad1C2; // 1C2
std::uint32_t pad1C4; // 1C4
#ifdef SKYRIMVR
std::uint32_t unk1C8; // 1C8
std::uint32_t unk1CA; // 1CA
#endif
private:
KEEP_FOR_RE()
};
#ifndef SKYRIMVR
static_assert(sizeof(UI) == 0x1C8);
#else
static_assert(sizeof(UI) == 0x1D0);
#endif

template <class T>
Expand Down