From 6b795364c8ed52a2ee2a82d557906710066c86d7 Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Fri, 23 Oct 2015 16:30:40 -0700 Subject: [PATCH 1/7] make handGrab treat shoulder bumbers and triggers as merged control --- examples/controllers/handControllerGrab.js | 25 +++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/examples/controllers/handControllerGrab.js b/examples/controllers/handControllerGrab.js index 17d16d1718..80a3ea98a4 100644 --- a/examples/controllers/handControllerGrab.js +++ b/examples/controllers/handControllerGrab.js @@ -148,6 +148,7 @@ function MyController(hand, triggerAction) { this.state = STATE_OFF; this.pointer = null; // entity-id of line object this.triggerValue = 0; // rolling average of trigger value + this.rawTriggerValue = 0; var _this = this; @@ -244,12 +245,18 @@ function MyController(hand, triggerAction) { this.pointer = null; }; - this.updateSmoothedTrigger = function() { - var triggerValue = Controller.getValue(this.triggerAction); + this.eitherTrigger = function (value) { + _this.rawTriggerValue = value; + }; + + this.updateSmoothedTrigger = function () { + //var triggerValue = Controller.getValue(this.triggerAction); // this.rawTriggerValue; // + var triggerValue = this.rawTriggerValue; // smooth out trigger value this.triggerValue = (this.triggerValue * TRIGGER_SMOOTH_RATIO) + (triggerValue * (1.0 - TRIGGER_SMOOTH_RATIO)); - } + + }; this.triggerSmoothedSqueezed = function() { return this.triggerValue > TRIGGER_ON_VALUE; @@ -259,8 +266,9 @@ function MyController(hand, triggerAction) { return this.triggerValue < TRIGGER_OFF_VALUE; }; - this.triggerSqueezed = function() { - var triggerValue = Controller.getValue(this.triggerAction); + this.triggerSqueezed = function() { + var triggerValue = Controller.getValue(this.triggerAction); // this.rawTriggerValue; // + print("triggerSqueezed() triggerValue:" + triggerValue); return triggerValue > TRIGGER_ON_VALUE; }; @@ -861,6 +869,12 @@ function MyController(hand, triggerAction) { var rightController = new MyController(RIGHT_HAND, Controller.Standard.RT); var leftController = new MyController(LEFT_HAND, Controller.Standard.LT); +var mapping = Controller.newMapping("handGrab"); +mapping.from([Controller.Standard.RB, Controller.Standard.RT]).to(rightController.eitherTrigger); +mapping.from([Controller.Standard.LB, Controller.Standard.LT]).to(leftController.eitherTrigger); +Controller.enableMapping("handGrab"); + + function update() { rightController.update(); leftController.update(); @@ -869,6 +883,7 @@ function update() { function cleanup() { rightController.cleanup(); leftController.cleanup(); + Controller.disableMapping("handGrab"); } Script.scriptEnding.connect(cleanup); From 9285cf8e2cff33e2389a1b0cde10ed85b05cae49 Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Fri, 23 Oct 2015 17:12:26 -0700 Subject: [PATCH 2/7] fix hydraGrabHockey.js to use new API --- examples/example/games/hydraGrabHockey.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/examples/example/games/hydraGrabHockey.js b/examples/example/games/hydraGrabHockey.js index b9f760fa08..26f9a443ab 100644 --- a/examples/example/games/hydraGrabHockey.js +++ b/examples/example/games/hydraGrabHockey.js @@ -59,9 +59,7 @@ function controller(side) { this.triggerHeld = false; this.triggerThreshold = 0.9; this.side = side; - this.palm = 2 * side; - this.tip = 2 * side + 1; - this.trigger = side; + this.trigger = side == LEFT ? Controller.Standard.LT : Controller.Standard.RT; this.originalGravity = { x: 0, y: 0, @@ -150,8 +148,8 @@ function controller(side) { this.updateControllerState = function() { - this.palmPosition = Controller.getSpatialControlPosition(this.palm); - this.tipPosition = Controller.getSpatialControlPosition(this.tip); + this.palmPosition = this.side == RIGHT ? MyAvatar.rightHandPose.translation : MyAvatar.leftHandPose.translation; + this.tipPosition = this.side == RIGHT ? MyAvatar.rightHandTipPose.translation : MyAvatar.leftHandTipPose.translation; this.triggerValue = Controller.getTriggerValue(this.trigger); } From ed20e7d209dc12eb73f057ac4b3202e0525f8726 Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Fri, 23 Oct 2015 17:14:13 -0700 Subject: [PATCH 3/7] CR feedback --- examples/controllers/handControllerGrab.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/controllers/handControllerGrab.js b/examples/controllers/handControllerGrab.js index 80a3ea98a4..2b370a3b89 100644 --- a/examples/controllers/handControllerGrab.js +++ b/examples/controllers/handControllerGrab.js @@ -869,10 +869,10 @@ function MyController(hand, triggerAction) { var rightController = new MyController(RIGHT_HAND, Controller.Standard.RT); var leftController = new MyController(LEFT_HAND, Controller.Standard.LT); -var mapping = Controller.newMapping("handGrab"); +var mapping = Controller.newMapping("com.highfidelity.handControllerGrab"); mapping.from([Controller.Standard.RB, Controller.Standard.RT]).to(rightController.eitherTrigger); mapping.from([Controller.Standard.LB, Controller.Standard.LT]).to(leftController.eitherTrigger); -Controller.enableMapping("handGrab"); +Controller.enableMapping("com.highfidelity.handControllerGrab"); function update() { From 090dc5409b968356fcd69685ae84b04d3a78047a Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Fri, 23 Oct 2015 17:14:59 -0700 Subject: [PATCH 4/7] CR feedback --- examples/controllers/handControllerGrab.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/examples/controllers/handControllerGrab.js b/examples/controllers/handControllerGrab.js index 2b370a3b89..9e21429cdc 100644 --- a/examples/controllers/handControllerGrab.js +++ b/examples/controllers/handControllerGrab.js @@ -250,7 +250,6 @@ function MyController(hand, triggerAction) { }; this.updateSmoothedTrigger = function () { - //var triggerValue = Controller.getValue(this.triggerAction); // this.rawTriggerValue; // var triggerValue = this.rawTriggerValue; // smooth out trigger value this.triggerValue = (this.triggerValue * TRIGGER_SMOOTH_RATIO) + @@ -267,8 +266,7 @@ function MyController(hand, triggerAction) { }; this.triggerSqueezed = function() { - var triggerValue = Controller.getValue(this.triggerAction); // this.rawTriggerValue; // - print("triggerSqueezed() triggerValue:" + triggerValue); + var triggerValue = this.rawTriggerValue; return triggerValue > TRIGGER_ON_VALUE; }; From 9ba1b800d91655bda082a35035fcad1a138c4dd5 Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Fri, 23 Oct 2015 17:15:39 -0700 Subject: [PATCH 5/7] CR feedback --- examples/controllers/handControllerGrab.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/controllers/handControllerGrab.js b/examples/controllers/handControllerGrab.js index 9e21429cdc..a61f52117b 100644 --- a/examples/controllers/handControllerGrab.js +++ b/examples/controllers/handControllerGrab.js @@ -881,7 +881,7 @@ function update() { function cleanup() { rightController.cleanup(); leftController.cleanup(); - Controller.disableMapping("handGrab"); + Controller.disableMapping("com.highfidelity.handControllerGrab"); } Script.scriptEnding.connect(cleanup); From 9aaef9aabd0034670c15539b45bdfaab0277b93f Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Fri, 23 Oct 2015 17:32:06 -0700 Subject: [PATCH 6/7] fix hydraPaint.js to use new API --- examples/example/painting/hydraPaint.js | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/examples/example/painting/hydraPaint.js b/examples/example/painting/hydraPaint.js index 29a3323e72..36137945cc 100644 --- a/examples/example/painting/hydraPaint.js +++ b/examples/example/painting/hydraPaint.js @@ -71,10 +71,8 @@ function controller(side, cycleColorButton) { this.triggerHeld = false; this.triggerThreshold = 0.9; this.side = side; - this.palm = 2 * side; - this.tip = 2 * side + 1; - this.trigger = side; - this.cycleColorButton = cycleColorButton; + this.trigger = side == LEFT ? Controller.Stantard.LT : Controller.Standard.RT; + this.cycleColorButton = side == LEFT ? Controller.Stantard.LeftPrimaryThumb : Controller.Standard.RightPrimaryThumb; this.points = []; this.normals = []; @@ -173,11 +171,10 @@ function controller(side, cycleColorButton) { this.updateControllerState = function() { - this.cycleColorButtonPressed = Controller.isButtonPressed(this.cycleColorButton); - this.palmPosition = Controller.getSpatialControlPosition(this.palm); - this.tipPosition = Controller.getSpatialControlPosition(this.tip); - this.palmNormal = Controller.getSpatialControlNormal(this.palm); - this.triggerValue = Controller.getTriggerValue(this.trigger); + this.cycleColorButtonPressed = Controller.getValue(this.cycleColorButton); + this.palmPosition = this.side == RIGHT ? MyAvatar.rightHandPose.translation : MyAvatar.leftHandPose.translation; + this.tipPosition = this.side == RIGHT ? MyAvatar.rightHandTipPose.translation : MyAvatar.leftHandTipPose.translation; + this.triggerValue = Controller.getValue(this.trigger); if (this.prevCycleColorButtonPressed === true && this.cycleColorButtonPressed === false) { @@ -215,8 +212,8 @@ function vectorIsZero(v) { } -var rightController = new controller(RIGHT, RIGHT_BUTTON_4); -var leftController = new controller(LEFT, LEFT_BUTTON_4); +var rightController = new controller(RIGHT); +var leftController = new controller(LEFT); Script.update.connect(update); Script.scriptEnding.connect(scriptEnding); From 060f87d14a58e16cd0039863edc90e57837b8bfb Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Fri, 23 Oct 2015 17:33:45 -0700 Subject: [PATCH 7/7] CR feedback --- examples/controllers/handControllerGrab.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/controllers/handControllerGrab.js b/examples/controllers/handControllerGrab.js index a61f52117b..29d6595c3a 100644 --- a/examples/controllers/handControllerGrab.js +++ b/examples/controllers/handControllerGrab.js @@ -867,10 +867,12 @@ function MyController(hand, triggerAction) { var rightController = new MyController(RIGHT_HAND, Controller.Standard.RT); var leftController = new MyController(LEFT_HAND, Controller.Standard.LT); -var mapping = Controller.newMapping("com.highfidelity.handControllerGrab"); +var MAPPING_NAME = "com.highfidelity.handControllerGrab"; + +var mapping = Controller.newMapping(MAPPING_NAME); mapping.from([Controller.Standard.RB, Controller.Standard.RT]).to(rightController.eitherTrigger); mapping.from([Controller.Standard.LB, Controller.Standard.LT]).to(leftController.eitherTrigger); -Controller.enableMapping("com.highfidelity.handControllerGrab"); +Controller.enableMapping(MAPPING_NAME); function update() { @@ -881,7 +883,7 @@ function update() { function cleanup() { rightController.cleanup(); leftController.cleanup(); - Controller.disableMapping("com.highfidelity.handControllerGrab"); + Controller.disableMapping(MAPPING_NAME); } Script.scriptEnding.connect(cleanup);