This commit is contained in:
James B. Pollack 2016-08-02 12:25:24 -07:00
parent 6a72fe7df4
commit a7b8f2c9df
4 changed files with 90 additions and 24 deletions

View file

@ -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" }

View file

@ -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" },

View file

@ -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;

View file

@ -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);
}
}
}
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);