mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 01:43:27 +02:00
Fix virtual trigger buttons from sending real click events
This commit is contained in:
parent
66493ee541
commit
55c004fb65
3 changed files with 11 additions and 6 deletions
|
@ -222,6 +222,8 @@ void EntityScriptingInterface::attachDefaultEventHandlers(ScriptManager* manager
|
|||
* <td>{@link Entities.hoverOverEntity}</td></tr>
|
||||
* <tr><td><code>"hoverLeaveEntity"</code></td><td>{@link Script~pointerEventCallback|pointerEventCallback}</td>
|
||||
* <td>{@link Entities.hoverLeaveEntity}</td></tr>
|
||||
* <tr><td><code>"scrollOnEntity"</code></td><td>{@link Script~pointerEventCallback|pointerEventCallback}</td>
|
||||
* <td>{@link Entities.scrollOnEntity}</td></tr>
|
||||
* <tr><td><code>"collisionWithEntity"</code><td>{@link Script~collisionEventCallback|collisionEventCallback}</td>
|
||||
* </td><td>{@link Entities.collisionWithEntity}</td></tr>
|
||||
* </tbody>
|
||||
|
@ -243,6 +245,8 @@ void EntityScriptingInterface::attachDefaultEventHandlers(ScriptManager* manager
|
|||
connect(this, &EntityScriptingInterface::hoverOverEntity, manager, makePointerHandler("hoverOverEntity"));
|
||||
connect(this, &EntityScriptingInterface::hoverLeaveEntity, manager, makePointerHandler("hoverLeaveEntity"));
|
||||
|
||||
connect(this, &EntityScriptingInterface::scrollOnEntity, manager, makePointerHandler("scrollOnEntity"));
|
||||
|
||||
connect(this, &EntityScriptingInterface::collisionWithEntity, manager, makeCollisionHandler("collisionWithEntity"));
|
||||
}
|
||||
|
||||
|
|
|
@ -113,6 +113,12 @@ void Pointer::generatePointerEvents(unsigned int pointerID, const PickResultPoin
|
|||
if (_enabled && shouldTrigger(pickResult)) {
|
||||
buttons = getPressedButtons(pickResult);
|
||||
for (const std::string& button : buttons) {
|
||||
auto buttonType = chooseButton(button);
|
||||
if (buttonType == PointerEvent::NoButtons) {
|
||||
// don't issue trigger events for virtual triggers
|
||||
continue;
|
||||
}
|
||||
|
||||
if (_prevButtons.find(button) == _prevButtons.end()) {
|
||||
newButtons.insert(button);
|
||||
} else {
|
||||
|
@ -225,11 +231,10 @@ void Pointer::generatePointerEvents(unsigned int pointerID, const PickResultPoin
|
|||
}
|
||||
|
||||
// Trigger begin
|
||||
const std::string SHOULD_FOCUS_BUTTON = "Focus";
|
||||
for (const std::string& button : newButtons) {
|
||||
hoveredEvent.setType(PointerEvent::Press);
|
||||
hoveredEvent.setButton(chooseButton(button));
|
||||
hoveredEvent.setShouldFocus(button == SHOULD_FOCUS_BUTTON);
|
||||
hoveredEvent.setShouldFocus(true);
|
||||
if (hoveredObject.type == ENTITY) {
|
||||
emit pointerManager->triggerBeginEntity(hoveredObject.objectID, hoveredEvent);
|
||||
} else if (hoveredObject.type == LOCAL_ENTITY) {
|
||||
|
|
|
@ -580,7 +580,6 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
|||
joint: "_CAMERA_RELATIVE_CONTROLLER_LEFTHAND",
|
||||
filter: Picks.PICK_OVERLAYS | Picks.PICK_ENTITIES | Picks.PICK_INCLUDE_NONCOLLIDABLE,
|
||||
triggers: [
|
||||
{action: controllerStandard.LTClick, button: "Focus"},
|
||||
{action: controllerStandard.LTClick, button: "Primary"},
|
||||
{action: controllerStandard.LT, button: "ScrollActive"},
|
||||
{action: controllerStandard.LX, button: "ScrollX"},
|
||||
|
@ -598,7 +597,6 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
|||
joint: "_CAMERA_RELATIVE_CONTROLLER_RIGHTHAND",
|
||||
filter: Picks.PICK_OVERLAYS | Picks.PICK_ENTITIES | Picks.PICK_INCLUDE_NONCOLLIDABLE,
|
||||
triggers: [
|
||||
{action: controllerStandard.RTClick, button: "Focus"},
|
||||
{action: controllerStandard.RTClick, button: "Primary"},
|
||||
{action: controllerStandard.RT, button: "ScrollActive"},
|
||||
{action: controllerStandard.RX, button: "ScrollX"},
|
||||
|
@ -618,7 +616,6 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
|||
maxDistance: DEFAULT_SEARCH_SPHERE_DISTANCE,
|
||||
posOffset: getGrabPointSphereOffset(controllerStandard.LeftHand, true),
|
||||
triggers: [
|
||||
{action: controllerStandard.LTClick, button: "Focus"},
|
||||
{action: controllerStandard.LTClick, button: "Primary"},
|
||||
{action: controllerStandard.LT, button: "ScrollActive"},
|
||||
{action: controllerStandard.LX, button: "ScrollX"},
|
||||
|
@ -636,7 +633,6 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
|||
maxDistance: DEFAULT_SEARCH_SPHERE_DISTANCE,
|
||||
posOffset: getGrabPointSphereOffset(controllerStandard.RightHand, true),
|
||||
triggers: [
|
||||
{action: controllerStandard.RTClick, button: "Focus"},
|
||||
{action: controllerStandard.RTClick, button: "Primary"},
|
||||
{action: controllerStandard.RT, button: "ScrollActive"},
|
||||
{action: controllerStandard.RX, button: "ScrollX"},
|
||||
|
|
Loading…
Reference in a new issue