Skip to content

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

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

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

Conversation

@johannschopplich

@johannschopplich johannschopplich commented Jun 15, 2026

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.
  • Save manager – download any slot as a backup, import a .lsd save file into the first free slot, and grab a screenshot. Built on a native <dialog>, touch-friendly.

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 now toggles enter/exit and reflects its state (still 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.
  • UI icons consolidated into one inline SVG sprite (<symbol> / <use>).

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.
@johannschopplich

Copy link
Copy Markdown
Contributor Author

Pushed a follow-up batch from the same setup: a save manager! Fits nicely into the design.

Updated the description above accordingly. 🙂

@jetrotal

Copy link
Copy Markdown
Contributor

Hello, since you are working on the touch screen buttons for the weblpayer, maybe consider taking a look at this proposal from a user called Bilou Master Joke: https://codepen.io/editor/BilouMaster/pen/019edf09-20e1-73a0-8efa-3ccb9a832518

He made a bunch of suggestions to both support the complete vanilla keyboard, and some quality of life usage of buttons.

@johannschopplich

Copy link
Copy Markdown
Contributor Author

@jetrotal Thanks for the input! Honestly, it feels a bit rough, but it's a draft anyway. Worth digging into for a future iteration after this PR. (It already touches a lot of parts of the shell.)

@BilouMaster

Copy link
Copy Markdown

Ah yes, that's perfect because I've been doing the design only like an empty shell and not finished/merged with the real player yet, so I'll also take inspiration of your work then! :D

You can check the codepen Jetrotal shared (most recent take) or my old previous player which had better layout too but not commutable/customisable yet
https://biloumaster.fr/jeux/bogossstory

I like your buttons for importing save files or toggle between perfect pixel/not perfect, that's a good point but they are small and too close to each other, it would likely need a bit scale up + more margin but 👍

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.

4 participants