Skip to content
Snippets Groups Projects
Verified Commit 17e203e7 authored by João Magalhães's avatar João Magalhães :rocket:
Browse files

feat: true fullscreen support at browser level

parent 1e8217c9
No related branches found
No related tags found
No related merge requests found
......@@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
*
* Support for true fullscreen at a browser level
### Changed
......
......@@ -279,7 +279,6 @@ class GameboyEmulator extends EmulatorBase implements Emulator {
case "neo":
this.gameBoy = new GameBoy();
break;
default:
if (!this.gameBoy) {
throw new Error("No engine requested");
......
......@@ -333,13 +333,11 @@ export const App: FC<AppProps> = ({
event.stopPropagation();
event.preventDefault();
break;
case "-":
setKeyaction("Minus");
event.stopPropagation();
event.preventDefault();
break;
case "Escape":
setKeyaction("Escape");
event.stopPropagation();
......
......@@ -92,6 +92,10 @@ export const Display: FC<DisplayProps> = ({
resizeRef.current();
document.getElementsByTagName("body")[0].style.overflow = "hidden";
window.addEventListener("resize", resizeRef.current);
// requests the browser to go fullscreen using the
// body of the document as the entry HTML element
document.body.requestFullscreen();
} else {
setWidth(undefined);
setHeight(undefined);
......@@ -99,6 +103,10 @@ export const Display: FC<DisplayProps> = ({
.getElementsByTagName("body")[0]
.style.removeProperty("overflow");
window.removeEventListener("resize", resizeRef.current);
// restores the window mode, returning from the
// fullscreen browser
document.exitFullscreen();
}
return () => {
window.removeEventListener("resize", resizeRef.current);
......
......@@ -26,8 +26,8 @@ pub struct Mmu {
rom: Cartridge,
/// Flag that control the access to the boot section in the
/// 0x0000-0x00fe memory area, this flag should be unset after
/// the bool sequence has been finished.
/// 0x0000-0x00FE memory area, this flag should be unset after
/// the boot sequence has been finished.
boot_active: bool,
boot: [u8; BOOT_SIZE],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment