diff --git a/interface/resources/controllers/hydra.json b/interface/resources/controllers/hydra.json index 716d283a86..8fffe3a922 100644 --- a/interface/resources/controllers/hydra.json +++ b/interface/resources/controllers/hydra.json @@ -26,8 +26,7 @@ { "from": [ "Hydra.L1", "Hydra.L3" ], "to": "Standard.LeftPrimaryThumb" }, { "from": [ "Hydra.R1", "Hydra.R3" ], "to": "Standard.RightPrimaryThumb" }, - { "from": [ "Hydra.R2", "Hydra.R4" ], "to": "Standard.RightSecondaryThumb" }, - { "from": [ "Hydra.L2", "Hydra.L4" ], "to": "Standard.LeftSecondaryThumb" }, + { "from": "Hydra.LeftHand", "to": "Standard.LeftHand" }, { "from": "Hydra.RightHand", "to": "Standard.RightHand" } diff --git a/interface/resources/controllers/oculus_touch.json b/interface/resources/controllers/oculus_touch.json index 001d5b8716..6fc7daf1f8 100644 --- a/interface/resources/controllers/oculus_touch.json +++ b/interface/resources/controllers/oculus_touch.json @@ -3,8 +3,8 @@ "channels": [ { "from": "OculusTouch.A", "to": "Standard.RightPrimaryThumb" }, { "from": "OculusTouch.B", "to": "Standard.RightSecondaryThumb" }, - { "from": "OculusTouch.X", "to": "Standard.LeftPrimaryThumb" }, - { "from": "OculusTouch.Y", "to": "Standard.LeftSecondaryThumb" }, + // { "from": "OculusTouch.X", "to": "Standard.LeftPrimaryThumb" }, + // { "from": "OculusTouch.Y", "to": "Standard.LeftSecondaryThumb" }, { "from": "OculusTouch.LY", "filters": "invert", "to": "Standard.LY" }, { "from": "OculusTouch.LX", "to": "Standard.LX" }, diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index 00c37bd074..53ed7e91c9 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -1365,7 +1365,7 @@ function MyController(hand) { }; this.distanceHoldingEnter = function() { - + Messages.sendLocalMessage('Hifi-Teleport-Disabler','disable'); this.clearEquipHaptics(); // controller pose is in avatar frame @@ -1620,6 +1620,7 @@ function MyController(hand) { }; this.nearGrabbingEnter = function() { + Messages.sendLocalMessage('Hifi-Teleport-Disabler','disable'); this.lineOff(); this.overlayLineOff(); @@ -1947,6 +1948,7 @@ function MyController(hand) { }; this.release = function() { + Messages.sendLocalMessage('Hifi-Teleport-Disabler','enable'); this.turnOffVisualizations(); var noVelocity = false; diff --git a/scripts/system/controllers/teleport.js b/scripts/system/controllers/teleport.js index ca8891f6ab..33ec226c94 100644 --- a/scripts/system/controllers/teleport.js +++ b/scripts/system/controllers/teleport.js @@ -239,19 +239,22 @@ function Teleporter() { this.update = function() { + if (isDisabled) { + return; + } if (teleporter.teleportHand === 'left') { teleporter.leftRay(); - - if ((leftPad.buttonValue === 0 || leftTrigger.buttonValue === 0) && inTeleportMode === true) { + //|| leftTrigger.buttonValue === 0 + if ((leftPad.buttonValue === 0 ) && inTeleportMode === true) { _this.teleport(); return; } } else { teleporter.rightRay(); - - if ((rightPad.buttonValue === 0 || rightTrigger.buttonValue === 0) && inTeleportMode === true) { + //|| rightTrigger.buttonValue === 0 + if ((rightPad.buttonValue === 0 ) && inTeleportMode === true) { _this.teleport(); return; } @@ -570,8 +573,8 @@ var rightTrigger = new Trigger('right'); var mappingName, teleportMapping; -var TELEPORT_DELAY = 100; - +var activationTimeout = null; +var TELEPORT_DELAY = 800; function registerMappings() { mappingName = 'Hifi-Teleporter-Dev-' + Math.random(); @@ -582,22 +585,63 @@ function registerMappings() { teleportMapping.from(Controller.Standard.RightPrimaryThumb).peek().to(rightPad.buttonPress); teleportMapping.from(Controller.Standard.LeftPrimaryThumb).peek().to(leftPad.buttonPress); - teleportMapping.from(Controller.Standard.LeftPrimaryThumb).when(leftTrigger.down).to(function(value) { - teleporter.enterTeleportMode('left') + teleportMapping.from(Controller.Standard.LeftPrimaryThumb) + // .when(leftTrigger.down) + .to(function(value) { + if (isDisabled === true) { + return; + } + if (activationTimeout !== null) { + return + } + activationTimeout = Script.setTimeout(function() { + teleporter.enterTeleportMode('left') + Script.clearTimeout(activationTimeout); + activationTimeout = null; + }, TELEPORT_DELAY) return; }); - teleportMapping.from(Controller.Standard.RightPrimaryThumb).when(rightTrigger.down).to(function(value) { - teleporter.enterTeleportMode('right') - return; - }); - teleportMapping.from(Controller.Standard.RT).when(Controller.Standard.RightPrimaryThumb).to(function(value) { - teleporter.enterTeleportMode('right') - return; - }); - teleportMapping.from(Controller.Standard.LT).when(Controller.Standard.LeftPrimaryThumb).to(function(value) { - teleporter.enterTeleportMode('left') + teleportMapping.from(Controller.Standard.RightPrimaryThumb) + // .when(rightTrigger.down) + .to(function(value) { + if (isDisabled === true) { + return; + } + if (activationTimeout !== null) { + return + } + activationTimeout = Script.setTimeout(function() { + teleporter.enterTeleportMode('right') + Script.clearTimeout(activationTimeout); + activationTimeout = null; + }, TELEPORT_DELAY) return; }); + // teleportMapping.from(Controller.Standard.RT).when(Controller.Standard.RightPrimaryThumb).to(function(value) { + // if (isDisabled === true) { + // return; + // } + // if (activationTimeout !== null) { + // return + // } + // activationTimeout = Script.setTimeout(function() { + // teleporter.enterTeleportMode('right') + // Script.clearTimeout(activationTimeout); + // activationTimeout = null; + // }, TELEPORT_DELAY) + // return; + // }); + // teleportMapping.from(Controller.Standard.LT).when(Controller.Standard.LeftPrimaryThumb).to(function(value) { + // if (isDisabled === true) { + // return; + // } + // activationTimeout = Script.setTimeout(function() { + // teleporter.enterTeleportMode('left') + // Script.clearTimeout(activationTimeout); + // activationTimeout = null; + // }, TELEPORT_DELAY) + // return; + // }); } @@ -618,4 +662,25 @@ function cleanup() { if (teleporter.updateConnected !== null) { Script.update.disconnect(teleporter.update); } -} \ No newline at end of file +} + +var isDisabled = false; +var handleHandMessages = function(channel, message, sender) { + var data; + print('its a message') + if (sender === MyAvatar.sessionUUID) { + if (channel === 'Hifi-Teleport-Disabler') { + print('got teleport disabler message' + message) + if (message === 'disable') { + isDisabled = true; + } + if (message === 'enable') { + isDisabled = false; + } + + } + } +} + +Messages.subscribe('Hifi-Teleport-Disabler'); +Messages.messageReceived.connect(handleHandMessages); \ No newline at end of file