Skip to content

Commit

Permalink
Merge pull request CharmedBaryon#25 from Nightfallstorm/vr
Browse files Browse the repository at this point in the history
VR Menus RE
  • Loading branch information
alandtse authored Aug 28, 2023
2 parents 17065ba + 971f5e8 commit edfff9f
Show file tree
Hide file tree
Showing 26 changed files with 460 additions and 96 deletions.
5 changes: 5 additions & 0 deletions cmake/sourcelist.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ set(SOURCES
include/RE/B/BSNiAllocator.h
include/RE/B/BSNiNode.h
include/RE/B/BSOpenVR.h
include/RE/B/BSOpenVRControllerDevice.h
include/RE/B/BSOrderedNode.h
include/RE/B/BSPCGamepadDeviceDelegate.h
include/RE/B/BSPCGamepadDeviceHandler.h
Expand Down Expand Up @@ -365,6 +366,7 @@ set(SOURCES
include/RE/B/BSThread.h
include/RE/B/BSThreadEvent.h
include/RE/B/BSTimer.h
include/RE/B/BSTrackedControllerDevice.h
include/RE/B/BSTreeManager.h
include/RE/B/BSTriShape.h
include/RE/B/BSUIMessageData.h
Expand Down Expand Up @@ -909,6 +911,7 @@ set(SOURCES
include/RE/H/HighProcessData.h
include/RE/H/HitData.h
include/RE/H/HorseCameraState.h
include/RE/H/HudModeChangeEvent.h
include/RE/H/hkAabb.h
include/RE/H/hkArray.h
include/RE/H/hkBaseObject.h
Expand Down Expand Up @@ -1625,6 +1628,7 @@ set(SOURCES
include/RE/V/VoiceSpellFireHandler.h
include/RE/V/VrWandTouchpadPositionEvent.h
include/RE/V/VrWandTouchpadSwipeEvent.h
include/RE/W/WSActivateRollover.h
include/RE/W/WeaponAnimationGraphManagerHolder.h
include/RE/W/WeatherType.h
include/RE/W/WerewolfEffect.h
Expand Down Expand Up @@ -1975,6 +1979,7 @@ set(SOURCES
src/RE/U/UserEvents.cpp
src/RE/V/Variable.cpp
src/RE/V/VirtualMachine.cpp
src/RE/W/WorldSpaceMenu.cpp
src/RE/Z/ZeroFunctionArguments.cpp
src/REL/Relocation.cpp
src/SKSE/API.cpp
Expand Down
24 changes: 12 additions & 12 deletions include/RE/B/BSOpenVR.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
NiSourceTexture* unk230; // 230 - name is SIMPLE_NORMAL_MAP
Unk238 unk238[4]; // 238
std::uint64_t unk338; // 380
std::uint64_t unk340[9]; // 340
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
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
};
static_assert(sizeof(BSOpenVR) == 0x408);
#endif
Expand Down
47 changes: 47 additions & 0 deletions include/RE/B/BSOpenVRControllerDevice.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#pragma once

#ifdef SKYRIMVR

# include "RE/B/BSTrackedControllerDevice.h"

namespace RE
{
class BSOpenVRControllerDevice :
public BSTrackedControllerDevice // 00
{
public:
inline static constexpr auto RTTI = RTTI_BSOpenVRControllerDevice;

struct Keys
{
enum Key : std::uint32_t // Only tested with Oculus, keys are same for both controllers
{
kBY = 1, // Y/B button on left/right hand respectively
kGrip = 2, // Grip button
kXA = 7, // X/A button on left/right hand respectively
// kJoystick = 11, // Joystick moving event
kJoystickTrigger = 32, // Joystick press
kTrigger = 33 // Trigger button
};
};
using Key = Keys::Key;

// override (BSIInputDevice)
virtual void Initialize() override;
virtual void Process(float a_arg1) override;
virtual void Reset() override;

// members
std::uint64_t unk80[0x16]; // 080
std::uint32_t unk130; // 130
std::uint32_t unk134; // 134
std::uint32_t unk138; // 138
std::uint32_t unk13C; // 13C
std::uint32_t unk140; // 140
std::uint32_t unk144; // 144
std::uint32_t unk148; // 148
std::uint32_t unk14C; // 14C
};
static_assert(sizeof(BSOpenVRControllerDevice) == 0x150);
}
#endif
11 changes: 9 additions & 2 deletions include/RE/B/BSPCGamepadDeviceHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,18 @@ namespace RE
void InitializeDelegate(); // called by Initialize() and Process() to initialize the delegate

// members
BSPCGamepadDeviceDelegate* currentPCGamePadDelegate; // 08
#ifdef SKYRIMVR
std::uint64_t unk08; // 08
#endif
BSPCGamepadDeviceDelegate* currentPCGamePadDelegate; // 08, 10 in VR
protected:
friend class BSInputDeviceFactory;
BSPCGamepadDeviceHandler();
};

#ifdef SKYRIMVR
static_assert(sizeof(BSPCGamepadDeviceHandler) == 0x18);
#else
static_assert(sizeof(BSPCGamepadDeviceHandler) == 0x10);
#endif

}
26 changes: 26 additions & 0 deletions include/RE/B/BSTrackedControllerDevice.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#pragma once

#ifdef SKYRIMVR

namespace RE
{
enum class ControllerDeviceHand // Not sure on this one, enum needs more RE
{
kLeft = 0,
kRight = 1,

kNeither = 3
};

class BSTrackedControllerDevice :
public BSInputDevice
{
public:
// members
std::uint64_t unk70; // 70
ControllerDeviceHand hand; // 78
vr::TrackedDeviceIndex_t trackedDeviceIndex; // 7C
};
static_assert(sizeof(BSTrackedControllerDevice) == 0x80);
}
#endif
2 changes: 1 addition & 1 deletion include/RE/B/BSVRInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ namespace RE
std::uint64_t unk1E0; // 1E0
std::uint64_t unk1E8; // 1E8
std::uint64_t unk1F0; // 1F0
vr::VROverlayHandle_t unk1F8; // 1F8 - current overlay handle?
vr::VROverlayHandle_t unk1F8; // 1F8 - current overlay handle? Used in 2D overlay menus like JournalMenu
std::byte unk200; // 200
};
static_assert(sizeof(BSVRInterface) == 0x208);
Expand Down
1 change: 1 addition & 0 deletions include/RE/C/CalibrationOptionMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace RE
public IMenu, // 00
public MenuEventHandler // 40
{
public:
inline static constexpr auto RTTI = RTTI_CalibrationOptionMenu;

// override (IMenu)
Expand Down
10 changes: 8 additions & 2 deletions include/RE/C/CraftingMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ namespace RE
// menuDepth = 0
// flags = kUsesMenuContext | kDisablePauseMenu | kUpdateUsesCursor | kInventoryItemMenu | kDontHideCursorWhenTopmost
// context = kItemMenu
class CraftingMenu : public IMenu
class CraftingMenu :
#ifdef SKYRIMVR
public IMenu,
public MenuEventHandler
#else
public IMenu
#endif
{
public:
inline static constexpr auto RTTI = RTTI_CraftingMenu;
Expand All @@ -31,6 +37,6 @@ namespace RE
#ifndef SKYRIMVR
static_assert(sizeof(CraftingMenu) == 0x38);
#else
//static_assert(sizeof(CraftingMenu) == 0x58);
static_assert(sizeof(CraftingMenu) == 0x58);
#endif
}
21 changes: 19 additions & 2 deletions include/RE/D/DialogueMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "RE/B/BSTArray.h"
#include "RE/B/BSTEvent.h"
#include "RE/I/IMenu.h"
#include "RE/W/WorldSpaceMenu.h"

namespace RE
{
Expand All @@ -12,7 +13,11 @@ namespace RE
// flags = kUpdateUsesCursor | kDontHideCursorWhenTopmost
// context = kMenuMode
class DialogueMenu :
public IMenu, // 00
#ifndef SKYRIMVR
public IMenu, // 00
#else
public WorldSpaceMenu,
#endif
public BSTEventSink<MenuOpenCloseEvent> // 30
{
public:
Expand All @@ -32,15 +37,27 @@ namespace RE
void Accept(CallbackProcessor* a_processor) override; // 01
UI_MESSAGE_RESULTS ProcessMessage(UIMessage& a_message) override; // 04

#ifdef SKYRIMVR
virtual void SetupMenuNode() override;
virtual RE::NiNode* GetMenuParentNode() override; // 0C
virtual void SetTransform() override; // 0D
#endif
// override (BSTEventSink<MenuOpenCloseEvent>)
BSEventNotifyControl ProcessEvent(const MenuOpenCloseEvent* a_event, BSTEventSource<MenuOpenCloseEvent>* a_eventSource) override; // 01

#ifdef SKYRIMVR
// override (BSTEventSink<HudModeChangeEvent>)
BSEventNotifyControl ProcessEvent(const HudModeChangeEvent* a_event, BSTEventSource<HudModeChangeEvent>* a_eventSource) override; // 01
#endif
// members
BSTArray<Data> unk38; // 38
#ifdef SKYRIMVR
RE::NiNode* occlusionCheckNode; // 78 - name is "Dialogue Menu Occlusion Check Node"
#endif
};
#ifndef SKYRIMVR
static_assert(sizeof(DialogueMenu) == 0x50);
#else
//static_assert(sizeof(DialogueMenu) == 0x80);
static_assert(sizeof(DialogueMenu) == 0x80);
#endif
}
4 changes: 2 additions & 2 deletions include/RE/G/GFxMovieDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ namespace RE
[[nodiscard]] virtual GFxResource* GetMovieDataResource() const = 0; // 14
[[nodiscard]] virtual const GFxExporterInfo* GetExporterInfo() const = 0; // 15
virtual MemoryContext* CreateMemoryContext(const char* a_heapName, const MemoryParams& a_memParams, bool a_debugHeap) = 0; // 16
virtual GFxMovieView* CreateInstance(const MemoryParams& a_memParams, bool a_initFirstFrame = true) = 0; // 17
virtual GFxMovieView* CreateInstance(MemoryContext* a_memContext, bool a_initFirstFrame = true) = 0; // 18
virtual GFxMovieView* CreateInstanceWithContext(MemoryContext* a_memContext, bool a_initFirstFrame = true) = 0; // 17
virtual GFxMovieView* CreateInstance(const MemoryParams& a_memParams, bool a_initFirstFrame = true) = 0; // 18
virtual void VisitImportedMovies(ImportVisitor* a_visitor) = 0; // 19
virtual void VisitResources(ResourceVisitor* a_visitor, VisitResourceMask a_visitMask = VisitResourceMask::kAllImages) = 0; // 1A
virtual GFxResource* GetResource(const char* a_exportName) const = 0; // 1B
Expand Down
5 changes: 5 additions & 0 deletions include/RE/H/HUDMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ namespace RE
void AdvanceMovie(float a_interval, std::uint32_t a_currentTime) override; // 05
void RefreshPlatform() override; // 08

// override (WorldSpaceMenu)
void SetupMenuNode() override; // 0B
RE::NiNode* GetMenuParentNode() override; // 0C
void SetTransform() override; // 0D

// override (BSTEventSink<HudModeChangeEvent>)
BSEventNotifyControl ProcessEvent(const HudModeChangeEvent* a_event, BSTEventSource<HudModeChangeEvent>* a_eventSource) override; // 01

Expand Down
30 changes: 30 additions & 0 deletions include/RE/H/HudModeChangeEvent.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#pragma once

#ifdef SKYRIMVR
namespace RE
{
class HudModeChangeEvent
{
};

// TODO: Name not fully accurate, needs REing to determine usage for this
class HudMoveChangeEventSource : public BSTEventSource<HudModeChangeEvent>
{
public:
HudMoveChangeEventSource* GetSingleton(); // TODO: Add singleton

// members
std::uint64_t unk58; // 58
std::uint64_t unk60; // 60
std::uint64_t unk68; // 68
std::uint32_t unk6C; // 6C - set to 32
std::uint32_t unk70; // 70 - set to 32
std::uint32_t unk74; // 74 - set to 32
void* unk78; // 78 - set to SkyrimVR.exe+0x1EAAB34
std::uint64_t unk80; // 80
void* unk88; // 88 - points to allocated array of size 32, each member 0x18 size it seems
std::uint64_t unk90[10]; // 90
};
static_assert(sizeof(HudMoveChangeEventSource) == 0xE8); // Unconfirmed, highest seen so far
}
#endif
19 changes: 14 additions & 5 deletions include/RE/I/IMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "RE/F/FxDelegateHandler.h"
#include "RE/G/GFxMovieView.h"
#include "RE/G/GPtr.h"
#include "RE/S/Setting.h"
#include "RE/U/UserEvents.h"

namespace RE
Expand Down Expand Up @@ -51,6 +52,14 @@ namespace RE
kPassOn = 2
};

#ifdef SKYRIMVR
enum class UI_MENU_Unk09
{
kNone = static_cast<std::underlying_type_t<UI_MENU_Unk09>>(-1), // Entire enum needs more REing

};
#endif

class IMenu : public FxDelegateHandler
{
public:
Expand All @@ -73,8 +82,8 @@ namespace RE
virtual void PreDisplay(); // 07 - { return; } - only available if kRendersOffscreenTargets is set
virtual void RefreshPlatform(); // 08
#ifdef SKYRIMVR
virtual void Unk_09(void); // 09
virtual void Unk_0A(void); // 0A
virtual void Unk_09(UI_MENU_Unk09 a_unk); // 09 - { unk30 = a_unk; }
virtual void Unk_0A(); // 0A - Does something with _root.ResetOnShow swf function
#endif

[[nodiscard]] constexpr bool AdvancesUnderPauseMenu() const noexcept
Expand Down Expand Up @@ -119,9 +128,9 @@ namespace RE
std::uint32_t pad24{ 0 }; // 24
GPtr<FxDelegate> fxDelegate{ nullptr }; // 28
#ifdef SKYRIMVR
std::int32_t unk30{ -1 };
std::int32_t unk34{ 1 };
std::uint64_t unk38{ 0 };
stl::enumeration<UI_MENU_Unk09, std::uint32_t> unk30{ UI_MENU_Unk09::kNone };
std::byte unk34{ 1 };
BSFixedString menuName{ "N/A" }; // 38
#endif
};
#ifndef SKYRIMVR
Expand Down
Loading

0 comments on commit edfff9f

Please sign in to comment.