diff --git a/scripts/system/controllers/controllerDispatcher.js b/scripts/system/controllers/controllerDispatcher.js index b04363e2fb..5439383744 100644 --- a/scripts/system/controllers/controllerDispatcher.js +++ b/scripts/system/controllers/controllerDispatcher.js @@ -246,7 +246,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); Pointers.getPrevPickResult(_this.leftHudPointer), Pointers.getPrevPickResult(_this.rightHudPointer) ]; - var mouseRayPick = RayPick.getPrevRayPickResult(_this.mouseRayPick); + var mouseRayPick = Pointers.getPrevPickResult(_this.mouseRayPick); // if the pickray hit something very nearby, put it into the nearby entities list for (h = LEFT_HAND; h <= RIGHT_HAND; h++) { @@ -435,7 +435,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); distanceScaleEnd: true, hand: RIGHT_HAND }); - this.mouseRayPick = RayPick.createRayPick({ + this.mouseRayPick = Pointers.createPointer(PickType.Ray, { joint: "Mouse", filter: Picks.PICK_ENTITIES | Picks.PICK_OVERLAYS, enabled: true @@ -472,7 +472,8 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); this.cleanup = function () { Script.update.disconnect(_this.update); Controller.disableMapping(MAPPING_NAME); - this.pointerManager.removePointers(); + _this.pointerManager.removePointers(); + Pointers.removePointer(this.mouseRayPick); }; } function mouseReleaseOnOverlay(overlayID, event) { @@ -480,7 +481,22 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); Messages.sendLocalMessage("home", overlayID); } } + + var HAPTIC_STYLUS_STRENGTH = 1.0; + var HAPTIC_STYLUS_DURATION = 20.0; + function mousePress(id, event) { + if (HMD.active) { + var runningPlugins = controllerDispatcher.runningPluginNames; + if (event.id === controllerDispatcher.leftPointer && event.button === "Primary" && runningPlugins.LeftWebSurfaceLaserInput) { + Controller.triggerHapticPulse(HAPTIC_STYLUS_STRENGTH, HAPTIC_STYLUS_DURATION, LEFT_HAND); + } else if (event.id === controllerDispatcher.rightPointer && event.button === "Primary" && runningPlugins.RightWebSurfaceLaserInput) { + Controller.triggerHapticPulse(HAPTIC_STYLUS_STRENGTH, HAPTIC_STYLUS_DURATION, RIGHT_HAND); + } + } + } Overlays.mouseReleaseOnOverlay.connect(mouseReleaseOnOverlay); + Overlays.mousePressOnOverlay.connect(mousePress); + Entities.mousePressOnEntity.connect(mousePress); var controllerDispatcher = new ControllerDispatcher(); Messages.subscribe('Hifi-Hand-RayPick-Blacklist'); Messages.messageReceived.connect(controllerDispatcher.handleHandMessage); diff --git a/scripts/system/controllers/controllerModules/farActionGrabEntity.js b/scripts/system/controllers/controllerModules/farActionGrabEntity.js index 8d5c3a7446..0d421bbaec 100644 --- a/scripts/system/controllers/controllerModules/farActionGrabEntity.js +++ b/scripts/system/controllers/controllerModules/farActionGrabEntity.js @@ -539,8 +539,6 @@ Script.include("/~/system/libraries/Xform.js"); enableDispatcherModule("RightFarActionGrabEntity", rightFarActionGrabEntity); function cleanup() { - leftFarActionGrabEntity.cleanup(); - rightFarActionGrabEntity.cleanup(); disableDispatcherModule("LeftFarActionGrabEntity"); disableDispatcherModule("RightFarActionGrabEntity"); } diff --git a/scripts/system/controllers/controllerModules/inEditMode.js b/scripts/system/controllers/controllerModules/inEditMode.js index ff7f10be28..f79b2db1e2 100644 --- a/scripts/system/controllers/controllerModules/inEditMode.js +++ b/scripts/system/controllers/controllerModules/inEditMode.js @@ -96,7 +96,7 @@ Script.include("/~/system/libraries/utils.js"); } } - var overlayLaser = getEnabledModuleByName(this.hand === RIGHT_HAND ? "RightOverlayLaserInput" : "LeftOverlayLaserInput"); + var overlayLaser = getEnabledModuleByName(this.hand === RIGHT_HAND ? "RightWebSurfaceLaserInput" : "LeftWebSurfaceLaserInput"); if (overlayLaser) { var overlayLaserReady = overlayLaser.isReady(controllerData); diff --git a/scripts/system/controllers/controllerModules/tabletStylusInput.js b/scripts/system/controllers/controllerModules/stylusInput.js similarity index 96% rename from scripts/system/controllers/controllerModules/tabletStylusInput.js rename to scripts/system/controllers/controllerModules/stylusInput.js index 6e75c6d15d..3edb8df984 100644 --- a/scripts/system/controllers/controllerModules/tabletStylusInput.js +++ b/scripts/system/controllers/controllerModules/stylusInput.js @@ -42,7 +42,7 @@ Script.include("/~/system/libraries/controllers.js"); }; } - function TabletStylusInput(hand) { + function StylusInput(hand) { this.hand = hand; this.parameters = makeDispatcherModuleParameters( @@ -71,8 +71,8 @@ Script.include("/~/system/libraries/controllers.js"); }; this.overlayLaserActive = function(controllerData) { - var rightOverlayLaserModule = getEnabledModuleByName("RightOverlayLaserInput"); - var leftOverlayLaserModule = getEnabledModuleByName("LeftOverlayLaserInput"); + var rightOverlayLaserModule = getEnabledModuleByName("RightWebSurfaceLaserInput"); + var leftOverlayLaserModule = getEnabledModuleByName("LeftWebSurfaceLaserInput"); var rightModuleRunning = rightOverlayLaserModule ? rightOverlayLaserModule.isReady(controllerData).active : false; var leftModuleRunning = leftOverlayLaserModule ? leftOverlayLaserModule.isReady(controllerData).active : false; return leftModuleRunning || rightModuleRunning; @@ -185,15 +185,15 @@ Script.include("/~/system/libraries/controllers.js"); } } - var leftTabletStylusInput = new TabletStylusInput(LEFT_HAND); - var rightTabletStylusInput = new TabletStylusInput(RIGHT_HAND); + var leftTabletStylusInput = new StylusInput(LEFT_HAND); + var rightTabletStylusInput = new StylusInput(RIGHT_HAND); enableDispatcherModule("LeftTabletStylusInput", leftTabletStylusInput); enableDispatcherModule("RightTabletStylusInput", rightTabletStylusInput); Overlays.hoverEnterOverlay.connect(mouseHoverEnter); Overlays.hoverLeaveOverlay.connect(mouseHoverLeave); - Overlays.mousePressOnOverlay.connect(mousePress); + Overlays.mousePressOnOverlay.connect(mousePress); this.cleanup = function () { leftTabletStylusInput.cleanup(); diff --git a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js index c5e2e885a7..bf90124cab 100644 --- a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js +++ b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js @@ -16,7 +16,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); Script.include("/~/system/libraries/controllers.js"); (function() { - function OverlayLaserInput(hand) { + function WebSurfaceLaserInput(hand) { this.hand = hand; this.running = false; @@ -99,15 +99,15 @@ Script.include("/~/system/libraries/controllers.js"); }; } - var leftOverlayLaserInput = new OverlayLaserInput(LEFT_HAND); - var rightOverlayLaserInput = new OverlayLaserInput(RIGHT_HAND); + var leftOverlayLaserInput = new WebSurfaceLaserInput(LEFT_HAND); + var rightOverlayLaserInput = new WebSurfaceLaserInput(RIGHT_HAND); - enableDispatcherModule("LeftOverlayLaserInput", leftOverlayLaserInput); - enableDispatcherModule("RightOverlayLaserInput", rightOverlayLaserInput); + enableDispatcherModule("LeftWebSurfaceLaserInput", leftOverlayLaserInput); + enableDispatcherModule("RightWebSurfaceLaserInput", rightOverlayLaserInput); function cleanup() { - disableDispatcherModule("LeftOverlayLaserInput"); - disableDispatcherModule("RightOverlayLaserInput"); + disableDispatcherModule("LeftWebSurfaceLaserInput"); + disableDispatcherModule("RightWebSurfaceLaserInput"); } Script.scriptEnding.connect(cleanup); }()); diff --git a/scripts/system/controllers/controllerScripts.js b/scripts/system/controllers/controllerScripts.js index 2e74797383..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/tabletStylusInput.js", + "controllerModules/stylusInput.js", "controllerModules/equipEntity.js", "controllerModules/nearTrigger.js", "controllerModules/webSurfaceLaserInput.js",