mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01:00
fix trigger clicks on vive
This commit is contained in:
parent
bec54cc182
commit
b420ef8cf2
1 changed files with 25 additions and 14 deletions
|
@ -761,13 +761,13 @@ SelectionDisplay = (function() {
|
||||||
// We get mouseMoveEvents from the handControllers, via handControllerPointer.
|
// We get mouseMoveEvents from the handControllers, via handControllerPointer.
|
||||||
// But we dont' get mousePressEvents.
|
// But we dont' get mousePressEvents.
|
||||||
that.triggerMapping = Controller.newMapping(Script.resolvePath('') + '-click');
|
that.triggerMapping = Controller.newMapping(Script.resolvePath('') + '-click');
|
||||||
|
that.triggerPressMapping = Controller.newMapping(Script.resolvePath('') + '-press');
|
||||||
Script.scriptEnding.connect(that.triggerMapping.disable);
|
Script.scriptEnding.connect(that.triggerMapping.disable);
|
||||||
that.triggeredHand = NO_TRIGGER_HAND;
|
that.triggeredHand = NO_TRIGGER_HAND;
|
||||||
that.triggered = function() {
|
that.triggered = function() {
|
||||||
return that.triggeredHand !== NO_TRIGGER_HAND;
|
return that.triggeredHand !== NO_TRIGGER_HAND;
|
||||||
}
|
}
|
||||||
function triggerPress(hand) {
|
function triggerPress(hand) {
|
||||||
that.triggeredHand = hand;
|
|
||||||
var pointingAtDesktopWindow = (hand === Controller.Standard.RightHand &&
|
var pointingAtDesktopWindow = (hand === Controller.Standard.RightHand &&
|
||||||
SelectionManager.pointingAtDesktopWindowRight) ||
|
SelectionManager.pointingAtDesktopWindowRight) ||
|
||||||
(hand === Controller.Standard.LeftHand &&
|
(hand === Controller.Standard.LeftHand &&
|
||||||
|
@ -777,6 +777,7 @@ SelectionDisplay = (function() {
|
||||||
if (pointingAtDesktopWindow || pointingAtTablet) {
|
if (pointingAtDesktopWindow || pointingAtTablet) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
that.triggeredHand = hand;
|
||||||
that.mousePressEvent({});
|
that.mousePressEvent({});
|
||||||
}
|
}
|
||||||
function triggerRelease(hand) {
|
function triggerRelease(hand) {
|
||||||
|
@ -791,23 +792,33 @@ SelectionDisplay = (function() {
|
||||||
triggerPress(otherHand);
|
triggerPress(otherHand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function makeTriggerHandler(hand) {
|
function handleTriggerPress(hand, triggerClicked) {
|
||||||
return function () {
|
// Don't allow both hands to trigger at the same time
|
||||||
// Don't allow both hands to trigger at the same time
|
if (that.triggered() && hand !== that.triggeredHand) {
|
||||||
if (that.triggered() && hand !== that.triggeredHand) {
|
return;
|
||||||
return;
|
}
|
||||||
}
|
if (!that.triggered() && triggerClicked) {
|
||||||
|
triggerPress(hand);
|
||||||
|
} else if (that.triggered() && !triggerClicked) {
|
||||||
|
triggerRelease(hand);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function makePressHandler(hand) {
|
||||||
|
return function (value) {
|
||||||
var triggerClicked = hand == Controller.Standard.RightHand ? SelectionManager.triggerClickedRight :
|
var triggerClicked = hand == Controller.Standard.RightHand ? SelectionManager.triggerClickedRight :
|
||||||
SelectionManager.triggerClickedLeft;
|
SelectionManager.triggerClickedLeft;
|
||||||
if (!that.triggered() && triggerClicked) {
|
handleTriggerPress(hand, triggerClicked);
|
||||||
triggerPress(hand);
|
|
||||||
} else if (that.triggered() && !triggerClicked) {
|
|
||||||
triggerRelease(hand);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
that.triggerMapping.from(Controller.Standard.RT).peek().to(makeTriggerHandler(Controller.Standard.RightHand));
|
function makeClickHandler(hand) {
|
||||||
that.triggerMapping.from(Controller.Standard.LT).peek().to(makeTriggerHandler(Controller.Standard.LeftHand));
|
return function (clicked) {
|
||||||
|
handleTriggerPress(hand, clicked);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
that.triggerPressMapping.from(Controller.Standard.RT).peek().to(makePressHandler(Controller.Standard.RightHand));
|
||||||
|
that.triggerPressMapping.from(Controller.Standard.LT).peek().to(makePressHandler(Controller.Standard.LeftHand));
|
||||||
|
that.triggerMapping.from(Controller.Standard.RTClick).peek().to(makeClickHandler(Controller.Standard.RightHand));
|
||||||
|
that.triggerMapping.from(Controller.Standard.LTClick).peek().to(makeClickHandler(Controller.Standard.LeftHand));
|
||||||
|
|
||||||
// FUNCTION DEF(s): Intersection Check Helpers
|
// FUNCTION DEF(s): Intersection Check Helpers
|
||||||
function testRayIntersect(queryRay, overlayIncludes, overlayExcludes) {
|
function testRayIntersect(queryRay, overlayIncludes, overlayExcludes) {
|
||||||
|
|
Loading…
Reference in a new issue