Skip to content

Commit

Permalink
Small VR update
Browse files Browse the repository at this point in the history
  • Loading branch information
Exit-9B committed Oct 30, 2024
1 parent cf023c6 commit d73660f
Show file tree
Hide file tree
Showing 46 changed files with 1,532 additions and 175 deletions.
9 changes: 9 additions & 0 deletions cmake/sourcelist.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ set(SOURCES
include/RE/B/BSNavmeshInfoMap.h
include/RE/B/BSNiAllocator.h
include/RE/B/BSNiNode.h
include/RE/B/BSOpenVR.h
include/RE/B/BSPCGamepadDeviceDelegate.h
include/RE/B/BSPCGamepadDeviceHandler.h
include/RE/B/BSPathingCell.h
Expand Down Expand Up @@ -305,6 +306,7 @@ set(SOURCES
include/RE/B/BSTriShape.h
include/RE/B/BSUIMessageData.h
include/RE/B/BSUIScaleformData.h
include/RE/B/BSVRInterface.h
include/RE/B/BSVirtualKeyboardDevice.h
include/RE/B/BSVisit.h
include/RE/B/BSVolumetricLightingRenderData.h
Expand Down Expand Up @@ -1349,6 +1351,13 @@ set(SOURCES
include/SKSE/Trampoline.h
include/SKSE/Translation.h
include/SKSE/Version.h
include/vr/COpenVRContext.h
include/vr/Hmd.h
include/vr/IVROverlay.h
include/vr/OpenVR.h
include/vr/OpenVRTypes.h
include/vr/Properties.h
include/vr/VREvent.h
src/RE/A/AIFormulas.cpp
src/RE/A/AIProcess.cpp
src/RE/A/ActiveEffect.cpp
Expand Down
2 changes: 1 addition & 1 deletion include/RE/A/AIProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ namespace RE
};
static_assert(sizeof(Data0B8) == 0x38);

void ClearFurniture();
void ClearFurniture(RE::Actor* a_actor);
float GetCachedHeight() const;
bhkCharacterController* GetCharController();
ActorHandle GetCommandingActor() const;
Expand Down
11 changes: 7 additions & 4 deletions include/RE/A/Actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -340,10 +340,13 @@ namespace RE
BSSimpleList<ActiveEffect*>* GetActiveEffectList() override; // 007

// add
virtual void Unk_A2(void); // 0A2
virtual void PlayPickUpSound(TESBoundObject* a_object, bool a_pickup, bool a_use); // 0A3
virtual float GetHeading(bool a_ignoreRaceSettings) const; // 0A4
virtual void SetAvoidanceDisabled(bool a_set); // 0A5 - { return; }
virtual void Unk_A2(void); // 0A2
virtual void PlayPickUpSound(TESBoundObject* a_object, bool a_pickup, bool a_use); // 0A3
virtual float GetHeading(bool a_ignoreRaceSettings) const; // 0A4
virtual void SetAvoidanceDisabled(bool a_set); // 0A5 - { return; }
#ifdef SKYRIMVR
virtual void UnkVR_A7(void); // 0A7
#endif
virtual void DrawWeaponMagicHands(bool a_draw); // 0A6
virtual void Unk_A7(void); // 0A7
virtual void Unk_A8(void); // 0A8
Expand Down
4 changes: 4 additions & 0 deletions include/RE/B/BSInputDeviceManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,9 @@ namespace RE
std::uint32_t unkE4; // E4
std::uint64_t unkE8; // E8
};
#ifndef SKYRIMVR
static_assert(sizeof(BSInputDeviceManager) == 0xF0);
#else
static_assert(sizeof(BSInputDeviceManager) == 0x120);
#endif
}
53 changes: 53 additions & 0 deletions include/RE/B/BSOpenVR.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#pragma once

#include "RE/B/BSVRInterface.h"

