Skip to content

Fix touch-control support for mobile#37

Open
Wunkolo wants to merge 1 commit intoVesCodes:Mainfrom
Wunkolo:patch-1
Open

Fix touch-control support for mobile#37
Wunkolo wants to merge 1 commit intoVesCodes:Mainfrom
Wunkolo:patch-1

Conversation

@Wunkolo
Copy link

@Wunkolo Wunkolo commented Apr 9, 2025

Touch-events don't have intermediate move-events leading up to it like a mouse does. In the case of a touch-down event, an additional MousePos event needs to be dispatched ahead of the MouseButton event to position the cursor properly before registering the button-down event.

Touch-events don't have intermediate move-events leading up to it like a mouse does. In the case of a touch-down event, an additional MousePos event needs to be dispatched ahead of the MouseButton event to position the cursor properly before registering the button-down event.
@VesCodes VesCodes mentioned this pull request Apr 9, 2025
@VesCodes
Copy link
Owner

Heya, looking to merge this but I'm not familiar with touch event handling in the engine so couple of questions:

  1. Is the pointer position update in HandleMouseButtonDownEvent (L193-194) for touch events necessary? Didn't spot this sort of behaviour in the sample ImGui backend implementations, but can imagine why it could be needed.
  2. Would it be worth adding a source event to HandleMouseWheelOrGestureEvent as well to handle swipe gestures or is that covered by the touch down/move/up events?

@Wunkolo
Copy link
Author

Wunkolo commented Jun 27, 2025

Is the pointer position update in HandleMouseButtonDownEvent (L193-194) for touch events necessary? Didn't spot this sort of behaviour in the sample ImGui backend implementations, but can imagine why it could be needed.

This is the primary fix in this case. Otherwise the touch-down event would just use the last position event, and touch-down at the last location the finger was touch-dragging at. Instead, a position-update and then a touch-down event is required to handle cases like a one-off tap.

Would it be worth adding a source event to HandleMouseWheelOrGestureEvent as well to handle swipe gestures or is that covered by the touch down/move/up events?

Gestures get kind of tricky depending on the platform and felt a bit outside of the scope of this PR. It does sound appropriate though to ensure everything has a proper source-event. I notice that this fix works just fine for Android, but iOS also has some more nuances about the order in which it sends certain events, enough to sound like another PR.

@VesCodes
Copy link
Owner

Thanks for the info! I should be able to set up a test on iOS, will drop an update when I get a chance.

@Maxmystere
Copy link

Hello
I've tested the PR and I can propose some improvements on IOS
98d0d61

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.

3 participants