From c492d125e080a018d20b56b322a43a523ecb9e2e Mon Sep 17 00:00:00 2001 From: howard-stearns Date: Tue, 28 Jun 2016 13:19:03 -0700 Subject: [PATCH] limit hand controller actions to recommended area --- scripts/system/controllers/handControllerPointer.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/system/controllers/handControllerPointer.js b/scripts/system/controllers/handControllerPointer.js index a0f1f47b3c..8e2edbe467 100644 --- a/scripts/system/controllers/handControllerPointer.js +++ b/scripts/system/controllers/handControllerPointer.js @@ -125,8 +125,18 @@ function ignoreMouseActivity() { weMovedReticle = false; return true; } +var reticleMinX, reticleMaxX, reticleMinY, reticleMaxY; +function updateRecommendedArea() { + var rectangle = Controller.getRecommendedOverlayRect(); + reticleMinX = rectangle.x; + reticleMaxX = rectangle.x + rectangle.width; + reticleMinY = rectangle.y; + reticleMaxY = rectangle.y + rectangle.height; +} var setReticlePosition = function (point2d) { weMovedReticle = true; + point2d.x = Math.max(reticleMinX, Math.min(point2d.x, reticleMaxX)); + point2d.y = Math.max(reticleMinY, Math.min(point2d.y, reticleMaxY)); Reticle.setPosition(point2d); }; @@ -463,6 +473,7 @@ Script.scriptEnding.connect(function () { var SETTINGS_CHANGE_RECHECK_INTERVAL = 10 * 1000; // milliseconds function checkSettings() { updateFieldOfView(); + updateRecommendedArea(); } checkSettings(); var settingsChecker = Script.setInterval(checkSettings, SETTINGS_CHANGE_RECHECK_INTERVAL);