mirror of
https://github.com/overte-org/overte.git
synced 2025-08-11 05:53:07 +02:00
Make scrolling only lock the relevant thumbstick
This commit is contained in:
parent
b713eadca8
commit
310dc7f78f
4 changed files with 58 additions and 27 deletions
|
@ -216,15 +216,16 @@ Pointer::PickedObject PathPointer::getHoveredObject(const PickResultPointer& pic
|
|||
}
|
||||
|
||||
glm::vec2 PathPointer::getScroll(const PickResultPointer& pickResult) {
|
||||
bool isActive = false;
|
||||
bool isActive = true;
|
||||
glm::vec2 accum { 0.0f };
|
||||
|
||||
for (const PointerTrigger& trigger : _triggers) {
|
||||
std::string button = trigger.getButton();
|
||||
|
||||
// don't activate scrolling if the laser isn't even on
|
||||
if (button == "ScrollActive" && trigger.getEndpoint()->peek().value > 0.1f) {
|
||||
isActive = true;
|
||||
// if ScrollActive is available, use it to lock out accidental scrolls
|
||||
// (like on the UI, where the lasers are always active even though they're invisible)
|
||||
if (button == "ScrollActive" && trigger.getEndpoint()->peek().value < 0.1f) {
|
||||
isActive = false;
|
||||
} else if (button == "ScrollX") {
|
||||
accum.x += trigger.getEndpoint()->peek().value;
|
||||
} else if (button == "ScrollY") {
|
||||
|
|
|
@ -581,7 +581,6 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
|||
filter: Picks.PICK_OVERLAYS | Picks.PICK_LOCAL_ENTITIES | Picks.PICK_ENTITIES | Picks.PICK_INCLUDE_NONCOLLIDABLE,
|
||||
triggers: [
|
||||
{action: controllerStandard.LTClick, button: "Primary"},
|
||||
{action: controllerStandard.LT, button: "ScrollActive"},
|
||||
{action: controllerStandard.LX, button: "ScrollX"},
|
||||
{action: controllerStandard.LY, button: "ScrollY"},
|
||||
],
|
||||
|
@ -598,7 +597,6 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
|||
filter: Picks.PICK_OVERLAYS | Picks.PICK_LOCAL_ENTITIES | Picks.PICK_ENTITIES | Picks.PICK_INCLUDE_NONCOLLIDABLE,
|
||||
triggers: [
|
||||
{action: controllerStandard.RTClick, button: "Primary"},
|
||||
{action: controllerStandard.RT, button: "ScrollActive"},
|
||||
{action: controllerStandard.RX, button: "ScrollX"},
|
||||
{action: controllerStandard.RY, button: "ScrollY"},
|
||||
],
|
||||
|
|
|
@ -76,23 +76,41 @@
|
|||
return this.hand === RIGHT_HAND ? leftHudOverlayPointer : rightHudOverlayPointer;
|
||||
};
|
||||
|
||||
const SCROLL_MAPPING_NAME = `overte.thumbstick_scroll_${this.hand}.hud`;
|
||||
this.scrollMappingEnabled = false;
|
||||
this.scrollMapping = Controller.newMapping(SCROLL_MAPPING_NAME);
|
||||
this.stickXMapping = this.scrollMapping.from(
|
||||
this.hand == LEFT_HAND ? Controller.Standard.LX : Controller.Standard.RX
|
||||
).to(function(_value) { /* dummy to temporarily eat stick input */ });
|
||||
this.stickYMapping = this.scrollMapping.from(
|
||||
this.hand == LEFT_HAND ? Controller.Standard.LY : Controller.Standard.RY
|
||||
).to(function(_value) { /* dummy to temporarily eat stick input */ });
|
||||
|
||||
this.processLaser = function(controllerData) {
|
||||
var controllerLocation = controllerData.controllerLocations[this.hand];
|
||||
if ((controllerData.triggerValues[this.hand] < ControllerDispatcherUtils.TRIGGER_ON_VALUE || !controllerLocation.valid) ||
|
||||
this.pointingAtTablet(controllerData)) {
|
||||
Controller.releaseActionEvents("hudOverlayPointer_" + this.hand);
|
||||
return false;
|
||||
}
|
||||
var hudRayPick = controllerData.hudRayPicks[this.hand];
|
||||
var point2d = this.calculateNewReticlePosition(hudRayPick.intersection);
|
||||
if (!Window.isPointOnDesktopWindow(point2d) && !this.triggerClicked) {
|
||||
Controller.releaseActionEvents("hudOverlayPointer_" + this.hand);
|
||||
return false;
|
||||
}
|
||||
|
||||
this.triggerClicked = controllerData.triggerClicks[this.hand];
|
||||
Controller.captureActionEvents("hudOverlayPointer_" + this.hand);
|
||||
return true;
|
||||
|
||||
if (
|
||||
(controllerData.triggerValues[this.hand] < ControllerDispatcherUtils.TRIGGER_ON_VALUE || !controllerLocation.valid) ||
|
||||
this.pointingAtTablet(controllerData) ||
|
||||
(!Window.isPointOnDesktopWindow(point2d) && !this.triggerClicked)
|
||||
) {
|
||||
if (this.scrollMappingEnabled) {
|
||||
this.scrollMapping.disable();
|
||||
this.scrollMappingEnabled = false;
|
||||
}
|
||||
|
||||
return false;
|
||||
} else {
|
||||
if (!this.scrollMappingEnabled) {
|
||||
this.scrollMapping.enable();
|
||||
this.scrollMappingEnabled = true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
this.isReady = function (controllerData) {
|
||||
|
|
|
@ -232,11 +232,15 @@ Script.include("/~/system/libraries/controllers.js");
|
|||
return !otherModuleRunning && !grabModuleNeedsToRun;
|
||||
};
|
||||
|
||||
this.tryCaptureActions = function(isTriggerPressed) {
|
||||
if (isTriggerPressed) {
|
||||
Controller.captureActionEvents("webSurfaceLaserInput_" + this.hand);
|
||||
}
|
||||
};
|
||||
const SCROLL_MAPPING_NAME = `overte.thumbstick_scroll_${this.hand}.web`;
|
||||
this.scrollMappingEnabled = false;
|
||||
this.scrollMapping = Controller.newMapping(SCROLL_MAPPING_NAME);
|
||||
this.stickXMapping = this.scrollMapping.from(
|
||||
this.hand == LEFT_HAND ? Controller.Standard.LX : Controller.Standard.RX
|
||||
).to(function(_value) { /* dummy to temporarily eat stick input */ });
|
||||
this.stickYMapping = this.scrollMapping.from(
|
||||
this.hand == LEFT_HAND ? Controller.Standard.LY : Controller.Standard.RY
|
||||
).to(function(_value) { /* dummy to temporarily eat stick input */ });
|
||||
|
||||
this.run = function(controllerData, deltaTime) {
|
||||
this.addObjectToIgnoreList(controllerData);
|
||||
|
@ -247,23 +251,33 @@ Script.include("/~/system/libraries/controllers.js");
|
|||
|
||||
if (type === intersectionType["HifiTablet"] && laserOn) {
|
||||
if (this.shouldThisModuleRun(controllerData)) {
|
||||
this.tryCaptureActions(isTriggerPressed);
|
||||
if (!this.scrollMappingEnabled) {
|
||||
this.scrollMapping.enable();
|
||||
this.scrollMappingEnabled = true;
|
||||
}
|
||||
this.running = true;
|
||||
return makeRunningValues(true, [], []);
|
||||
}
|
||||
} else if ((type === intersectionType["WebOverlay"] || type === intersectionType["WebEntity"]) && laserOn) { // auto laser on WebEntities andWebOverlays
|
||||
if (this.shouldThisModuleRun(controllerData)) {
|
||||
this.tryCaptureActions(isTriggerPressed);
|
||||
if (!this.scrollMappingEnabled) {
|
||||
this.scrollMapping.enable();
|
||||
this.scrollMappingEnabled = true;
|
||||
}
|
||||
this.running = true;
|
||||
return makeRunningValues(true, [], []);
|
||||
}
|
||||
} else if ((type === intersectionType["HifiKeyboard"] && laserOn) || type === intersectionType["Overlay"]) {
|
||||
this.tryCaptureActions(isTriggerPressed);
|
||||
if (!this.scrollMappingEnabled) {
|
||||
this.scrollMapping.enable();
|
||||
this.scrollMappingEnabled = true;
|
||||
}
|
||||
this.running = true;
|
||||
return makeRunningValues(true, [], []);
|
||||
}
|
||||
|
||||
Controller.releaseActionEvents("webSurfaceLaserInput_" + this.hand);
|
||||
this.scrollMapping.disable();
|
||||
this.scrollMappingEnabled = false;
|
||||
this.running = false;
|
||||
this.dominantHandOverride = false;
|
||||
return makeRunningValues(false, [], []);
|
||||
|
|
Loading…
Reference in a new issue