forked from TannerRogalsky/love.js
-
Notifications
You must be signed in to change notification settings - Fork 38
feat: Add Emscripten 2.0.34+ support and mobile keyboard #112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
itsthisjustin
wants to merge
4
commits into
Davidobot:master
Choose a base branch
from
itsthisjustin:feat/emscripten-2.0.34-mobile-keyboard
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat: Add Emscripten 2.0.34+ support and mobile keyboard #112
itsthisjustin
wants to merge
4
commits into
Davidobot:master
from
itsthisjustin:feat/emscripten-2.0.34-mobile-keyboard
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This commit adds partial support for canvas resizing in response to browser window size changes, addressing issues Davidobot#88 and Davidobot#59. ## Changes: **JavaScript (index.html):** - Added resizeCanvas() function that monitors canvas size changes - Updates canvas element dimensions when browser window resizes - Triggers SDL resize events to notify the engine - Handles window resize, fullscreen changes, and periodic checks **CSS (love.css):** - Made canvas responsive with max-width: 100% and max-height: 100vh - Maintains aspect ratio while adapting to window size **Documentation (readme.md):** - Added comprehensive note about canvas resizing (Note Davidobot#9) - Clearly documents current limitations - Explains that game viewport doesn't scale (engine limitation) - References upstream issues Davidobot#88 and Davidobot#59 ## What This Fixes: ✅ Canvas element no longer cuts off when window resizes ✅ Better responsive behavior for different screen sizes ✅ Improved fullscreen handling ## Known Limitations: - Game content renders at size specified in conf.lua - Canvas resizes but game viewport doesn't scale to fill it - love.window.setMode() from game code still won't work - love.resize() callback may not be triggered These limitations would require engine-level changes to SDL/Emscripten integration to fully resolve. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
- Fixed goFullScreen() to use correct API method names (requestFullscreen vs requestFullScreen) - Added mobile device detection to use CSS-based fullscreen on mobile (more reliable than Fullscreen API) - Auto-fullscreen on mobile devices when game finishes loading - Desktop browsers continue to use native Fullscreen API - Updated all HTML templates (release, compat, sample) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
- Made all UI elements (header, footer, canvas, loading screen) fully responsive - Added CSS media queries for mobile devices (768px and 480px breakpoints) - Fixed desktop fullscreen to hide header via CSS :fullscreen pseudo-class - Fixed mobile fullscreen to properly fill 100vh by: - Setting actual canvas buffer dimensions to window.innerWidth/innerHeight - Removing all CSS max-width/max-height constraints (set to 'none') - Hiding footer and header elements - Setting body background to black to prevent color bleed-through - Loading screen now scales dynamically based on container width - Footer is now fixed at bottom and centered on all devices 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
- Upgrade to Emscripten 2.0.34 for ARM64 Mac compatibility - Add mobile keyboard support for iOS/Android browsers - Fix deprecated Module.getMemory() API - Add IDBFS safety patches via automated script - Update build process for CMake 3.10+ requirement BREAKING: Requires Emscripten 2.0.34+ for building from source Older systems can still use Emscripten 2.0.0 Mobile keyboard implementation uses two-phase approach: 1. WASM calls JavaScript when text input is requested 2. Touch listener activates keyboard synchronously during user gesture This satisfies browser security requirements while enabling mobile keyboard support for love.keyboard.setTextInput().
This was referenced Oct 7, 2025
Author
|
If you have no interest in these features or this is way too messy of way to do this, feel free to close and ignore. They work great for my game though and I feel like we are getting pretty close to an awesome solution for using Love for mobile web games :) I figured if it works well enough for my stuff I might as well share it in case someone else wants to riff off this or use it. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request: Emscripten 2.0.34+ Support & Mobile Keyboard
Summary
This PR adds support for Emscripten 2.0.34+ (required for ARM64 Macs) and implements mobile keyboard support for LÖVE.js games.
Changes Made
1. Emscripten 2.0.34+ Compatibility
Files Modified:
src/game.js- UpdatedModule.getMemory()→Module._malloc()src/compat/love.js- Added safety checks for IDBFS operationssrc/release/love.js- Added safety checks for IDBFS operationsbuild_lovejs.sh- Added-DCMAKE_POLICY_VERSION_MINIMUM=3.5flagREADME.md- Updated build instructionsTechnical Details:
Module.getMemory()API (line 230 in game.js template)stream.node.contentsto prevent undefined errors2. Mobile Keyboard Support
Files Modified:
src/compat/index.htmlsrc/release/index.htmlmegasource/love/src/modules/keyboard/sdl/Keyboard.cpp(external repo)JavaScript Implementation:
C++ Hooks (in megasource/love repo):
How It Works:
love.keyboard.setTextInput(true)when player taps input fieldwindow.SDL_StartTextInput()love.keyboard.setTextInput(false)removes listener3. Binary Updates
Files Updated:
src/compat/love.js(295KB) - Rebuilt with Emscripten 2.0.34src/compat/love.wasm(4.7MB) - Rebuilt with Emscripten 2.0.34src/release/love.js(347KB) - Rebuilt with Emscripten 2.0.34src/release/love.wasm(4.7MB) - Rebuilt with Emscripten 2.0.34src/release/love.worker.js(2.7KB) - Rebuilt with Emscripten 2.0.34All binaries now include mobile keyboard hooks and are compatible with Emscripten 2.0.34+.
Testing
✅ Clean package builds successfully
✅ Game loads without errors
✅ Mobile keyboard appears when
love.keyboard.setTextInput(true)is called✅ Compatible with both ARM64 and x86_64 Macs
✅ Backward compatible with existing games
Breaking Changes
None - all changes are backward compatible.
Migration Guide
For Users
No changes needed - just update love.js package and rebuild your game.
For Builders (from source)
Update your build command to use Emscripten 2.0.34 and apply IDBFS patches:
./emsdk install 2.0.34 ./emsdk activate 2.0.34 # After building with build_lovejs.sh ./patch_idbfs.shWhy the patch? Emscripten 2.0.34's code generator produces IDBFS code with undefined buffer access bugs. The
patch_idbfs.shscript applies 6 safety patches to the generated JavaScript files.