Fix aspect ratio of PSX games in full-screen

This commit is contained in:
Sergey Stepanov 2024-03-21 23:02:53 +03:00
parent 84f55691eb
commit 5da77a6b4f
No known key found for this signature in database
GPG key ID: A56B4929BAA8556B

View file

@ -86,28 +86,26 @@ screen.addEventListener('canplay', () => {
useCustomScreen(options.mirrorMode === 'mirror');
}, false);
const screenToAspect = (el) => {
const w = window.screen.width ?? window.innerWidth;
const hh = el.innerHeight || el.clientHeight || 0;
const dw = (w - hh * state.aspect) / 2
screen.style.padding = `0 ${dw}px`
}
screen.addEventListener('fullscreenchange', () => {
state.fullscreen = !!document.fullscreenElement;
const w = window.screen.width ?? window.innerWidth;
const h = window.screen.height ?? window.innerHeight;
const ww = document.documentElement.innerWidth;
const hh = document.documentElement.innerHeight;
screen.style.padding = '0'
if (state.fullscreen) {
const dw = (w - ww * state.aspect) / 2
screen.style.padding = `0 ${dw}px`
if (!state.fullscreen) {
screen.style.padding = '0'
} else {
screenToAspect(document.fullscreenElement);
// chrome bug
setTimeout(() => {
const dw = (h - hh * state.aspect) / 2
screen.style.padding = `0 ${dw}px`
screenToAspect(document.fullscreenElement)
}, 1)
makeFullscreen(true);
} else {
makeFullscreen(false);
}
makeFullscreen(state.fullscreen);
// !to flipped
})