Skip to content

Commit

Permalink
Fix aspect ratio of PSX games in full-screen
Browse files Browse the repository at this point in the history
  • Loading branch information
sergystepanov committed Mar 21, 2024
1 parent 84f5569 commit 5da77a6
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions web/js/stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,28 +86,26 @@ screen.addEventListener('canplay', () => {
useCustomScreen(options.mirrorMode === 'mirror');
}, false);

screen.addEventListener('fullscreenchange', () => {
state.fullscreen = !!document.fullscreenElement;

const screenToAspect = (el) => {
const w = window.screen.width ?? window.innerWidth;
const h = window.screen.height ?? window.innerHeight;
const hh = el.innerHeight || el.clientHeight || 0;
const dw = (w - hh * state.aspect) / 2
screen.style.padding = `0 ${dw}px`
}

const ww = document.documentElement.innerWidth;
const hh = document.documentElement.innerHeight;
screen.addEventListener('fullscreenchange', () => {
state.fullscreen = !!document.fullscreenElement;

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
})
Expand Down

0 comments on commit 5da77a6

Please sign in to comment.