diff --git a/data/emulator.js b/data/emulator.js
index 7245db5..d55234c 100644
--- a/data/emulator.js
+++ b/data/emulator.js
@@ -995,6 +995,13 @@ class EmulatorJS {
this.virtualGamepad.style.display = "";
}
this.handleResize();
+ if (this.config.fullscreenOnLoad) {
+ try {
+ this.toggleFullscreen(true);
+ } catch(e) {
+ if (this.debug) console.warn("Could not fullscreen on load");
+ }
+ }
} catch(e) {
console.warn("failed to start game", e);
this.textElem.innerText = this.localization("Failed to start game");
@@ -1614,43 +1621,52 @@ class EmulatorJS {
})
const enter = addButton("Enter Fullscreen", '', () => {
- if (this.elements.parent.requestFullscreen) {
- this.elements.parent.requestFullscreen();
- } else if (this.elements.parent.mozRequestFullScreen) {
- this.elements.parent.mozRequestFullScreen();
- } else if (this.elements.parent.webkitRequestFullscreen) {
- this.elements.parent.webkitRequestFullscreen();
- } else if (this.elements.parent.msRequestFullscreen) {
- this.elements.parent.msRequestFullscreen();
- }
- exit.style.display = "";
- enter.style.display = "none";
- if (this.isMobile) {
- try {
- screen.orientation.lock(this.getCore(true) === "nds" ? "portrait" : "landscape").catch(e => {});;
- } catch(e) {}
- }
+ this.toggleFullscreen(true);
});
const exit = addButton("Exit Fullscreen", '', () => {
- if (document.exitFullscreen) {
- document.exitFullscreen();
- } else if (document.webkitExitFullscreen) {
- document.webkitExitFullscreen();
- } else if (document.mozCancelFullScreen) {
- document.mozCancelFullScreen();
- } else if (document.msExitFullscreen) {
- document.msExitFullscreen();
- }
- exit.style.display = "none";
- enter.style.display = "";
- if (this.isMobile) {
- try {
- screen.orientation.unlock();
- } catch(e) {}
- }
+ this.toggleFullscreen(false);
});
exit.style.display = "none";
+ this.toggleFullscreen = (fullscreen) => {
+ if (fullscreen) {
+ if (this.elements.parent.requestFullscreen) {
+ this.elements.parent.requestFullscreen();
+ } else if (this.elements.parent.mozRequestFullScreen) {
+ this.elements.parent.mozRequestFullScreen();
+ } else if (this.elements.parent.webkitRequestFullscreen) {
+ this.elements.parent.webkitRequestFullscreen();
+ } else if (this.elements.parent.msRequestFullscreen) {
+ this.elements.parent.msRequestFullscreen();
+ }
+ exit.style.display = "";
+ enter.style.display = "none";
+ if (this.isMobile) {
+ try {
+ screen.orientation.lock(this.getCore(true) === "nds" ? "portrait" : "landscape").catch(e => {});;
+ } catch(e) {}
+ }
+ } else {
+ if (document.exitFullscreen) {
+ document.exitFullscreen();
+ } else if (document.webkitExitFullscreen) {
+ document.webkitExitFullscreen();
+ } else if (document.mozCancelFullScreen) {
+ document.mozCancelFullScreen();
+ } else if (document.msExitFullscreen) {
+ document.msExitFullscreen();
+ }
+ exit.style.display = "none";
+ enter.style.display = "";
+ if (this.isMobile) {
+ try {
+ screen.orientation.unlock();
+ } catch(e) {}
+ }
+ }
+ }
+
+
this.addEventListener(document, "webkitfullscreenchange mozfullscreenchange fullscreenchange", (e) => {
if (e.target !== this.elements.parent) return;
if (document.fullscreenElement === null) {
diff --git a/data/loader.js b/data/loader.js
index acdb485..2ad42f3 100644
--- a/data/loader.js
+++ b/data/loader.js
@@ -61,6 +61,7 @@
config.volume = window.EJS_volume;
config.defaultControllers = window.EJS_defaultControls;
config.startOnLoad = window.EJS_startOnLoaded;
+ config.fullscreenOnLoad = window.EJS_fullscreenOnLoaded;
config.filePaths = window.EJS_paths;
config.loadState = window.EJS_loadStateURL;
config.cacheLimit = window.EJS_CacheLimit;