diff --git a/scripts/system/controllers/controllerDispatcher.js b/scripts/system/controllers/controllerDispatcher.js index cb1870ed73..1ce695c87f 100644 --- a/scripts/system/controllers/controllerDispatcher.js +++ b/scripts/system/controllers/controllerDispatcher.js @@ -500,7 +500,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); } } catch (e) { - print("WARNING: handControllerGrab.js -- error parsing Hifi-Hand-RayPick-Blacklist message: " + message); + print("WARNING: handControllerGrab.js -- error parsing message: " + data); } } }; diff --git a/scripts/system/controllers/controllerModules/nearParentGrabOverlay.js b/scripts/system/controllers/controllerModules/nearParentGrabOverlay.js index 368d5c483b..2c881aceca 100644 --- a/scripts/system/controllers/controllerModules/nearParentGrabOverlay.js +++ b/scripts/system/controllers/controllerModules/nearParentGrabOverlay.js @@ -27,6 +27,7 @@ Script.include("/~/system/libraries/utils.js"); this.previousParentJointIndex = {}; this.previouslyUnhooked = {}; this.robbed = false; + this.miniTabletID = null; this.parameters = makeDispatcherModuleParameters( 90, @@ -42,6 +43,10 @@ Script.include("/~/system/libraries/utils.js"); return (this.hand === RIGHT_HAND) ? leftNearParentingGrabOverlay : rightNearParentingGrabOverlay; }; + this.setMiniTabletID = function (id) { + this.miniTabletID = id; + } + this.otherHandIsParent = function(props) { return this.getOtherModule().thisHandIsParent(props); }; @@ -163,7 +168,10 @@ Script.include("/~/system/libraries/utils.js"); var handPosition = controllerData.controllerLocations[this.hand].position; var distance = Vec3.distance(overlayPosition, handPosition); if (distance <= NEAR_GRAB_RADIUS * sensorScaleFactor) { - return overlays[i]; + if (overlays[i] !== this.miniTabletID || controllerData.secondaryValues[this.hand] === 0) { + // Don't grab mini tablet with grip. + return overlays[i]; + } } } return null; @@ -217,6 +225,25 @@ Script.include("/~/system/libraries/utils.js"); }; } + function handleMessage(channel, data, sender) { + if (sender !== MyAvatar.sessionUUID) { + return; + } + + if (channel === 'Hifi-MiniTablet-Details') { + try { + var message = JSON.parse(data); + leftNearParentingGrabOverlay.setMiniTabletID(message.overlay); + rightNearParentingGrabOverlay.setMiniTabletID(message.overlay); + } catch (e) { + print("WARNING: nearParentGrabOverlay.js -- error parsing message: " + data); + } + } + } + + Messages.subscribe('Hifi-MiniTablet-Details'); + Messages.messageReceived.connect(handleMessage); + var leftNearParentingGrabOverlay = new NearParentingGrabOverlay(LEFT_HAND); var rightNearParentingGrabOverlay = new NearParentingGrabOverlay(RIGHT_HAND);