Skip to content

Fix double button presses (pointer for 2D viewport) in Godot 4.7+ - #795

Open
NetroScript wants to merge 1 commit into
GodotVR:masterfrom
NetroScript:fix-double-button-press
Open

NetroScript wants to merge 1 commit into
GodotVR:masterfrom
NetroScript:fix-double-button-press

Conversation

@NetroScript

Copy link
Copy Markdown
Contributor

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.gd emits 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_EMULATION as 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.

@BastiaanOlij BastiaanOlij added enhancement New feature or request need-rebase PR needs rebase or merge conflicts fixed. labels Aug 2, 2026
@BastiaanOlij

Copy link
Copy Markdown
Member

Looks good, just needs rebase,

@NetroScript
NetroScript force-pushed the fix-double-button-press branch from 259f828 to 9f5df1b Compare August 3, 2026 14:38
@NetroScript

Copy link
Copy Markdown
Contributor Author

Rebase done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request need-rebase PR needs rebase or merge conflicts fixed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants