From efa6f1f02fdcead0a13981de851cd2d46d7a4d8d Mon Sep 17 00:00:00 2001 From: David Rowe Date: Thu, 4 Jan 2018 15:00:17 +1300 Subject: [PATCH] Use "Prefer Stylus Over Laser" setting --- .../controllers/controllerModules/stylusInput.js | 5 ++++- .../controllerModules/webSurfaceLaserInput.js | 14 ++++++++++++-- scripts/system/controllers/controllerScripts.js | 2 +- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/scripts/system/controllers/controllerModules/stylusInput.js b/scripts/system/controllers/controllerModules/stylusInput.js index d9fa0f76a9..aa65135289 100644 --- a/scripts/system/controllers/controllerModules/stylusInput.js +++ b/scripts/system/controllers/controllerModules/stylusInput.js @@ -142,7 +142,10 @@ Script.include("/~/system/libraries/controllers.js"); }; this.isReady = function (controllerData) { - if (this.processStylus(controllerData)) { + var PREFER_STYLUS_OVER_LASER = "preferStylusOverLaser"; + var isUsingStylus = Settings.getValue(PREFER_STYLUS_OVER_LASER, false); + + if (isUsingStylus && this.processStylus(controllerData)) { Pointers.enablePointer(this.pointer); return makeRunningValues(true, [], []); } else { diff --git a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js index 94cb2f86cb..4e9171f924 100644 --- a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js +++ b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js @@ -76,18 +76,28 @@ Script.include("/~/system/libraries/controllers.js"); } }; + this.updateAllwaysOn = function () { + var PREFER_STYLUS_OVER_LASER = "preferStylusOverLaser"; + this.parameters.handLaser.allwaysOn = !Settings.getValue(PREFER_STYLUS_OVER_LASER, false); + }; + this.isReady = function (controllerData) { var otherModuleRunning = this.getOtherModule().running; if ((this.isPointingAtOverlay(controllerData) || this.isPointingAtWebEntity(controllerData)) && !otherModuleRunning) { - return makeRunningValues(true, [], []); + this.updateAllwaysOn(); + if (this.parameters.handLaser.allwaysOn || controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE) { + return makeRunningValues(true, [], []); + } } return makeRunningValues(false, [], []); }; this.run = function (controllerData, deltaTime) { var grabModuleNeedsToRun = this.grabModuleWantsNearbyOverlay(controllerData); - if ((controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE || (this.isPointingAtOverlay(controllerData) || this.isPointingAtWebEntity(controllerData))) && !grabModuleNeedsToRun) { + if (!grabModuleNeedsToRun && (controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE + || this.parameters.handLaser.allwaysOn + && (this.isPointingAtOverlay(controllerData) || this.isPointingAtWebEntity(controllerData)))) { this.running = true; return makeRunningValues(true, [], []); } diff --git a/scripts/system/controllers/controllerScripts.js b/scripts/system/controllers/controllerScripts.js index 1208b1ab83..1eb30bbefd 100644 --- a/scripts/system/controllers/controllerScripts.js +++ b/scripts/system/controllers/controllerScripts.js @@ -19,7 +19,7 @@ var CONTOLLER_SCRIPTS = [ "controllerModules/nearParentGrabOverlay.js", "controllerModules/nearActionGrabEntity.js", "controllerModules/farActionGrabEntity.js", - //"controllerModules/stylusInput.js", + "controllerModules/stylusInput.js", "controllerModules/equipEntity.js", "controllerModules/nearTrigger.js", "controllerModules/webSurfaceLaserInput.js",