Skip to content

Emscripten: Rework touch input and add pixel-perfect scaling#3556

Open
johannschopplich wants to merge 6 commits into
EasyRPG:masterfrom
johannschopplich:emscripten-shell-rework
Open

Emscripten: Rework touch input and add pixel-perfect scaling#3556
johannschopplich wants to merge 6 commits into
EasyRPG:masterfrom
johannschopplich:emscripten-shell-rework

Conversation

@johannschopplich

Copy link
Copy Markdown
Contributor

This PR brings a batch of web-shell improvements over from my production setup on realtroll.de. Mostly touch and scaling work that's been running there a while – figured it's worth upstreaming rather than sitting in a fork. 🙂

What's New?

  • Touch controls – rewritten on modern browser's Pointer Events. The on-screen controls are now a responsive grid (d-pad / screen / action buttons) with safe-area insets, both orientations, in place of the floating corner buttons.
  • Pixel-perfect scaling – optional toggle that snaps the canvas to whole multiples of 320×240 (letterboxed), persisted in localStorage. Defaults on for non-touch devices – a visible change for existing desktop pages, so happy to flip it to opt-in if you'd rather not move the default.

Smaller bits

  • Touch controls dim when idle, light back up on input. Great for cut scenes!
  • Wake Lock re-acquired on visibilitychange so the screen doesn't sleep mid-session.
  • Fullscreen button hides if unsupported (iOS Safari).
  • Dropped the legacy scanGamePads poll – it only armed when ongamepadconnected was missing, but those events predate WASM in every browser, so nothing that can run the player reached that path.

The embedded player should work as is, integer scaling is of course disabled in this case.

Tested on past + edge releases of the EasyRPG Player build I ship at realtroll.de, desktop + touch (Android/iOS).

@github-actions github-actions Bot added the Emscripten WebAssembly/JavaScript port for web browsers label Jun 15, 2026
@Ghabry

Ghabry commented Jun 15, 2026

Copy link
Copy Markdown
Member

Jenkins: Test this please

Thanks! Have to take a look at this :)

The shell sized the canvas from document.body, which collapses to zero
height in this layout, so SDL's inline size shrank it on load (most
visibly in Chrome). Make the fit-mode CSS authoritative with !important,
and recompute integer scaling from a ResizeObserver on the viewport so
it reflows correctly after an orientation change instead of overflowing.
Clicking a control button moves focus to the button and swallows the
arrow keys. Return focus to the canvas after a control click and on
fullscreen change so keyboard input keeps reaching the game.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Emscripten WebAssembly/JavaScript port for web browsers

Development

Successfully merging this pull request may close these issues.

2 participants