diff --git a/scripts/defaultScripts.js b/scripts/defaultScripts.js index feb9d8c2d6..aba1e1ba51 100644 --- a/scripts/defaultScripts.js +++ b/scripts/defaultScripts.js @@ -21,11 +21,11 @@ Script.load("system/edit.js"); Script.load("system/mod.js"); Script.load("system/selectAudioDevice.js"); Script.load("system/notifications.js"); +Script.load("system/controllers/toggleAdvancedMovementForHandControllers.js") Script.load("system/controllers/handControllerGrab.js"); Script.load("system/controllers/handControllerPointer.js"); Script.load("system/controllers/squeezeHands.js"); Script.load("system/controllers/grab.js"); Script.load("system/controllers/teleport.js"); -Script.load("system/controllers/advancedMovement.js") Script.load("system/dialTone.js"); Script.load("system/firstPersonHMD.js"); \ No newline at end of file diff --git a/scripts/system/controllers/teleport.js b/scripts/system/controllers/teleport.js index d1dd5b6348..d223b59bca 100644 --- a/scripts/system/controllers/teleport.js +++ b/scripts/system/controllers/teleport.js @@ -202,6 +202,7 @@ function Teleporter() { this.turnOffOverlayBeams(); this.updateConnected = null; + _this.inCoolIn = false; Script.setTimeout(function() { inTeleportMode = false; @@ -209,8 +210,6 @@ function Teleporter() { }, 200); }; - - this.update = function() { if (isDisabled === 'both') { return; @@ -223,12 +222,15 @@ function Teleporter() { teleporter.leftRay(); if ((leftPad.buttonValue === 0) && inTeleportMode === true) { if (_this.inCoolIn === true) { + print('released during cool in period. exit.') _this.exitTeleportMode(); _this.deleteTargetOverlay(); _this.deleteCancelOverlay(); } else { + print('release while not in cool in and in teleport mode. should teleport') _this.teleport(); } + print('some other state::' + leftPad.buttonValue + "///" + inTeleportMode) return; } @@ -239,12 +241,15 @@ function Teleporter() { teleporter.rightRay(); if ((rightPad.buttonValue === 0) && inTeleportMode === true) { if (_this.inCoolIn === true) { + print('released during cool in period. exit.') _this.exitTeleportMode(); _this.deleteTargetOverlay(); _this.deleteCancelOverlay(); } else { + print('release while not in cool in and in teleport mode. should teleport') _this.teleport(); } + print('some other state::' + rightPad.buttonValue + "///" + inTeleportMode) return; } } diff --git a/scripts/system/controllers/advancedMovement.js b/scripts/system/controllers/toggleAdvancedMovementForHandControllers.js similarity index 65% rename from scripts/system/controllers/advancedMovement.js rename to scripts/system/controllers/toggleAdvancedMovementForHandControllers.js index d53fa3a2f9..57aa4cd2c1 100644 --- a/scripts/system/controllers/advancedMovement.js +++ b/scripts/system/controllers/toggleAdvancedMovementForHandControllers.js @@ -1,26 +1,26 @@ +// Created by james b. pollack @imgntn on 7/2/2016 +// Copyright 2016 High Fidelity, Inc. //advanced movements settings are in individual controller json files //what we do is check the status of the 'advance movement' checkbox when you enter HMD mode //if 'advanced movement' is checked...we give you the defaults that are in the json. //if 'advanced movement' is not checked... we override the advanced controls with basic ones. -//when the script stops, - -//todo: store in prefs // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html - -var mappingName, basicMapping,isChecked; +var mappingName, basicMapping, isChecked; var previousSetting = Settings.getValue('advancedMovementForHandControllersIsChecked'); if (previousSetting === '') { previousSetting = false; - isChecked=false; + isChecked = false; } -if(previousSetting===true){ - isChecked=true; +if (previousSetting === true) { + isChecked = true; } -if(previousSetting===false){ - isChecked=false; +if (previousSetting === false) { + isChecked = false; } function addAdvancedMovementItemToSettingsMenu() { @@ -37,31 +37,57 @@ function rotate180() { MyAvatar.orientation = Quat.inverse(MyAvatar.orientation); } +var inFlipTurn = false; + function registerBasicMapping() { mappingName = 'Hifi-AdvancedMovement-Dev-' + Math.random(); basicMapping = Controller.newMapping(mappingName); basicMapping.from(Controller.Standard.LY).to(function(value) { var stick = Controller.getValue(Controller.Standard.LS); - if (value === 1) { + if (value === 1 && Controller.Hardware.OculusTouch !== undefined) { rotate180(); } - print('should do LY stuff' + value + ":stick:" + stick); + if (Controller.Hardware.Vive !== undefined) { + if (value > 0.75 && inFlipTurn === false) { + print('vive should flip turn') + inFlipTurn = true; + rotate180(); + Script.setTimeout(function() { + print('vive should be able to flip turn again') + inFlipTurn = false; + }, 250) + } else { + print('vive should not flip turn') + + } + } return; }); basicMapping.from(Controller.Standard.LX).to(Controller.Standard.RX); basicMapping.from(Controller.Standard.RY).to(function(value) { var stick = Controller.getValue(Controller.Standard.RS); - if (value === 1) { + if (value === 1 && Controller.Hardware.OculusTouch !== undefined) { rotate180(); } + if (Controller.Hardware.Vive !== undefined) { + if (value > 0.75 && inFlipTurn === false) { + print('vive should flip turn') + inFlipTurn = true; + rotate180(); + Script.setTimeout(function() { + print('vive should be able to flip turn again') + inFlipTurn = false; + }, 250) + } else { + print('vive should not flip turn') + + } + } print('should do RY stuff' + value + ":stick:" + stick); return; }) } -function testPrint(what) { - print('it was controller: ' + what) -} function enableMappings() { Controller.enableMapping(mappingName); @@ -79,7 +105,6 @@ function scriptEnding() { function menuItemEvent(menuItem) { if (menuItem == "Advanced Movement For Hand Controllers") { - print(" checked=" + Menu.isOptionChecked("Advanced Movement For Hand Controllers")); isChecked = Menu.isOptionChecked("Advanced Movement For Hand Controllers"); if (isChecked === true) { Settings.setValue('advancedMovementForHandControllersIsChecked', true); @@ -100,10 +125,8 @@ Menu.menuItemEvent.connect(menuItemEvent); registerBasicMapping(); if (previousSetting === true) { - print('JBP WAS SET TO TRUE') disableMappings(); } else if (previousSetting === false) { - print('JBP WAS SET TO FALSE') enableMappings(); }