diff --git a/interface/src/ui/Keyboard.cpp b/interface/src/ui/Keyboard.cpp index 40894f1121..b5f561bff6 100644 --- a/interface/src/ui/Keyboard.cpp +++ b/interface/src/ui/Keyboard.cpp @@ -406,7 +406,7 @@ void Keyboard::startLayerSwitchTimer() { } } -bool Keyboard::isLayerSwitchTimerFinished() { +bool Keyboard::isLayerSwitchTimerFinished() const { if (_layerSwitchTimer) { return (_layerSwitchTimer->remainingTime() <= 0); } @@ -493,12 +493,11 @@ bool Keyboard::shouldProcessPointerEvent(const PointerEvent& event) const { unsigned int pointerID = event.getID(); bool isStylusEvent = (pointerID == _leftHandStylus || pointerID == _rightHandStylus); bool isLaserEvent = (pointerID == _leftHandLaser || pointerID == _rightHandLaser); - qDebug() << isLaserEvent; return ((isStylusEvent && preferMalletsOverLasers) || (isLaserEvent && !preferMalletsOverLasers)); } void Keyboard::handleTriggerBegin(const OverlayID& overlayID, const PointerEvent& event) { - if (_keyboardLayers.empty() || !isLayerSwitchTimerFinished() || overlayID == _backPlate.overlayID) { + if (getExitEarly(overlayID)) { return; } @@ -609,7 +608,7 @@ void Keyboard::setRightHandLaser(unsigned int rightHandLaser) { } void Keyboard::handleTriggerEnd(const OverlayID& overlayID, const PointerEvent& event) { - if (_keyboardLayers.empty() || !isLayerSwitchTimerFinished() || overlayID == _backPlate.overlayID) { + if (getExitEarly(overlayID)) { return; } @@ -642,7 +641,7 @@ void Keyboard::handleTriggerEnd(const OverlayID& overlayID, const PointerEvent& } void Keyboard::handleTriggerContinue(const OverlayID& overlayID, const PointerEvent& event) { - if (_keyboardLayers.empty() || !isLayerSwitchTimerFinished() || overlayID == _backPlate.overlayID) { + if (getExitEarly(overlayID)) { return; } @@ -685,7 +684,7 @@ void Keyboard::handleTriggerContinue(const OverlayID& overlayID, const PointerEv } void Keyboard::handleHoverBegin(const OverlayID& overlayID, const PointerEvent& event) { - if (_keyboardLayers.empty() || !isLayerSwitchTimerFinished() || overlayID == _backPlate.overlayID) { + if (getExitEarly(overlayID)) { return; } @@ -705,7 +704,7 @@ void Keyboard::handleHoverBegin(const OverlayID& overlayID, const PointerEvent& } void Keyboard::handleHoverEnd(const OverlayID& overlayID, const PointerEvent& event) { - if (_keyboardLayers.empty() || !isLayerSwitchTimerFinished() || overlayID == _backPlate.overlayID) { + if (getExitEarly(overlayID)) { return; } @@ -928,6 +927,10 @@ void Keyboard::loadKeyboardFile(const QString& keyboardFile) { request->send(); } +bool Keyboard::getExitEarly(OverlayID overlayID) const { + return (_keyboardLayers.empty() || !isLayerSwitchTimerFinished() || overlayID == _backPlate.overlayID); +} + QVector Keyboard::getKeysID() { return _ignoreItemsLock.resultWithReadLock>([&] { return _itemsToIgnore; @@ -956,13 +959,9 @@ void Keyboard::clearKeyboardKeys() { void Keyboard::enableStylus() { if (getPreferMalletsOverLasers()) { - auto pointerManager = DependencyManager::get(); - pointerManager->setRenderState(_leftHandStylus, "events on"); - pointerManager->enablePointer(_leftHandStylus); - pointerManager->setRenderState(_rightHandStylus, "events on"); - pointerManager->enablePointer(_rightHandStylus); + enableRightMallet(); + enableLeftMallet(); } - } void Keyboard::enableRightMallet() { diff --git a/interface/src/ui/Keyboard.h b/interface/src/ui/Keyboard.h index b917b60eb4..f5a034334a 100644 --- a/interface/src/ui/Keyboard.h +++ b/interface/src/ui/Keyboard.h @@ -152,9 +152,10 @@ private: void clearKeyboardKeys(); void switchToLayer(int layerIndex); void updateTextDisplay(); + bool getExitEarly(OverlayID overlayID) const; void startLayerSwitchTimer(); - bool isLayerSwitchTimerFinished(); + bool isLayerSwitchTimerFinished() const; bool shouldProcessPointerEvent(const PointerEvent& event) const; diff --git a/libraries/shared/src/Preferences.h b/libraries/shared/src/Preferences.h index 0fec8708e8..9f84d9c8b7 100644 --- a/libraries/shared/src/Preferences.h +++ b/libraries/shared/src/Preferences.h @@ -374,7 +374,7 @@ public: const QStringList& getItems() { return _items; } void setHeading(const QString& heading) { _heading = heading; } void setItems(const QStringList& items) { _items = items; } - bool getIndented() { return _indented; } + bool getIndented() const { return _indented; } void setIndented(const bool indented) { _indented = indented; } protected: diff --git a/scripts/system/controllers/controllerDispatcher.js b/scripts/system/controllers/controllerDispatcher.js index a579fee0d9..aeb2529170 100644 --- a/scripts/system/controllers/controllerDispatcher.js +++ b/scripts/system/controllers/controllerDispatcher.js @@ -453,7 +453,6 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); distanceScaleEnd: true, hand: LEFT_HAND }); - Keyboard.setLeftHandLaser(this.leftPointer); this.rightPointer = this.pointerManager.createPointer(false, PickType.Ray, { joint: "_CAMERA_RELATIVE_CONTROLLER_RIGHTHAND", diff --git a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js index c1b0658af2..1dc8bbf023 100644 --- a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js +++ b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js @@ -125,7 +125,7 @@ Script.include("/~/system/libraries/controllers.js"); this.ignoredObjects = []; }; - this.isPointingAtTriggerable = function(controllerData, triggerPressed, checkEntitiesOnly) { + this.getInteractableType = function(controllerData, triggerPressed, checkEntitiesOnly) { // allow pointing at tablet, unlocked web entities, or web overlays automatically without pressing trigger, // but for pointing at locked web entities or non-web overlays user must be pressing trigger var intersection = controllerData.rayPicks[this.hand]; @@ -175,7 +175,7 @@ Script.include("/~/system/libraries/controllers.js"); this.updateAlwaysOn = function(type) { var PREFER_STYLUS_OVER_LASER = "preferStylusOverLaser"; - this.parameters.handLaser.allwaysOn = (!Settings.getValue(PREFER_STYLUS_OVER_LASER, false) || type === intersectionType["HifiKeyboard"]); + this.parameters.handLaser.alwaysOn = (!Settings.getValue(PREFER_STYLUS_OVER_LASER, false) || type === intersectionType["HifiKeyboard"]); }; this.getDominantHand = function() { @@ -186,8 +186,8 @@ Script.include("/~/system/libraries/controllers.js"); this.isReady = function(controllerData) { var isTriggerPressed = controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE && - controllerData.triggerValues[this.otherHand] <= TRIGGER_OFF_VALUE; - var type = this.isPointingAtTriggerable(controllerData, isTriggerPressed, false); + controllerData.triggerValues[this.otherHand] <= TRIGGER_OFF_VALUE; + var type = this.getInteractableType(controllerData, isTriggerPressed, false); if (type !== intersectionType["None"] && !this.grabModuleWantsNearbyOverlay(controllerData)) { if (type === intersectionType["WebOverlay"] || type === intersectionType["WebEntity"] || type === intersectionType["HifiTablet"]) { @@ -206,7 +206,7 @@ Script.include("/~/system/libraries/controllers.js"); } this.updateAlwaysOn(type); - if (this.parameters.handLaser.allwaysOn || isTriggerPressed) { + if (this.parameters.handLaser.alwaysOn || isTriggerPressed) { return makeRunningValues(true, [], []); } } @@ -228,9 +228,9 @@ Script.include("/~/system/libraries/controllers.js"); this.run = function(controllerData, deltaTime) { this.addObjectToIgnoreList(controllerData); - var type = this.isPointingAtTriggerable(controllerData, isTriggerPressed, false); + var type = this.getInteractableType(controllerData, isTriggerPressed, false); var isTriggerPressed = controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE; - var laserOn = isTriggerPressed || this.parameters.handLaser.allwaysOn; + var laserOn = isTriggerPressed || this.parameters.handLaser.alwaysOn; this.addObjectToIgnoreList(controllerData); if (type === intersectionType["HifiTablet"] && laserOn) { @@ -246,7 +246,7 @@ Script.include("/~/system/libraries/controllers.js"); } else if ((type === intersectionType["HifiKeyboard"] && laserOn) || type === intersectionType["Overlay"]) { this.running = true; return makeRunningValues(true, [], []); - } else if (isTriggerPressed && !this.isPointingAtTriggerable(controllerData, isTriggerPressed, true)) { + } else if (isTriggerPressed && !this.getInteractableType(controllerData, isTriggerPressed, true)) { // if trigger is down + not pointing at a web entity, keep running web surface laser this.running = true; return makeRunningValues(true, [], []); diff --git a/scripts/system/libraries/controllerDispatcherUtils.js b/scripts/system/libraries/controllerDispatcherUtils.js index ab2801087e..070997d479 100644 --- a/scripts/system/libraries/controllerDispatcherUtils.js +++ b/scripts/system/libraries/controllerDispatcherUtils.js @@ -181,14 +181,14 @@ makeLaserLockInfo = function(targetID, isOverlay, hand, offset) { }; }; -makeLaserParams = function(hand, allwaysOn) { - if (allwaysOn === undefined) { - allwaysOn = false; +makeLaserParams = function(hand, alwaysOn) { + if (alwaysOn === undefined) { + alwaysOn = false; } return { hand: hand, - allwaysOn: allwaysOn + alwaysOn: alwaysOn }; }; diff --git a/scripts/system/libraries/pointersUtils.js b/scripts/system/libraries/pointersUtils.js index a2a1e674b1..ec9a08b7eb 100644 --- a/scripts/system/libraries/pointersUtils.js +++ b/scripts/system/libraries/pointersUtils.js @@ -145,7 +145,7 @@ Pointer = function(hudLayer, pickType, pointerData) { mode = "hold"; } else if (triggerClicks[this.hand]) { mode = "full"; - } else if (triggerValues[this.hand] > TRIGGER_ON_VALUE || this.allwaysOn) { + } else if (triggerValues[this.hand] > TRIGGER_ON_VALUE || this.alwaysOn) { mode = "half"; } } @@ -171,7 +171,7 @@ PointerManager = function() { var index = laserParams.hand; if (index < this.pointers.length && index >= 0) { this.pointers[index].makeVisible(); - this.pointers[index].allwaysOn = laserParams.allwaysOn; + this.pointers[index].alwaysOn = laserParams.alwaysOn; } };