#ifdef SKYRIMVR
namespace RE
{
class BSOpenVR : public BSVRInterface
{
public:
struct Data238
{
std::uint64_t unk00; // 00
std::uint64_t unk08; // 08
std::uint64_t unk10; // 10
std::uint64_t unk18; // 18
std::uint64_t unk20; // 20
std::uint64_t unk28; // 28
std::uint64_t unk30; // 30
std::uint64_t unk38; // 38
};
static_assert(sizeof(Data238) == 0x40);

[[nodiscard]] static BSOpenVR* GetSingleton()
{
static REL::Relocation<BSOpenVR**> singleton{ REL::Offset(0x2FEB9B0) };
return *singleton;
}

// members
std::uint64_t unk208; // 208
void* unk210; // 210
std::uint64_t unk218; // 218
void* unk220; // 220
std::uint64_t unk228; // 228
std::uint64_t unk230; // 230
Data238 unk238[4]; // 238
std::uint64_t unk338; // 338
std::uint64_t unk340; // 340
std::uint64_t unk348; // 348
std::uint64_t unk350; // 350
std::uint64_t unk358; // 358
std::uint64_t unk360; // 360
std::uint64_t unk368; // 368
std::uint64_t unk370; // 370
std::uint64_t unk378; // 378
std::uint64_t unk380; // 380
std::uint64_t unk388[2]; // 388
std::uint64_t unk398; // 398
};
static_assert(sizeof(BSOpenVR) == 0x3A0);
}
#endif
50 changes: 50 additions & 0 deletions include/RE/B/BSVRInterface.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#pragma once

#include "RE/B/BSTEvent.h"
#include "vr/COpenVRContext.h"
#include "vr/OpenVRTypes.h"

#ifdef SKYRIMVR

namespace RE
{
struct VROverlayChange;
struct VRDeviceConnectionChange;
struct VRResetHMDHeight;

class BSVRInterface : public BSTEventSource<VROverlayChange>, // 00
public BSTEventSource<VRDeviceConnectionChange>, // 58
public BSTEventSource<VRResetHMDHeight> // B0
{
public:
[[nodiscard]] vr::IVROverlay* VROverlay()
{
static REL::Relocation<vr::IVROverlay*(vr::COpenVRContext&)> get{ REL::Offset(0x8A0110) };
return get(moduleContext);
}

// members
std::uint64_t unk108; // 108
std::uint64_t unk110; // 118
std::uint64_t unk118; // 118
std::uint64_t unk120; // 120
std::uint64_t unk128; // 128
std::uint64_t unk130; // 130
std::uint64_t unk138; // 138
std::uint64_t unk140; // 140
std::uint64_t unk148; // 148
std::uint64_t unk150; // 150
std::uint64_t unk158; // 158
std::uint64_t unk160; // 160
std::uint64_t unk168; // 168
std::uint64_t unk170; // 170
std::uint64_t unk178; // 178
std::uint64_t unk180; // 180
std::uint64_t unk188; // 188
vr::COpenVRContext moduleContext; // 190
vr::VROverlayHandle_t currentOverlay; // 1F8
std::uint64_t unk200; // 200
};
static_assert(sizeof(BSVRInterface) == 0x208);
}
#endif
9 changes: 9 additions & 0 deletions include/RE/C/ControlMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ namespace RE
// members
BSTArray<UserEventMapping> deviceMappings[INPUT_DEVICES::kTotal]; // 00
};
#if !defined(SKYRIMVR)
static_assert(sizeof(InputContext) == 0x60);
#else
static_assert(sizeof(InputContext) == 0xF0);
#endif

struct LinkedMapping
{
Expand Down Expand Up @@ -97,5 +101,10 @@ namespace RE
std::uint8_t pad12B; // 12B
stl::enumeration<PC_GAMEPAD_TYPE, std::uint32_t> gamePadMapType; // 12C
};
#if !defined(SKYRIMVR)
static_assert(sizeof(ControlMap) == 0x130);
#else
static_assert(offsetof(ControlMap, textEntryCount) == 0x140);
static_assert(sizeof(ControlMap) == 0x148);
#endif
}
9 changes: 7 additions & 2 deletions include/RE/C/CraftingMenu.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "RE/I/IMenu.h"
#include "RE/M/MenuEventHandler.h"

