From a310acd37fbdf7c8c59ac514a4351d3b8be8dd20 Mon Sep 17 00:00:00 2001 From: Zach Pomerantz Date: Tue, 18 Apr 2017 18:05:17 -0400 Subject: [PATCH 1/2] check HMD usage for tutorial teleport --- interface/src/Application.cpp | 53 ++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index c6cd185034..f0a1c0f7ab 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1458,46 +1458,53 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo const auto testScript = property(hifi::properties::TEST).toUrl(); scriptEngines->loadScript(testScript, false); } else { - // Get sandbox content set version, if available + enum HandControllerType { + Vive, + Oculus + }; + static const std::map MIN_CONTENT_VERSION = { + { Vive, 1 }, + { Oculus, 27 } + }; + + // Get sandbox content set version auto acDirPath = PathUtils::getAppDataPath() + "../../" + BuildInfo::MODIFIED_ORGANIZATION + "/assignment-client/"; auto contentVersionPath = acDirPath + "content-version.txt"; qCDebug(interfaceapp) << "Checking " << contentVersionPath << " for content version"; - auto contentVersion = 0; + int contentVersion = 0; QFile contentVersionFile(contentVersionPath); if (contentVersionFile.open(QIODevice::ReadOnly | QIODevice::Text)) { QString line = contentVersionFile.readAll(); - // toInt() returns 0 if the conversion fails, so we don't need to specifically check for failure - contentVersion = line.toInt(); + contentVersion = line.toInt(); // returns 0 if conversion fails } - qCDebug(interfaceapp) << "Server content version: " << contentVersion; - static const int MIN_VIVE_CONTENT_VERSION = 1; - static const int MIN_OCULUS_TOUCH_CONTENT_VERSION = 27; - - bool hasSufficientTutorialContent = false; + // Get controller availability bool hasHandControllers = false; - - // Only specific hand controllers are currently supported, so only send users to the tutorial - // if they have one of those hand controllers. + HandControllerType handControllerType = Vive; if (PluginUtils::isViveControllerAvailable()) { hasHandControllers = true; - hasSufficientTutorialContent = contentVersion >= MIN_VIVE_CONTENT_VERSION; + handControllerType = Vive; } else if (PluginUtils::isOculusTouchControllerAvailable()) { hasHandControllers = true; - hasSufficientTutorialContent = contentVersion >= MIN_OCULUS_TOUCH_CONTENT_VERSION; + handControllerType = Oculus; } + // Check tutorial content versioning + bool hasTutorialContent = contentVersion >= MIN_CONTENT_VERSION.at(handControllerType); + + // Check HMD use (may be technically available without being in use) + bool hasHMD = PluginUtils::isHMDAvailable(); + bool isUsingHMD = hasHMD && hasHandControllers && _displayPlugin->isHmd(); + + Setting::Handle tutorialComplete { "tutorialComplete", false }; Setting::Handle firstRun { Settings::firstRun, true }; - bool hasHMDAndHandControllers = PluginUtils::isHMDAvailable() && hasHandControllers; - Setting::Handle tutorialComplete { "tutorialComplete", false }; + bool isTutorialComplete = tutorialComplete.get(); + bool shouldGoToTutorial = isUsingHMD && hasTutorialContent && !isTutorialComplete; - bool shouldGoToTutorial = hasHMDAndHandControllers && hasSufficientTutorialContent && !tutorialComplete.get(); - - qCDebug(interfaceapp) << "Has HMD + Hand Controllers: " << hasHMDAndHandControllers << ", current plugin: " << _displayPlugin->getName(); - qCDebug(interfaceapp) << "Has sufficient tutorial content (" << contentVersion << ") : " << hasSufficientTutorialContent; - qCDebug(interfaceapp) << "Tutorial complete: " << tutorialComplete.get(); - qCDebug(interfaceapp) << "Should go to tutorial: " << shouldGoToTutorial; + qCDebug(interfaceapp) << "HMD:" << hasHMD << ", Hand Controllers: " << hasHandControllers << ", Using HMD: " << isUsingHMD; + qCDebug(interfaceapp) << "Tutorial version:" << contentVersion << ", sufficient:" << hasTutorialContent << + ", complete:" << isTutorialComplete << ", should go:" << shouldGoToTutorial; // when --url in command line, teleport to location const QString HIFI_URL_COMMAND_LINE_KEY = "--url"; @@ -1534,7 +1541,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo // If this is a first run we short-circuit the address passed in if (isFirstRun) { - if (hasHMDAndHandControllers) { + if (isUsingHMD) { if (sandboxIsRunning) { qCDebug(interfaceapp) << "Home sandbox appears to be running, going to Home."; DependencyManager::get()->goToLocalSandbox(); From f432cfea6292098fc4c495fdc45c5f7935d26b98 Mon Sep 17 00:00:00 2001 From: Zach Pomerantz Date: Tue, 18 Apr 2017 18:09:14 -0400 Subject: [PATCH 2/2] check HMD.active for tutorial zone --- tutorial/tutorialStartZone.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tutorial/tutorialStartZone.js b/tutorial/tutorialStartZone.js index cb0d223200..13e5ac89d0 100644 --- a/tutorial/tutorialStartZone.js +++ b/tutorial/tutorialStartZone.js @@ -13,7 +13,7 @@ var self = this; // send message to outer zone print("TutorialStartZone | Entered the tutorial start area"); - if (HMD.isHMDAvailable() && HMD.isHandControllerAvailable()) { + if (HMD.isHMDAvailable() && HMD.isHandControllerAvailable() && HMD.active) { function sendStart() { print("TutorialStartZone | Checking parent ID"); var parentID = Entities.getEntityProperties(self.entityID, 'parentID').parentID; @@ -28,8 +28,8 @@ this.sendStartIntervalID = Script.setInterval(sendStart, 1500); sendStart(); } else { - print("TutorialStartZone | User tried to go to tutorial with HMD and hand controllers, sending back to /"); - Window.alert("To proceed with this tutorial, please connect your Vive headset and hand controllers."); + print("TutorialStartZone | User tried to go to tutorial without active HMD and hand controllers, sending back to /"); + Window.alert("To proceed with this tutorial, please connect your Vive or Oculus headset and hand controllers."); location = "/"; } },