eri0o
March 2, 2023, 8:26pm
#1
Hi, has anyone been successful with orientation hints in Emscripten builds. My guess is they aren’t supported, but it would be really nice if they were. As far as I can tell it’s possible to force a rotation in the browser on mobile.
1 Like
eri0o
March 5, 2023, 3:55pm
#2
opened 11:27PM - 22 Feb 23 UTC
I think emscripten_set_orientationchange_callback should be included in [`src/vi… deo/emscripten/SDL_emscriptenevents.c`](https://github.com/libsdl-org/SDL/blob/SDL2/src/video/emscripten/SDL_emscriptenevents.c), so it can generate a resize event.
See [Device Orientation](https://emscripten.org/docs/api_reference/html5.h.html#device-orientation) in Emscripten API documentation.
As is now, rotating the device doesn't produce any event, so even though the canvas css size changes, this isn't update inside SDL, and the application can't get a window resize event.
I tried this workaround below, but it didn't work, no SDL resize event is generated on orientation changed - but listening to the resize event in JS I can see it indeed happens.
```
window.addEventListener("orientationchange", function() {
window.dispatchEvent(new Event("resize"));
}, false);
```
You can use [`chrome://inspect#devices`](https://developer.chrome.com/docs/devtools/remote-debugging/) for remote debugging from chrome, if using an Android device.
To be honest, rotation and resizing for me are different things, but from [the comment here](https://github.com/libsdl-org/SDL/issues/7076#issuecomment-1381996855), it seems it's settled they should be the same, so at least the events should be produced here - or alternatively some rotation event.
Added in the issue here, with some additional information.
1 Like