diff --git a/examples/controllers/squeezeHands.js b/examples/controllers/squeezeHands.js index 29965f77eb..3bf13d8646 100644 --- a/examples/controllers/squeezeHands.js +++ b/examples/controllers/squeezeHands.js @@ -25,8 +25,6 @@ var LAST_FRAME = 15.0; // What is the number of the last frame we want to us var SMOOTH_FACTOR = 0.75; var MAX_FRAMES = 30.0; -var LEFT_HAND_CLICK = Controller.findAction("LEFT_HAND_CLICK"); -var RIGHT_HAND_CLICK = Controller.findAction("RIGHT_HAND_CLICK"); var CONTROLLER_DEAD_SPOT = 0.25; @@ -45,8 +43,8 @@ function normalizeControllerValue(val) { } Script.update.connect(function(deltaTime) { - var leftTrigger = normalizeControllerValue(Controller.getActionValue(LEFT_HAND_CLICK)); - var rightTrigger = normalizeControllerValue(Controller.getActionValue(RIGHT_HAND_CLICK)); + var leftTrigger = normalizeControllerValue(Controller.getValue(Controller.Standard.LT)); + var rightTrigger = normalizeControllerValue(Controller.getValue(Controller.Standard.RT)); // Average last few trigger values together for a bit of smoothing var smoothLeftTrigger = leftTrigger * (1.0 - SMOOTH_FACTOR) + lastLeftTrigger * SMOOTH_FACTOR; diff --git a/examples/example/games/sword.js b/examples/example/games/sword.js index abd94b5319..31a9a82d87 100644 --- a/examples/example/games/sword.js +++ b/examples/example/games/sword.js @@ -361,8 +361,8 @@ function update() { } function updateControllerState() { - rightTriggerValue = Controller.getActionValue(rightHandClick); - leftTriggerValue = Controller.getActionValue(leftHandClick); + rightTriggerValue = Controller.getValue(Controller.Standard.RT); + leftTriggerValue =Controller.getValue(Controller.Standard.LT); if (rightTriggerValue > TRIGGER_THRESHOLD && !swordHeld) { grabSword("right") diff --git a/examples/painting/closePaint.js b/examples/painting/closePaint.js index 563ed1dafb..60b4ac2e25 100644 --- a/examples/painting/closePaint.js +++ b/examples/painting/closePaint.js @@ -159,7 +159,8 @@ function MyController(hand, triggerAction) { } this.updateControllerState = function() { - this.triggerValue = Controller.getActionValue(this.triggerAction); + this.triggerValue = Controller.getValue(this.triggerAction); + if (this.triggerValue > TRIGGER_ON_VALUE && this.prevTriggerValue <= TRIGGER_ON_VALUE) { this.squeeze(); } else if (this.triggerValue < TRIGGER_ON_VALUE && this.prevTriggerValue >= TRIGGER_ON_VALUE) { @@ -256,8 +257,8 @@ function MyController(hand, triggerAction) { } } -var rightController = new MyController(RIGHT_HAND, Controller.findAction("RIGHT_HAND_CLICK")); -var leftController = new MyController(LEFT_HAND, Controller.findAction("LEFT_HAND_CLICK")); +var rightController = new MyController(RIGHT_HAND, Controller.Standard.RT); +var leftController = new MyController(LEFT_HAND, Controller.Standard.LT); Controller.actionEvent.connect(function(action, state) { if (state === 0) { diff --git a/examples/toybox/flashlight/createFlashlight.js b/examples/toybox/flashlight/createFlashlight.js index 490792027a..b049d2632e 100644 --- a/examples/toybox/flashlight/createFlashlight.js +++ b/examples/toybox/flashlight/createFlashlight.js @@ -12,10 +12,9 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // /*global MyAvatar, Entities, AnimationCache, SoundCache, Scene, Camera, Overlays, HMD, AvatarList, AvatarManager, Controller, UndoStack, Window, Account, GlobalServices, Script, ScriptDiscoveryService, LODManager, Menu, Vec3, Quat, AudioDevice, Paths, Clipboard, Settings, XMLHttpRequest, randFloat, randInt */ -Script.include("https://hifi-public.s3.amazonaws.com/scripts/utilities.js"); +Script.include("../../libraries/utils.js"); - -var scriptURL = Script.resolvePath('flashlight.js?123123'); +var scriptURL = Script.resolvePath('flashlight.js'); var modelURL = "https://hifi-public.s3.amazonaws.com/models/props/flashlight.fbx"; diff --git a/examples/toybox/flashlight/flashlight.js b/examples/toybox/flashlight/flashlight.js index 722a5c1bfc..8911c0ecd8 100644 --- a/examples/toybox/flashlight/flashlight.js +++ b/examples/toybox/flashlight/flashlight.js @@ -183,11 +183,14 @@ }, changeLightWithTriggerPressure: function(flashLightHand) { - var handClickString = flashLightHand + "_HAND_CLICK"; - var handClick = Controller.findAction(handClickString); + if (flashLightHand === 'LEFT') { + this.triggerValue = Controller.getValue(Controller.Standard.LT); + } + if (flashLightHand === 'RIGHT') { + this.triggerValue = Controller.getValue(Controller.Standard.RT); - this.triggerValue = Controller.getActionValue(handClick); + } if (this.triggerValue < DISABLE_LIGHT_THRESHOLD && this.lightOn === true) { this.turnLightOff(); @@ -266,4 +269,4 @@ // entity scripts always need to return a newly constructed object of our type return new Flashlight(); -}); +}); \ No newline at end of file