namespace RE
{
Expand All @@ -12,7 +13,11 @@ namespace RE
// menuDepth = 0
// flags = kUsesMenuContext | kDisablePauseMenu | kUpdateUsesCursor | kInventoryItemMenu | kDontHideCursorWhenTopmost
// context = kItemMenu
class CraftingMenu : public IMenu
class CraftingMenu : public IMenu // 00
#ifdef SKYRIMVR
,
public MenuEventHandler // 40
#endif
{
public:
inline static constexpr auto RTTI = RTTI_CraftingMenu;
Expand All @@ -31,6 +36,6 @@ namespace RE
#ifndef SKYRIMVR
static_assert(sizeof(CraftingMenu) == 0x38);
#else
//static_assert(sizeof(CraftingMenu) == 0x58);
static_assert(sizeof(CraftingMenu) == 0x58);
#endif
}
4 changes: 2 additions & 2 deletions include/RE/C/CreationClubMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ namespace RE
void AdvanceMovie(float a_interval, std::uint32_t a_currentTime) override; // 05

// override (MenuEventHandler)
bool CanProcess(InputEvent* a_event) override; // 01
bool ProcessThumbstick(ThumbstickEvent* a_event) override; // 03
bool ShouldHandleEvent(const InputEvent* a_event) override; // 01
bool HandleEvent(const ThumbstickEvent* a_event) override; // 03

// override (GFxFunctionHandler)
void Call(Params& a_params) override; // 01
Expand Down
6 changes: 3 additions & 3 deletions include/RE/C/CursorMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ namespace RE
UI_MESSAGE_RESULTS ProcessMessage(UIMessage& a_message) override; // 04

// override (MenuEventHandler)
bool CanProcess(InputEvent* a_event) override; // 01
bool ProcessThumbstick(ThumbstickEvent* a_event) override; // 03
bool ProcessMouseMove(MouseMoveEvent* a_event) override; // 04
bool ShouldHandleEvent(const InputEvent* a_event) override; // 01
bool HandleEvent(const MouseMoveEvent* a_event) override; // 04
bool HandleEvent(const ThumbstickEvent* a_event) override; // 03
};
#ifndef SKYRIMVR
static_assert(sizeof(CursorMenu) == 0x40);
Expand Down
6 changes: 3 additions & 3 deletions include/RE/D/DirectionHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ namespace RE
virtual ~DirectionHandler(); // 00

// override (MenuEventHandler)
bool CanProcess(InputEvent* a_event) override; // 01
bool ProcessThumbstick(ThumbstickEvent* a_event) override; // 03
bool ProcessButton(ButtonEvent* a_event) override; // 05
bool ShouldHandleEvent(const InputEvent* a_event) override; // 01
bool HandleEvent(const ButtonEvent* a_event) override; // 05
bool HandleEvent(const ThumbstickEvent* a_event) override; // 03

// members
std::uint32_t unk10; // 10
Expand Down
6 changes: 3 additions & 3 deletions include/RE/F/FavoritesHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ namespace RE
~FavoritesHandler() override; // 00

// add
bool CanProcess(InputEvent* a_event) override; // 01
bool ProcessKinect(KinectEvent* a_event) override; // 02
bool ProcessButton(ButtonEvent* a_event) override; // 05
bool ShouldHandleEvent(const InputEvent* a_event) override; // 01
bool HandleEvent(const ButtonEvent* a_event) override; // 05
bool HandleEvent(const KinectEvent* a_event) override; // 02
};
static_assert(sizeof(FavoritesHandler) == 0x10);
}
6 changes: 3 additions & 3 deletions include/RE/F/FavoritesMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ namespace RE
UI_MESSAGE_RESULTS ProcessMessage(UIMessage& a_message) override; // 04

// override (MenuEventHandler)
bool CanProcess(InputEvent* a_event) override; // 01
bool ProcessKinect(KinectEvent* a_event) override; // 02
bool ProcessButton(ButtonEvent* a_event) override; // 05
bool ShouldHandleEvent(const InputEvent* a_event) override; // 01
bool HandleEvent(const ButtonEvent* a_event) override; // 05
bool HandleEvent(const KinectEvent* a_event) override; // 02

// members
GFxValue root; // 40 - "Menu_mc"
Expand Down
29 changes: 23 additions & 6 deletions include/RE/I/IMenu.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include "RE/B/BSString.h"
#include "RE/F/FxDelegate.h"
#include "RE/F/FxDelegateHandler.h"
#include "RE/G/GFxMovieView.h"
Expand Down Expand Up @@ -59,7 +60,14 @@ namespace RE
using Context = UserEvents::INPUT_CONTEXT_ID;
using Flag = UI_MENU_FLAGS;

