Skip to content

Commit

Permalink
Platform: handle (multi-)touch events in EmscriptenApplication.
Browse files Browse the repository at this point in the history
The impossible-to-reliably-disable behavior with compatibility mouse
events is quite a headache. I wish Emscripten implemented pointer events
already so I could ditch this mess -- especially the array of 32 touches
where all of them but one will be unchanged is stupid.

For the internals unfortunately, EmscriptenMouseEvent and
EmscriptenTouchEvent have no common base, so I had to give up on the
current way of querying the event struct directly from event getters, as
that'd be too nasty with the branching and casts. Instead the relevant
fields are put directly into the events themselves.

HTML5 also doesn't provide any relative pointer position. For the mouse
it was rather straightforward, but for the up-to-32 touches I have to
maintain an array of per-finger positions and match them by ID.
Hopefully the linear lookup is fine. I'll probably use the same approach
for the AndroidApplication.
  • Loading branch information
mosra committed Oct 22, 2024
1 parent fee6bed commit 755a551
Show file tree
Hide file tree
Showing 6 changed files with 628 additions and 117 deletions.
8 changes: 6 additions & 2 deletions doc/changelog.dox
Original file line number Diff line number Diff line change
Expand Up @@ -339,10 +339,14 @@ See also:
@relativeref{Platform::GlfwApplication,tickEvent()} to match the interface
of @ref Platform::Sdl2Application (see [mosra/magnum#577](https://github.com/mosra/magnum/issues/577)
and [mosra/magnum#580](https://github.com/mosra/magnum/pull/580))
- Multi-touch support in @ref Platform::Sdl2Application through new
- Multi-touch support in @ref Platform::Sdl2Application and
@ref Platform::EmscriptenApplication through new
@relativeref{Platform::Sdl2Application,PointerEvent} and
@relativeref{Platform::Sdl2Application,PointerMoveEvent} that unify mouse
and touch input events
and touch input events. This also means @ref Platform::EmscriptenApplication
finally supports touch drag ([mosra/magnum#532](https://github.com/mosra/magnum/issues/532))
--- no touch-to-mouse event passthrough needs to be implemented, it works
out of the box with the new pointer events.

@subsubsection changelog-latest-new-scenegraph SceneGraph library

Expand Down
Loading

0 comments on commit 755a551

Please sign in to comment.