Merge pull request #8081 from howard-stearns/continue-grabbing-through-overlays

Continue grabbing through overlays
This commit is contained in:
Howard Stearns 2016-06-15 16:07:01 -07:00 committed by GitHub
commit faa2624ca7
2 changed files with 33 additions and 7 deletions

View file

@ -309,12 +309,19 @@ function MyController(hand) {
var _this = this;
var suppressedIn2D = [STATE_OFF, STATE_SEARCHING, STATE_HOLD_SEARCHING];
this.ignoreInput = function () {
// We've made the decision to use 'this' for new code, even though it is fragile,
// in order to keep/ the code uniform without making any no-op line changes.
return (-1 !== suppressedIn2D.indexOf(this.state)) && isIn2DMode();
};
this.update = function() {
this.updateSmoothedTrigger();
if (isIn2DMode()) {
_this.turnOffVisualizations();
if (this.ignoreInput()) {
this.turnOffVisualizations();
return;
}

View file

@ -48,9 +48,10 @@ function TimeLock(expiration) {
}
var handControllerLockOut = new TimeLock(2000);
function Trigger() {
function Trigger(label) {
// This part is copied and adapted from handControllerGrab.js. Maybe we should refactor this.
var that = this;
that.label = label;
that.TRIGGER_SMOOTH_RATIO = 0.1; // Time averaging of trigger - 0.0 disables smoothing
that.TRIGGER_ON_VALUE = 0.4; // Squeezed just enough to activate search or near grab
that.TRIGGER_GRAB_VALUE = 0.85; // Squeezed far enough to complete distant grab
@ -301,8 +302,8 @@ setupHandler(Controller.mouseDoublePressEvent, onMouseClick);
// CONTROLLER MAPPING ---------
//
var leftTrigger = new Trigger();
var rightTrigger = new Trigger();
var leftTrigger = new Trigger('left');
var rightTrigger = new Trigger('right');
var activeTrigger = rightTrigger;
var activeHand = Controller.Standard.RightHand;
var LEFT_HUD_LASER = 1;
@ -336,8 +337,26 @@ Script.scriptEnding.connect(clickMapping.disable);
clickMapping.from(Controller.Standard.RT).peek().to(rightTrigger.triggerPress);
clickMapping.from(Controller.Standard.LT).peek().to(leftTrigger.triggerPress);
// Full smoothed trigger is a click.
clickMapping.from(rightTrigger.full).when(isPointingAtOverlay).to(Controller.Actions.ReticleClick);
clickMapping.from(leftTrigger.full).when(isPointingAtOverlay).to(Controller.Actions.ReticleClick);
function isPointingAtOverlayStartedNonFullTrigger(trigger) {
// true if isPointingAtOverlay AND we were NOT full triggered when we became so.
// The idea is to not count clicks when we're full-triggering and reach the edge of a window.
var lockedIn = false;
return function () {
if (trigger !== activeTrigger) {
return lockedIn = false;
}
if (!isPointingAtOverlay()) {
return lockedIn = false;
}
if (lockedIn) {
return true;
}
lockedIn = !trigger.full();
return lockedIn;
}
}
clickMapping.from(rightTrigger.full).when(isPointingAtOverlayStartedNonFullTrigger(rightTrigger)).to(Controller.Actions.ReticleClick);
clickMapping.from(leftTrigger.full).when(isPointingAtOverlayStartedNonFullTrigger(leftTrigger)).to(Controller.Actions.ReticleClick);
clickMapping.from(Controller.Standard.RightSecondaryThumb).peek().to(Controller.Actions.ContextMenu);
clickMapping.from(Controller.Standard.LeftSecondaryThumb).peek().to(Controller.Actions.ContextMenu);
// Partial smoothed trigger is activation.