Fix double button presses (pointer for 2D viewport) in Godot 4.7+#795
Open
NetroScript wants to merge 1 commit into
Open
Fix double button presses (pointer for 2D viewport) in Godot 4.7+#795NetroScript wants to merge 1 commit into
NetroScript wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Godot version 4.7-dev5 added multitouch support to Buttons ( godotengine/godot#110893 ).
This causes buttons displayed in 2D Viewport in 3D to misbehave. This is because
addons/godot-xr-tools/objects/viewport_2d_in_3d_body.gdemits both a touch event and a mouse event. For buttons this was no problem before Godot 4.7-dev5, as touch events were not handled by the button.Now however, a button press is triggered twice, once for the touch event emitted, once for the mouse event emitted. If the button is for example a toggle button, its state will now not change.
To prevent double emissions when mouse/touch emulation are enabled, the new commit guards against
InputEvent::DEVICE_ID_EMULATION.This PR adds a minimal change setting the input device ID of the touch events to
InputEvent::DEVICE_ID_EMULATION. This ensures the duplicate event is ignored where appropriate. This change is also backwards compatible to at least Godot 4.3 (which is the minimum version defined for this addon (versions >=4.5.0))InputEvent::DEVICE_ID_EMULATIONas an enum is only defined starting Godot 4.3, in theory one could also write the direct value-1, which would then support even older Godot versions.