Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VR releasing one side button when both are pressed unpresses both #432

Open
moreApi opened this issue Jun 23, 2021 · 7 comments
Open

VR releasing one side button when both are pressed unpresses both #432

moreApi opened this issue Jun 23, 2021 · 7 comments
Assignees
Labels
bug Issue contains a bug bugfixathon-2021 Issues that are up for grabs for the 2021 scenery & sciview bugfixathon confirmed Issue is reproducible

Comments

@moreApi
Copy link
Member

moreApi commented Jun 23, 2021

Reproduce:

The log messages show that with the first release both buttons are released.

@moreApi moreApi added the bug Issue contains a bug label Jun 23, 2021
@skalarproduktraum skalarproduktraum added the bugfixathon-2021 Issues that are up for grabs for the 2021 scenery & sciview bugfixathon label Dec 16, 2021
@skalarproduktraum
Copy link
Member

skalarproduktraum commented Dec 16, 2021

The place this probably goes wrong should be

while(VRSystem_PollNextEvent(event)) {
val role = when(VRSystem_GetControllerRoleForTrackedDeviceIndex(event.trackedDeviceIndex())) {
ETrackedControllerRole_TrackedControllerRole_LeftHand -> TrackerRole.LeftHand
ETrackedControllerRole_TrackedControllerRole_RightHand -> TrackerRole.RightHand
ETrackedControllerRole_TrackedControllerRole_Invalid -> TrackerRole.Invalid
else -> TrackerRole.Invalid
}
logger.debug("Event ${idToEventType(event.eventType())} for role $role")
if(event.eventType() == EVREventType_VREvent_ButtonPress) {
val button = event.data().controller().button()
OpenVRButton.values().find { it.internalId == button }?.let {
logger.debug("Button pressed: $it on $role")
val keyEvent = it.toKeyEvent(role)
GlobalKeyEventDispatcher.getInstance().dispatchKeyEvent(keyEvent.first)
inputHandler.keyPressed(keyEvent.first)
keysDown.add(it to role)
GlobalKeyEventDispatcher.getInstance().dispatchKeyEvent(keyEvent.second)
}
}
if(event.eventType() == EVREventType_VREvent_ButtonUnpress) {
val button = event.data().controller().button()
OpenVRButton.values().find { it.internalId == button }?.let {
logger.debug("Button unpressed: $it on $role")
val keyEvent = it.toKeyEvent(role)
GlobalKeyEventDispatcher.getInstance().dispatchKeyEvent(keyEvent.second)
inputHandler.keyReleased(keyEvent.second)
keysDown.remove(it to role)
}
}
if(event.eventType() == EVREventType_VREvent_MouseMove) {
val x = event.data().mouse().x()
val y = event.data().mouse().y()
val down = event.data().mouse().button()
logger.debug("Touchpad moved $x $y, down=$down")
}
}

@skalarproduktraum skalarproduktraum added the confirmed Issue is reproducible label Dec 16, 2021
@moreApi
Copy link
Member Author

moreApi commented May 17, 2022

Same behavior for button Side,Trigger and A and probably all others

@skalarproduktraum
Copy link
Member

Okay, so this is probably not an oversight, but an actual semantic error -.-

@moreApi
Copy link
Member Author

moreApi commented Jun 20, 2023

line 566 of the excerpt above is the cause of pressed keys being empty.
But withouyt that line no VR button works anymore.
At least for drag behaviors that is because https://github.com/scijava/ui-behaviour/blob/9cbc0df842c240e36af48b48fc294ea8c982a63d/src/main/java/org/scijava/ui/behaviour/MouseAndKeyHandler.java#L440 only does exact matching and since there is always this axis or proximity thing pressed it always returns false.
There is something about "irgnored keys" in that match function. But this whole thing looks like highe magic to me.

@skalarproduktraum
Copy link
Member

Input handling is one of the darkest kinds of magic.

@skalarproduktraum
Copy link
Member

Jokes aside - I'd argue here it'd likely be best to allow only the actual buttons to trigger events, and and ignore the proximity sensor. What do you think, @moreApi?

@moreApi
Copy link
Member Author

moreApi commented Jun 26, 2023

I dont think we need to care about the proximity sensor 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue contains a bug bugfixathon-2021 Issues that are up for grabs for the 2021 scenery & sciview bugfixathon confirmed Issue is reproducible
Projects
None yet
Development

No branches or pull requests

2 participants