mirror of
https://github.com/mitch030504/Wiicompiled_VR_Frame.git
synced 2026-10-06 05:00:27 +02:00
Added Desktop view selector
This commit is contained in:
1 parent
a138670b37
commit
4cf9f60ee7
7 files changed
+260
-16
No files matched your search
@@ -56,6 +56,7 @@ struct RuntimeUserConfig {
|
||||
std::optional<bool> vrHudVirtualScreen;
|
||||
std::optional<bool> vrStopAtDisplayCopy;
|
||||
std::optional<bool> vrSkipCopyClears;
|
||||
std::optional<std::string> vrMirrorView;
|
||||
std::optional<bool> vrFirstPerson;
|
||||
std::optional<float> vrFirstPersonUnitsPerMeter;
|
||||
std::optional<float> vrFirstPersonHeadUpMeters;
|
||||
@@ -158,6 +159,15 @@ inline constexpr const char* kVrFirstPersonRotationDefault = "yaw";
|
||||
inline bool IsSupportedVrFirstPersonRotation(std::string_view value) {
|
||||
return value == "yaw" || value == "yaw_pitch" || value == "full";
|
||||
}
|
||||
// What the desktop window shows while the headset is running: "normal" leaves
|
||||
// the ordinary desktop view alone, "both", "left" and "right" mirror the
|
||||
// headset's eyes, and "none" blacks the window out. Matches
|
||||
// AuroraStereoMirrorView.
|
||||
inline constexpr const char* kVrMirrorViewDefault = "normal";
|
||||
|
||||
inline bool IsSupportedVrMirrorView(std::string_view value) {
|
||||
return value == "normal" || value == "both" || value == "left" || value == "right" || value == "none";
|
||||
}
|
||||
// SDL scancode name, spelled the way SDL_GetScancodeName produces it. An
|
||||
// empty string leaves the recenter hotkey unbound, menu button only.
|
||||
inline constexpr std::string_view kVrRecenterKeyDefault = "F9";
|
||||
@@ -360,6 +370,11 @@ inline void EnsureConfigFile() {
|
||||
"# to the ordinary desktop renderer. These values are read at launch.\n"
|
||||
"enabled = false\n"
|
||||
"required = false\n"
|
||||
"# What the desktop window shows while the headset is running:\n"
|
||||
"# \"normal\" keeps the ordinary desktop view, \"both\", \"left\" and\n"
|
||||
"# \"right\" mirror the headset's eyes, and \"none\" blacks the window\n"
|
||||
"# out. Changeable live from the F10 menu.\n"
|
||||
"mirror_view = \"normal\"\n"
|
||||
"render_scale = 1.0\n"
|
||||
"world_units_per_meter = 500.0\n"
|
||||
"hud_distance_meters = 2.0\n"
|
||||
@@ -616,6 +631,10 @@ inline RuntimeUserConfig ParseConfigDocument(const toml::value& document) {
|
||||
value && IsSupportedVrFirstPersonRotation(*value)) {
|
||||
config.vrFirstPersonRotation = *value;
|
||||
}
|
||||
if (auto value = FindConfigValue<std::string>(document, "vr", "mirror_view");
|
||||
value && IsSupportedVrMirrorView(*value)) {
|
||||
config.vrMirrorView = *value;
|
||||
}
|
||||
if (auto value = FindConfigInt(document, "vr", "first_person_hidden_model");
|
||||
value && *value >= -1 && *value <= 31) {
|
||||
config.vrFirstPersonHiddenModel = static_cast<int32_t>(*value);
|
||||
@@ -909,6 +928,14 @@ inline bool SetVrFirstPersonHideDriver(bool value) {
|
||||
return WriteSetting("vr", "first_person_hide_driver", value ? "true" : "false");
|
||||
}
|
||||
|
||||
inline bool SetVrMirrorView(std::string value) {
|
||||
if (!IsSupportedVrMirrorView(value)) {
|
||||
return false;
|
||||
}
|
||||
Mutable().vrMirrorView = value;
|
||||
return WriteSetting("vr", "mirror_view", FormatString(value));
|
||||
}
|
||||
|
||||
inline bool SetVrFirstPersonRotation(std::string value) {
|
||||
if (!IsSupportedVrFirstPersonRotation(value)) {
|
||||
return false;
|
||||
@@ -1236,6 +1263,11 @@ inline bool VrFirstPersonHideDriver(bool fallback = kVrFirstPersonHideDriverDefa
|
||||
return Get().vrFirstPersonHideDriver.value_or(fallback);
|
||||
}
|
||||
|
||||
inline std::string VrMirrorView(std::string fallback = kVrMirrorViewDefault) {
|
||||
const auto& value = Get().vrMirrorView;
|
||||
return value && IsSupportedVrMirrorView(*value) ? *value : std::move(fallback);
|
||||
}
|
||||
|
||||
inline std::string VrFirstPersonRotation(std::string fallback = kVrFirstPersonRotationDefault) {
|
||||
const auto& value = Get().vrFirstPersonRotation;
|
||||
return value && IsSupportedVrFirstPersonRotation(*value) ? *value : std::move(fallback);
|
||||
|
||||
@@ -118,6 +118,25 @@ float g_vrFirstPersonHeadForward = RuntimeConfigFile::VrFirstPersonHeadForwardMe
|
||||
float g_vrFirstPersonHeadRight = RuntimeConfigFile::VrFirstPersonHeadRightMeters();
|
||||
bool g_vrFirstPersonHideDriver = RuntimeConfigFile::VrFirstPersonHideDriver();
|
||||
int g_vrFirstPersonHiddenModel = RuntimeConfigFile::VrFirstPersonHiddenModel();
|
||||
// Config spellings and menu labels for the desktop mirror, index-matched to
|
||||
// AuroraStereoMirrorView so the combo selection converts to either directly.
|
||||
constexpr std::array<const char*, 5> kVrMirrorViewNames{"normal", "both", "left", "right", "none"};
|
||||
constexpr std::array<const char*, 5> kVrMirrorViewLabels{"Normal", "Both eyes", "Left eye", "Right eye", "None"};
|
||||
static_assert(kVrMirrorViewNames.size() == kVrMirrorViewLabels.size());
|
||||
static_assert(static_cast<int>(AURORA_STEREO_MIRROR_NORMAL) == 0);
|
||||
static_assert(static_cast<int>(AURORA_STEREO_MIRROR_BOTH_EYES) == 1);
|
||||
static_assert(static_cast<int>(AURORA_STEREO_MIRROR_LEFT_EYE) == 2);
|
||||
static_assert(static_cast<int>(AURORA_STEREO_MIRROR_RIGHT_EYE) == 3);
|
||||
static_assert(static_cast<int>(AURORA_STEREO_MIRROR_NONE) == 4);
|
||||
int g_vrMirrorView = [] {
|
||||
const std::string mode = RuntimeConfigFile::VrMirrorView();
|
||||
for (size_t i = 0; i < kVrMirrorViewNames.size(); ++i) {
|
||||
if (mode == kVrMirrorViewNames[i]) {
|
||||
return static_cast<int>(i);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}();
|
||||
constexpr std::array<const char*, 3> kVrFirstPersonRotationNames{"yaw", "yaw_pitch", "full"};
|
||||
int g_vrFirstPersonRotation = [] {
|
||||
const std::string mode = RuntimeConfigFile::VrFirstPersonRotation();
|
||||
@@ -891,9 +910,23 @@ void DrawVrSettings() {
|
||||
RuntimeConfigFile::SetVrEnabled(g_vrEnabled);
|
||||
}
|
||||
ImGui::TextDisabled("OpenXR mode changes take effect after restarting the game.");
|
||||
// Live, unlike the enable toggle above, so it is left usable either way:
|
||||
// set before a restart it is simply what the next session starts on.
|
||||
if (ImGui::Combo("Desktop view", &g_vrMirrorView, kVrMirrorViewLabels.data(),
|
||||
static_cast<int>(kVrMirrorViewLabels.size()))) {
|
||||
aurora_set_stereo_mirror_view(static_cast<AuroraStereoMirrorView>(g_vrMirrorView));
|
||||
RuntimeConfigFile::SetVrMirrorView(kVrMirrorViewNames[static_cast<size_t>(g_vrMirrorView)]);
|
||||
}
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::SetTooltip(
|
||||
"What this window shows while the headset is running. Normal keeps the ordinary "
|
||||
"desktop view, the eye choices mirror what you are actually seeing in the headset, "
|
||||
"and None leaves the window black. Menus reach the headset as a screen showing this "
|
||||
"same desktop image, so the eye choices only differ from Normal during a race.");
|
||||
}
|
||||
|
||||
// Unlike the toggle above, these two apply to the very next frame, so they
|
||||
// can be compared against each other from inside a running race.
|
||||
// Like the mirror above and unlike the enable toggle, these two apply to the
|
||||
// very next frame, so they can be compared from inside a running race.
|
||||
ImGui::Separator();
|
||||
ImGui::Text("VR eye replay (EFB)");
|
||||
if (ImGui::Checkbox("Stop eye at display copy", &g_vrStopAtDisplayCopy)) {
|
||||
@@ -1331,6 +1364,7 @@ void InitializeRuntimeSettings() noexcept {
|
||||
aurora_set_disable_copy_filter(g_disableCopyFilter);
|
||||
aurora_set_stereo_stop_at_display_copy(g_vrStopAtDisplayCopy);
|
||||
aurora_set_stereo_skip_copy_clears(g_vrSkipCopyClears);
|
||||
aurora_set_stereo_mirror_view(static_cast<AuroraStereoMirrorView>(g_vrMirrorView));
|
||||
ApplyVrHudVirtualScreen();
|
||||
aurora_set_skip_unready_pipelines(g_skipUnreadyPipelines);
|
||||
mkw::vr::MkwVRFirstPersonApplyConfiguredSettings();
|
||||
|
||||
Reference in new issue
Block a user