~IMenu() override = default; // 00
#ifdef SKYRIMVR
IMenu() :
depthPriority(4),
inputContext(static_cast<Context>(22))
{}
#endif

~IMenu() override; // 00

// override (FxDelegateHandler)
void Accept(CallbackProcessor* a_processor) override; // 01 - { return; }
Expand All @@ -72,8 +80,15 @@ namespace RE
virtual void PostDisplay(); // 06
virtual void PreDisplay(); // 07 - { return; } - only available if kRendersOffscreenTargets is set
virtual void RefreshPlatform(); // 08
#ifdef SKYRIMVR
virtual void Unk_09(std::int32_t a_arg1); // 09
virtual void ResetOnShow(); // 0A
#endif

[[nodiscard]] constexpr bool AdvancesUnderPauseMenu() const noexcept { return menuFlags.all(Flag::kAdvancesUnderPauseMenu); }
[[nodiscard]] constexpr bool AdvancesUnderPauseMenu() const noexcept
{
return menuFlags.all(Flag::kAdvancesUnderPauseMenu);
}
[[nodiscard]] constexpr bool AllowSaving() const noexcept { return menuFlags.all(Flag::kAllowSaving); }
[[nodiscard]] constexpr bool AlwaysOpen() const noexcept { return menuFlags.all(Flag::kAlwaysOpen); }
[[nodiscard]] constexpr bool ApplicationMenu() const noexcept { return menuFlags.all(Flag::kApplicationMenu); }
Expand Down Expand Up @@ -106,15 +121,17 @@ namespace RE
GPtr<GFxMovieView> uiMovie{ nullptr }; // 10
std::int8_t depthPriority{ 3 }; // 18
std::uint8_t pad19{ 0 }; // 19
std::uint16_t pad20{ 0 }; // 1A
std::uint16_t pad1A{ 0 }; // 1A
stl::enumeration<UI_MENU_FLAGS, std::uint32_t> menuFlags{ Flag::kNone }; // 1C
stl::enumeration<Context, std::uint32_t> inputContext{ Context::kNone }; // 20
std::uint32_t pad24{ 0 }; // 24
GPtr<FxDelegate> fxDelegate{ nullptr }; // 28
#ifdef SKYRIMVR
std::int32_t unk30; // 30
std::int32_t unk34; // 34
std::uint64_t unk38; // 38
std::int32_t unkVR30{ -1 }; // 30
std::uint8_t unkVR34{ 1 }; // 34
std::uint8_t padVR35; // 35
std::uint16_t padVR36; // 36
BSFixedString unkVR38{ "N/A"sv }; // 38
#endif
};
#ifndef SKYRIMVR
Expand Down
20 changes: 20 additions & 0 deletions include/RE/I/InputDevices.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,30 @@ namespace RE
kKeyboard = 0,
kMouse,
kGamepad,
#ifdef SKYRIMVR
kVivePrimary,
kViveSecondary,
kOculusPrimary,
kOculusSecondary,
kWMRPrimary,
kWMRSecondary,
#endif
kVirtualKeyboard,

kTotal
};
};
using INPUT_DEVICE = INPUT_DEVICES::INPUT_DEVICE;

#ifdef SKYRIMVR
[[nodiscard]] inline bool IsVRWandDevice(INPUT_DEVICE a_device)
{
return a_device == INPUT_DEVICE::kVivePrimary ||
a_device == INPUT_DEVICE::kViveSecondary ||
a_device == INPUT_DEVICE::kOculusPrimary ||
a_device == INPUT_DEVICE::kOculusSecondary ||
a_device == INPUT_DEVICE::kWMRPrimary ||
a_device == INPUT_DEVICE::kWMRSecondary;
}
#endif
}
6 changes: 5 additions & 1 deletion include/RE/I/InputEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ namespace RE
kChar,
kThumbstick,
kDeviceConnect,
kKinect
kKinect,
#ifdef SKYRIMVR
kVrWandTouchpadPosition,
kVrWandTouchpadSwipe,
#endif
};

class ButtonEvent;
Expand Down
Loading

0 comments on commit d73660f

Please sign in to comment.