From 0a024616cc1ca939fb99ddf5e95279898fcc303e Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 20 Dec 2016 14:21:23 -0800 Subject: [PATCH] add special equip for oculus style grab --- .../system/controllers/handControllerGrab.js | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index f75fcd1e9b..d17ff0582e 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -823,7 +823,7 @@ function MyController(hand) { if (this.hand === RIGHT_HAND && this.state === STATE_SEARCHING && this.getOtherHandController().state === STATE_SEARCHING) { this.maybeScaleMyAvatar(); } - + if (this.ignoreInput()) { this.turnOffVisualizations(); return; @@ -1063,11 +1063,16 @@ function MyController(hand) { this.secondaryPress = function(value) { _this.rawSecondaryValue = value; - // The value to check if we will allow the release function to be called - var allowReleaseValue = 0.1; - if (value > 0 && _this.state == STATE_HOLD) { - _this.release(); + if (_this.state == STATE_HOLD && !this.secondaryHeldEquip) { + // when using the index trigger click equip + // any click on the middle finger trigger should release + // check if the middle finger trigger is pressed past the threshold + var allowReleaseValue = 0.1; + if (value > allowReleaseValue) { + _this.release(); + } } + }; this.updateSmoothedTrigger = function() { @@ -1095,6 +1100,12 @@ function MyController(hand) { this.secondaryReleased = function() { return _this.rawSecondaryValue < BUMPER_ON_VALUE; + + if (_this.state == STATE_HOLD && this.secondaryHeldEquip) { + // when using the middle finger hold equip, the equip is + // dropped when the middle finger trigger is released + _this.release(); + } }; // this.triggerOrsecondarySqueezed = function () { @@ -1502,6 +1513,10 @@ function MyController(hand) { this.grabbedHotspot = potentialEquipHotspot; this.grabbedEntity = potentialEquipHotspot.entityID; this.setState(STATE_HOLD, "equipping '" + entityPropertiesCache.getProps(this.grabbedEntity).name + "'"); + + // handle the Oculus Touch equip where the middle finger trigger is held + this.secondaryHeldEquip = this.secondarySqueezed && !this.triggerSmoothedGrab; + return; } }