mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-11-25 19:41:20 -08:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aa4eacccdc | ||
|
|
34ebf5ca8b | ||
|
|
25ba150e51 |
No files matched your search
@@ -30,6 +30,8 @@
|
||||
/server/src/main/java/dev/slimevr/tracking/processor/ @Erimelowo
|
||||
/server/src/main/java/dev/slimevr/filtering/ @Erimelowo
|
||||
|
||||
/bindings-provider/ @ImSapphire
|
||||
|
||||
# Linux files
|
||||
*.nix @loucass003
|
||||
/flake.lock @loucass003
|
||||
|
||||
@@ -0,0 +1,297 @@
|
||||
---
|
||||
Language: Cpp
|
||||
AccessModifierOffset: -4
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignArrayOfStructures: None
|
||||
AlignConsecutiveAssignments:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
AlignFunctionDeclarations: false
|
||||
AlignFunctionPointers: false
|
||||
PadOperators: true
|
||||
AlignConsecutiveBitFields:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
AlignFunctionDeclarations: false
|
||||
AlignFunctionPointers: false
|
||||
PadOperators: false
|
||||
AlignConsecutiveDeclarations:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
AlignFunctionDeclarations: true
|
||||
AlignFunctionPointers: false
|
||||
PadOperators: false
|
||||
AlignConsecutiveMacros:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
AlignFunctionDeclarations: false
|
||||
AlignFunctionPointers: false
|
||||
PadOperators: false
|
||||
AlignConsecutiveShortCaseStatements:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCaseArrows: false
|
||||
AlignCaseColons: false
|
||||
AlignConsecutiveTableGenBreakingDAGArgColons:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
AlignFunctionDeclarations: false
|
||||
AlignFunctionPointers: false
|
||||
PadOperators: false
|
||||
AlignConsecutiveTableGenCondOperatorColons:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
AlignFunctionDeclarations: false
|
||||
AlignFunctionPointers: false
|
||||
PadOperators: false
|
||||
AlignConsecutiveTableGenDefinitionColons:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
AlignFunctionDeclarations: false
|
||||
AlignFunctionPointers: false
|
||||
PadOperators: false
|
||||
AlignEscapedNewlines: Right
|
||||
AlignOperands: DontAlign
|
||||
AlignTrailingComments:
|
||||
Kind: Never
|
||||
OverEmptyLines: 0
|
||||
AllowAllArgumentsOnNextLine: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: true
|
||||
AllowBreakBeforeNoexceptSpecifier: Never
|
||||
AllowShortBlocksOnASingleLine: Empty
|
||||
AllowShortCaseExpressionOnASingleLine: true
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortCompoundRequirementOnASingleLine: true
|
||||
AllowShortEnumsOnASingleLine: true
|
||||
AllowShortFunctionsOnASingleLine: All
|
||||
AllowShortIfStatementsOnASingleLine: Never
|
||||
AllowShortLambdasOnASingleLine: All
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AllowShortNamespacesOnASingleLine: false
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
AttributeMacros:
|
||||
- __capability
|
||||
BinPackArguments: true
|
||||
BinPackLongBracedList: true
|
||||
BinPackParameters: BinPack
|
||||
BitFieldColonSpacing: Both
|
||||
BracedInitializerIndentWidth: -1
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: false
|
||||
AfterClass: false
|
||||
AfterControlStatement: Never
|
||||
AfterEnum: false
|
||||
AfterExternBlock: false
|
||||
AfterFunction: true
|
||||
AfterNamespace: false
|
||||
AfterObjCDeclaration: false
|
||||
AfterStruct: false
|
||||
AfterUnion: false
|
||||
BeforeCatch: false
|
||||
BeforeElse: false
|
||||
BeforeLambdaBody: false
|
||||
BeforeWhile: false
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: true
|
||||
SplitEmptyRecord: true
|
||||
SplitEmptyNamespace: true
|
||||
BreakAdjacentStringLiterals: true
|
||||
BreakAfterAttributes: Leave
|
||||
BreakAfterJavaFieldAnnotations: false
|
||||
BreakAfterReturnType: None
|
||||
BreakArrays: true
|
||||
BreakBeforeBinaryOperators: All
|
||||
BreakBeforeConceptDeclarations: Always
|
||||
BreakBeforeBraces: Attach
|
||||
BreakBeforeInlineASMColon: OnlyMultiline
|
||||
BreakBeforeTemplateCloser: false
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakBinaryOperations: Never
|
||||
BreakConstructorInitializers: BeforeComma
|
||||
BreakFunctionDefinitionParameters: false
|
||||
BreakInheritanceList: BeforeColon
|
||||
BreakStringLiterals: true
|
||||
BreakTemplateDeclarations: MultiLine
|
||||
ColumnLimit: 0
|
||||
CommentPragmas: '^ IWYU pragma:'
|
||||
CompactNamespaces: false
|
||||
ConstructorInitializerIndentWidth: 4
|
||||
ContinuationIndentWidth: 4
|
||||
Cpp11BracedListStyle: false
|
||||
DerivePointerAlignment: false
|
||||
DisableFormat: false
|
||||
EmptyLineAfterAccessModifier: Never
|
||||
EmptyLineBeforeAccessModifier: LogicalBlock
|
||||
EnumTrailingComma: Leave
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
FixNamespaceComments: false
|
||||
ForEachMacros:
|
||||
- foreach
|
||||
- Q_FOREACH
|
||||
- BOOST_FOREACH
|
||||
IfMacros:
|
||||
- KJ_IF_MAYBE
|
||||
IncludeBlocks: Preserve
|
||||
IncludeCategories:
|
||||
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
|
||||
Priority: 2
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
|
||||
Priority: 3
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
- Regex: '.*'
|
||||
Priority: 1
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
IncludeIsMainRegex: '(Test)?$'
|
||||
IncludeIsMainSourceRegex: ''
|
||||
IndentAccessModifiers: false
|
||||
IndentCaseBlocks: false
|
||||
IndentCaseLabels: false
|
||||
IndentExportBlock: true
|
||||
IndentExternBlock: AfterExternBlock
|
||||
IndentGotoLabels: true
|
||||
IndentPPDirectives: None
|
||||
IndentRequiresClause: true
|
||||
IndentWidth: 4
|
||||
IndentWrappedFunctionNames: false
|
||||
InsertBraces: false
|
||||
InsertNewlineAtEOF: false
|
||||
InsertTrailingCommas: None
|
||||
IntegerLiteralSeparator:
|
||||
Binary: 0
|
||||
BinaryMinDigits: 0
|
||||
Decimal: 0
|
||||
DecimalMinDigits: 0
|
||||
Hex: 0
|
||||
HexMinDigits: 0
|
||||
JavaScriptQuotes: Leave
|
||||
JavaScriptWrapImports: true
|
||||
KeepEmptyLines:
|
||||
AtEndOfFile: false
|
||||
AtStartOfBlock: true
|
||||
AtStartOfFile: true
|
||||
KeepFormFeed: false
|
||||
LambdaBodyIndentation: Signature
|
||||
LineEnding: DeriveLF
|
||||
MacroBlockBegin: ''
|
||||
MacroBlockEnd: ''
|
||||
MainIncludeChar: Quote
|
||||
MaxEmptyLinesToKeep: 1
|
||||
NamespaceIndentation: Inner
|
||||
ObjCBinPackProtocolList: Auto
|
||||
ObjCBlockIndentWidth: 4
|
||||
ObjCBreakBeforeNestedBlockParam: true
|
||||
ObjCSpaceAfterProperty: true
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
OneLineFormatOffRegex: ''
|
||||
PackConstructorInitializers: BinPack
|
||||
PenaltyBreakAssignment: 2
|
||||
PenaltyBreakBeforeFirstCallParameter: 19
|
||||
PenaltyBreakBeforeMemberAccess: 150
|
||||
PenaltyBreakComment: 300
|
||||
PenaltyBreakFirstLessLess: 120
|
||||
PenaltyBreakOpenParenthesis: 0
|
||||
PenaltyBreakScopeResolution: 500
|
||||
PenaltyBreakString: 1000
|
||||
PenaltyBreakTemplateDeclaration: 10
|
||||
PenaltyExcessCharacter: 1000000
|
||||
PenaltyIndentedWhitespace: 0
|
||||
PenaltyReturnTypeOnItsOwnLine: 60
|
||||
PointerAlignment: Right
|
||||
PPIndentWidth: -1
|
||||
QualifierAlignment: Leave
|
||||
ReferenceAlignment: Pointer
|
||||
ReflowComments: Always
|
||||
RemoveBracesLLVM: false
|
||||
RemoveEmptyLinesInUnwrappedLines: false
|
||||
RemoveParentheses: Leave
|
||||
RemoveSemicolon: false
|
||||
RequiresClausePosition: OwnLine
|
||||
RequiresExpressionIndentation: OuterScope
|
||||
SeparateDefinitionBlocks: Leave
|
||||
ShortNamespaceLines: 1
|
||||
SkipMacroDefinitionBody: false
|
||||
SortIncludes:
|
||||
Enabled: true
|
||||
IgnoreCase: false
|
||||
SortJavaStaticImport: Before
|
||||
SortUsingDeclarations: LexicographicNumeric
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterOperatorKeyword: false
|
||||
SpaceAfterTemplateKeyword: true
|
||||
SpaceAroundPointerQualifiers: Default
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCaseColon: false
|
||||
SpaceBeforeCpp11BracedList: false
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeJsonColon: false
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceBeforeParensOptions:
|
||||
AfterControlStatements: true
|
||||
AfterForeachMacros: true
|
||||
AfterFunctionDefinitionName: false
|
||||
AfterFunctionDeclarationName: false
|
||||
AfterIfMacros: true
|
||||
AfterNot: false
|
||||
AfterOverloadedOperator: false
|
||||
AfterPlacementOperator: true
|
||||
AfterRequiresInClause: false
|
||||
AfterRequiresInExpression: false
|
||||
BeforeNonEmptyParentheses: false
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceBeforeSquareBrackets: false
|
||||
SpaceInEmptyBlock: true
|
||||
SpacesBeforeTrailingComments: 1
|
||||
SpacesInAngles: Never
|
||||
SpacesInContainerLiterals: true
|
||||
SpacesInLineCommentPrefix:
|
||||
Minimum: 1
|
||||
Maximum: -1
|
||||
SpacesInParens: Never
|
||||
SpacesInParensOptions:
|
||||
ExceptDoubleParentheses: false
|
||||
InCStyleCasts: false
|
||||
InConditionalStatements: false
|
||||
InEmptyParentheses: false
|
||||
Other: false
|
||||
SpacesInSquareBrackets: false
|
||||
Standard: Latest
|
||||
StatementAttributeLikeMacros:
|
||||
- Q_EMIT
|
||||
StatementMacros:
|
||||
- Q_UNUSED
|
||||
- QT_REQUIRE_VERSION
|
||||
TableGenBreakInsideDAGArg: DontBreak
|
||||
TabWidth: 8
|
||||
UseTab: Never
|
||||
VerilogBreakBetweenInstancePorts: true
|
||||
WhitespaceSensitiveMacros:
|
||||
- BOOST_PP_STRINGIZE
|
||||
- CF_SWIFT_NAME
|
||||
- NS_SWIFT_NAME
|
||||
- PP_STRINGIZE
|
||||
- STRINGIZE
|
||||
WrapNamespaceBodyWithEmptyLines: Leave
|
||||
...
|
||||
|
||||
@@ -10,13 +10,12 @@ Logger::Logger()
|
||||
: log_stream(Paths::getLogPath() / "slimevr-bindings-provider.log",
|
||||
std::ios::out | std::ios::app)
|
||||
#ifdef _WIN32
|
||||
,
|
||||
should_log_to_std_streams(GetConsoleWindow() != nullptr)
|
||||
, should_log_to_std_streams(GetConsoleWindow() != nullptr)
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
||||
Logger &Logger::get() {
|
||||
static Logger logger;
|
||||
return logger;
|
||||
static Logger logger;
|
||||
return logger;
|
||||
}
|
||||
@@ -9,69 +9,69 @@
|
||||
|
||||
class Logger {
|
||||
private:
|
||||
std::ofstream log_stream;
|
||||
std::ofstream log_stream;
|
||||
#ifdef _WIN32
|
||||
bool should_log_to_std_streams;
|
||||
bool should_log_to_std_streams;
|
||||
#endif
|
||||
|
||||
template <bool important, typename... Args>
|
||||
void log(std::string_view suffix, std::format_string<Args...> fmt,
|
||||
Args &&...args) {
|
||||
auto now = std::chrono::system_clock::now();
|
||||
auto time_t = std::chrono::system_clock::to_time_t(now);
|
||||
template <bool important, typename... Args>
|
||||
void log(std::string_view suffix, std::format_string<Args...> fmt,
|
||||
Args &&...args) {
|
||||
auto now = std::chrono::system_clock::now();
|
||||
auto time_t = std::chrono::system_clock::to_time_t(now);
|
||||
|
||||
auto s = std::format(fmt, std::forward<Args>(args)...);
|
||||
auto s = std::format(fmt, std::forward<Args>(args)...);
|
||||
#ifdef _WIN32
|
||||
if (should_log_to_std_streams) {
|
||||
if (should_log_to_std_streams) {
|
||||
#endif
|
||||
if constexpr (important)
|
||||
std::cerr << suffix << ' ' << s << '\n';
|
||||
else
|
||||
std::cout << suffix << ' ' << s << '\n';
|
||||
if constexpr (important)
|
||||
std::cerr << suffix << ' ' << s << '\n';
|
||||
else
|
||||
std::cout << suffix << ' ' << s << '\n';
|
||||
#ifdef _WIN32
|
||||
}
|
||||
#endif
|
||||
|
||||
log_stream << std::put_time(std::localtime(&time_t), "[%F %T]") //
|
||||
<< ' ' << suffix << ' ' << s << '\n';
|
||||
}
|
||||
#endif
|
||||
|
||||
log_stream << std::put_time(std::localtime(&time_t), "[%F %T]") //
|
||||
<< ' ' << suffix << ' ' << s << '\n';
|
||||
}
|
||||
|
||||
public:
|
||||
Logger();
|
||||
Logger();
|
||||
|
||||
template <typename... Args>
|
||||
void debug(std::format_string<Args...> fmt, Args &&...args) {
|
||||
template <typename... Args>
|
||||
void debug(std::format_string<Args...> fmt, Args &&...args) {
|
||||
#ifndef NDEBUG
|
||||
log<false>("[DEBUG]", fmt, std::forward<Args>(args)...);
|
||||
log<false>("[DEBUG]", fmt, std::forward<Args>(args)...);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void info(std::format_string<Args...> fmt, Args &&...args) {
|
||||
log<false>("[INFO]", fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void warning(std::format_string<Args...> fmt, Args &&...args) {
|
||||
log<true>("[WARN]", fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void error(std::format_string<Args...> fmt, Args &&...args) {
|
||||
log<true>("[ERROR]", fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
void flush() {
|
||||
#ifdef _WIN32
|
||||
if (should_log_to_std_streams) {
|
||||
#endif
|
||||
std::cerr.flush();
|
||||
std::cout.flush();
|
||||
#ifdef _WIN32
|
||||
}
|
||||
#endif
|
||||
log_stream.flush();
|
||||
}
|
||||
|
||||
static Logger &get();
|
||||
template <typename... Args>
|
||||
void info(std::format_string<Args...> fmt, Args &&...args) {
|
||||
log<false>("[INFO]", fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void warning(std::format_string<Args...> fmt, Args &&...args) {
|
||||
log<true>("[WARN]", fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void error(std::format_string<Args...> fmt, Args &&...args) {
|
||||
log<true>("[ERROR]", fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
void flush() {
|
||||
#ifdef _WIN32
|
||||
if (should_log_to_std_streams) {
|
||||
#endif
|
||||
std::cerr.flush();
|
||||
std::cout.flush();
|
||||
#ifdef _WIN32
|
||||
}
|
||||
#endif
|
||||
log_stream.flush();
|
||||
}
|
||||
|
||||
static Logger &get();
|
||||
};
|
||||
+225
-211
@@ -21,254 +21,268 @@ using namespace solarxr_protocol;
|
||||
static void shutdown_vr(vr::IVRSystem *_sys) { vr::VR_Shutdown(); }
|
||||
|
||||
static void onYawReset(SolarXRConnection &conn) {
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
|
||||
auto resetReq = rpc::CreateResetRequest(fbb, rpc::ResetType::Yaw, 0, 0.f);
|
||||
auto msgHeader = rpc::CreateRpcMessageHeader(
|
||||
fbb, nullptr, rpc::RpcMessage::ResetRequest, resetReq.Union());
|
||||
auto resetReq = rpc::CreateResetRequest(fbb, rpc::ResetType::Yaw, 0, 0.f);
|
||||
auto msgHeader = rpc::CreateRpcMessageHeader(
|
||||
fbb, nullptr, rpc::RpcMessage::ResetRequest, resetReq.Union());
|
||||
|
||||
auto rpcMsgs = fbb.CreateVector({msgHeader});
|
||||
auto bundle = CreateMessageBundle(fbb, 0, rpcMsgs, 0);
|
||||
fbb.Finish(bundle);
|
||||
conn.sendMsg(fbb);
|
||||
auto rpcMsgs = fbb.CreateVector({ msgHeader });
|
||||
auto bundle = CreateMessageBundle(fbb, 0, rpcMsgs, 0);
|
||||
fbb.Finish(bundle);
|
||||
conn.sendMsg(fbb);
|
||||
}
|
||||
static void onFullReset(SolarXRConnection &conn) {
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
|
||||
auto resetReq = rpc::CreateResetRequest(fbb, rpc::ResetType::Full, 0, 0.f);
|
||||
auto msgHeader = rpc::CreateRpcMessageHeader(
|
||||
fbb, nullptr, rpc::RpcMessage::ResetRequest, resetReq.Union());
|
||||
auto resetReq = rpc::CreateResetRequest(fbb, rpc::ResetType::Full, 0, 0.f);
|
||||
auto msgHeader = rpc::CreateRpcMessageHeader(
|
||||
fbb, nullptr, rpc::RpcMessage::ResetRequest, resetReq.Union());
|
||||
|
||||
auto rpcMsgs = fbb.CreateVector({msgHeader});
|
||||
auto bundle = CreateMessageBundle(fbb, 0, rpcMsgs, 0);
|
||||
fbb.Finish(bundle);
|
||||
conn.sendMsg(fbb);
|
||||
auto rpcMsgs = fbb.CreateVector({ msgHeader });
|
||||
auto bundle = CreateMessageBundle(fbb, 0, rpcMsgs, 0);
|
||||
fbb.Finish(bundle);
|
||||
conn.sendMsg(fbb);
|
||||
}
|
||||
static void onMountingCalibration(SolarXRConnection &conn) {
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
|
||||
auto resetReq =
|
||||
rpc::CreateResetRequest(fbb, rpc::ResetType::Mounting, 0, 0.f);
|
||||
auto msgHeader = rpc::CreateRpcMessageHeader(
|
||||
fbb, nullptr, rpc::RpcMessage::ResetRequest, resetReq.Union());
|
||||
auto resetReq = rpc::CreateResetRequest(fbb, rpc::ResetType::Mounting, 0, 0.f);
|
||||
auto msgHeader = rpc::CreateRpcMessageHeader(
|
||||
fbb, nullptr, rpc::RpcMessage::ResetRequest, resetReq.Union());
|
||||
|
||||
auto rpcMsgs = fbb.CreateVector({msgHeader});
|
||||
auto bundle = CreateMessageBundle(fbb, 0, rpcMsgs, 0);
|
||||
fbb.Finish(bundle);
|
||||
conn.sendMsg(fbb);
|
||||
auto rpcMsgs = fbb.CreateVector({ msgHeader });
|
||||
auto bundle = CreateMessageBundle(fbb, 0, rpcMsgs, 0);
|
||||
fbb.Finish(bundle);
|
||||
conn.sendMsg(fbb);
|
||||
}
|
||||
static void onFeetMountingCalibration(SolarXRConnection &conn) {
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
|
||||
auto bodyParts = fbb.CreateVector(
|
||||
{datatypes::BodyPart::LEFT_FOOT, datatypes::BodyPart::RIGHT_FOOT});
|
||||
auto resetReq =
|
||||
rpc::CreateResetRequest(fbb, rpc::ResetType::Mounting, bodyParts, 0.f);
|
||||
auto msgHeader = rpc::CreateRpcMessageHeader(
|
||||
fbb, nullptr, rpc::RpcMessage::ResetRequest, resetReq.Union());
|
||||
auto bodyParts = fbb.CreateVector(
|
||||
{ datatypes::BodyPart::LEFT_FOOT, datatypes::BodyPart::RIGHT_FOOT });
|
||||
auto resetReq = rpc::CreateResetRequest(fbb, rpc::ResetType::Mounting, bodyParts, 0.f);
|
||||
auto msgHeader = rpc::CreateRpcMessageHeader(
|
||||
fbb, nullptr, rpc::RpcMessage::ResetRequest, resetReq.Union());
|
||||
|
||||
auto rpcMsgs = fbb.CreateVector({msgHeader});
|
||||
auto bundle = CreateMessageBundle(fbb, 0, rpcMsgs, 0);
|
||||
fbb.Finish(bundle);
|
||||
conn.sendMsg(fbb);
|
||||
auto rpcMsgs = fbb.CreateVector({ msgHeader });
|
||||
auto bundle = CreateMessageBundle(fbb, 0, rpcMsgs, 0);
|
||||
fbb.Finish(bundle);
|
||||
conn.sendMsg(fbb);
|
||||
}
|
||||
static void onToggleTracking(SolarXRConnection &conn) {
|
||||
static bool shouldPause = false;
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
static bool shouldPause = false;
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
|
||||
shouldPause = !shouldPause;
|
||||
auto toggleReq = rpc::CreateSetPauseTrackingRequest(fbb, shouldPause);
|
||||
auto msgHeader = rpc::CreateRpcMessageHeader(
|
||||
fbb, nullptr, rpc::RpcMessage::SetPauseTrackingRequest,
|
||||
toggleReq.Union());
|
||||
shouldPause = !shouldPause;
|
||||
auto toggleReq = rpc::CreateSetPauseTrackingRequest(fbb, shouldPause);
|
||||
auto msgHeader = rpc::CreateRpcMessageHeader(
|
||||
fbb, nullptr, rpc::RpcMessage::SetPauseTrackingRequest,
|
||||
toggleReq.Union());
|
||||
|
||||
auto rpcMsgs = fbb.CreateVector({msgHeader});
|
||||
auto bundle = CreateMessageBundle(fbb, 0, rpcMsgs, 0);
|
||||
fbb.Finish(bundle);
|
||||
conn.sendMsg(fbb);
|
||||
auto rpcMsgs = fbb.CreateVector({ msgHeader });
|
||||
auto bundle = CreateMessageBundle(fbb, 0, rpcMsgs, 0);
|
||||
fbb.Finish(bundle);
|
||||
conn.sendMsg(fbb);
|
||||
}
|
||||
|
||||
sig_atomic_t should_exit = 0;
|
||||
|
||||
static void signal_handler(int signal) {
|
||||
Logger::get().info("Received signal {}", signal);
|
||||
should_exit = 1;
|
||||
Logger::get().info("Received signal {}", signal);
|
||||
should_exit = 1;
|
||||
}
|
||||
|
||||
int main() {
|
||||
auto &logger = Logger::get();
|
||||
auto &logger = Logger::get();
|
||||
|
||||
try {
|
||||
SolarXRConnection conn;
|
||||
std::unique_ptr<vr::IVRSystem, decltype(&shutdown_vr)> sys{nullptr,
|
||||
shutdown_vr};
|
||||
try {
|
||||
SolarXRConnection conn;
|
||||
std::unique_ptr<vr::IVRSystem, decltype(&shutdown_vr)> sys{ nullptr,
|
||||
shutdown_vr };
|
||||
|
||||
// On vrlink, VR_Init returns
|
||||
// VRInitError_Driver_WirelessHmdNotConnected while the connection
|
||||
// is initialising, so keep calling VR_Init until it ends up
|
||||
// succeeding
|
||||
// On vrlink, VR_Init returns
|
||||
// VRInitError_Driver_WirelessHmdNotConnected while the connection
|
||||
// is initialising, so keep calling VR_Init until it ends up
|
||||
// succeeding
|
||||
|
||||
vr::EVRInitError err{vr::VRInitError_Driver_WirelessHmdNotConnected};
|
||||
while (err == vr::VRInitError_Driver_WirelessHmdNotConnected) {
|
||||
sys.reset(vr::VR_Init(&err, vr::VRApplication_Background));
|
||||
if (err == vr::VRInitError_Driver_WirelessHmdNotConnected)
|
||||
std::this_thread::sleep_for(500ms);
|
||||
}
|
||||
|
||||
if (sys == nullptr or err != vr::VRInitError_None) {
|
||||
logger.error("Failed to init OpenVR: {} ({})",
|
||||
vr::VR_GetVRInitErrorAsSymbol(err),
|
||||
vr::VR_GetVRInitErrorAsEnglishDescription(err));
|
||||
return 1;
|
||||
}
|
||||
|
||||
logger.info("Initialised OpenVR, HMD model '{}'",
|
||||
VRUtils::getStringProp(vr::k_unTrackedDeviceIndex_Hmd,
|
||||
vr::Prop_ModelNumber_String)
|
||||
.value_or("<unknown>"));
|
||||
|
||||
vr::IVRApplications *app = vr::VRApplications();
|
||||
vr::IVRInput *input = vr::VRInput();
|
||||
|
||||
auto [appManifestPath, actionManifestPath] = VRUtils::initialiseManifest();
|
||||
|
||||
if (auto err =
|
||||
app->AddApplicationManifest(appManifestPath.string().data(), true);
|
||||
err != vr::VRApplicationError_None) {
|
||||
logger.error("Failed to add application manifest: {}",
|
||||
app->GetApplicationsErrorNameFromEnum(err));
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (auto err =
|
||||
input->SetActionManifestPath(actionManifestPath.string().data());
|
||||
err != vr::VRInputError_None) {
|
||||
logger.error("Failed to set action manifest path: {}",
|
||||
std::to_underlying(err));
|
||||
return 1;
|
||||
}
|
||||
|
||||
vr::VRActionSetHandle_t action_set;
|
||||
if (auto err = input->GetActionSetHandle("/actions/main", &action_set);
|
||||
err != vr::VRInputError_None) {
|
||||
logger.error("Failed to get main action set handle: {}",
|
||||
std::to_underlying(err));
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::map<std::string, std::tuple<vr::VRActionHandle_t,
|
||||
std::function<void(SolarXRConnection &)>>>
|
||||
actions{
|
||||
{"/actions/main/in/YawReset",
|
||||
std::make_tuple(vr::k_ulInvalidActionHandle, onYawReset)},
|
||||
{"/actions/main/in/FullReset",
|
||||
std::make_tuple(vr::k_ulInvalidActionHandle, onFullReset)},
|
||||
{"/actions/main/in/MountingCalibration",
|
||||
std::make_tuple(vr::k_ulInvalidActionHandle,
|
||||
onMountingCalibration)},
|
||||
{"/actions/main/in/FeetMountingCalibration",
|
||||
std::make_tuple(vr::k_ulInvalidActionHandle,
|
||||
onFeetMountingCalibration)},
|
||||
{"/actions/main/in/ToggleTracking",
|
||||
std::make_tuple(vr::k_ulInvalidActionHandle, onToggleTracking)},
|
||||
};
|
||||
|
||||
for (auto &[name, tuple] : actions) {
|
||||
auto &[handle, _] = tuple;
|
||||
if (auto err = input->GetActionHandle(name.c_str(), &handle);
|
||||
err != vr::VRInputError_None ||
|
||||
handle == vr::k_ulInvalidActionHandle) {
|
||||
logger.warning("Failed to get action handle for action {}: {}", name,
|
||||
std::to_underlying(err));
|
||||
}
|
||||
}
|
||||
|
||||
constexpr auto interval = 1000ms / 30;
|
||||
|
||||
signal(SIGINT, signal_handler);
|
||||
signal(SIGTERM, signal_handler);
|
||||
while (!should_exit) {
|
||||
vr::VREvent_t event{};
|
||||
while (sys->PollNextEvent(&event, sizeof(event))) {
|
||||
switch (event.eventType) {
|
||||
case vr::VREvent_Quit:
|
||||
logger.info("OpenVR runtime requested quit");
|
||||
should_exit = 1;
|
||||
break;
|
||||
case vr::VREvent_Input_BindingLoadFailed: {
|
||||
auto &loadData = event.data.inputBinding;
|
||||
logger.debug("Binding load failed (ulAppContainer={} "
|
||||
"pathMessage={} pathUrl={} pathControllerType={})",
|
||||
loadData.ulAppContainer, loadData.pathMessage,
|
||||
loadData.pathUrl, loadData.pathControllerType);
|
||||
break;
|
||||
vr::EVRInitError err{ vr::VRInitError_Driver_WirelessHmdNotConnected };
|
||||
while (err == vr::VRInitError_Driver_WirelessHmdNotConnected) {
|
||||
sys.reset(vr::VR_Init(&err, vr::VRApplication_Background));
|
||||
if (err == vr::VRInitError_Driver_WirelessHmdNotConnected)
|
||||
std::this_thread::sleep_for(500ms);
|
||||
}
|
||||
case vr::VREvent_Input_BindingLoadSuccessful: {
|
||||
auto &loadData = event.data.inputBinding;
|
||||
logger.debug("Binding load successful (ulAppContainer={} "
|
||||
"pathMessage={} pathUrl={} pathControllerType={})",
|
||||
loadData.ulAppContainer, loadData.pathMessage,
|
||||
loadData.pathUrl, loadData.pathControllerType);
|
||||
break;
|
||||
}
|
||||
case vr::VREvent_Input_ActionManifestReloaded:
|
||||
logger.debug("Action manifest reloaded");
|
||||
break;
|
||||
case vr::VREvent_Input_ActionManifestLoadFailed: {
|
||||
auto &manifestData = event.data.actionManifest;
|
||||
logger.debug(
|
||||
"Action manifest load failed (pathAppKey={} pathMessage={} "
|
||||
"pathMessageParam={} pathManifestPath={})",
|
||||
manifestData.pathAppKey, manifestData.pathMessage,
|
||||
manifestData.pathMessageParam, manifestData.pathManifestPath);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
vr::VRActiveActionSet_t set{
|
||||
.ulActionSet = action_set,
|
||||
.ulRestrictedToDevice = vr::k_ulInvalidInputValueHandle,
|
||||
.ulSecondaryActionSet = vr::k_ulInvalidActionSetHandle,
|
||||
.nPriority = 0,
|
||||
};
|
||||
if (auto err = input->UpdateActionState(&set, sizeof(set), 1);
|
||||
err != vr::VRInputError_None) {
|
||||
logger.warning("Error when updating action states: {}",
|
||||
std::to_underlying(err));
|
||||
}
|
||||
if (sys == nullptr or err != vr::VRInitError_None) {
|
||||
logger.error("Failed to init OpenVR: {} ({})",
|
||||
vr::VR_GetVRInitErrorAsSymbol(err),
|
||||
vr::VR_GetVRInitErrorAsEnglishDescription(err));
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (auto &[name, tuple] : actions) {
|
||||
auto &[handle, callback] = tuple;
|
||||
vr::InputDigitalActionData_t action_data{};
|
||||
if (auto err = input->GetDigitalActionData(
|
||||
handle, &action_data, sizeof(action_data),
|
||||
vr::k_ulInvalidInputValueHandle);
|
||||
logger.info("Initialised OpenVR, HMD model '{}'",
|
||||
VRUtils::getStringProp(vr::k_unTrackedDeviceIndex_Hmd,
|
||||
vr::Prop_ModelNumber_String)
|
||||
.value_or("<unknown>"));
|
||||
|
||||
vr::IVRApplications *app = vr::VRApplications();
|
||||
vr::IVRInput *input = vr::VRInput();
|
||||
|
||||
auto [appManifestPath, actionManifestPath] = VRUtils::initialiseManifest();
|
||||
|
||||
if (auto err = app->AddApplicationManifest(appManifestPath.string().data(), true);
|
||||
err != vr::VRApplicationError_None) {
|
||||
logger.error("Failed to add application manifest: {}",
|
||||
app->GetApplicationsErrorNameFromEnum(err));
|
||||
return 1;
|
||||
}
|
||||
|
||||
// SetActionManifestPath may return IPCError if vrserver is busy and takes
|
||||
// too long to reply, so keep invoking until it succeeds
|
||||
{
|
||||
vr::EVRInputError err{};
|
||||
constexpr int max_tries = 5;
|
||||
int tries = 0;
|
||||
while ((err = input->SetActionManifestPath(
|
||||
actionManifestPath.string().data()))
|
||||
== vr::VRInputError_IPCError
|
||||
&& tries++ < max_tries) {
|
||||
logger.debug("IPC error loading action manifest, retrying ({}/{})",
|
||||
tries, max_tries);
|
||||
std::this_thread::sleep_for(20ms);
|
||||
}
|
||||
|
||||
if (err != vr::VRInputError_None) {
|
||||
logger.error("Failed to set action manifest path: {}",
|
||||
std::to_underlying(err));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
vr::VRActionSetHandle_t action_set;
|
||||
if (auto err = input->GetActionSetHandle("/actions/main", &action_set);
|
||||
err != vr::VRInputError_None) {
|
||||
logger.warning("Failed to get action state for {} ({}): {}", name,
|
||||
handle, std::to_underlying(err));
|
||||
continue;
|
||||
logger.error("Failed to get main action set handle: {}",
|
||||
std::to_underlying(err));
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (action_data.bActive && action_data.bChanged && action_data.bState) {
|
||||
logger.debug("Action {} triggered", name);
|
||||
callback(conn);
|
||||
}
|
||||
}
|
||||
std::map<std::string, std::tuple<vr::VRActionHandle_t, std::function<void(SolarXRConnection &)>>>
|
||||
actions{
|
||||
{ "/actions/main/in/YawReset",
|
||||
std::make_tuple(vr::k_ulInvalidActionHandle, onYawReset) },
|
||||
{ "/actions/main/in/FullReset",
|
||||
std::make_tuple(vr::k_ulInvalidActionHandle, onFullReset) },
|
||||
{ "/actions/main/in/MountingCalibration",
|
||||
std::make_tuple(vr::k_ulInvalidActionHandle,
|
||||
onMountingCalibration) },
|
||||
{ "/actions/main/in/FeetMountingCalibration",
|
||||
std::make_tuple(vr::k_ulInvalidActionHandle,
|
||||
onFeetMountingCalibration) },
|
||||
{ "/actions/main/in/ToggleTracking",
|
||||
std::make_tuple(vr::k_ulInvalidActionHandle, onToggleTracking) },
|
||||
};
|
||||
|
||||
logger.flush();
|
||||
std::this_thread::sleep_for(interval);
|
||||
for (auto &[name, tuple] : actions) {
|
||||
auto &[handle, _] = tuple;
|
||||
if (auto err = input->GetActionHandle(name.c_str(), &handle);
|
||||
err != vr::VRInputError_None || handle == vr::k_ulInvalidActionHandle) {
|
||||
logger.warning("Failed to get action handle for action {}: {}", name,
|
||||
std::to_underlying(err));
|
||||
}
|
||||
}
|
||||
|
||||
constexpr auto interval = 1000ms / 30;
|
||||
|
||||
signal(SIGINT, signal_handler);
|
||||
signal(SIGTERM, signal_handler);
|
||||
while (!should_exit) {
|
||||
vr::VREvent_t event{};
|
||||
while (sys->PollNextEvent(&event, sizeof(event))) {
|
||||
switch (event.eventType) {
|
||||
case vr::VREvent_Quit:
|
||||
logger.info("OpenVR runtime requested quit");
|
||||
should_exit = 1;
|
||||
break;
|
||||
case vr::VREvent_Input_BindingLoadFailed: {
|
||||
auto &loadData = event.data.inputBinding;
|
||||
logger.debug("Binding load failed (ulAppContainer={} "
|
||||
"pathMessage={} pathUrl={} pathControllerType={})",
|
||||
loadData.ulAppContainer, loadData.pathMessage,
|
||||
loadData.pathUrl, loadData.pathControllerType);
|
||||
break;
|
||||
}
|
||||
case vr::VREvent_Input_BindingLoadSuccessful: {
|
||||
auto &loadData = event.data.inputBinding;
|
||||
logger.debug("Binding load successful (ulAppContainer={} "
|
||||
"pathMessage={} pathUrl={} pathControllerType={})",
|
||||
loadData.ulAppContainer, loadData.pathMessage,
|
||||
loadData.pathUrl, loadData.pathControllerType);
|
||||
break;
|
||||
}
|
||||
case vr::VREvent_Input_ActionManifestReloaded:
|
||||
logger.debug("Action manifest reloaded");
|
||||
break;
|
||||
case vr::VREvent_Input_ActionManifestLoadFailed: {
|
||||
auto &manifestData = event.data.actionManifest;
|
||||
logger.debug(
|
||||
"Action manifest load failed (pathAppKey={} pathMessage={} "
|
||||
"pathMessageParam={} pathManifestPath={})",
|
||||
manifestData.pathAppKey, manifestData.pathMessage,
|
||||
manifestData.pathMessageParam, manifestData.pathManifestPath);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!conn.connected()) {
|
||||
logger.warning("Connection to SlimeVR lost, exiting");
|
||||
break;
|
||||
}
|
||||
|
||||
vr::VRActiveActionSet_t set{
|
||||
.ulActionSet = action_set,
|
||||
.ulRestrictedToDevice = vr::k_ulInvalidInputValueHandle,
|
||||
.ulSecondaryActionSet = vr::k_ulInvalidActionSetHandle,
|
||||
.nPriority = 0,
|
||||
};
|
||||
if (auto err = input->UpdateActionState(&set, sizeof(set), 1);
|
||||
err != vr::VRInputError_None) {
|
||||
logger.warning("Error when updating action states: {}",
|
||||
std::to_underlying(err));
|
||||
}
|
||||
|
||||
for (auto &[name, tuple] : actions) {
|
||||
auto &[handle, callback] = tuple;
|
||||
vr::InputDigitalActionData_t action_data{};
|
||||
if (auto err = input->GetDigitalActionData(
|
||||
handle, &action_data, sizeof(action_data),
|
||||
vr::k_ulInvalidInputValueHandle);
|
||||
err != vr::VRInputError_None) {
|
||||
logger.warning("Failed to get action state for {} ({}): {}", name,
|
||||
handle, std::to_underlying(err));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (action_data.bActive && action_data.bChanged && action_data.bState) {
|
||||
logger.debug("Action {} triggered", name);
|
||||
callback(conn);
|
||||
}
|
||||
}
|
||||
|
||||
logger.flush();
|
||||
std::this_thread::sleep_for(interval);
|
||||
}
|
||||
|
||||
logger.info("Main loop done");
|
||||
} catch (std::exception &ex) {
|
||||
logger.error("Exception in main: {}", ex.what());
|
||||
logger.flush();
|
||||
return 1;
|
||||
}
|
||||
|
||||
logger.info("Main loop done");
|
||||
} catch (std::exception &ex) {
|
||||
logger.error("Exception in main: {}", ex.what());
|
||||
logger.flush();
|
||||
return 1;
|
||||
}
|
||||
|
||||
logger.flush();
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
@@ -3,31 +3,31 @@
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
fs::path Paths::getDataPath() {
|
||||
fs::path basePath{};
|
||||
fs::path basePath{};
|
||||
|
||||
#if defined(__linux__)
|
||||
if (const char *dataHomeOverride = getenv("XDG_DATA_HOME")) {
|
||||
basePath = dataHomeOverride;
|
||||
} else {
|
||||
const char *homeDir = getenv("HOME");
|
||||
if (homeDir == nullptr)
|
||||
throw std::runtime_error("HOME is unset");
|
||||
if (const char *dataHomeOverride = getenv("XDG_DATA_HOME")) {
|
||||
basePath = dataHomeOverride;
|
||||
} else {
|
||||
const char *homeDir = getenv("HOME");
|
||||
if (homeDir == nullptr)
|
||||
throw std::runtime_error("HOME is unset");
|
||||
|
||||
basePath = fs::path(homeDir) / ".local" / "share";
|
||||
}
|
||||
basePath = fs::path(homeDir) / ".local" / "share";
|
||||
}
|
||||
#elif defined(_WIN32)
|
||||
{
|
||||
const char *appData = getenv("APPDATA");
|
||||
if (appData == nullptr)
|
||||
throw std::runtime_error("APPDATA is unset");
|
||||
{
|
||||
const char *appData = getenv("APPDATA");
|
||||
if (appData == nullptr)
|
||||
throw std::runtime_error("APPDATA is unset");
|
||||
|
||||
basePath = appData;
|
||||
}
|
||||
basePath = appData;
|
||||
}
|
||||
#else
|
||||
#error "Unsupported platform"
|
||||
#endif
|
||||
|
||||
return basePath / "dev.slimevr.SlimeVR";
|
||||
return basePath / "dev.slimevr.SlimeVR";
|
||||
}
|
||||
|
||||
fs::path Paths::getLogPath() { return Paths::getDataPath() / "logs"; }
|
||||
@@ -15,74 +15,75 @@
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
fs::path SolarXRConnection::getSocketPath() {
|
||||
using namespace std::string_view_literals;
|
||||
using namespace std::string_view_literals;
|
||||
#if defined(__linux__)
|
||||
#define MAKE_SOCKET_PATH(PATH) \
|
||||
std::make_pair(PATH##sv, static_cast<const char *>(getenv(PATH)))
|
||||
#define MAKE_SOCKET_PATH(PATH) \
|
||||
std::make_pair(PATH##sv, static_cast<const char *>(getenv(PATH)))
|
||||
|
||||
constexpr std::string_view socketName = "SlimeVRRpc";
|
||||
std::array<std::pair<std::string_view, const char *>, 4> socketPaths{
|
||||
MAKE_SOCKET_PATH("SLIMEVR_SOCKET_DIR"),
|
||||
MAKE_SOCKET_PATH("XDG_RUNTIME_DIR"),
|
||||
MAKE_SOCKET_PATH("TMPDIR"),
|
||||
{"/tmp", "/tmp"}};
|
||||
constexpr std::string_view socketName = "SlimeVRRpc";
|
||||
std::array<std::pair<std::string_view, const char *>, 4> socketPaths{
|
||||
MAKE_SOCKET_PATH("SLIMEVR_SOCKET_DIR"),
|
||||
MAKE_SOCKET_PATH("XDG_RUNTIME_DIR"),
|
||||
MAKE_SOCKET_PATH("TMPDIR"),
|
||||
{ "/tmp", "/tmp" }
|
||||
};
|
||||
|
||||
#undef MAKE_SOCKET_PATH
|
||||
|
||||
for (auto [name, path] : socketPaths) {
|
||||
if (path == nullptr) {
|
||||
Logger::get().info(
|
||||
"Skipping socket directory {} because it doesn't exist", name);
|
||||
continue;
|
||||
}
|
||||
fs::path socketPath = fs::path(path) / socketName;
|
||||
if (fs::exists(socketPath))
|
||||
return socketPath;
|
||||
for (auto [name, path] : socketPaths) {
|
||||
if (path == nullptr) {
|
||||
Logger::get().info(
|
||||
"Skipping socket directory {} because it doesn't exist", name);
|
||||
continue;
|
||||
}
|
||||
fs::path socketPath = fs::path(path) / socketName;
|
||||
if (fs::exists(socketPath))
|
||||
return socketPath;
|
||||
|
||||
Logger::get().info(
|
||||
"Skipping socket directory {} because socket does not exist", name);
|
||||
}
|
||||
Logger::get().info(
|
||||
"Skipping socket directory {} because socket does not exist", name);
|
||||
}
|
||||
#elif defined(_WIN32)
|
||||
throw std::logic_error(
|
||||
"SolarXRConnection::getSocketPath should not be called on Windows");
|
||||
throw std::logic_error(
|
||||
"SolarXRConnection::getSocketPath should not be called on Windows");
|
||||
#else
|
||||
#error "Unsupported platform"
|
||||
#endif
|
||||
|
||||
throw std::runtime_error("Failed to find socket directory");
|
||||
throw std::runtime_error("Failed to find socket directory");
|
||||
}
|
||||
|
||||
SolarXRConnection::SolarXRConnection() {
|
||||
#if defined(__linux__)
|
||||
sockaddr_un addr{};
|
||||
addr.sun_family = AF_UNIX;
|
||||
strcpy(addr.sun_path, getSocketPath().string().data());
|
||||
sockaddr_un addr{};
|
||||
addr.sun_family = AF_UNIX;
|
||||
strcpy(addr.sun_path, getSocketPath().string().data());
|
||||
|
||||
fd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
if (fd == -1) {
|
||||
throw std::runtime_error(
|
||||
std::format("Failed to create listen socket: {}", strerror(errno)));
|
||||
}
|
||||
fd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
if (fd == -1) {
|
||||
throw std::runtime_error(
|
||||
std::format("Failed to create listen socket: {}", strerror(errno)));
|
||||
}
|
||||
|
||||
if (connect(fd, reinterpret_cast<sockaddr *>(&addr), sizeof(addr)) == -1) {
|
||||
int e = errno;
|
||||
close(fd);
|
||||
throw std::runtime_error(std::format("Failed to connect to socket {}: {}",
|
||||
addr.sun_path, strerror(e)));
|
||||
}
|
||||
if (connect(fd, reinterpret_cast<sockaddr *>(&addr), sizeof(addr)) == -1) {
|
||||
int e = errno;
|
||||
close(fd);
|
||||
throw std::runtime_error(std::format("Failed to connect to socket {}: {}",
|
||||
addr.sun_path, strerror(e)));
|
||||
}
|
||||
|
||||
#elif defined(_WIN32)
|
||||
const char *pipeName = R"(\\.\pipe\SlimeVRRpc)";
|
||||
if (!WaitNamedPipe(pipeName, 5000)) {
|
||||
throw std::runtime_error("Timed out waiting for pipe");
|
||||
}
|
||||
const char *pipeName = R"(\\.\pipe\SlimeVRRpc)";
|
||||
if (!WaitNamedPipe(pipeName, 5000)) {
|
||||
throw std::runtime_error("Timed out waiting for pipe");
|
||||
}
|
||||
|
||||
pipe = CreateFile(pipeName, GENERIC_READ | GENERIC_WRITE, 0, nullptr,
|
||||
OPEN_EXISTING, 0, nullptr);
|
||||
if (pipe == INVALID_HANDLE_VALUE) {
|
||||
throw std::runtime_error(
|
||||
std::format("Unable to open pipe (error={})", GetLastError()));
|
||||
}
|
||||
pipe = CreateFile(pipeName, GENERIC_READ | GENERIC_WRITE, 0, nullptr,
|
||||
OPEN_EXISTING, 0, nullptr);
|
||||
if (pipe == INVALID_HANDLE_VALUE) {
|
||||
throw std::runtime_error(
|
||||
std::format("Unable to open pipe (error={})", GetLastError()));
|
||||
}
|
||||
#else
|
||||
#error "Unsupported platform"
|
||||
#endif
|
||||
@@ -90,50 +91,72 @@ SolarXRConnection::SolarXRConnection() {
|
||||
|
||||
SolarXRConnection::~SolarXRConnection() {
|
||||
#if defined(__linux__)
|
||||
if (fd != -1)
|
||||
close(fd);
|
||||
if (fd != -1)
|
||||
close(fd);
|
||||
#elif defined(_WIN32)
|
||||
if (pipe != INVALID_HANDLE_VALUE)
|
||||
CloseHandle(pipe);
|
||||
if (pipe != INVALID_HANDLE_VALUE)
|
||||
CloseHandle(pipe);
|
||||
#else
|
||||
#error "Unsupported platform"
|
||||
#endif
|
||||
}
|
||||
|
||||
bool SolarXRConnection::connected() {
|
||||
#if defined(__linux__)
|
||||
if (read(fd, nullptr, 0) == -1) {
|
||||
return !(errno == EBADF || errno == EINVAL);
|
||||
}
|
||||
|
||||
return true;
|
||||
#elif defined(_WIN32)
|
||||
if (!WriteFile(pipe, nullptr, 0, nullptr, nullptr)) {
|
||||
int err = GetLastError();
|
||||
// The documentation says it should return ERROR_BROKEN_PIPE
|
||||
// when the write-end has been closed, but it seems to actually
|
||||
// return ERROR_NO_DATA...
|
||||
return !(err == ERROR_NO_DATA || err == ERROR_BROKEN_PIPE);
|
||||
}
|
||||
|
||||
return true;
|
||||
#else
|
||||
#error "Unsupported platform"
|
||||
#endif
|
||||
}
|
||||
|
||||
void SolarXRConnection::sendMsg(flatbuffers::FlatBufferBuilder &fbb) {
|
||||
// The server expects the total size of the buffer to be written at the
|
||||
// start of the packet, including the first 4 bytes for the size
|
||||
int size = fbb.GetSize() + 4;
|
||||
// This may be wrong on mixed-endianness, but oh well...
|
||||
if constexpr (std::endian::native != std::endian::little)
|
||||
size = std::byteswap(size);
|
||||
// The server expects the total size of the buffer to be written at the
|
||||
// start of the packet, including the first 4 bytes for the size
|
||||
int size = fbb.GetSize() + 4;
|
||||
// This may be wrong on mixed-endianness, but oh well...
|
||||
if constexpr (std::endian::native != std::endian::little)
|
||||
size = std::byteswap(size);
|
||||
|
||||
#if defined(__linux__)
|
||||
if (write(fd, &size, sizeof(size)) == -1) {
|
||||
Logger::get().warning("Failed to write message size to socket: {}",
|
||||
strerror(errno));
|
||||
return;
|
||||
}
|
||||
if (write(fd, &size, sizeof(size)) == -1) {
|
||||
Logger::get().warning("Failed to write message size to socket: {}",
|
||||
strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
if (write(fd, fbb.GetBufferPointer(), fbb.GetSize()) == -1) {
|
||||
Logger::get().warning("Failed to write message to socket: {}",
|
||||
strerror(errno));
|
||||
return;
|
||||
}
|
||||
if (write(fd, fbb.GetBufferPointer(), fbb.GetSize()) == -1) {
|
||||
Logger::get().warning("Failed to write message to socket: {}",
|
||||
strerror(errno));
|
||||
return;
|
||||
}
|
||||
#elif defined(_WIN32)
|
||||
uint8_t tempBuf[2048];
|
||||
if (fbb.GetSize() > 2048 - 4) {
|
||||
Logger::get().warning("Message is too big for temporary buffer");
|
||||
return;
|
||||
}
|
||||
uint8_t tempBuf[2048];
|
||||
if (fbb.GetSize() > 2048 - 4) {
|
||||
Logger::get().warning("Message is too big for temporary buffer");
|
||||
return;
|
||||
}
|
||||
|
||||
*reinterpret_cast<int *>(&tempBuf[0]) = size;
|
||||
memcpy(&tempBuf[4], fbb.GetBufferPointer(), fbb.GetSize());
|
||||
if (!WriteFile(pipe, tempBuf, fbb.GetSize() + 4, nullptr, nullptr)) {
|
||||
Logger::get().warning("Failed to write message to pipe (error={})",
|
||||
GetLastError());
|
||||
return;
|
||||
}
|
||||
*reinterpret_cast<int *>(&tempBuf[0]) = size;
|
||||
memcpy(&tempBuf[4], fbb.GetBufferPointer(), fbb.GetSize());
|
||||
if (!WriteFile(pipe, tempBuf, fbb.GetSize() + 4, nullptr, nullptr)) {
|
||||
Logger::get().warning("Failed to write message to pipe (error={})",
|
||||
GetLastError());
|
||||
return;
|
||||
}
|
||||
#else
|
||||
#error "Unsupported platform"
|
||||
#endif
|
||||
|
||||
@@ -12,19 +12,20 @@
|
||||
class SolarXRConnection {
|
||||
private:
|
||||
#if defined(__linux__)
|
||||
int fd{-1};
|
||||
int fd{ -1 };
|
||||
#elif defined(_WIN32)
|
||||
HANDLE pipe{INVALID_HANDLE_VALUE};
|
||||
HANDLE pipe{ INVALID_HANDLE_VALUE };
|
||||
#else
|
||||
#error "Unsupported platform"
|
||||
#endif
|
||||
|
||||
static std::filesystem::path getSocketPath();
|
||||
static std::filesystem::path getSocketPath();
|
||||
|
||||
public:
|
||||
SolarXRConnection() noexcept(false);
|
||||
SolarXRConnection() noexcept(false);
|
||||
|
||||
~SolarXRConnection();
|
||||
~SolarXRConnection();
|
||||
|
||||
void sendMsg(flatbuffers::FlatBufferBuilder &fbb);
|
||||
bool connected();
|
||||
void sendMsg(flatbuffers::FlatBufferBuilder &fbb);
|
||||
};
|
||||
@@ -13,61 +13,60 @@ namespace fs = std::filesystem;
|
||||
std::optional<std::string>
|
||||
VRUtils::getStringProp(vr::TrackedDeviceIndex_t deviceIndex,
|
||||
vr::ETrackedDeviceProperty prop) {
|
||||
vr::IVRSystem *sys = vr::VRSystem();
|
||||
vr::ETrackedPropertyError err{vr::TrackedProp_Success};
|
||||
vr::IVRSystem *sys = vr::VRSystem();
|
||||
vr::ETrackedPropertyError err{ vr::TrackedProp_Success };
|
||||
|
||||
uint32_t required_len =
|
||||
sys->GetStringTrackedDeviceProperty(deviceIndex, prop, nullptr, 0, &err);
|
||||
if (err != vr::TrackedProp_BufferTooSmall) {
|
||||
Logger::get().info(
|
||||
"Failed to get size of string property {} for device {}: {}",
|
||||
std::to_underlying(prop), deviceIndex,
|
||||
sys->GetPropErrorNameFromEnum(err));
|
||||
return std::nullopt;
|
||||
}
|
||||
uint32_t required_len = sys->GetStringTrackedDeviceProperty(deviceIndex, prop, nullptr, 0, &err);
|
||||
if (err != vr::TrackedProp_BufferTooSmall) {
|
||||
Logger::get().info(
|
||||
"Failed to get size of string property {} for device {}: {}",
|
||||
std::to_underlying(prop), deviceIndex,
|
||||
sys->GetPropErrorNameFromEnum(err));
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::string s(required_len - 1, '\0');
|
||||
sys->GetStringTrackedDeviceProperty(deviceIndex, prop, s.data(), required_len,
|
||||
&err);
|
||||
if (err != vr::TrackedProp_Success) {
|
||||
Logger::get().info("Failed to get string property {} for device {}: {}",
|
||||
std::to_underlying(prop), deviceIndex,
|
||||
sys->GetPropErrorNameFromEnum(err));
|
||||
return std::nullopt;
|
||||
}
|
||||
std::string s(required_len - 1, '\0');
|
||||
sys->GetStringTrackedDeviceProperty(deviceIndex, prop, s.data(), required_len,
|
||||
&err);
|
||||
if (err != vr::TrackedProp_Success) {
|
||||
Logger::get().info("Failed to get string property {} for device {}: {}",
|
||||
std::to_underlying(prop), deviceIndex,
|
||||
sys->GetPropErrorNameFromEnum(err));
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return s;
|
||||
return s;
|
||||
}
|
||||
|
||||
std::tuple<fs::path, fs::path> VRUtils::initialiseManifest() {
|
||||
fs::path manifestDir = Paths::getDataPath() / "bindings-provider";
|
||||
std::error_code ec;
|
||||
fs::create_directories(manifestDir, ec);
|
||||
if (ec) {
|
||||
throw std::runtime_error(
|
||||
std::format("Failed to create manifest folder: {}", ec.message()));
|
||||
}
|
||||
|
||||
using namespace std::string_view_literals;
|
||||
// Make sure the vrmanifest and action manifest are 1st and 2nd respectively
|
||||
// in the array
|
||||
std::array requiredFiles{
|
||||
std::make_pair("manifest.vrmanifest"sv, SVR_VRAPP_MANIFEST),
|
||||
std::make_pair("action_manifest.json"sv, SVR_VRAPP_ACTION_MANIFEST),
|
||||
std::make_pair("generic.json"sv, SVR_VRAPP_GENERIC_BINDS),
|
||||
std::make_pair("knuckles.json"sv, SVR_VRAPP_KNUCKLES_BINDS),
|
||||
std::make_pair("oculus_touch.json"sv, SVR_VRAPP_OCULUS_BINDS),
|
||||
std::make_pair("vive_controller.json"sv, SVR_VRAPP_VIVE_BINDS),
|
||||
};
|
||||
|
||||
for (auto &[name, contents] : requiredFiles) {
|
||||
fs::path path = manifestDir / name;
|
||||
if (!fs::exists(path)) {
|
||||
std::ofstream stream(path);
|
||||
stream << contents;
|
||||
fs::path manifestDir = Paths::getDataPath() / "bindings-provider";
|
||||
std::error_code ec;
|
||||
fs::create_directories(manifestDir, ec);
|
||||
if (ec) {
|
||||
throw std::runtime_error(
|
||||
std::format("Failed to create manifest folder: {}", ec.message()));
|
||||
}
|
||||
}
|
||||
|
||||
return {manifestDir / requiredFiles.at(0).first,
|
||||
manifestDir / requiredFiles.at(1).first};
|
||||
using namespace std::string_view_literals;
|
||||
// Make sure the vrmanifest and action manifest are 1st and 2nd respectively
|
||||
// in the array
|
||||
std::array requiredFiles{
|
||||
std::make_pair("manifest.vrmanifest"sv, SVR_VRAPP_MANIFEST),
|
||||
std::make_pair("action_manifest.json"sv, SVR_VRAPP_ACTION_MANIFEST),
|
||||
std::make_pair("generic.json"sv, SVR_VRAPP_GENERIC_BINDS),
|
||||
std::make_pair("knuckles.json"sv, SVR_VRAPP_KNUCKLES_BINDS),
|
||||
std::make_pair("oculus_touch.json"sv, SVR_VRAPP_OCULUS_BINDS),
|
||||
std::make_pair("vive_controller.json"sv, SVR_VRAPP_VIVE_BINDS),
|
||||
};
|
||||
|
||||
for (auto &[name, contents] : requiredFiles) {
|
||||
fs::path path = manifestDir / name;
|
||||
if (!fs::exists(path)) {
|
||||
std::ofstream stream(path);
|
||||
stream << contents;
|
||||
}
|
||||
}
|
||||
|
||||
return { manifestDir / requiredFiles.at(0).first,
|
||||
manifestDir / requiredFiles.at(1).first };
|
||||
}
|
||||
@@ -671,7 +671,7 @@ settings-general-fk_settings-self_localization-description = Mocap Mode allows t
|
||||
## Gesture control settings (tracker tapping)
|
||||
settings-general-gesture_control = Gesture control
|
||||
settings-general-gesture_control-subtitle = Tap based resets
|
||||
settings-general-gesture_control-description = Allows for resets to be triggered by tapping a tracker. The tracker highest up on your torso is used for Yaw Reset, the tracker highest up on your left leg is used for Full Reset, and the tracker highest up on your right leg is used for Mounting Calibration. Taps must occur within the time limit of 0.3 seconds times the number of taps to be recognized.
|
||||
settings-general-gesture_control-description = Allows for resets to be triggered by tapping a tracker. If the preferred body part is unset, or the preferred body part is not assigned to a connected tracker, the tracker highest up on your torso is used for Yaw Reset, the tracker highest up on your left leg is used for Full Reset, and the tracker highest up on your right leg is used for Mounting Calibration. Taps must occur within the time limit of 0.3 seconds times the number of taps to be recognized.
|
||||
# This is a unit: 3 taps, 2 taps, 1 tap
|
||||
# $amount (Number) - Amount of taps (touches to the tracker's case)
|
||||
settings-general-gesture_control-taps = { $amount ->
|
||||
@@ -684,13 +684,20 @@ settings-general-gesture_control-trackers = { $amount ->
|
||||
[one] 1 tracker
|
||||
*[other] { $amount } trackers
|
||||
}
|
||||
settings-general-gesture_control-part_select = Which tracker do you want to tap to trigger the reset?
|
||||
settings-general-gesture_control-part_select-edit = Edit
|
||||
settings-general-gesture_control-part_select-reset = Reset preference
|
||||
settings-general-gesture_control-part_select-no_preference = No preference
|
||||
settings-general-gesture_control-yawResetEnabled = Enable tap to yaw reset
|
||||
settings-general-gesture_control-yawResetPart = Preferred tracker for yaw reset taps
|
||||
settings-general-gesture_control-yawResetDelay = Yaw reset delay
|
||||
settings-general-gesture_control-yawResetTaps = Taps for yaw reset
|
||||
settings-general-gesture_control-fullResetEnabled = Enable tap to full reset
|
||||
settings-general-gesture_control-fullResetPart = Preferred tracker for full reset taps
|
||||
settings-general-gesture_control-fullResetDelay = Full reset delay
|
||||
settings-general-gesture_control-fullResetTaps = Taps for full reset
|
||||
settings-general-gesture_control-mountingResetEnabled = Enable tap to perform mounting calibration
|
||||
settings-general-gesture_control-mountingResetPart = Preferred tracker for mounting calibration taps
|
||||
settings-general-gesture_control-mountingResetDelay = Mounting calibration delay
|
||||
settings-general-gesture_control-mountingResetTaps = Taps for mounting calibration
|
||||
# The number of trackers that can have higher acceleration before a tap is rejected
|
||||
|
||||
@@ -103,11 +103,13 @@ export function BodyAssignment({
|
||||
rolesWithErrors = {},
|
||||
highlightedRoles = [],
|
||||
onlyAssigned = false,
|
||||
showAssignedTracker = true,
|
||||
dotSize,
|
||||
}: {
|
||||
assignMode: AssignMode | null;
|
||||
mirror: boolean;
|
||||
onlyAssigned?: boolean;
|
||||
showAssignedTracker?: boolean;
|
||||
rolesWithErrors?: Partial<Record<BodyPart, BodyPartError>>;
|
||||
highlightedRoles?: BodyPart[];
|
||||
onRoleSelected: (role: BodyPart) => void;
|
||||
@@ -165,6 +167,7 @@ export function BodyAssignment({
|
||||
{hasBodyPart(BodyPart.HEAD) && (
|
||||
<TrackerPartCard
|
||||
onlyAssigned={onlyAssigned}
|
||||
showAssignedTracker={showAssignedTracker}
|
||||
roleError={rolesWithErrors[BodyPart.HEAD]?.label}
|
||||
td={trackerPartGrouped[BodyPart.HEAD]}
|
||||
role={BodyPart.HEAD}
|
||||
@@ -176,6 +179,7 @@ export function BodyAssignment({
|
||||
{hasBodyPart(BodyPart.NECK) && (
|
||||
<TrackerPartCard
|
||||
onlyAssigned={onlyAssigned}
|
||||
showAssignedTracker={showAssignedTracker}
|
||||
roleError={rolesWithErrors[BodyPart.NECK]?.label}
|
||||
td={trackerPartGrouped[BodyPart.NECK]}
|
||||
role={BodyPart.NECK}
|
||||
@@ -188,6 +192,7 @@ export function BodyAssignment({
|
||||
{hasBodyPart(SIDES[left].shoulder) && (
|
||||
<TrackerPartCard
|
||||
onlyAssigned={onlyAssigned}
|
||||
showAssignedTracker={showAssignedTracker}
|
||||
roleError={rolesWithErrors[SIDES[left].shoulder]?.label}
|
||||
td={trackerPartGrouped[SIDES[left].shoulder]}
|
||||
role={SIDES[left].shoulder}
|
||||
@@ -199,6 +204,7 @@ export function BodyAssignment({
|
||||
{hasBodyPart(SIDES[left].upperArm) && (
|
||||
<TrackerPartCard
|
||||
onlyAssigned={onlyAssigned}
|
||||
showAssignedTracker={showAssignedTracker}
|
||||
roleError={rolesWithErrors[SIDES[left].upperArm]?.label}
|
||||
td={trackerPartGrouped[SIDES[left].upperArm]}
|
||||
role={SIDES[left].upperArm}
|
||||
@@ -211,6 +217,7 @@ export function BodyAssignment({
|
||||
{hasBodyPart(SIDES[left].lowerArm) && (
|
||||
<TrackerPartCard
|
||||
onlyAssigned={onlyAssigned}
|
||||
showAssignedTracker={showAssignedTracker}
|
||||
roleError={rolesWithErrors[SIDES[left].lowerArm]?.label}
|
||||
td={trackerPartGrouped[SIDES[left].lowerArm]}
|
||||
role={SIDES[left].lowerArm}
|
||||
@@ -222,6 +229,7 @@ export function BodyAssignment({
|
||||
{hasBodyPart(SIDES[left].hand) && (
|
||||
<TrackerPartCard
|
||||
onlyAssigned={onlyAssigned}
|
||||
showAssignedTracker={showAssignedTracker}
|
||||
roleError={rolesWithErrors[SIDES[left].hand]?.label}
|
||||
td={trackerPartGrouped[SIDES[left].hand]}
|
||||
role={SIDES[left].hand}
|
||||
@@ -234,6 +242,7 @@ export function BodyAssignment({
|
||||
{hasBodyPart(BodyPart.HIP) && (
|
||||
<TrackerPartCard
|
||||
onlyAssigned={onlyAssigned}
|
||||
showAssignedTracker={showAssignedTracker}
|
||||
roleError={rolesWithErrors[BodyPart.HIP]?.label}
|
||||
td={trackerPartGrouped[BodyPart.HIP]}
|
||||
onClick={() => onRoleSelected(BodyPart.HIP)}
|
||||
@@ -246,6 +255,7 @@ export function BodyAssignment({
|
||||
{hasBodyPart(SIDES[left].upperLeg) && (
|
||||
<TrackerPartCard
|
||||
onlyAssigned={onlyAssigned}
|
||||
showAssignedTracker={showAssignedTracker}
|
||||
roleError={rolesWithErrors[SIDES[left].upperLeg]?.label}
|
||||
td={trackerPartGrouped[SIDES[left].upperLeg]}
|
||||
role={SIDES[left].upperLeg}
|
||||
@@ -257,6 +267,7 @@ export function BodyAssignment({
|
||||
{hasBodyPart(SIDES[left].lowerLeg) && (
|
||||
<TrackerPartCard
|
||||
onlyAssigned={onlyAssigned}
|
||||
showAssignedTracker={showAssignedTracker}
|
||||
roleError={rolesWithErrors[SIDES[left].lowerLeg]?.label}
|
||||
td={trackerPartGrouped[SIDES[left].lowerLeg]}
|
||||
role={SIDES[left].lowerLeg}
|
||||
@@ -268,6 +279,7 @@ export function BodyAssignment({
|
||||
{hasBodyPart(SIDES[left].foot) && (
|
||||
<TrackerPartCard
|
||||
onlyAssigned={onlyAssigned}
|
||||
showAssignedTracker={showAssignedTracker}
|
||||
roleError={rolesWithErrors[SIDES[left].foot]?.label}
|
||||
td={trackerPartGrouped[SIDES[left].foot]}
|
||||
role={SIDES[left].foot}
|
||||
@@ -284,6 +296,7 @@ export function BodyAssignment({
|
||||
{hasBodyPart(BodyPart.UPPER_CHEST) && (
|
||||
<TrackerPartCard
|
||||
onlyAssigned={onlyAssigned}
|
||||
showAssignedTracker={showAssignedTracker}
|
||||
roleError={rolesWithErrors[BodyPart.UPPER_CHEST]?.label}
|
||||
td={trackerPartGrouped[BodyPart.UPPER_CHEST]}
|
||||
role={BodyPart.UPPER_CHEST}
|
||||
@@ -295,6 +308,7 @@ export function BodyAssignment({
|
||||
{hasBodyPart(BodyPart.CHEST) && (
|
||||
<TrackerPartCard
|
||||
onlyAssigned={onlyAssigned}
|
||||
showAssignedTracker={showAssignedTracker}
|
||||
roleError={rolesWithErrors[BodyPart.CHEST]?.label}
|
||||
td={trackerPartGrouped[BodyPart.CHEST]}
|
||||
role={BodyPart.CHEST}
|
||||
@@ -308,6 +322,7 @@ export function BodyAssignment({
|
||||
{hasBodyPart(SIDES[right].shoulder) && (
|
||||
<TrackerPartCard
|
||||
onlyAssigned={onlyAssigned}
|
||||
showAssignedTracker={showAssignedTracker}
|
||||
roleError={rolesWithErrors[SIDES[right].shoulder]?.label}
|
||||
td={trackerPartGrouped[SIDES[right].shoulder]}
|
||||
role={SIDES[right].shoulder}
|
||||
@@ -319,6 +334,7 @@ export function BodyAssignment({
|
||||
{hasBodyPart(SIDES[right].upperArm) && (
|
||||
<TrackerPartCard
|
||||
onlyAssigned={onlyAssigned}
|
||||
showAssignedTracker={showAssignedTracker}
|
||||
roleError={rolesWithErrors[SIDES[right].upperArm]?.label}
|
||||
td={trackerPartGrouped[SIDES[right].upperArm]}
|
||||
role={SIDES[right].upperArm}
|
||||
@@ -332,6 +348,7 @@ export function BodyAssignment({
|
||||
{hasBodyPart(SIDES[right].lowerArm) && (
|
||||
<TrackerPartCard
|
||||
onlyAssigned={onlyAssigned}
|
||||
showAssignedTracker={showAssignedTracker}
|
||||
roleError={rolesWithErrors[SIDES[right].lowerArm]?.label}
|
||||
td={trackerPartGrouped[SIDES[right].lowerArm]}
|
||||
role={SIDES[right].lowerArm}
|
||||
@@ -343,6 +360,7 @@ export function BodyAssignment({
|
||||
{hasBodyPart(SIDES[right].hand) && (
|
||||
<TrackerPartCard
|
||||
onlyAssigned={onlyAssigned}
|
||||
showAssignedTracker={showAssignedTracker}
|
||||
roleError={rolesWithErrors[SIDES[right].hand]?.label}
|
||||
td={trackerPartGrouped[SIDES[right].hand]}
|
||||
onClick={() => onRoleSelected(SIDES[right].hand)}
|
||||
@@ -355,6 +373,7 @@ export function BodyAssignment({
|
||||
{hasBodyPart(BodyPart.WAIST) && (
|
||||
<TrackerPartCard
|
||||
onlyAssigned={onlyAssigned}
|
||||
showAssignedTracker={showAssignedTracker}
|
||||
roleError={rolesWithErrors[BodyPart.WAIST]?.label}
|
||||
td={trackerPartGrouped[BodyPart.WAIST]}
|
||||
onClick={() => onRoleSelected(BodyPart.WAIST)}
|
||||
@@ -367,6 +386,7 @@ export function BodyAssignment({
|
||||
{hasBodyPart(SIDES[right].upperLeg) && (
|
||||
<TrackerPartCard
|
||||
onlyAssigned={onlyAssigned}
|
||||
showAssignedTracker={showAssignedTracker}
|
||||
roleError={rolesWithErrors[SIDES[right].upperLeg]?.label}
|
||||
td={trackerPartGrouped[SIDES[right].upperLeg]}
|
||||
role={SIDES[right].upperLeg}
|
||||
@@ -378,6 +398,7 @@ export function BodyAssignment({
|
||||
{hasBodyPart(SIDES[right].lowerLeg) && (
|
||||
<TrackerPartCard
|
||||
onlyAssigned={onlyAssigned}
|
||||
showAssignedTracker={showAssignedTracker}
|
||||
roleError={rolesWithErrors[SIDES[right].lowerLeg]?.label}
|
||||
td={trackerPartGrouped[SIDES[right].lowerLeg]}
|
||||
role={SIDES[right].lowerLeg}
|
||||
@@ -389,6 +410,7 @@ export function BodyAssignment({
|
||||
{hasBodyPart(SIDES[right].foot) && (
|
||||
<TrackerPartCard
|
||||
onlyAssigned={onlyAssigned}
|
||||
showAssignedTracker={showAssignedTracker}
|
||||
roleError={rolesWithErrors[SIDES[right].foot]?.label}
|
||||
td={trackerPartGrouped[SIDES[right].foot]}
|
||||
role={SIDES[right].foot}
|
||||
|
||||
@@ -100,7 +100,11 @@ export function TrackersAssignPage() {
|
||||
tapDetectionSettings.mountingResetDelay,
|
||||
tapDetectionSettings.mountingResetEnabled,
|
||||
tapDetectionSettings.mountingResetTaps,
|
||||
true
|
||||
true,
|
||||
null,
|
||||
tapDetectionSettings.yawResetTracker,
|
||||
tapDetectionSettings.fullResetTracker,
|
||||
tapDetectionSettings.mountingResetTracker
|
||||
);
|
||||
|
||||
sendRPCPacket(
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
import { Localized, useLocalization } from '@fluent/react';
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { DefaultValues, useForm } from 'react-hook-form';
|
||||
import {
|
||||
Control,
|
||||
Controller,
|
||||
DefaultValues,
|
||||
FieldPath,
|
||||
FieldValues,
|
||||
useForm,
|
||||
} from 'react-hook-form';
|
||||
import {
|
||||
ChangeSettingsRequestT,
|
||||
FilteringSettingsT,
|
||||
@@ -15,8 +22,9 @@ import {
|
||||
SteamVRTrackersSettingT,
|
||||
TapDetectionSettingsT,
|
||||
HIDSettingsT,
|
||||
BodyPart,
|
||||
} from 'solarxr-protocol';
|
||||
import { useConfig } from '@/hooks/config';
|
||||
import { AssignMode, defaultConfig, useConfig } from '@/hooks/config';
|
||||
import { useWebsocketAPI } from '@/hooks/websocket-api';
|
||||
import { useLocaleConfig } from '@/i18n/config';
|
||||
import { CheckBox } from '@/components/commons/Checkbox';
|
||||
@@ -46,6 +54,100 @@ import {
|
||||
import { atom, useAtomValue, useSetAtom } from 'jotai';
|
||||
import { isEqual } from '@react-hookz/deep-equal';
|
||||
import { selectAtom } from 'jotai/utils';
|
||||
import { BodyPartIcon } from '@/components/commons/BodyPartIcon';
|
||||
import { Button } from '@/components/commons/Button';
|
||||
import { BodyAssignment } from '@/components/onboarding/BodyAssignment';
|
||||
import { useBreakpoint } from '@/hooks/breakpoint';
|
||||
import ReactModal from 'react-modal';
|
||||
|
||||
function TapResetPartSelector<T extends FieldValues = FieldValues>({
|
||||
id,
|
||||
control,
|
||||
name,
|
||||
}: {
|
||||
id: string;
|
||||
control: Control<T>;
|
||||
name: FieldPath<T>;
|
||||
}) {
|
||||
const { isMobile } = useBreakpoint('mobile');
|
||||
const { config } = useConfig();
|
||||
const [bodyPartSelectorOpen, setBodyPartSelectorOpen] = useState(false);
|
||||
|
||||
return (
|
||||
<Controller
|
||||
control={control}
|
||||
name={name}
|
||||
render={({ field: { onChange, value } }) => (
|
||||
<>
|
||||
<div className="flex flex-col gap-1 w-full">
|
||||
<Typography bold id={id} />
|
||||
<div className="flex justify-between bg-background-80 w-full p-3 rounded-lg">
|
||||
<div className="flex gap-3 items-center fill-background-10">
|
||||
<BodyPartIcon bodyPart={value} />
|
||||
<Typography
|
||||
id={
|
||||
value === BodyPart.NONE
|
||||
? 'settings-general-gesture_control-part_select-no_preference'
|
||||
: 'body_part-' + BodyPart[value]
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
<div className="flex">
|
||||
<Button
|
||||
variant="secondary"
|
||||
onClick={() => setBodyPartSelectorOpen(true)}
|
||||
id="settings-general-gesture_control-part_select-edit"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<ReactModal
|
||||
isOpen={bodyPartSelectorOpen}
|
||||
shouldCloseOnOverlayClick
|
||||
shouldCloseOnEsc
|
||||
onRequestClose={() => setBodyPartSelectorOpen(false)}
|
||||
overlayClassName="fixed top-0 right-0 left-0 bottom-0 flex flex-col items-center w-full h-full justify-center bg-background-90 bg-opacity-90 z-20"
|
||||
className="focus:ring-transparent focus:ring-offset-transparent focus:outline-transparent outline-none mt-12 z-10 overflow-y-auto"
|
||||
>
|
||||
<div className="flex w-full h-full flex-col gap-10 px-3">
|
||||
<div className="flex xs:flex-row h-full xs:gap-8 mobile:flex-col xs:justify-center items-center">
|
||||
<div className="flex flex-col xs:flex-grow gap-3 rounded-xl fill-background-50 py-2">
|
||||
<div className="flex flex-col xs:max-w-sm gap-3">
|
||||
<Typography
|
||||
variant="mobile-title"
|
||||
bold
|
||||
id="settings-general-gesture_control-part_select"
|
||||
/>
|
||||
</div>
|
||||
<BodyAssignment
|
||||
mirror={config?.mirrorView ?? defaultConfig.mirrorView}
|
||||
width={isMobile ? 160 : undefined}
|
||||
assignMode={AssignMode.All}
|
||||
showAssignedTracker={false}
|
||||
onRoleSelected={(part) => {
|
||||
onChange(part);
|
||||
setBodyPartSelectorOpen(false);
|
||||
}}
|
||||
/>
|
||||
<div className="flex justify-center">
|
||||
<Button
|
||||
variant="secondary"
|
||||
id="settings-general-gesture_control-part_select-reset"
|
||||
onClick={() => {
|
||||
onChange(BodyPart.NONE);
|
||||
setBodyPartSelectorOpen(false);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ReactModal>
|
||||
</>
|
||||
)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export type SettingsForm = {
|
||||
trackers: {
|
||||
@@ -89,15 +191,18 @@ export type SettingsForm = {
|
||||
interpKneeAnkle: number;
|
||||
};
|
||||
tapDetection: {
|
||||
mountingResetEnabled: boolean;
|
||||
yawResetEnabled: boolean;
|
||||
fullResetEnabled: boolean;
|
||||
mountingResetEnabled: boolean;
|
||||
yawResetDelay: number;
|
||||
fullResetDelay: number;
|
||||
mountingResetDelay: number;
|
||||
yawResetTaps: number;
|
||||
fullResetTaps: number;
|
||||
mountingResetTaps: number;
|
||||
yawResetTracker: BodyPart;
|
||||
fullResetTracker: BodyPart;
|
||||
mountingResetTracker: BodyPart;
|
||||
numberTrackersOverThreshold: number;
|
||||
};
|
||||
legTweaks: {
|
||||
@@ -149,15 +254,18 @@ const defaultValues: SettingsForm = {
|
||||
},
|
||||
filtering: { amount: 0.1, type: FilteringType.NONE },
|
||||
tapDetection: {
|
||||
mountingResetEnabled: false,
|
||||
yawResetEnabled: false,
|
||||
fullResetEnabled: false,
|
||||
mountingResetEnabled: false,
|
||||
yawResetDelay: 0.2,
|
||||
fullResetDelay: 1.0,
|
||||
mountingResetDelay: 1.0,
|
||||
yawResetTaps: 2,
|
||||
fullResetTaps: 3,
|
||||
mountingResetTaps: 3,
|
||||
yawResetTracker: BodyPart.NONE,
|
||||
fullResetTracker: BodyPart.NONE,
|
||||
mountingResetTracker: BodyPart.NONE,
|
||||
numberTrackersOverThreshold: 1,
|
||||
},
|
||||
legTweaks: { correctionStrength: 0.3 },
|
||||
@@ -302,13 +410,17 @@ export function GeneralSettings() {
|
||||
tapDetection.fullResetDelay = values.tapDetection.fullResetDelay;
|
||||
tapDetection.fullResetEnabled = values.tapDetection.fullResetEnabled;
|
||||
tapDetection.fullResetTaps = values.tapDetection.fullResetTaps;
|
||||
tapDetection.fullResetTracker = values.tapDetection.fullResetTracker;
|
||||
tapDetection.yawResetDelay = values.tapDetection.yawResetDelay;
|
||||
tapDetection.yawResetEnabled = values.tapDetection.yawResetEnabled;
|
||||
tapDetection.yawResetTaps = values.tapDetection.yawResetTaps;
|
||||
tapDetection.yawResetTracker = values.tapDetection.yawResetTracker;
|
||||
tapDetection.mountingResetEnabled =
|
||||
values.tapDetection.mountingResetEnabled;
|
||||
tapDetection.mountingResetDelay = values.tapDetection.mountingResetDelay;
|
||||
tapDetection.mountingResetTaps = values.tapDetection.mountingResetTaps;
|
||||
tapDetection.mountingResetTracker =
|
||||
values.tapDetection.mountingResetTracker;
|
||||
tapDetection.numberTrackersOverThreshold =
|
||||
values.tapDetection.numberTrackersOverThreshold;
|
||||
tapDetection.setupMode = false;
|
||||
@@ -416,6 +528,15 @@ export function GeneralSettings() {
|
||||
mountingResetTaps:
|
||||
settings.tapDetectionSettings.mountingResetTaps ||
|
||||
defaultValues.tapDetection.mountingResetTaps,
|
||||
yawResetTracker:
|
||||
settings.tapDetectionSettings.yawResetTracker ||
|
||||
defaultValues.tapDetection.yawResetTracker,
|
||||
fullResetTracker:
|
||||
settings.tapDetectionSettings.fullResetTracker ||
|
||||
defaultValues.tapDetection.fullResetTracker,
|
||||
mountingResetTracker:
|
||||
settings.tapDetectionSettings.mountingResetTracker ||
|
||||
defaultValues.tapDetection.mountingResetTracker,
|
||||
numberTrackersOverThreshold:
|
||||
settings.tapDetectionSettings.numberTrackersOverThreshold ||
|
||||
defaultValues.tapDetection.numberTrackersOverThreshold,
|
||||
@@ -1237,6 +1358,23 @@ export function GeneralSettings() {
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
<div className="grid sm:grid-cols-3 gap-5 pb-2">
|
||||
<TapResetPartSelector
|
||||
control={control}
|
||||
name="tapDetection.yawResetTracker"
|
||||
id="settings-general-gesture_control-yawResetPart"
|
||||
/>
|
||||
<TapResetPartSelector
|
||||
control={control}
|
||||
name="tapDetection.fullResetTracker"
|
||||
id="settings-general-gesture_control-fullResetPart"
|
||||
/>
|
||||
<TapResetPartSelector
|
||||
control={control}
|
||||
name="tapDetection.mountingResetTracker"
|
||||
id="settings-general-gesture_control-mountingResetPart"
|
||||
/>
|
||||
</div>
|
||||
<div className="grid sm:grid-cols-3 gap-5 pb-2">
|
||||
<NumberSelector
|
||||
control={control}
|
||||
|
||||
@@ -38,12 +38,14 @@ export function TrackerPartCard({
|
||||
direction,
|
||||
roleError,
|
||||
onlyAssigned,
|
||||
showAssignedTracker,
|
||||
onClick,
|
||||
}: {
|
||||
td: FlatDeviceTracker[];
|
||||
role: BodyPart;
|
||||
roleError: string | undefined;
|
||||
onlyAssigned: boolean;
|
||||
showAssignedTracker: boolean;
|
||||
direction: 'left' | 'right';
|
||||
onClick?: MouseEventHandler<HTMLDivElement>;
|
||||
}) {
|
||||
@@ -107,17 +109,21 @@ export function TrackerPartCard({
|
||||
>
|
||||
{l10n.getString('body_part-' + BodyPart[role])}
|
||||
</Typography>
|
||||
{td?.map(({ tracker }, index) => (
|
||||
<Tracker
|
||||
tracker={tracker}
|
||||
key={index}
|
||||
updateVelocity={(vel) => updateVelocity(vel)}
|
||||
/>
|
||||
))}
|
||||
{!td && (
|
||||
<Typography color="text-background-30">
|
||||
{l10n.getString('tracker-part_card-unassigned')}
|
||||
</Typography>
|
||||
{showAssignedTracker && (
|
||||
<>
|
||||
{td?.map(({ tracker }, index) => (
|
||||
<Tracker
|
||||
tracker={tracker}
|
||||
key={index}
|
||||
updateVelocity={(vel) => updateVelocity(vel)}
|
||||
/>
|
||||
))}
|
||||
{!td && (
|
||||
<Typography color="text-background-30">
|
||||
{l10n.getString('tracker-part_card-unassigned')}
|
||||
</Typography>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
)) || <></>
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
package dev.slimevr.config
|
||||
|
||||
import com.jme3.math.FastMath
|
||||
|
||||
// handles the tap detection config
|
||||
// this involves the number of taps, the delay, and whether or not the feature is enabled
|
||||
// for each reset type
|
||||
class TapDetectionConfig {
|
||||
var yawResetDelay = 0.2f
|
||||
var fullResetDelay = 1.0f
|
||||
var mountingResetDelay = 1.0f
|
||||
var yawResetEnabled = true
|
||||
var yawResetDesignation: String? = null
|
||||
var fullResetEnabled = true
|
||||
var fullResetDesignation: String? = null
|
||||
var mountingResetEnabled = true
|
||||
var mountingResetDesignation: String? = null
|
||||
var setupMode = false
|
||||
var yawResetTaps = 2
|
||||
set(yawResetTaps) {
|
||||
|
||||
@@ -19,6 +19,7 @@ import dev.slimevr.filtering.TrackerFilters.Companion.getByConfigkey
|
||||
import dev.slimevr.tracking.processor.HumanPoseManager
|
||||
import dev.slimevr.tracking.processor.config.SkeletonConfigToggles
|
||||
import dev.slimevr.tracking.processor.config.SkeletonConfigValues
|
||||
import dev.slimevr.tracking.trackers.TrackerPosition
|
||||
import dev.slimevr.tracking.trackers.TrackerRole
|
||||
import solarxr_protocol.rpc.AutoBoneSettings
|
||||
import solarxr_protocol.rpc.DriftCompensationSettings
|
||||
@@ -163,9 +164,15 @@ fun createTapDetectionSettings(
|
||||
tapDetectionConfig.mountingResetTaps,
|
||||
tapDetectionConfig.setupMode,
|
||||
tapDetectionConfig.numberTrackersOverThreshold,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
tapDetectionConfig.yawResetDesignation?.let {
|
||||
TrackerPosition.getByDesignation(it)
|
||||
}?.bodyPart ?: 0,
|
||||
tapDetectionConfig.fullResetDesignation?.let {
|
||||
TrackerPosition.getByDesignation(it)
|
||||
}?.bodyPart ?: 0,
|
||||
tapDetectionConfig.mountingResetDesignation?.let {
|
||||
TrackerPosition.getByDesignation(it)
|
||||
}?.bodyPart ?: 0
|
||||
)
|
||||
|
||||
fun createSteamVRSettings(fbb: FlatBufferBuilder, bridge: ISteamVRBridge?): Int {
|
||||
|
||||
@@ -9,6 +9,7 @@ import dev.slimevr.protocol.ProtocolAPI
|
||||
import dev.slimevr.protocol.rpc.RPCHandler
|
||||
import dev.slimevr.tracking.processor.config.SkeletonConfigToggles
|
||||
import dev.slimevr.tracking.processor.config.SkeletonConfigValues
|
||||
import dev.slimevr.tracking.trackers.TrackerPosition
|
||||
import dev.slimevr.tracking.trackers.TrackerRole
|
||||
import solarxr_protocol.rpc.ChangeSettingsRequest
|
||||
import solarxr_protocol.rpc.RpcMessage
|
||||
@@ -192,6 +193,10 @@ class RPCSettingsHandler(var rpcHandler: RPCHandler, var api: ProtocolAPI) {
|
||||
.mountingResetTaps = tapDetectionSettings.mountingResetTaps()
|
||||
}
|
||||
|
||||
tapDetectionConfig.yawResetDesignation = TrackerPosition.getByBodyPart(tapDetectionSettings.yawResetTracker())?.designation
|
||||
tapDetectionConfig.fullResetDesignation = TrackerPosition.getByBodyPart(tapDetectionSettings.fullResetTracker())?.designation
|
||||
tapDetectionConfig.mountingResetDesignation = TrackerPosition.getByBodyPart(tapDetectionSettings.mountingResetTracker())?.designation
|
||||
|
||||
api.server.humanPoseManager.updateTapDetectionConfig()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import java.util.*
|
||||
// class that monitors the acceleration of the waist, hip, chest or upper chest trackers to detect taps
|
||||
// and use this to trigger a variety of resets (if your wondering why no single tap class exists, it's because
|
||||
// to many false positives)
|
||||
class TapDetection(val skeleton: HumanSkeleton, val trackerToWatch: Tracker, val numberTrackersOverThreshold: Int, val tapToComplete: Int, val onTapCompleted: () -> Unit) {
|
||||
class TapDetection(val skeleton: HumanSkeleton, val trackerToWatch: Tracker, val accelThreshold: Int, val tapToComplete: Int, val onTapCompleted: () -> Unit) {
|
||||
|
||||
private val accelList = LinkedList<FloatArray>()
|
||||
private val tapTimestamps = LinkedList<Float>()
|
||||
@@ -92,64 +92,20 @@ class TapDetection(val skeleton: HumanSkeleton, val trackerToWatch: Tracker, val
|
||||
// force on any of the torso or upper leg trackers (this sadly implies that
|
||||
// you need two or more trackers for this feature to be reliable)
|
||||
private fun isUserStatic(trackerToExclude: Tracker): Boolean {
|
||||
var num = 0
|
||||
if (skeleton.upperChestTracker != null &&
|
||||
skeleton.upperChestTracker != trackerToExclude
|
||||
) {
|
||||
if (skeleton.upperChestTracker!!.getAcceleration().lenSq()
|
||||
> ALLOWED_BODY_ACCEL_SQUARED
|
||||
) {
|
||||
num++
|
||||
}
|
||||
val trackersToCheck = arrayOf(
|
||||
skeleton.upperChestTracker,
|
||||
skeleton.chestTracker,
|
||||
skeleton.hipTracker,
|
||||
skeleton.waistTracker,
|
||||
skeleton.leftUpperLegTracker,
|
||||
skeleton.rightUpperLegTracker,
|
||||
skeleton.leftFootTracker,
|
||||
skeleton.rightFootTracker,
|
||||
)
|
||||
val numTrackersAboveThreshold = trackersToCheck.count {
|
||||
it != null && it != trackerToExclude && it.getAcceleration().lenSq() > ALLOWED_BODY_ACCEL_SQUARED
|
||||
}
|
||||
if (skeleton.chestTracker != null &&
|
||||
skeleton.chestTracker != trackerToExclude
|
||||
) {
|
||||
if (skeleton.chestTracker!!.getAcceleration().lenSq() > ALLOWED_BODY_ACCEL_SQUARED) num++
|
||||
}
|
||||
if (skeleton.hipTracker != null && skeleton.hipTracker != trackerToExclude) {
|
||||
if (skeleton.hipTracker!!.getAcceleration().lenSq() > ALLOWED_BODY_ACCEL_SQUARED) num++
|
||||
}
|
||||
if (skeleton.waistTracker != null &&
|
||||
skeleton.waistTracker != trackerToExclude
|
||||
) {
|
||||
if (skeleton.waistTracker!!.getAcceleration().lenSq() > ALLOWED_BODY_ACCEL_SQUARED) num++
|
||||
}
|
||||
if (skeleton.leftUpperLegTracker != null &&
|
||||
skeleton.leftUpperLegTracker != trackerToExclude
|
||||
) {
|
||||
if (skeleton.leftUpperLegTracker!!.getAcceleration().lenSq()
|
||||
> ALLOWED_BODY_ACCEL_SQUARED
|
||||
) {
|
||||
num++
|
||||
}
|
||||
}
|
||||
if (skeleton.rightUpperLegTracker != null &&
|
||||
skeleton.rightUpperLegTracker != trackerToExclude
|
||||
) {
|
||||
if (skeleton.rightUpperLegTracker!!.getAcceleration().lenSq()
|
||||
> ALLOWED_BODY_ACCEL_SQUARED
|
||||
) {
|
||||
num++
|
||||
}
|
||||
}
|
||||
if (skeleton.leftFootTracker != null &&
|
||||
skeleton.leftFootTracker != trackerToExclude
|
||||
) {
|
||||
if (skeleton.leftFootTracker!!.getAcceleration().lenSq() > ALLOWED_BODY_ACCEL_SQUARED) {
|
||||
num++
|
||||
}
|
||||
}
|
||||
if (skeleton.rightFootTracker != null &&
|
||||
skeleton.rightFootTracker != trackerToExclude
|
||||
) {
|
||||
if (skeleton.rightFootTracker!!.getAcceleration().lenSq()
|
||||
> ALLOWED_BODY_ACCEL_SQUARED
|
||||
) {
|
||||
num++
|
||||
}
|
||||
}
|
||||
return num < numberTrackersOverThreshold
|
||||
return numTrackersAboveThreshold < accelThreshold
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
+23
@@ -3,6 +3,8 @@ package dev.slimevr.tracking.processor.skeleton
|
||||
import dev.slimevr.VRServer
|
||||
import dev.slimevr.tracking.processor.HumanPoseManager
|
||||
import dev.slimevr.tracking.trackers.Tracker
|
||||
import dev.slimevr.tracking.trackers.TrackerPosition
|
||||
import dev.slimevr.tracking.trackers.TrackerUtils
|
||||
import java.util.concurrent.CopyOnWriteArrayList
|
||||
|
||||
class TapDetectionManager(
|
||||
@@ -87,7 +89,14 @@ class TapDetectionManager(
|
||||
|
||||
private val mountingResetTracker: Tracker?
|
||||
get() {
|
||||
val selectedTracker = config.mountingResetDesignation?.let {
|
||||
TrackerUtils.getTrackerForSkeleton(server.allTrackers,
|
||||
TrackerPosition.getByDesignation(it)
|
||||
?: error("unknown designation '$it'")
|
||||
)
|
||||
}
|
||||
return arrayOf(
|
||||
selectedTracker,
|
||||
skeleton.rightUpperLegTracker,
|
||||
skeleton.rightLowerLegTracker,
|
||||
).firstNotNullOfOrNull { it }
|
||||
@@ -95,7 +104,14 @@ class TapDetectionManager(
|
||||
|
||||
private val fullResetTracker: Tracker?
|
||||
get() {
|
||||
val selectedTracker = config.fullResetDesignation?.let {
|
||||
TrackerUtils.getTrackerForSkeleton(server.allTrackers,
|
||||
TrackerPosition.getByDesignation(it)
|
||||
?: error("unknown designation '$it'")
|
||||
)
|
||||
}
|
||||
return arrayOf(
|
||||
selectedTracker,
|
||||
skeleton.leftUpperLegTracker,
|
||||
skeleton.leftLowerLegTracker,
|
||||
).firstNotNullOfOrNull { it }
|
||||
@@ -103,7 +119,14 @@ class TapDetectionManager(
|
||||
|
||||
private val yawResetTracker: Tracker?
|
||||
get() {
|
||||
val selectedTracker = config.yawResetDesignation?.let {
|
||||
TrackerUtils.getTrackerForSkeleton(server.allTrackers,
|
||||
TrackerPosition.getByDesignation(it)
|
||||
?: error("unknown designation '$it'")
|
||||
)
|
||||
}
|
||||
return arrayOf(
|
||||
selectedTracker,
|
||||
skeleton.upperChestTracker,
|
||||
skeleton.chestTracker,
|
||||
skeleton.hipTracker,
|
||||
|
||||
Reference in new issue
Block a user