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 ...@@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added ### Added
* * Support for true fullscreen at a browser level
### Changed ### Changed
......
...@@ -279,7 +279,6 @@ class GameboyEmulator extends EmulatorBase implements Emulator { ...@@ -279,7 +279,6 @@ class GameboyEmulator extends EmulatorBase implements Emulator {
case "neo": case "neo":
this.gameBoy = new GameBoy(); this.gameBoy = new GameBoy();
break; break;
default: default:
if (!this.gameBoy) { if (!this.gameBoy) {
throw new Error("No engine requested"); throw new Error("No engine requested");
......
...@@ -333,13 +333,11 @@ export const App: FC<AppProps> = ({ ...@@ -333,13 +333,11 @@ export const App: FC<AppProps> = ({
event.stopPropagation(); event.stopPropagation();
event.preventDefault(); event.preventDefault();
break; break;
case "-": case "-":
setKeyaction("Minus"); setKeyaction("Minus");
event.stopPropagation(); event.stopPropagation();
event.preventDefault(); event.preventDefault();
break; break;
case "Escape": case "Escape":
setKeyaction("Escape"); setKeyaction("Escape");
event.stopPropagation(); event.stopPropagation();
......
...@@ -92,6 +92,10 @@ export const Display: FC<DisplayProps> = ({ ...@@ -92,6 +92,10 @@ export const Display: FC<DisplayProps> = ({
resizeRef.current(); resizeRef.current();
document.getElementsByTagName("body")[0].style.overflow = "hidden"; document.getElementsByTagName("body")[0].style.overflow = "hidden";
window.addEventListener("resize", resizeRef.current); 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 { } else {
setWidth(undefined); setWidth(undefined);
setHeight(undefined); setHeight(undefined);
...@@ -99,6 +103,10 @@ export const Display: FC<DisplayProps> = ({ ...@@ -99,6 +103,10 @@ export const Display: FC<DisplayProps> = ({
.getElementsByTagName("body")[0] .getElementsByTagName("body")[0]
.style.removeProperty("overflow"); .style.removeProperty("overflow");
window.removeEventListener("resize", resizeRef.current); window.removeEventListener("resize", resizeRef.current);
// restores the window mode, returning from the
// fullscreen browser
document.exitFullscreen();
} }
return () => { return () => {
window.removeEventListener("resize", resizeRef.current); window.removeEventListener("resize", resizeRef.current);
......
...@@ -26,8 +26,8 @@ pub struct Mmu { ...@@ -26,8 +26,8 @@ pub struct Mmu {
rom: Cartridge, rom: Cartridge,
/// Flag that control the access to the boot section in the /// Flag that control the access to the boot section in the
/// 0x0000-0x00fe memory area, this flag should be unset after /// 0x0000-0x00FE memory area, this flag should be unset after
/// the bool sequence has been finished. /// the boot sequence has been finished.
boot_active: bool, boot_active: bool,
boot: [u8; BOOT_SIZE], 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