Skip to content

Commit 4e9bc1f

Browse files
committed
Add warning if vive layers are present, but not using SteamVR
fixes #27
1 parent b2c7cda commit 4e9bc1f

3 files changed

Lines changed: 65 additions & 0 deletions

File tree

src/Architectures.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ class Architectures {
4747
return std::to_underlying(mValue);
4848
}
4949

50+
constexpr Architecture get_only() const {
51+
if (std::popcount(underlying()) != 1) {
52+
return Architecture::Invalid;
53+
}
54+
return mValue;
55+
}
56+
5057
std::generator<Architecture> enumerate() const {
5158
for (auto arch: magic_enum::enum_values<Architecture>()) {
5259
if (arch == Architecture::Invalid) {

src/lib.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ if (WIN32)
9393
linters/windows/ProgramFilesLinter.cpp
9494
linters/windows/UltraleapLastLinter.cpp
9595
linters/windows/UnsignedDllLinter.cpp
96+
linters/windows/ViveLayersLinter.cpp
9697
linters/windows/XRNeckSaferLinter.cpp
9798
)
9899

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// Copyright 2026 Fred Emmott <fred@fredemmott.com>
2+
// SPDX-License-Identifier: MIT
3+
4+
#include <fmt/core.h>
5+
6+
#include <unordered_set>
7+
8+
#include "APILayerStore.hpp"
9+
#include "Linter.hpp"
10+
11+
// Warn about a registry value that is not a DWORD
12+
namespace FredEmmott::OpenXRLayers {
13+
14+
class ViveLayersLinter final : public Linter {
15+
std::vector<std::shared_ptr<LintError>> Lint(
16+
const APILayerStore* store,
17+
const std::vector<std::tuple<APILayer, APILayerDetails>>& layers) override {
18+
const auto arch = store->GetArchitectures().get_only();
19+
if (arch == Architecture::Invalid) {
20+
return {};
21+
}
22+
const auto runtime = Platform::Get().GetActiveRuntime(arch);
23+
if (!runtime) {
24+
return {};
25+
}
26+
if (runtime->mName == "SteamVR") {
27+
return {};
28+
}
29+
const auto runtimeName = runtime->mName.value_or(runtime->mPath.string());
30+
31+
static const std::unordered_set<std::string_view> LayerNames {
32+
"XR_APILAYER_VIVE_hand_tracking",
33+
"XR_APILAYER_VIVE_facial_tracking",
34+
"XR_APILAYER_VIVE_srworks",
35+
};
36+
37+
std::vector<std::shared_ptr<LintError>> ret;
38+
for (const auto& [layer, details]: layers) {
39+
if (!LayerNames.contains(details.mName)) {
40+
continue;
41+
}
42+
ret.push_back(
43+
std::make_shared<InvalidLayerStateLintError>(
44+
fmt::format(
45+
"{} requires the SteamVR runtime, but you are currently using "
46+
"'{}'; this can cause game crashes or other issues.",
47+
details.mName,
48+
runtimeName),
49+
layer));
50+
}
51+
return ret;
52+
}
53+
};
54+
55+
static ViveLayersLinter gInstance;
56+
57+
}// namespace FredEmmott::OpenXRLayers

0 commit comments

Comments
 (0)