From 35639bb896a3c85d76723cffb0417d659255688c Mon Sep 17 00:00:00 2001 From: Allan Niles Date: Sat, 21 Dec 2024 11:39:08 -0700 Subject: [PATCH] Fix SharedArrayBuffer check & video rotation without reload (#923) * video_roation without reload * fix SharedArrayBuffer check * remove notCoreOption check --- data/src/GameManager.js | 10 +++++++++- data/src/emulator.js | 9 ++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/data/src/GameManager.js b/data/src/GameManager.js index df980e5..8b6382f 100644 --- a/data/src/GameManager.js +++ b/data/src/GameManager.js @@ -29,7 +29,8 @@ class EJS_GameManager { toggleSlowMotion: this.Module.cwrap('toggle_slow_motion', 'null', ['number']), setSlowMotionRatio: this.Module.cwrap('set_sm_ratio', 'null', ['number']), getFrameNum: this.Module.cwrap('get_current_frame_count', 'number', ['']), - setVSync: this.Module.cwrap('set_vsync', 'null', ['number']) + setVSync: this.Module.cwrap('set_vsync', 'null', ['number']), + setVideoRoation: this.Module.cwrap('set_video_rotation', 'null', ['number']) } this.writeFile("/home/web_user/retroarch/userdata/retroarch.cfg", this.getRetroArchCfg()); @@ -421,6 +422,13 @@ class EJS_GameManager { getFrameNum() { return this.functions.getFrameNum(); } + setVideoRotation(rotation) { + try { + this.functions.setVideoRoation(rotation); + } catch(e) { + console.warn(e); + } + } } window.EJS_GameManager = EJS_GameManager; diff --git a/data/src/emulator.js b/data/src/emulator.js index 8a58429..62ab8af 100644 --- a/data/src/emulator.js +++ b/data/src/emulator.js @@ -557,7 +557,7 @@ class EmulatorJS { this.webgl2Enabled = true; } let threads = false; - if (SharedArrayBuffer instanceof Function) { + if (typeof window.SharedArrayBuffer === "function") { const opt = this.preGetSetting("ejs_threads"); if (opt) { threads = (opt === "enabled"); @@ -3986,6 +3986,8 @@ class EmulatorJS { } } else if (option === "vsync") { this.gameManager.setVSync(value === "enabled"); + } else if (option === "videoRotation") { + this.gameManager.setVideoRotation(value); } } menuOptionChanged(option, value) { @@ -4392,7 +4394,7 @@ class EmulatorJS { if (core && core.length > 1) { addToMenu(this.localization("Core" + " (" + this.localization('Requires restart') + ")"), 'retroarch_core', core, this.getCore(), home); } - if (SharedArrayBuffer instanceof Function && !this.requiresThreads(this.getCore())) { + if (typeof window.SharedArrayBuffer === "function" && !this.requiresThreads(this.getCore())) { addToMenu(this.localization("Threads"), "ejs_threads", { 'enabled': this.localization("Enabled"), 'disabled': this.localization("Disabled") @@ -4448,7 +4450,7 @@ class EmulatorJS { 'disabled': this.localization("Disabled") }, "enabled", graphicsOptions, true); - addToMenu(this.localization("Video Rotation" + " (" + this.localization('Requires restart') + ")"), 'videoRotation', { + addToMenu(this.localization('Video Rotation'), 'videoRotation', { '0': "0 deg", '1': "90 deg", '2': "180 deg", @@ -4530,6 +4532,7 @@ class EmulatorJS { true); }) } + /* this.retroarchOpts = [