OHOS: Fix touch event processing to only handle the triggering finger#1
Merged
MetsukiMio merged 1 commit intoOpenMinecraft-Dev:mainfrom Feb 10, 2026
Merged
Conversation
The previous implementation processed all touch points in the array for every touch event, which could cause duplicate or incorrect events since the array contains the current state of all fingers. Now we correctly identify and process only the finger that triggered the current event (touchEvent.id), improving touch event accuracy on OpenHarmony platforms.
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.
Problem
The
onNativeTouchcallback was iterating through all touch points intouchEvent.touchPoints[]and sending SDL events for each one. However, this array contains the current state of all active fingers, not just the finger that triggered the current event.This caused issues like:
Solution
The
OH_NativeXComponent_TouchEventstructure has anidfield that identifies which finger triggered the current callback. We now find the matching touch point in the array using this ID and only process that single finger.Changes
targetIndexby matchingtouchEvent.touchPoints[i].id == touchEvent.idtargetIndexinstead of iterating all pointsTesting
Tested on HarmonyOS device - single taps now correctly register as single events.