Android: Allow virtual joystick and touch events at the same time - #2951
Merged
riccardobl merged 5 commits intoSep 19, 2026
Merged
riccardobl merged 5 commits into
riccardobl merged 5 commits into
Conversation
…ng used. Previously it was not possible to move using the joystick AND rotate the camera using the touch screen at the same time. You could do one or the other at any one time. This change fixes that so the user can move forward/back/left/right AND rotate the camera at the same time; just like using a mouse and keyboard.
pointer taints an in-progress gesture, send a single synthetic ACTION_CANCEL and then withhold further events until the gesture ends. Previously the detectors were starved mid-stream, which could leave a pending long-press or fling that fired later. - Keep pointers that were hidden at DOWN hidden until their UP/CANCEL, even if the joystick drops the capture mid-gesture (setEnabled(false), layout resize), so the application never sees a MOVE/UP with no matching DOWN. - Clear any stale hidden bit on a fresh DOWN for a non-captured pointer, so a DOWN that never saw its UP cannot keep a pointer id hidden forever. - Pass the joystick pointer mask explicitly through setJoystickPointerMask() instead of exposing handler state via isPointerCapturedByJoystick(), which was only valid during the nested dispatch and leaked AndroidInputHandler internals. - Drop the unrelated keyboardSuppressedAutoJoystick reset on touch DOWN: it changes AUTO-mode virtual joystick visibility policy and is not needed to use touch and the joystick at the same time. Co-authored-by: Muse <muse@robot.rblb.it>
When joyInput.onTouch(event) consumes a pointer DOWN or UP, explicitly preserve that pointer's bit in joystickPointerMask. This prevents a race condition where joystick captures are cleared asynchronously (e.g. via setEnabled(false) or layout resizing on another thread) between joyInput.onTouch() and the subsequent getCapturedPointerMask() snapshot, which would previously cause the captured DOWN to leak into the touch pipeline. Co-authored-by: Gemini 3.8 Flash <gemini@google.com>
Ensure hiddenPointerMask is updated and stale hidden bits are cleared prior to calling countReportedPointers(event). On ACTION_DOWN, the mask is reset to 0L to start fresh for a new gesture stream. On ACTION_POINTER_DOWN, any stale bit for an ordinary pointer is cleared before computing numPointers, preventing stale hidden state from corrupting pointer counts and triggering spurious emulated mouse-down events. Also reset hiddenPointerMask upon ACTION_UP and ACTION_CANCEL. Co-authored-by: Gemini 3.8 Flash <gemini@google.com>
If a pointer was captured by the virtual joystick during its DOWN event, subsequent MOVE and UP events should not be processed by IosTouchHandler if the joystick capture is dropped mid-gesture (e.g. on resize or disable). Ensure actionMove and actionUp are ignored when the pointer ID is not present in activePointers, avoiding orphan MOVE and UP events. Co-authored-by: Gemini 3.8 Flash <gemini@google.com>
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.
Improve handling of android touch events when virtual joystick is being used.
Previously it was not possible to move using the joystick AND rotate the camera using the touch screen at the same time. You could do one or the other at any one time. If you were using the joystick, touch events would be ignored.
This change fixes that so the user can move forward/back/left/right AND rotate the camera at the same time; just like using a mouse and keyboard.
Disclaimer: this is done using Claude code. I don't have the expertise to understand the changes and what they do. This code should be reviewed by a human who understands this part of the engine.
I found it a big improvement to the UX of my android application so I think it should be seriously considered for inclusion.