@@ -150,6 +150,11 @@ constexpr bool HAS_FLAG(T1 flags, T2 test_flag) {
150150 return ((uint64_t )(flags) & (uint64_t )test_flag) == (uint64_t )(test_flag);
151151}
152152
153+ template <typename T>
154+ bool HasEnumFlag (T enumVal, T enumFlag) {
155+ return (std::to_underlying (enumVal) & std::to_underlying (enumFlag)) != 0 ;
156+ }
157+
153158template <typename T>
154159inline T swapEndianness (T val) {
155160 if constexpr (std::is_floating_point<T>::value) {
@@ -427,99 +432,104 @@ struct BEMatrix44 : BETypeCompatible {
427432 }
428433};
429434
430- enum class EventMode {
435+ enum class EventMode : int32_t {
431436 NO_EVENT = 0 ,
432437 ALWAYS_FIRST_PERSON = 1 ,
433438 FOLLOW_DEFAULT_EVENT_SETTINGS = 2 ,
434439 ALWAYS_THIRD_PERSON = 3 ,
435440};
436441
437- struct data_VRSettingsIn {
438- BEType<int32_t > cameraModeSetting;
439- BEType<int32_t > leftHandedSetting;
440- BEType<int32_t > guiFollowSetting;
441- BEType<float > playerHeightSetting;
442- BEType<int32_t > enable2DVRView;
443- BEType<int32_t > cropFlatTo16x9Setting;
444- BEType<int32_t > enableDebugOverlay;
445- BEType<int32_t > buggyAngularVelocity;
446- BEType<int32_t > cutsceneCameraMode;
447- BEType<int32_t > cutsceneBlackBars;
448-
449- bool IsLeftHanded () const {
450- return leftHandedSetting == 1 ;
451- }
442+ enum class CameraMode : int32_t {
443+ THIRD_PERSON = 0 ,
444+ FIRST_PERSON = 1 ,
445+ };
452446
453- bool IsFirstPersonMode () const {
454- return cameraModeSetting == 1 ;
455- }
447+ enum class PlayMode : int32_t {
448+ SEATED = 0 ,
449+ STANDING = 1 ,
450+ };
456451
457- bool IsThirdPersonMode () const {
458- return cameraModeSetting == 0 ;
459- }
452+ enum class GazeFollowUISetting : int32_t {
453+ FIXED = 0 ,
454+ FOLLOW_LOOKING_DIRECTION = 1 ,
455+ };
460456
457+ enum class AngularVelocityFixerMode : int32_t {
458+ AUTO = 0 , // Angular velocity fixer is automatically enabled for Oculus Link
459+ FORCED_ON = 1 ,
460+ FORCED_OFF = 2 ,
461+ };
462+
463+ struct ModSettings {
464+ // playing mode settings
465+ std::atomic<CameraMode> cameraMode = CameraMode::FIRST_PERSON;
466+ std::atomic<PlayMode> playMode = PlayMode::STANDING;
467+ std::atomic<float > thirdPlayerDistance = 0 .5f ;
468+ std::atomic<EventMode> cutsceneCameraMode = EventMode::FOLLOW_DEFAULT_EVENT_SETTINGS;
469+ std::atomic_bool useBlackBarsForCutscenes = false ;
470+
471+ // first-person settings
472+ std::atomic<float > playerHeightOffset = 0 .0f ;
473+ std::atomic_bool leftHanded = false ;
474+ std::atomic_bool uiFollowsGaze = true ;
475+ std::atomic_bool cropFlatTo16x9 = true ;
476+
477+ // advanced settings
478+ std::atomic_bool enableDebugOverlay = false ;
479+ std::atomic<AngularVelocityFixerMode> buggyAngularVelocity = AngularVelocityFixerMode::AUTO;
480+ std::atomic_uint32_t performanceOverlay = 0 ;
481+ std::atomic_uint32_t performanceOverlayFrequency = 60 ;
482+
483+ CameraMode GetCameraMode () const { return cameraMode; }
484+
485+ PlayMode GetPlayMode () const { return playMode; }
486+ bool DoesUIFollowGaze () const { return uiFollowsGaze; }
487+ bool IsLeftHanded () const { return leftHanded; }
488+ float GetPlayerHeightOffset () const {
489+ // disable height offset in third-person mode
490+ if (GetCameraMode () == CameraMode::THIRD_PERSON) {
491+ return 0 .0f ;
492+ }
493+
494+ return playerHeightOffset;
495+ }
461496 EventMode GetCutsceneCameraMode () const {
462497 // if in third-person mode, always use third-person cutscene camera
463- if (IsThirdPersonMode () ) {
498+ if (GetCameraMode () == CameraMode::THIRD_PERSON ) {
464499 return EventMode::ALWAYS_THIRD_PERSON;
465500 }
466-
467- return (EventMode)cutsceneCameraMode.getLE ();
501+ return cutsceneCameraMode;
468502 }
503+ bool UseBlackBarsForCutscenes () const { return useBlackBarsForCutscenes; }
504+ bool ShouldFlatPreviewBeCroppedTo16x9 () const { return cropFlatTo16x9 == 1 ; }
505+
506+ bool ShowDebugOverlay () const { return enableDebugOverlay; }
507+ AngularVelocityFixerMode AngularVelocityFixer_GetMode () const { return buggyAngularVelocity; }
469508
470- bool UseBlackBarsForCutscenes () const {
471- return cutsceneBlackBars == 1 ;
472- }
473-
474- bool UIFollowsLookingDirection () const {
475- return guiFollowSetting == 1 ;
476- }
477-
478- bool Is2DVRViewEnabled () const {
479- return enable2DVRView == 1 ;
480- }
481-
482- bool ShouldFlatPreviewBeCroppedTo16x9 () const {
483- return cropFlatTo16x9Setting == 1 ;
484- }
485-
486- bool ShowDebugOverlay () const {
487- return enableDebugOverlay.getLE () != 0 ;
488- }
489-
490- float GetZNear () const {
491- return 0 .1f ;
492- }
493-
494- float GetZFar () const {
495- return 25000 .0f ;
496- }
497-
498- enum class AngularVelocityFixerMode {
499- AUTO = 0 , // Angular velocity fixer is automatically enabled for Oculus Link
500- FORCED_ON = 1 ,
501- FORCED_OFF = 2 ,
502- };
503-
504- AngularVelocityFixerMode AngularVelocityFixer_GetMode () {
505- return (AngularVelocityFixerMode)buggyAngularVelocity.getLE ();
506- }
509+ // By default BotW's camera uses 0.1f for near plane and 25000.0f for far plane, except maybe some indoor areas? But for simplicity, we'll use the default values everywhere.
510+ float GetZNear () const { return 0 .1f ; }
511+ float GetZFar () const { return 25000 .0f ; }
507512
508513 std::string ToString () const {
509514 std::string buffer = " " ;
510- std::format_to (std::back_inserter (buffer), " - Camera Mode: {}\n " , IsFirstPersonMode () ? " First Person" : " Third Person" );
515+ std::format_to (std::back_inserter (buffer), " - Camera Mode: {}\n " , GetCameraMode () == CameraMode::FIRST_PERSON ? " First Person" : " Third Person" );
511516 std::format_to (std::back_inserter (buffer), " - Left Handed: {}\n " , IsLeftHanded () ? " Yes" : " No" );
512- std::format_to (std::back_inserter (buffer), " - GUI Follow Setting: {}\n " , UIFollowsLookingDirection () ? " Follow Looking Direction" : " Fixed" );
513- std::format_to (std::back_inserter (buffer), " - Player Height: {} meters\n " , playerHeightSetting.getLE ());
514- std::format_to (std::back_inserter (buffer), " - 2D VR View Enabled: {}\n " , Is2DVRViewEnabled () ? " Yes" : " No" );
517+ std::format_to (std::back_inserter (buffer), " - GUI Follow Setting: {}\n " , DoesUIFollowGaze () ? " Follow Looking Direction" : " Fixed" );
518+ std::format_to (std::back_inserter (buffer), " - Player Height: {} meters\n " , GetPlayerHeightOffset ());
515519 std::format_to (std::back_inserter (buffer), " - Crop Flat to 16:9: {}\n " , ShouldFlatPreviewBeCroppedTo16x9 () ? " Yes" : " No" );
516520 std::format_to (std::back_inserter (buffer), " - Debug Overlay: {}\n " , ShowDebugOverlay () ? " Enabled" : " Disabled" );
517521 std::format_to (std::back_inserter (buffer), " - Cutscene Camera Mode: {}\n " , GetCutsceneCameraMode () == EventMode::ALWAYS_FIRST_PERSON ? " Always First Person" : (GetCutsceneCameraMode () == EventMode::ALWAYS_THIRD_PERSON ? " Always Third Person" : " Follow Default Event Settings" ));
518522 std::format_to (std::back_inserter (buffer), " - Show Black Bars for Third-Person Cutscenes: {}\n " , UseBlackBarsForCutscenes () ? " Yes" : " No" );
523+ std::format_to (std::back_inserter (buffer), " - Performance Overlay: {}\n " , performanceOverlay == 0 ? " Disabled" : (performanceOverlay == 1 ? " 2D Only" : " Enabled" ));
524+ std::format_to (std::back_inserter (buffer), " - Performance Overlay Frequency: {} Hz\n " , performanceOverlayFrequency.load ());
519525 return buffer;
520526 }
527+
521528};
522529
530+ extern ModSettings& GetSettings ();
531+ extern void InitSettings ();
532+
523533
524534
525535#pragma pack(push, 1)
@@ -562,4 +572,4 @@ struct data_VRProjectionMatrixOut {
562572#include " utils/logger.h"
563573
564574constexpr uint32_t SEMAPHORE_TO_VULKAN = 0 ;
565- constexpr uint32_t SEMAPHORE_TO_D3D12 = 1 ;
575+ constexpr uint32_t SEMAPHORE_TO_D3D12 = 1 ;
0 commit comments