Skip to content

OHOS: Fix touch event processing to only handle the triggering finger#1

Merged
MetsukiMio merged 1 commit intoOpenMinecraft-Dev:mainfrom
bytemain:main
Feb 10, 2026
Merged

OHOS: Fix touch event processing to only handle the triggering finger#1
MetsukiMio merged 1 commit intoOpenMinecraft-Dev:mainfrom
bytemain:main

Conversation

@bytemain
Copy link

@bytemain bytemain commented Feb 3, 2026

Problem

The onNativeTouch callback was iterating through all touch points in touchEvent.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:

  • A single tap registering as multiple taps
  • Touch events being duplicated for multi-touch scenarios

Solution

The OH_NativeXComponent_TouchEvent structure has an id field 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

  • Find targetIndex by matching touchEvent.touchPoints[i].id == touchEvent.id
  • Only process the touch point at targetIndex instead of iterating all points
  • Early return if no matching finger is found (defensive)

Testing

Tested on HarmonyOS device - single taps now correctly register as single events.

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.
@MetsukiMio MetsukiMio merged commit c75458a into OpenMinecraft-Dev:main Feb 10, 2026
46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments