diff --git a/interface/resources/html/raiseAndLowerKeyboard.js b/interface/resources/html/raiseAndLowerKeyboard.js index a0aa1eb7fe..f40c0d7376 100644 --- a/interface/resources/html/raiseAndLowerKeyboard.js +++ b/interface/resources/html/raiseAndLowerKeyboard.js @@ -7,6 +7,9 @@ // // Sends messages over the EventBridge when text input is required. // + +/* global document, window, console, setTimeout, setInterval, EventBridge */ + (function () { var POLL_FREQUENCY = 500; // ms var MAX_WARNINGS = 3; @@ -37,22 +40,24 @@ } return false; } - }; + } function shouldSetNumeric() { return document.activeElement.type === "number"; - }; + } function scheduleBringToView(timeout) { - - var timer = setTimeout(function () { - clearTimeout(timer); - + setTimeout(function () { + // If the element is not visible because the keyboard has been raised over the top of it, scroll it up into view. + // If the element is not visible because the keyboard raising has moved it off screen, scroll it down into view. var elementRect = document.activeElement.getBoundingClientRect(); - var absoluteElementTop = elementRect.top + window.scrollY; - var middle = absoluteElementTop - (window.innerHeight / 2); - - window.scrollTo(0, middle); + var VISUAL_MARGIN = 3; + var delta = elementRect.y + elementRect.height + VISUAL_MARGIN - window.innerHeight; + if (delta > 0) { + window.scrollBy(0, delta); + } else if (elementRect.y < VISUAL_MARGIN) { + window.scrollBy(0, elementRect.y - VISUAL_MARGIN); + } }, timeout); } @@ -62,11 +67,13 @@ var passwordField = shouldSetPasswordField(); if (isWindowFocused && - (keyboardRaised !== window.isKeyboardRaised || numericKeyboard !== window.isNumericKeyboard || passwordField !== window.isPasswordField)) { + (keyboardRaised !== window.isKeyboardRaised || numericKeyboard !== window.isNumericKeyboard + || passwordField !== window.isPasswordField)) { if (typeof EventBridge !== "undefined" && EventBridge !== null) { EventBridge.emitWebEvent( - keyboardRaised ? ("_RAISE_KEYBOARD" + (numericKeyboard ? "_NUMERIC" : "") + (passwordField ? "_PASSWORD" : "")) : "_LOWER_KEYBOARD" + keyboardRaised ? ("_RAISE_KEYBOARD" + (numericKeyboard ? "_NUMERIC" : "") + + (passwordField ? "_PASSWORD" : "")) : "_LOWER_KEYBOARD" ); } else { if (numWarnings < MAX_WARNINGS) { @@ -77,7 +84,7 @@ if (!window.isKeyboardRaised) { scheduleBringToView(250); // Allow time for keyboard to be raised in QML. - // 2DO: should it be rather done from 'client area height changed' event? + // 2DO: should it be rather done from 'client area height changed' event? } window.isKeyboardRaised = keyboardRaised; diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 1cd5ef5591..3f1dc8c1af 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -735,9 +735,9 @@ extern InputPluginList getInputPlugins(); extern void saveInputPluginSettings(const InputPluginList& plugins); // Parameters used for running tests from teh command line -const QString TEST_SCRIPT_COMMAND { "--testScript" }; -const QString TEST_QUIT_WHEN_FINISHED_OPTION { "quitWhenFinished" }; -const QString TEST_SNAPSHOT_LOCATION_COMMAND { "--testSnapshotLocation" }; +const QString TEST_SCRIPT_COMMAND{ "--testScript" }; +const QString TEST_QUIT_WHEN_FINISHED_OPTION{ "quitWhenFinished" }; +const QString TEST_RESULTS_LOCATION_COMMAND{ "--testResultsLocation" }; bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { const char** constArgv = const_cast(argv); @@ -1015,22 +1015,25 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo // If the URL scheme is http(s) or ftp, then use as is, else - treat it as a local file // This is done so as not break previous command line scripts - if (testScriptPath.left(URL_SCHEME_HTTP.length()) == URL_SCHEME_HTTP || testScriptPath.left(URL_SCHEME_FTP.length()) == URL_SCHEME_FTP) { + if (testScriptPath.left(URL_SCHEME_HTTP.length()) == URL_SCHEME_HTTP || + testScriptPath.left(URL_SCHEME_FTP.length()) == URL_SCHEME_FTP) { + setProperty(hifi::properties::TEST, QUrl::fromUserInput(testScriptPath)); } else if (QFileInfo(testScriptPath).exists()) { setProperty(hifi::properties::TEST, QUrl::fromLocalFile(testScriptPath)); } - // quite when finished parameter must directly follow the test script + // quite when finished parameter must directly follow the test script if ((i + 2) < args.size() && args.at(i + 2) == TEST_QUIT_WHEN_FINISHED_OPTION) { quitWhenFinished = true; } - } else if (args.at(i) == TEST_SNAPSHOT_LOCATION_COMMAND) { + } else if (args.at(i) == TEST_RESULTS_LOCATION_COMMAND) { // Set test snapshot location only if it is a writeable directory - QString pathname(args.at(i + 1)); - QFileInfo fileInfo(pathname); + QString path(args.at(i + 1)); + + QFileInfo fileInfo(path); if (fileInfo.isDir() && fileInfo.isWritable()) { - testSnapshotLocation = pathname; + TestScriptingInterface::getInstance()->setTestResultsLocation(path); } } } @@ -7588,7 +7591,9 @@ void Application::loadAvatarBrowser() const { void Application::takeSnapshot(bool notify, bool includeAnimated, float aspectRatio, const QString& filename) { postLambdaEvent([notify, includeAnimated, aspectRatio, filename, this] { // Get a screenshot and save it - QString path = DependencyManager::get()->saveSnapshot(getActiveDisplayPlugin()->getScreenshot(aspectRatio), filename, testSnapshotLocation); + QString path = DependencyManager::get()->saveSnapshot(getActiveDisplayPlugin()->getScreenshot(aspectRatio), filename, + TestScriptingInterface::getInstance()->getTestResultsLocation()); + // If we're not doing an animated snapshot as well... if (!includeAnimated) { // Tell the dependency manager that the capture of the still snapshot has taken place. @@ -7602,7 +7607,9 @@ void Application::takeSnapshot(bool notify, bool includeAnimated, float aspectRa void Application::takeSecondaryCameraSnapshot(const QString& filename) { postLambdaEvent([filename, this] { - QString snapshotPath = DependencyManager::get()->saveSnapshot(getActiveDisplayPlugin()->getSecondaryCameraScreenshot(), filename, testSnapshotLocation); + QString snapshotPath = DependencyManager::get()->saveSnapshot(getActiveDisplayPlugin()->getSecondaryCameraScreenshot(), filename, + TestScriptingInterface::getInstance()->getTestResultsLocation()); + emit DependencyManager::get()->stillSnapshotTaken(snapshotPath, true); }); } diff --git a/interface/src/Application.h b/interface/src/Application.h index b7aa524456..23692f7072 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -420,7 +420,6 @@ public slots: void updateVerboseLogging(); Q_INVOKABLE void openAndroidActivity(const QString& activityName); - private slots: void onDesktopRootItemCreated(QQuickItem* qmlContext); void onDesktopRootContextCreated(QQmlContext* qmlContext); @@ -754,7 +753,6 @@ private: std::atomic _pendingIdleEvent { true }; std::atomic _pendingRenderEvent { true }; - QString testSnapshotLocation; bool quitWhenFinished { false }; }; #endif // hifi_Application_h diff --git a/interface/src/LODManager.cpp b/interface/src/LODManager.cpp index d06ba14bcf..da1f14c450 100644 --- a/interface/src/LODManager.cpp +++ b/interface/src/LODManager.cpp @@ -70,7 +70,7 @@ void LODManager::autoAdjustLOD(float realTimeDelta) { // Note: we MUST clamp the blend to 1.0 for stability float blend = (realTimeDelta < LOD_ADJUST_RUNNING_AVG_TIMESCALE) ? realTimeDelta / LOD_ADJUST_RUNNING_AVG_TIMESCALE : 1.0f; _avgRenderTime = (1.0f - blend) * _avgRenderTime + blend * maxRenderTime; // msec - if (!_automaticLODAdjust) { + if (!_automaticLODAdjust || _avgRenderTime == 0.0f) { // early exit return; } diff --git a/interface/src/Menu.h b/interface/src/Menu.h index 20375a71b2..be3dd705f7 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -193,7 +193,6 @@ namespace MenuOption { const QString ShowOtherLookAtVectors = "Show Other Eye Vectors"; const QString EnableLookAtSnapping = "Enable LookAt Snapping"; const QString ShowRealtimeEntityStats = "Show Realtime Entity Stats"; - const QString StandingHMDSensorMode = "Standing HMD Sensor Mode"; const QString SimulateEyeTracking = "Simulate"; const QString SMIEyeTracking = "SMI Eye Tracking"; const QString SparseTextureManagement = "Enable Sparse Texture Management"; diff --git a/interface/src/scripting/TestScriptingInterface.cpp b/interface/src/scripting/TestScriptingInterface.cpp index 9e7c0e142e..700994c517 100644 --- a/interface/src/scripting/TestScriptingInterface.cpp +++ b/interface/src/scripting/TestScriptingInterface.cpp @@ -160,3 +160,29 @@ void TestScriptingInterface::clearCaches() { qApp->reloadResourceCaches(); } +// Writes a JSON object from javascript to a file +void TestScriptingInterface::saveObject(QVariant variant, const QString& filename) { + if (_testResultsLocation.isNull()) { + return; + } + + QJsonDocument jsonDocument; + jsonDocument = QJsonDocument::fromVariant(variant); + if (jsonDocument.isNull()) { + return; + } + + QByteArray jsonData = jsonDocument.toJson(); + + // Append trailing slash if needed + if (_testResultsLocation.right(1) != "/") { + _testResultsLocation += "/"; + } + + QString filepath = QDir::cleanPath(_testResultsLocation + filename); + QFile file(filepath); + + file.open(QFile::WriteOnly); + file.write(jsonData); + file.close(); +} diff --git a/interface/src/scripting/TestScriptingInterface.h b/interface/src/scripting/TestScriptingInterface.h index 687cb41689..5666417727 100644 --- a/interface/src/scripting/TestScriptingInterface.h +++ b/interface/src/scripting/TestScriptingInterface.h @@ -18,6 +18,10 @@ class QScriptValue; class TestScriptingInterface : public QObject { Q_OBJECT +public: + void setTestResultsLocation(const QString path) { _testResultsLocation = path; } + const QString& getTestResultsLocation() { return _testResultsLocation; }; + public slots: static TestScriptingInterface* getInstance(); @@ -46,7 +50,6 @@ public slots: */ void waitIdle(); - bool waitForConnection(qint64 maxWaitMs = 10000); void wait(int milliseconds); @@ -83,8 +86,14 @@ public slots: */ void clearCaches(); + /**jsdoc + * Save a JSON object to a file in the test results location + */ + void saveObject(QVariant v, const QString& filename); + private: bool waitForCondition(qint64 maxWaitMs, std::function condition); + QString _testResultsLocation; }; -#endif // hifi_TestScriptingInterface_h +#endif // hifi_TestScriptingInterface_h diff --git a/plugins/openvr/src/OpenVrDisplayPlugin.cpp b/plugins/openvr/src/OpenVrDisplayPlugin.cpp index 714cb91b3f..5a7417cb49 100644 --- a/plugins/openvr/src/OpenVrDisplayPlugin.cpp +++ b/plugins/openvr/src/OpenVrDisplayPlugin.cpp @@ -36,7 +36,6 @@ Q_DECLARE_LOGGING_CATEGORY(displayplugins) -const char* StandingHMDSensorMode { "Standing HMD Sensor Mode" }; // this probably shouldn't be hardcoded here const char* OpenVrThreadedSubmit { "OpenVR Threaded Submit" }; // this probably shouldn't be hardcoded here PoseData _nextRenderPoseData; @@ -451,7 +450,6 @@ bool OpenVrDisplayPlugin::internalActivate() { qDebug() << "OpenVR Threaded submit enabled: " << _threadedSubmit; _openVrDisplayActive = true; - _container->setIsOptionChecked(StandingHMDSensorMode, true); _system->GetRecommendedRenderTargetSize(&_renderTargetSize.x, &_renderTargetSize.y); // Recommended render target size is per-eye, so double the X size for // left + right eyes @@ -507,7 +505,6 @@ void OpenVrDisplayPlugin::internalDeactivate() { Parent::internalDeactivate(); _openVrDisplayActive = false; - _container->setIsOptionChecked(StandingHMDSensorMode, false); if (_system) { // TODO: Invalidate poses. It's fine if someone else sets these shared values, but we're about to stop updating them, and // we don't want ViveControllerManager to consider old values to be valid. diff --git a/scripts/system/controllers/controllerModules/equipEntity.js b/scripts/system/controllers/controllerModules/equipEntity.js index 1fce772ec8..1f9a95c819 100644 --- a/scripts/system/controllers/controllerModules/equipEntity.js +++ b/scripts/system/controllers/controllerModules/equipEntity.js @@ -6,11 +6,11 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -/* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, - getControllerJointIndex, enableDispatcherModule, disableDispatcherModule, +/* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, Camera, + getControllerJointIndex, enableDispatcherModule, disableDispatcherModule, entityIsFarGrabbedByOther, Messages, makeDispatcherModuleParameters, makeRunningValues, Settings, entityHasActions, Vec3, Overlays, flatten, Xform, getControllerWorldLocation, ensureDynamic, entityIsCloneable, - cloneEntity, DISPATCHER_PROPERTIES, TEAR_AWAY_DISTANCE, Uuid, unhighlightTargetEntity + cloneEntity, DISPATCHER_PROPERTIES, Uuid, unhighlightTargetEntity, isInEditMode */ Script.include("/~/system/libraries/Xform.js"); @@ -781,7 +781,7 @@ EquipHotspotBuddy.prototype.update = function(deltaTime, timestamp, controllerDa } } }; - + var clearGrabActions = function(entityID) { var actionIDs = Entities.getActionIDs(entityID); var myGrabTag = "grab-" + MyAvatar.sessionUUID; @@ -794,7 +794,7 @@ EquipHotspotBuddy.prototype.update = function(deltaTime, timestamp, controllerDa } } }; - + var onMousePress = function(event) { if (isInEditMode() || !event.isLeftButton) { // don't consider any left clicks on the entity while in edit return; @@ -808,7 +808,7 @@ EquipHotspotBuddy.prototype.update = function(deltaTime, timestamp, controllerDa if (hasEquipData && entityProperties.parentID === EMPTY_PARENT_ID && !entityIsFarGrabbedByOther(entityID)) { entityProperties.id = entityID; var rightHandPosition = MyAvatar.getJointPosition("RightHand"); - var leftHandPosition = MyAvatar.getJointPosition("LeftHand"); + var leftHandPosition = MyAvatar.getJointPosition("LeftHand"); var distanceToRightHand = Vec3.distance(entityProperties.position, rightHandPosition); var distanceToLeftHand = Vec3.distance(entityProperties.position, leftHandPosition); var leftHandAvailable = leftEquipEntity.targetEntityID === null; @@ -828,7 +828,7 @@ EquipHotspotBuddy.prototype.update = function(deltaTime, timestamp, controllerDa }; var onKeyPress = function(event) { - if (event.text === UNEQUIP_KEY) { + if (event.text.toLowerCase() === UNEQUIP_KEY) { if (rightEquipEntity.targetEntityID) { rightEquipEntity.endEquipEntity(); } diff --git a/scripts/system/controllers/controllerModules/nearActionGrabEntity.js b/scripts/system/controllers/controllerModules/nearActionGrabEntity.js index a4e439fe2f..274a4264cd 100644 --- a/scripts/system/controllers/controllerModules/nearActionGrabEntity.js +++ b/scripts/system/controllers/controllerModules/nearActionGrabEntity.js @@ -10,7 +10,7 @@ propsArePhysical, Messages, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, entityIsGrabbable, Quat, Vec3, MSECS_PER_SEC, getControllerWorldLocation, makeDispatcherModuleParameters, makeRunningValues, TRIGGER_OFF_VALUE, NEAR_GRAB_RADIUS, findGroupParent, entityIsCloneable, propsAreCloneDynamic, cloneEntity, - HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, BUMPER_ON_VALUE, unhighlightTargetEntity + HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, BUMPER_ON_VALUE, unhighlightTargetEntity, Uuid */ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); diff --git a/scripts/system/controllers/controllerModules/nearGrabHyperLinkEntity.js b/scripts/system/controllers/controllerModules/nearGrabHyperLinkEntity.js index 59ce79cfd1..962ae89bb9 100644 --- a/scripts/system/controllers/controllerModules/nearGrabHyperLinkEntity.js +++ b/scripts/system/controllers/controllerModules/nearGrabHyperLinkEntity.js @@ -7,12 +7,8 @@ // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -/* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, - getControllerJointIndex, getGrabbableData, enableDispatcherModule, disableDispatcherModule, - propsArePhysical, Messages, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, entityIsGrabbable, - Quat, Vec3, MSECS_PER_SEC, getControllerWorldLocation, makeDispatcherModuleParameters, makeRunningValues, - TRIGGER_OFF_VALUE, NEAR_GRAB_RADIUS, findGroupParent, entityIsCloneable, propsAreCloneDynamic, cloneEntity, - HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, BUMPER_ON_VALUE, AddressManager +/* global Script, MyAvatar, RIGHT_HAND, LEFT_HAND, enableDispatcherModule, disableDispatcherModule, + makeDispatcherModuleParameters, makeRunningValues, TRIGGER_OFF_VALUE, NEAR_GRAB_RADIUS, BUMPER_ON_VALUE, AddressManager */ (function() { diff --git a/scripts/system/controllers/controllerModules/nearParentGrabEntity.js b/scripts/system/controllers/controllerModules/nearParentGrabEntity.js index d454d20a02..cf3a9cf14b 100644 --- a/scripts/system/controllers/controllerModules/nearParentGrabEntity.js +++ b/scripts/system/controllers/controllerModules/nearParentGrabEntity.js @@ -11,8 +11,7 @@ TRIGGER_OFF_VALUE, makeDispatcherModuleParameters, entityIsGrabbable, makeRunningValues, NEAR_GRAB_RADIUS, findGroupParent, Vec3, cloneEntity, entityIsCloneable, propsAreCloneDynamic, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, BUMPER_ON_VALUE, findHandChildEntities, TEAR_AWAY_DISTANCE, MSECS_PER_SEC, TEAR_AWAY_CHECK_TIME, - TEAR_AWAY_COUNT, distanceBetweenPointAndEntityBoundingBox, print, Selection, DISPATCHER_HOVERING_LIST, Uuid, - highlightTargetEntity, unhighlightTargetEntity + TEAR_AWAY_COUNT, distanceBetweenPointAndEntityBoundingBox, print, Uuid, highlightTargetEntity, unhighlightTargetEntity */ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); @@ -43,11 +42,6 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); [], 100); - - // XXX does handJointIndex change if the avatar changes? - this.handJointIndex = MyAvatar.getJointIndex(this.hand === RIGHT_HAND ? "RightHand" : "LeftHand"); - this.controllerJointIndex = getControllerJointIndex(this.hand); - this.thisHandIsParent = function(props) { if (!props) { return false; @@ -62,8 +56,7 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); return true; } - var controllerJointIndex = this.controllerJointIndex; - if (props.parentJointIndex === controllerJointIndex) { + if (props.parentJointIndex === getControllerJointIndex(this.hand)) { return true; } @@ -102,7 +95,7 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); // } else { // handJointIndex = MyAvatar.getJointIndex(this.hand === RIGHT_HAND ? "RightHand" : "LeftHand"); // } - handJointIndex = this.controllerJointIndex; + handJointIndex = getControllerJointIndex(this.hand); var args = [this.hand === RIGHT_HAND ? "right" : "left", MyAvatar.sessionUUID]; Entities.callEntityMethod(targetProps.id, "startNearGrab", args); diff --git a/scripts/system/controllers/controllerModules/nearParentGrabOverlay.js b/scripts/system/controllers/controllerModules/nearParentGrabOverlay.js index 0f876816b3..368d5c483b 100644 --- a/scripts/system/controllers/controllerModules/nearParentGrabOverlay.js +++ b/scripts/system/controllers/controllerModules/nearParentGrabOverlay.js @@ -9,7 +9,7 @@ /* global Script, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, getControllerJointIndex, enableDispatcherModule, disableDispatcherModule, Messages, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, makeDispatcherModuleParameters, Overlays, makeRunningValues, Vec3, resizeTablet, getTabletWidthFromSettings, - NEAR_GRAB_RADIUS + NEAR_GRAB_RADIUS, HMD, Uuid */ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); @@ -37,7 +37,6 @@ Script.include("/~/system/libraries/utils.js"); // XXX does handJointIndex change if the avatar changes? this.handJointIndex = MyAvatar.getJointIndex(this.hand === RIGHT_HAND ? "RightHand" : "LeftHand"); - this.controllerJointIndex = getControllerJointIndex(this.hand); this.getOtherModule = function() { return (this.hand === RIGHT_HAND) ? leftNearParentingGrabOverlay : rightNearParentingGrabOverlay; diff --git a/scripts/system/controllers/controllerModules/teleport.js b/scripts/system/controllers/controllerModules/teleport.js index 560da57b20..3bf99ca26a 100644 --- a/scripts/system/controllers/controllerModules/teleport.js +++ b/scripts/system/controllers/controllerModules/teleport.js @@ -10,7 +10,7 @@ /* jslint bitwise: true */ -/* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, getControllerJointIndex, +/* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, enableDispatcherModule, disableDispatcherModule, Messages, makeDispatcherModuleParameters, makeRunningValues, Vec3, HMD, Uuid, AvatarList, Picks, Pointers, PickType */ diff --git a/scripts/system/html/entityList.html b/scripts/system/html/entityList.html index d608ab63e5..7906a3c97f 100644 --- a/scripts/system/html/entityList.html +++ b/scripts/system/html/entityList.html @@ -14,7 +14,6 @@ - diff --git a/scripts/system/html/entityProperties.html b/scripts/system/html/entityProperties.html index 8647dca035..8d63261f4c 100644 --- a/scripts/system/html/entityProperties.html +++ b/scripts/system/html/entityProperties.html @@ -20,7 +20,6 @@ - diff --git a/scripts/system/html/gridControls.html b/scripts/system/html/gridControls.html index c0bd87988d..cd646fed51 100644 --- a/scripts/system/html/gridControls.html +++ b/scripts/system/html/gridControls.html @@ -16,7 +16,6 @@ - diff --git a/scripts/system/html/js/entityList.js b/scripts/system/html/js/entityList.js index 625aa26b00..88b3ccbf7c 100644 --- a/scripts/system/html/js/entityList.js +++ b/scripts/system/html/js/entityList.js @@ -444,8 +444,6 @@ function loaded() { augmentSpinButtons(); - setUpKeyboardControl(); - // Disable right-click context menu which is not visible in the HMD and makes it seem like the app has locked document.addEventListener("contextmenu", function (event) { event.preventDefault(); diff --git a/scripts/system/html/js/entityProperties.js b/scripts/system/html/js/entityProperties.js index 4b6329db44..2194b539ef 100644 --- a/scripts/system/html/js/entityProperties.js +++ b/scripts/system/html/js/entityProperties.js @@ -7,7 +7,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html /* global alert, augmentSpinButtons, clearTimeout, console, document, Element, EventBridge, - HifiEntityUI, JSONEditor, openEventBridge, setUpKeyboardControl, setTimeout, window, _ $ */ + HifiEntityUI, JSONEditor, openEventBridge, setTimeout, window, _ $ */ var PI = 3.14159265358979; var DEGREES_TO_RADIANS = PI / 180.0; @@ -2157,8 +2157,6 @@ function loaded() { augmentSpinButtons(); - setUpKeyboardControl(); - // Disable right-click context menu which is not visible in the HMD and makes it seem like the app has locked document.addEventListener("contextmenu", function(event) { event.preventDefault(); diff --git a/scripts/system/html/js/gridControls.js b/scripts/system/html/js/gridControls.js index be4271788e..79a169400a 100644 --- a/scripts/system/html/js/gridControls.js +++ b/scripts/system/html/js/gridControls.js @@ -129,8 +129,6 @@ function loaded() { augmentSpinButtons(); - setUpKeyboardControl(); - EventBridge.emitWebEvent(JSON.stringify({ type: 'init' })); }); document.addEventListener("keydown", function (keyDown) { diff --git a/scripts/system/html/js/keyboardControl.js b/scripts/system/html/js/keyboardControl.js deleted file mode 100644 index 7a8a314c62..0000000000 --- a/scripts/system/html/js/keyboardControl.js +++ /dev/null @@ -1,73 +0,0 @@ -// -// keyboardControl.js -// -// Created by David Rowe on 28 Sep 2016. -// Copyright 2016 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -function setUpKeyboardControl() { - - var lowerTimer = null; - var isRaised = false; - var KEYBOARD_HEIGHT = 200; - - function raiseKeyboard() { - window.isKeyboardRaised = true; - window.isNumericKeyboard = this.type === "number"; - - if (lowerTimer !== null) { - clearTimeout(lowerTimer); - lowerTimer = null; - } - - EventBridge.emitWebEvent("_RAISE_KEYBOARD" + (this.type === "number" ? "_NUMERIC" : "")); - - if (!isRaised) { - var delta = this.getBoundingClientRect().bottom + 10 - (document.body.clientHeight - KEYBOARD_HEIGHT); - if (delta > 0) { - setTimeout(function () { - document.body.scrollTop += delta; - }, 500); // Allow time for keyboard to be raised in QML. - } - } - - isRaised = true; - } - - function doLowerKeyboard() { - window.isKeyboardRaised = false; - window.isNumericKeyboard = false; - - EventBridge.emitWebEvent("_LOWER_KEYBOARD"); - lowerTimer = null; - isRaised = false; - } - - function lowerKeyboard() { - // Delay lowering keyboard a little in case immediately raise it again. - if (lowerTimer === null) { - lowerTimer = setTimeout(doLowerKeyboard, 20); - } - } - - function documentBlur() { - // Action any pending Lower keyboard event immediately upon leaving document window so that they don't interfere with - // other Entities Editor tab. - if (lowerTimer !== null) { - clearTimeout(lowerTimer); - doLowerKeyboard(); - } - } - - var inputs = document.querySelectorAll("input[type=text], input[type=password], input[type=number], textarea"); - for (var i = 0, length = inputs.length; i < length; i++) { - inputs[i].addEventListener("focus", raiseKeyboard); - inputs[i].addEventListener("blur", lowerKeyboard); - } - - window.addEventListener("blur", documentBlur); -} - diff --git a/scripts/system/libraries/controllerDispatcherUtils.js b/scripts/system/libraries/controllerDispatcherUtils.js index 71dc5e4273..04ae01bad6 100644 --- a/scripts/system/libraries/controllerDispatcherUtils.js +++ b/scripts/system/libraries/controllerDispatcherUtils.js @@ -7,7 +7,7 @@ /* global module, Camera, HMD, MyAvatar, controllerDispatcherPlugins:true, Quat, Vec3, Overlays, Xform, - Selection, + Selection, Uuid, MSECS_PER_SEC:true , LEFT_HAND:true, RIGHT_HAND:true, FORBIDDEN_GRAB_TYPES:true, HAPTIC_PULSE_STRENGTH:true, HAPTIC_PULSE_DURATION:true, ZERO_VEC:true, ONE_VEC:true, DEFAULT_REGISTRATION_POINT:true, INCHES_TO_METERS:true, @@ -34,11 +34,12 @@ getGrabbableData:true, entityIsGrabbable:true, entityIsDistanceGrabbable:true, + getControllerJointIndexCacheTime:true, + getControllerJointIndexCache:true, getControllerJointIndex:true, propsArePhysical:true, controllerDispatcherPluginsNeedSort:true, projectOntoXYPlane:true, - getChildrenProps:true, projectOntoEntityXYPlane:true, projectOntoOverlayXYPlane:true, makeLaserLockInfo:true, @@ -53,6 +54,8 @@ TEAR_AWAY_COUNT:true, TEAR_AWAY_CHECK_TIME:true, distanceBetweenPointAndEntityBoundingBox:true, + entityIsEquipped:true, + entityIsFarGrabbedByOther:true, highlightTargetEntity:true, clearHighlightedEntities:true, unhighlightTargetEntity:true @@ -265,20 +268,32 @@ entityIsDistanceGrabbable = function(props) { return true; }; -getControllerJointIndex = function (hand) { - if (HMD.isHandControllerAvailable()) { - var controllerJointIndex = -1; - if (Camera.mode === "first person") { - controllerJointIndex = MyAvatar.getJointIndex(hand === RIGHT_HAND ? - "_CONTROLLER_RIGHTHAND" : - "_CONTROLLER_LEFTHAND"); - } else if (Camera.mode === "third person") { - controllerJointIndex = MyAvatar.getJointIndex(hand === RIGHT_HAND ? - "_CAMERA_RELATIVE_CONTROLLER_RIGHTHAND" : - "_CAMERA_RELATIVE_CONTROLLER_LEFTHAND"); - } +getControllerJointIndexCacheTime = [0, 0]; +getControllerJointIndexCache = [-1, -1]; - return controllerJointIndex; +getControllerJointIndex = function (hand) { + var GET_CONTROLLERJOINTINDEX_CACHE_REFRESH_TIME = 3000; // msecs + + var now = Date.now(); + if (now - getControllerJointIndexCacheTime[hand] > GET_CONTROLLERJOINTINDEX_CACHE_REFRESH_TIME) { + if (HMD.isHandControllerAvailable()) { + var controllerJointIndex = -1; + if (Camera.mode === "first person") { + controllerJointIndex = MyAvatar.getJointIndex(hand === RIGHT_HAND ? + "_CONTROLLER_RIGHTHAND" : + "_CONTROLLER_LEFTHAND"); + } else if (Camera.mode === "third person") { + controllerJointIndex = MyAvatar.getJointIndex(hand === RIGHT_HAND ? + "_CAMERA_RELATIVE_CONTROLLER_RIGHTHAND" : + "_CAMERA_RELATIVE_CONTROLLER_LEFTHAND"); + } + + getControllerJointIndexCacheTime[hand] = now; + getControllerJointIndexCache[hand] = controllerJointIndex; + return controllerJointIndex; + } + } else { + return getControllerJointIndexCache[hand]; } return -1; diff --git a/scripts/system/marketplaces/marketplaces.js b/scripts/system/marketplaces/marketplaces.js index c3edee264f..dc4d5aa844 100644 --- a/scripts/system/marketplaces/marketplaces.js +++ b/scripts/system/marketplaces/marketplaces.js @@ -19,6 +19,7 @@ var selectionDisplay = null; // for gridTool.js to ignore Script.include("/~/system/libraries/WebTablet.js"); Script.include("/~/system/libraries/gridTool.js"); + Script.include("/~/system/libraries/connectionUtils.js"); var METAVERSE_SERVER_URL = Account.metaverseServerURL; var MARKETPLACE_URL = METAVERSE_SERVER_URL + "/marketplace";