From 1d05ae96f951538894765ed5e65ca22f6602456d Mon Sep 17 00:00:00 2001 From: Vasily Date: Sun, 17 Mar 2019 12:47:00 +0100 Subject: [PATCH] Implement prototype paths in manifest class --- src/openvr/ivrinput_manifest.h | 20 ++++++++++++++------ src/utils/paths.cpp | 2 +- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/openvr/ivrinput_manifest.h b/src/openvr/ivrinput_manifest.h index f00494e..7472273 100644 --- a/src/openvr/ivrinput_manifest.h +++ b/src/openvr/ivrinput_manifest.h @@ -2,6 +2,7 @@ #include #include #include +#include "../utils/paths.h" namespace input { @@ -14,16 +15,23 @@ class Manifest public: Manifest() { - QString actionManifestPath = QStandardPaths::locate( - QStandardPaths::AppDataLocation, - QStringLiteral( "action_manifest.json" ) ); + const auto actionManifestPath + = paths::binaryDirectoryFindFile( "action_manifest.json" ); - auto error = vr::VRInput()->SetActionManifestPath( - actionManifestPath.toStdString().c_str() ); + if ( !actionManifestPath.has_value() ) + { + LOG( ERROR ) << "Could not find action manifest. Action manifests " + "not initialized."; + return; + } + + const auto validManifestPath = actionManifestPath->c_str(); + + auto error = vr::VRInput()->SetActionManifestPath( validManifestPath ); if ( error != vr::EVRInputError::VRInputError_None ) { LOG( ERROR ) << "Error setting action manifest path: " - << actionManifestPath << ". OpenVR Error: " << error; + << validManifestPath << ". OpenVR Error: " << error; } } diff --git a/src/utils/paths.cpp b/src/utils/paths.cpp index 0275c31..d0b112e 100644 --- a/src/utils/paths.cpp +++ b/src/utils/paths.cpp @@ -26,7 +26,7 @@ optional binaryDirectoryFindFile( const string fileName ) if ( path == "" ) { - LOG( ERROR ) << "Could not find file '" << fileName + LOG( ERROR ) << "Could not find file '" << fileName.c_str() << "' in binary directory."; return std::nullopt; }