From fb09a9724ec776c5f6f2d28a99ca49dbe63f2ea5 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Fri, 5 Jan 2018 11:04:09 +1300 Subject: [PATCH] Change laser hand with trigger squeeze --- .../controllerModules/webSurfaceLaserInput.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js index eb9a426eeb..453ad10618 100644 --- a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js +++ b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js @@ -81,17 +81,24 @@ Script.include("/~/system/libraries/controllers.js"); this.parameters.handLaser.allwaysOn = !Settings.getValue(PREFER_STYLUS_OVER_LASER, false); }; - this.dominantHand = function () { + this.getDominantHand = function() { return MyAvatar.getDominantHand() === "right" ? 1 : 0; }; + this.dominantHandOverride = false; + this.isReady = function (controllerData) { var otherModuleRunning = this.getOtherModule().running; - otherModuleRunning = otherModuleRunning && this.dominantHand() !== this.hand; - if (!otherModuleRunning + otherModuleRunning = otherModuleRunning && this.getDominantHand() !== this.hand; // Auto-swap to dominant hand. + var isTriggerPressed = controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE; + if ((!otherModuleRunning || isTriggerPressed) && (this.isPointingAtOverlay(controllerData) || this.isPointingAtWebEntity(controllerData))) { this.updateAllwaysOn(); - if (this.parameters.handLaser.allwaysOn || controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE) { + if (isTriggerPressed) { + this.dominantHandOverride = true; // Override dominant hand. + this.getOtherModule().dominantHandOverride = false; + } + if (this.parameters.handLaser.allwaysOn || isTriggerPressed) { return makeRunningValues(true, [], []); } } @@ -100,7 +107,8 @@ Script.include("/~/system/libraries/controllers.js"); this.run = function (controllerData, deltaTime) { var otherModuleRunning = this.getOtherModule().running; - otherModuleRunning = otherModuleRunning && this.dominantHand() !== this.hand; + otherModuleRunning = otherModuleRunning && this.getDominantHand() !== this.hand; // Auto-swap to dominant hand. + otherModuleRunning = otherModuleRunning || this.getOtherModule().dominantHandOverride; // Override dominant hand. var grabModuleNeedsToRun = this.grabModuleWantsNearbyOverlay(controllerData); if (!otherModuleRunning && !grabModuleNeedsToRun && (controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE || this.parameters.handLaser.allwaysOn @@ -110,6 +118,7 @@ Script.include("/~/system/libraries/controllers.js"); } this.deleteContextOverlay(); this.running = false; + this.dominantHandOverride = false; return makeRunningValues(false, [], []); }; }