diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 00000000..b5e50b47
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1 @@
+text=auto eol=lf
diff --git a/.github/workflows/latest.yml b/.github/workflows/latest.yml
index fe8ec17c..f1522df8 100644
--- a/.github/workflows/latest.yml
+++ b/.github/workflows/latest.yml
@@ -11,8 +11,28 @@ jobs:
runs-on: emulatorjs-server
steps:
- name: Checkout
- uses: actions/checkout@v3
- - name: Run Script
+ uses: actions/checkout@v4
+ - name: Set Permissions
run: |
cd /mnt/HDD/public
- ./.latest.sh
+ chmod -R 755 .EmulatorJS/
+ - name: Update Latest
+ run: |
+ cd /mnt/HDD/public/.EmulatorJS/
+ git fetch --all
+ git reset --hard origin/main
+ git pull
+ - name: Minify Files
+ run: |
+ cd /mnt/HDD/public/.EmulatorJS/
+ npm i
+ npm run minify
+ - name: Zip Minified Files
+ run: |
+ cd /mnt/HDD/public/.EmulatorJS/data/
+ zip emulator.min.zip emulator.min.js emulator.min.css
+ - name: Clean Up Minify
+ run: |
+ cd /mnt/HDD/public/.EmulatorJS/
+ rm -f "minify/package-lock.json"
+ rm -rf "minify/node_modules/"
diff --git a/.github/workflows/newlines.yml b/.github/workflows/newlines.yml
new file mode 100644
index 00000000..5dd0f16b
--- /dev/null
+++ b/.github/workflows/newlines.yml
@@ -0,0 +1,42 @@
+name: Check for Newline at End of Files
+
+on:
+ pull_request:
+ types:
+ - opened
+ - synchronize
+ - reopened
+
+jobs:
+ check-newlines:
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v2
+
+ - name: Check for missing newlines
+ run: |
+ files=$(git ls-files)
+
+ newline_error=0
+
+ for file in $files; do
+ if file --mime "$file" | grep -q "binary"; then
+ #echo "Skipping binary file: $file"
+ continue
+ fi
+
+ last_char=$(tail -c 1 "$file" | xxd -p)
+ if [[ "$last_char" != "0a" ]]; then
+ echo "File $file does not end with a newline!"
+ newline_error=1
+ fi
+ done
+
+ if [[ $newline_error -eq 1 ]]; then
+ echo "One or more files do not end with a newline."
+ exit 1
+ else
+ echo "All files end with a newline."
+ fi
diff --git a/.github/workflows/npm.yml b/.github/workflows/npm.yml
index 690b8d1d..50bbc84e 100644
--- a/.github/workflows/npm.yml
+++ b/.github/workflows/npm.yml
@@ -9,12 +9,59 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- - uses: actions/setup-node@v3
+ - uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
+ - name: Get latest release tag (if workflow_dispatch)
+ if: ${{ github.event_name == 'workflow_dispatch' }}
+ run: |
+ LATEST_TAG=$(curl -s https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r '.tag_name')
+ echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV
+ - name: Download cores
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ run: |
+ TAG_NAME=${{ github.event.release.tag_name || env.LATEST_TAG }}
+ TRIMMED_TAG=${TAG_NAME#v}
+ echo "TRIMMED_TAG=$TRIMMED_TAG" >> $GITHUB_ENV
+ gh release download "$TAG_NAME" \
+ --repo ${{ github.repository }} \
+ --pattern "$TRIMMED_TAG.7z"
+ - name: Extract cores
+ run: |
+ 7z x -y "$TRIMMED_TAG.7z" "data/cores/*" -o./
+ rm "$TRIMMED_TAG.7z"
- run: npm i
- - run: npm ci
- - run: npm publish --access public
+ - name: Make @emulatorjs/emulatorjs
+ run: |
+ node build.js --npm=emulatorjs
+ npm ci
+ npm publish --access public
+ env:
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
+ - name: Get cores list
+ run: |
+ echo "CORES=$(node build.js --npm=get-cores | jq -r '. | join(" ")')" >> $GITHUB_ENV
+ - name: Setup cores
+ run: |
+ node build.js --npm=cores
+ - name: Publish each core
+ run: |
+ cd data/cores
+ for core in $CORES; do
+ echo "Processing core: $core"
+ cd $core
+ npm publish --access public
+ cd ..
+ done
+ env:
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
+ - name: Make @emulatorjs/cores
+ run: |
+ cd data/cores
+ npm i
+ npm ci
+ npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
diff --git a/.github/workflows/stable.yml b/.github/workflows/stable.yml
index b2cd9e8c..65ef1989 100644
--- a/.github/workflows/stable.yml
+++ b/.github/workflows/stable.yml
@@ -11,8 +11,59 @@ jobs:
runs-on: emulatorjs-server
steps:
- name: Checkout
- uses: actions/checkout@v3
- - name: Run Script
+ uses: actions/checkout@v4
+ - name: Set Variables
+ run: |
+ cd /mnt/HDD/public/
+ wget -q "https://api.github.com/repos/EmulatorJS/EmulatorJS/releases/latest" -O .tmp.json
+ version=$(jq -r '.tag_name' .tmp.json)
+ download_url=$(jq -r '.assets[0].browser_download_url' .tmp.json)
+ name=$(jq -r '.assets[0].name' .tmp.json)
+ old_version=$(jq -r '.github' versions.json)
+ v_version="$version"
+ if [[ $version == v* ]]; then
+ version="${version:1}"
+ fi
+ rm .tmp.json
+ echo "VERSION=$version" >> $GITHUB_ENV
+ echo "DOWNLOAD_URL=$download_url" >> $GITHUB_ENV
+ echo "NAME=$name" >> $GITHUB_ENV
+ echo "OLD_VERSION=$old_version" >> $GITHUB_ENV
+ echo "V_VERSION=$v_version" >> $GITHUB_ENV
+ - name: Download Stable
+ run: |
+ cd /mnt/HDD/public/
+ mkdir -p ".stable"
+ wget -q "$DOWNLOAD_URL" -O ".stable/$NAME"
+ - name: Extract Stable
+ run: |
+ cd /mnt/HDD/public/.stable/
+ 7z x "$NAME"
+ - name: Move Versions
+ run: |
+ cd /mnt/HDD/public/
+ mv ".stable/$NAME" releases/
+ mv "$OLD_VERSION" "$VERSION"
+ mv stable "$OLD_VERSION"
+ mv .stable stable
+ jq --arg version "$VERSION" '.github = $version' versions.json | sponge versions.json
+ - name: Set Permissions
run: |
cd /mnt/HDD/public
- ./.stable.sh
+ chmod -R 755 stable/
+ - name: Update Stable Cores
+ run: |
+ rsync -a --delete /mnt/HDD/public/stable/data/cores/ /mnt/HDD/public/.EmulatorJS/data/cores/
+ - name: Zip Stable
+ run: |
+ cd /mnt/HDD/public/stable/data/
+ zip emulator.min.zip emulator.min.js emulator.min.css
+ - name: Update Version
+ run: |
+ cd /mnt/HDD/public/
+ jq --arg old_version "$OLD_VERSION" '.versions += {($old_version): ($old_version + "/")}' versions.json | sponge versions.json
+ - name: Clean Up
+ run: |
+ cd /mnt/HDD/public/
+ rm -f "$OLD_VERSION/data/emulator.min.zip"
+ rm -rf "$OLD_VERSION/node_modules/"
diff --git a/.gitignore b/.gitignore
index 6116e25c..3b86629b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,11 +1,15 @@
-**/node_modules/
-*.db
-data/minify/package-lock.json
+node_modules/
package-lock.json
yarn.lock
roms/
data/emulator.min.js
data/emulator.min.css
-data/cores
+data/cores/*
+!data/cores/README.md
+!data/cores/core-README.md
+!data/cores/package.json
+!data/cores/.npmignore
.DS_Store
-.vscode/*
\ No newline at end of file
+.vscode/*
+*.tgz
+dist/
diff --git a/.npmignore b/.npmignore
new file mode 100644
index 00000000..470e291c
--- /dev/null
+++ b/.npmignore
@@ -0,0 +1,16 @@
+.git
+dist/
+node_modules/
+package-lock.json
+.github/
+*.tgz
+update.js
+build.js
+data/localization/translate.html
+data/cores/*
+!data/cores/README.md
+!data/cores/package.json
+minify/
+.npmignore
+.gitignore
+roms/
diff --git a/CHANGES.md b/CHANGES.md
index 392f81b6..f7699797 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,6 +1,99 @@
# Changes
-# 4.1.1
+# 4.2.3
+
+Bug fix release
+
+- Redo image capture features (Thanks to [@allancoding](https://github.com/allancoding))
+- Fix issue with invalid button names (Thanks to [@michael-j-green](https://github.com/michael-j-green))
+- Fix issues with canvas size
+- Update zh-CN translations (Thanks to [@incredibleIdea](https://github.com/incredibleIdea))
+
+# 4.2.2 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/a796c4a3866652d1b6cb74a2b90e9552955c2b13)
+
+- Prioritize gameName over gameUrl for the local storage identifier
+- Fix CSS parsing when setting a background image (Thanks to [@kellenmace](https://github.com/kellenmace))
+- Add `EJS_dontExtractBIOS` option (Thanks to [@pjft](https://github.com/pjft))
+- Delete old screenshot file before saving a new one (Thanks to [@gantoine](https://github.com/gantoine))
+- Add `saveSaveFiles` event for when save files are updated
+- Add `saveDatabaseLoaded` event, for when the `/data/saves` directory has been mounted
+- Add ability to set a system save interval
+- Add the ability to hide settings from the settings menu with the `EJS_hideSettings` option
+- Attempt to auto-detect system language and attempt to load that file.
+- Add `EJS_disableAutoLang` option to disable auto language detection in `loader.js`
+- Update Japanese translation file (Thanks to [@noel-forester](https://github.com/noel-forester))
+- Add dropdown selection for gamepads
+- Correct N64 virtual gamepad inputs
+- Change path to `retroarch.cfg`
+- Add `joystickInput` property for virtual gamepad buttons
+- Removed `this.listeners`
+- Update Korean translation file (Thanks to [@SooHyuck](https://github.com/SooHyuck))
+- Redo touchscreen detection (Thanks to [@allancoding](https://github.com/allancoding))
+- Redo toolbar visibility method (Thanks to [@allancoding](https://github.com/allancoding))
+- Add `dosbox_pure` core (requires threading)
+- Add toggle for direct keyboard input
+- Redo scrolling in settings menu
+- Redo about menu CSS
+- Add setting to enable/disable mouse lock
+- Properly handle failed save states
+- Fix unknown axis events being discarded
+- Write core settings file before loading the core (Some core settings are required to be loaded from here on startup)
+- Add option to disable `alt` key when using direct keyboard input
+- Cleanup famicom controls
+- Fix setting gamepad axis to input values 16 to 23
+- Rework internal method of getting user settings, add `this.getSettingValue` function
+- Add Romanian translation file (Thanks to [@jurcaalexandrucristian](https://github.com/jurcaalexandrucristian))
+- Fix build stack size when building cores
+- Fix CHD support
+
+# 4.2.1 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/13362ef0786990e93462f06505de772031cfc4c2)
+
+This was a bug-fix only release.
+
+- Core-fetch failsafe now fetches a pinned version (Thanks to [@gantoine](https://github.com/n-at))
+- Fixes video rotation on the arcade core (Thanks to [@allancoding](https://github.com/allancoding))
+- Updated French `af-FR` translation (Thanks to [@t3chnob0y](https://github.com/t3chnob0y))
+- Fixes switching between cores.
+- Change: Localstorage settings are now stored by game instead of by system.
+- Fixed gamepad input for c-down.
+- Fixed RetroArch always assuming save is `.srm`.
+- Fixed EJS exit event
+- Hide the "save/load save files" buttons if unsupported.
+- Corrects the order of the core list.
+- Corrects behaviour of the placement of bios/parent/patch files.
+- Fixed rar decompression.
+- Fixed picodrive core (`sega32x`)
+- Fixed libretro-uae core (`amiga`)
+
+# 4.2.0 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/8d42d53d4fdf0166f71eaa07529cadf93350b76e)
+
+In my opinion, this is the most stable release we've had in a while. Many features added in this release were just side affects of fixing up some bugs.
+
+- Let same_cdi core handle zipped bios file directly (Thanks to [@pastisme](https://github.com/pastisme))
+- Fix audio sliders/mute button (Thanks to [@n-at](https://github.com/n-at))
+- Add ability to rotate video (Thanks to [@allancoding](https://github.com/allancoding))
+- Added persian `fa-AF` language (Thanks to [@iits-reza](https://github.com/iits-reza))
+- Added more catches for a start-game error
+- Fixed default webgl2 option
+- Organized settings menu, by dividing entries into sub-menus
+- Fixed the EmulatorJS exit button
+- Added the ability to internally add configurable retroarch.cfg variables
+- Fixed default settings being saved to localstorage
+- Fixed in browser SRM saves (finally)
+- Read save state from WebAssembly Memory
+- Fixed an issue when loading PPSSPP assets
+- Refactored the internal downloadFile function to be promised based instead of callback based
+- Added checks if core requires threads or webgl2
+- Added ability to switch between cores in the settings menu
+- Added the ability to enable/disable threads if SharedArrayBuffer is defined
+- Added a PSP controller scheme for the control settings menu
+- Fixed the volume slider background height in firefox
+- Added handling for lightgun devices
+- Refactored the EmulatorJS `build-emulatorjs.sh` build script
+- Added `ppsspp` core
+
+# 4.1.1 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/4951a28de05e072acbe939f46147645a91664a07)
+
- Fixed 2xScaleHQ and 2xScaleHQ shaders (Thanks to [@n-at](https://github.com/n-at))
- Added Vietnamese (`vi-VN`) (Thanks to [@TimKieu](https://github.com/TimKieu))
- Disable CUE generation for the PUAE core (Thanks to [@michael-j-green](https://github.com/michael-j-green))
@@ -21,6 +114,7 @@
- Added support for `File` objects (Thanks to [@pastisme](https://github.com/pastisme)).
# 4.0.12 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/c3ba473d1afc278db136f8e1252d0456050d6047)
+
- Fix scroll bar css (Thanks to [@allancoding](https://github.com/allancoding))
- Flip the context menu instead of going off the page
- Add hooks for save files (Thanks to [@gantoine](https://github.com/gantoine))
@@ -33,12 +127,14 @@
- Added advanced shader configuration support (Thanks to [@n-at](https://github.com/n-at))
# 4.0.11 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/cafd80d023afa9562c7054e89a4240f3381d64ff)
+
- Added the ability to disable localstorage using `EJS_disableLocalStorage`. (Thanks to [@n-at](https://github.com/n-at))
- Added the ability to trigger `EJS_emulator.displayMessage` with a duration. (Thanks to [@allancoding](https://github.com/allancoding))
- `EJS_emulator.gameManager.getState` now returns a Uint8Array instead of a promise.
- Fixed broken save states from the 4.0.10 release.
# 4.0.10 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/390605d2ab48db16c07c8fb4fc2815033af5c3a6)
+
- Fixed bug with duplicate control inputs.
- Fixed mobile settings menu positioning.
- Ability to load custom files into the wasm instance.
@@ -53,6 +149,7 @@
- Fixed volume slider shadow. (Thanks to [@allancoding](https://github.com/allancoding))
# 4.0.9 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/ddb5c6092f12a63a46d74ea67e6469726665ebc2)
+
- Repository history rewrite - expect faster cloning times.
- Prevent Vice64 from creating cue files (Thanks to [@michael-j-green](https://github.com/michael-j-green))
- Chinese translation updated (Thanks to [@oyepriyansh](https://github.com/oyepriyansh))
@@ -64,6 +161,7 @@
- Added legacy nintendo 64 cores for browsers that don't support webgl2.
# 4.0.8 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/f579eb4c080f612723fd6a119b02173cafb37503)
+
- Fixed typo in virtual gamepad dpad.
- Added updated desmume core.
- Fixed key mapping (Thanks to [@allancoding](https://github.com/allancoding))
@@ -77,6 +175,7 @@
- Added c64 core.
# 4.0.7 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/f579eb4c080f612723fd6a119b02173cafb37503)
+
- Added rewind (Thanks to [@n-at](https://github.com/n-at))
- Added slowdown (Thanks to [@n-at](https://github.com/n-at))
- Fixed "zone" object in front of settings menu.
@@ -94,6 +193,7 @@
- Use keycodes instead of labels (Thanks to [@allancoding](https://github.com/allancoding))
# 4.0.6 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/5e338e7a888480cea331f6d4656bc8986a7d6b28)
+
- Fixed n64 on iOS safari
- virtual gamepads for atari2600, atari7800, lynx, jaguar, vb, 3do (Thanks to [@n-at](https://github.com/n-at))
- control buttons for gba, vb, 3do, atari2600, atari7800, lynx, jaguar (Thanks to [@n-at](https://github.com/n-at))
@@ -101,6 +201,7 @@
- Added Fast Forward
# 4.0.5 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/5307e6294ed9df5daabd6958b2b307bae01f59f1)
+
- Added `pcsx_rearmed` core
- Made `pcsx_rearmed` core the default `psx` core (better compatibility)
- Added `fbneo` core
@@ -115,20 +216,25 @@
- Add ***highly beta*** psp core - see readme
# 4.0.4 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/41491a738cf92ef9cee7d53f323aa2ab9732c053)
+
- Fix cheats "x" button
- Optimize memory usage
- Added ability to set urls to blob/arraybuffer/uint8array if needed
# 4.0.3 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/5219ab51227bc0fb60cbc7b60e476b0145c932c9)
+
- Remove RetroArch messages
- Center video at top
# 4.0.2 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/06fe386e780bb55ef6baa4fbc6addd486bee747a)
+
- Add link to RetroArch License on about page
- Fix gamepad support for legacy browsers
# 4.0.1 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/efbb9dd462ee0e4f2120a6947af312e02fcf657c)
+
Complete application re-write. Everything changed. Although some changes to note are:
+
- Optimization for smaller screens.
- No more dead code.
- Fix Gamepad for firefox.
@@ -139,10 +245,12 @@ Complete application re-write. Everything changed. Although some changes to note
And much much more was changed...
# 3.1.5 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/f7fa5d41487a424233b40e903020455606d68fee)
+
- Fixed iOS bug for iPads
- Added netplay! (only working on old cores)
# 3.1.0 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/614f5cb55e2768199ba05b756b47d0ab7ab283fd)
+
- Added ability to drag and drop save states.
- Fixed some "update" and "cancel" and "close" button confustion
- Removed save state retroarch messages
@@ -150,6 +258,7 @@ And much much more was changed...
- (Theoretically) fixed a bug that did not allow iOS devices to work
# 3.0.5 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/44c31371fb3c314cd8dea36ccbaad89fb3ab98e6)
+
- Fixed screen recording on devices that do not support getUserMedia api.
- Added C label buttons to nintendo 64 virtual gamepad.
- Fixed EJS_color bug.
@@ -167,63 +276,79 @@ And much much more was changed...
- Added feature that will display the current downloaded size when the content length is not available.
# 2.3.9 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/088942083e44510f07133f2074a2d63a8af477cd)
+
- Fixed incorrect variable referencing when update bios download data callback.
- Fixed rom storage size limits.
- Fixed download percent not showing with some files.
# 2.3.8 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/5f176b963e4b2055983b82396378d1e3837a69c4)
+
- Remove broken shader.
- Add download percent message.
- Fixed UI "saving state" message not going away.
# 2.3.7 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/8b9607becfe0aaad42b8b8486c7d379821b72125)
+
- Add more shaders.
- Add bold fontsize option to custom virtual gamepad settings.
- No longer set "normalOptions" from localization file.
# 2.3.6 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/b2919bc2c3d2d4c9fe3ab4f4486790a376b7acfe)
+
- Remove default control mappings for gamepads.
- Upgraded invalid character regex to catch more characters.
# 2.3.5 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/a5a9916aba041e75ee73815376ed4fd2e22701bd)
+
- Use regex to detect and replace invalid characters in filename/gamename settings.
# 2.3.4 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/45d982b6362cfd29cb2eda9721066e03893ba0d8)
+
- Add new arcade core.
- Fix patch file game id set bug.
# 2.3.4 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/45d982b6362cfd29cb2eda9721066e03893ba0d8)
+
- Add new arcade core.
# 2.3.3 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/11bddd5a4277aa04f80b941f05cc024b3de58bfc)
+
- Make version in loader.js reasonable.
- Created function to return the game id to prevent unnecessary data stored.
# 2.3.2 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/e9e017435f2c41c6c2b127024cc88ac51bdf04d9)
+
- Fix reference error.
- Fix bug in custom virtual gamepad processor where if value is set to 0 it will see that as the value being missing.
# 2.3.1 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/0fd6d58e2011fa1a39bd2e11ba3d2f17773f0961)
+
- Use let instead of var.
# 2.3.0 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/2fd0f545285151524262cc799efef6d996d7c6c1)
+
- Added ability to customize virtual gamepad UI.
- Fixed bug where shader is not set on start.
# 2.2.9 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/018c39d4065b866487f8f18ca88c9488eab69a6d)
+
- Added feature to save save files to indexeddb every 5 minutes.
# 2.2.8 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/9860d662d02b56417044cca11937448041d9cf43)
+
- Re-write gamepad handler.
# 2.2.7 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/c03d18990b6536c1503bba2c640dbc13db982bb3)
+
- Removed un-needed FS proxy functions.
# 2.2.6 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/fd71b5dfc2bd44d8e1f0e7c6c7b3ee1a1127a696)
+
- Added fps counter.
- Fixed gba core aspect.
# 2.2.5 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/4b444ec23918149a6052807d778af82f79883c01)
+
- Added ability to set custom control mappings.
- Added ability to set custom default volume value.
- Fixed gamepad axis as button, gamepad varaible compared to incorrect value.
@@ -231,16 +356,19 @@ And much much more was changed...
- Added ability to set game url to other data types.
# 2.2.3 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/41eed05677b4927bd114613040bfe4572c92c4b4)
+
- Fixed rar unarchiving function reference.
- Updated rar header detection.
- Removed netplay.
# 2.2.1 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/19980deb12c3f0790176db6fc7b8b2de4069bf4e)
+
- Added core menu options for new cores.
- Added new mame2003 core.
- Added support for debug emscripten setting for new cores.
# 2.0.1 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/a72222c39a793c4ff470ebb2b71c04829fee4b5e)
+
- Control mapping for beta cores.
- Updated beta cores.
- Beta cores now the default option!
@@ -248,25 +376,30 @@ And much much more was changed...
- Fixed save state for new n64 core.
# 1.2.2 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/8ab7bb3f49da373ed5d291c5f72039bbabf2fbc8)
+
- Moved virtual gamepad menu button to the top left as 3 lines.
- Added screen orientation lock.
- Added beta n64 core!
# 1.2.1 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/638658e6202fd39cb5c94bedcfa00ccdf8b25840)
+
- Updated beta core files.
# 1.1.6 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/fa153ba76791184d978f9fb8b69991b05b161bc8)
+
- Replaced axios module with custom script.
- Added pause/play for beta cores.
- Sepperated css into its own file.
- Renamed emu-min.js to emulator.min.js.
# 1.1.5 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/2767c635b8a6e05c57e054d2f9d01ae0c4ff6d47)
+
- Cleaned up fetch error function.
- Cleaned up virtual gamepad event listeners.
- Add code of conduct.
# 1.1.2 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/64731dd8219931155b4e698aa98dbf65c2120038)
+
- Fixed error where mame files were misnamed.
- Fixed bug where variable referenced was not defined in loader.js.
- Added .gitignore
@@ -278,6 +411,7 @@ And much much more was changed...
- Update nodejs buffer module.
# 1.1.0 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/715ded4ae23c2135bc9a8b9b7599f12c905393b3)
+
- Added minify feature.
- Added emulatorjs logo.
- Added beta nds and gb core.
@@ -285,6 +419,7 @@ And much much more was changed...
- Added volume setting and cheats to beta cores.
# 1.0 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/fde44b095bb89e299daaaa4c8d7deebc79019865)
+
- Official release of the beta cores.
- Ability to use beta cores in production.
- Ability to use the old emulatorjs netplay server.
@@ -293,6 +428,7 @@ And much much more was changed...
- Fixed virtual gamepad bug where a function was referenced to as an array.
# 0.4.26 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/0709829a11266b6ab4bbbf3e61d6dd6d3c372133)
+
- Sepperated emulator.js file into 2 files.
- Added support for a custom netplay server.
- Fixed netplay room password input bug.
@@ -307,6 +443,7 @@ And much much more was changed...
- Update webrtc adapter.
# 0.4.25 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/ef3200ef87bffe57241e05ae9646cc201142ec46)
+
- Moved load state on start from loader.js file to emulator.js file.
- Moved data path function from loader.js file to emulator.js file.
- Added ability to set custom path to data through `EJS_pathtodata` variable.
@@ -322,6 +459,7 @@ And much much more was changed...
- Created official emulatorjs website.
# 0.4.24 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/73ff641616bcd10f088a004002183760832a1afc)
+
- Deobsfocuted emulator.js and loader.js files to the most of my extent.
- Added quick save/load hotkeys.
- Added ability to use gamepad axis as button.
@@ -337,6 +475,7 @@ And much much more was changed...
- Updated n64 core.
# 0.4.23-07 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/83e148c82cbc8b4e835a808dcf84456975f82a7c)
+
- Removed not needed code.
- Added reset button to control settings.
- Added clear button to control settings.
@@ -345,27 +484,33 @@ And much much more was changed...
- Fixed RAR unarchiving.
# 0.4.23-05 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/018c787ccf6daca58c863d38fff61910f33f98ec)
+
- No longer cache games with the protocols of `file:`, and `chrome-extension:`.
- Changed default keymappings.
- Added screen recording button.
# 0.4.23-04 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/6464bbedc1cd58c023cd66656540fc174aedde8b)
+
- Added mame2003, snes2002, snes2005, snes2010, and vbanext cores.
- Added asmjs for all supported cores.
# 0.4.23-03 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/c883f267e1e56ed6b6472b891f78704c6e4b4c17)
+
- Start loader.js deobsfocuting.
- Deobsfocute extractzip.js.
- Added `EJS_gameName`, the ability to change the file name of save states.
# 0.4.23-02 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/5d97620b25a81e49c6ba313e586fb37a5ce66002)
-- Start emulator.js deobsfocuting.
+
+- Start emulator.js deobsfocuting.
# 0.4.23-01 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/42a7e129cfded266b72539e8d1b5978d5e4119d8)
+
- Added support for loading "blob:" urls.
- Added support for loading state on game start.
# 0.4.23 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/5f5cf5cbba29cfd772d525a4c73a4bc5ea26654c)
+
- Added update available message.
- Fixed a bug where the 'x' from the ad iframe was still visible on game start.
- Added a2600 and mame cores.
@@ -373,9 +518,11 @@ And much much more was changed...
- Add rar extraction support.
# 0.4.19 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/4fd22871663e5896bb5d0ce29a50ad508462387a)
+
- Added support for 32x, 3do, a7800, arcade, bluemsx, jaguar, lynx, ngp, pce, saturn, sega, segacd, and ws cores.
# Initial release [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/be2db16cba8bd85bf901cd89ca6de51414cea792)
+
- Support for unzipping zip files.
- Support for unzipping 7zip files.
- Support for vb, snes, psx, nes, nds, n64, gba, and gb systems. Only support for WASM.
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index f0c885e8..3f3e59a8 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -2,10 +2,54 @@
There are several ways to contribute, be it directly to helping develop features for EmulatorJS, update the documentation, media assets or heading over to libretro and helping them develop the emulator cores that make the magic happen.
-* EmulatorJS, take a look through the [issues](https://github.com/EmulatorJS/EmulatorJS/issues) on github and try to help out.
+- EmulatorJS, take a look through the [issues](https://github.com/EmulatorJS/EmulatorJS/issues) on github and try to help out.
-* Documentation [github page](https://github.com/EmulatorJS/emulatorjs.org).
+- Documentation [github page](https://github.com/EmulatorJS/emulatorjs.org).
Just wanna donate? That'd help too!
-[libretro](https://retroarch.com/index.php?page=donate)
-[EmulatorJS](https://www.patreon.com/EmulatorJS)
+
+Donate to: [EmulatorJS](https://www.patreon.com/EmulatorJS)
+
+Donate to: [libretro](https://retroarch.com/index.php?page=donate)
+
+## Project Scripts
+
+The project has several scripts that can be used to help with updating and deploying the project.
+
+### Build Script
+
+Runs the build script, which will compresses the project in 7z and zip output in dist/ folder. Note: Make sure you have the compiled cores in the `data/cores` folder before running this script.
+
+```bash
+npm run build
+```
+
+### Update Script
+
+Runs the update script, which updates dependencies and can change version number of project. It also will update the list of contributors.
+
+```bash
+npm run update # Just updates contributors list
+npm run update -- --ejs_v=4.3.1 # Updates contributors list and sets version to 4.3.1
+npm run update -- --deps=true # Updates contributors list and updates dependencies
+npm run update -- --dev=true # Updates contributors list and enables dev mode
+npm run update -- --dev=false # Updates contributors list and disables dev mode
+```
+
+## Attention Visual Studio Code Users
+
+By default Visual Studio Code will apply formatting that is not consistent with the standard formatting used by this project.
+
+Please disable the formatter *before* submitting a Pull Request.
+
+The formatter can be disabled for this repo only (without affecting your own preferences) by creating a new file called `.vscode/settings.json` (if it doesn't already exist).
+
+Add the following options to the settings.json file to disable the formatter while working on this repo:
+```json
+{
+ "diffEditor.ignoreTrimWhitespace": false,
+ "editor.formatOnPaste": false,
+ "editor.formatOnSave": false,
+ "editor.formatOnSaveMode": "modifications"
+}
+```
diff --git a/LICENSE b/LICENSE
index 2bb95c24..372f2fd9 100644
--- a/LICENSE
+++ b/LICENSE
@@ -632,7 +632,7 @@ state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
EmulatorJS: RetroArch on the web
- Copyright (C) 2023 Ethan O'Brien
+ Copyright (C) 2022-2024 Ethan O'Brien
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
- EmulatorJS Copyright (C) 2023 Ethan O'Brien
+ EmulatorJS Copyright (C) 2023-2025 Ethan O'Brien
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
diff --git a/README.md b/README.md
index 5cfc84e5..7f1cb76f 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,3 @@
-
@@ -8,20 +7,17 @@
[![Badge License]][License]
-
-
-Self-hosted **Javascript** emulation for various system.
+
+Self-hosted **Javascript** emulation for various systems.
-[![Button Website]][Website]
+[![Button Website]][Website]
[![Button Usage]][Usage]
[![Button Configurator]][Configurator]
-[![Button Demo]][Demo]
-[![Button Legacy]][Legacy]
-
-[![Button Contributors]][Contributors]
-
+[![Button Demo]][Demo]
+[![Button Contributors]][Contributors]
+
Join our Discord server:
[](https://discord.gg/6akryGkETU)
@@ -35,12 +31,10 @@ Or the Matrix server (#emulatorjs:matrix.emulatorjs.org):
> [!NOTE]
-> **As of EmulatorJS version 4.0, this project is no longer a reverse-engineered version of the emulatorjs.com project. It is now a complete re-write.**
+> **As of EmulatorJS version 4.0, this project is no longer a reverse-engineered version of the emulatorjs.com project. It is now a complete rewrite.**
> [!WARNING]
-> As of version 4.0.9 cores and minified files are no longer included in the repository. You will need to get them separately. You can get the from [releases](https://github.com/EmulatorJS/EmulatorJS/releases) or the * new CDN (see [this](#CDN) for more info). There is also a new version system that we will be using. (read [here](#Versioning) for more info).
->
-> The history of the project has been rewritten and force pushed. You will likely need to redo any active commits you have. Sorry for the inconvenience.
+> As of version 4.0.9 cores and minified files are no longer included in the repository. You will need to get them separately. You can get it from [releases](https://github.com/EmulatorJS/EmulatorJS/releases) or the \* new CDN (see [this](#CDN) for more info). There is also a new version system that we will be using. (read [here](#Versioning) for more info).
> [!TIP]
> Cloning the repository is no longer recommended for production use. You should use [releases](https://github.com/EmulatorJS/EmulatorJS/releases) or the [CDN](https://cdn.emulatorjs.org/) instead.
@@ -58,7 +52,6 @@ Or the Matrix server (#emulatorjs:matrix.emulatorjs.org):
-
### Issues
*If something doesn't work, please consider opening an* ***[Issue]***
@@ -66,34 +59,74 @@ Or the Matrix server (#emulatorjs:matrix.emulatorjs.org):
+### 3rd Party Projects
+
+EmulatorJS itself is built to be a plugin, rather than an entire website. This is why there is no docker container of this project. However, there are several projects you can use that use EmulatorJS!
+
+Looking for projects that integrate EmulatorJS? Check out https://emulatorjs.org/docs/3rd-party
+
+
+
### Versioning
+
There are three different version names that you need to be aware of:
+
1. **stable** - This will be the most stable version of the emulator both code and cores will be tested before release. It will be updated every time a new version is released on GitHub. This is the default version on the Demo.
2. **latest** - This will contain the latest code but use the stable cores. This will be updated every time the *main* branch is updated.
-3. **nightly** - This will contain the latest code and the latest cores. The cores will be updated every day, so this is consiterd alpha.
+3. **nightly** - This will contain the latest code and the latest cores. The cores will be updated every day, so this is considered alpha.
+
+
### CDN
-There is a new CDN that you can use to get any version of the emulator. The cdn is `https://cdn.emulatorjs.org/`. You can use this to get the stable, latest, nightly and any other main version by setting your `EJS_pathtodata` to `https://cdn.emulatorjs.org//data/`.
-### Extensions
+**EmulatorJS provides a CDN** at `https://cdn.emulatorjs.org/`, allowing access to any version of the emulator.
- **[GameLibrary]**
+To use it, set `EJS_pathtodata` to `https://cdn.emulatorjs.org//data/`, replacing `` with `stable`, `latest`, `nightly`, or another main release.
- *A library overview for your **ROM** folder.*
+Be sure to also update the `loader.js` path to:
+`https://cdn.emulatorjs.org//data/loader.js`
### Development:
*Run a local server with:*
-```
-npm i
-npm start
-```
+
+1. Open a terminal in the root of the project.
+
+2. Install the dependencies with:
+
+ ```sh
+ npm i
+ ```
+
+3. Start the minification with:
+
+ ```sh
+ node start
+ ```
+
+4. Open your browser and go to `http://localhost:8080/` to see the demo page.
-**>> When reporting bugs, please specify that you are using the old version**
+
+
+#### Minifying
+
+Before pushing the script files onto your production server it is recommended to minify them to save on load times as well as bandwidth.
+
+Read the [minifying](minify/README.md) documentation for more info.
+
+
+
+#### Localization
+
+If you want to help with localization, please check out the [localization](data/localization/README.md) documentation.
+
+
+
+**>> When reporting bugs, please specify what version you are using**
@@ -1247,7 +1465,7 @@ class EmulatorJS {
if (hidden) li.hidden = true;
const a = this.createElement("a");
if (functi0n instanceof Function) {
- this.addEventListener(li, 'click', (e) => {
+ this.addEventListener(li, "click", (e) => {
e.preventDefault();
functi0n();
});
@@ -1263,20 +1481,20 @@ class EmulatorJS {
let screenshotUrl;
const screenshot = addButton("Take Screenshot", false, () => {
if (screenshotUrl) URL.revokeObjectURL(screenshotUrl);
- this.gameManager.screenshot().then(screenshot => {
- const blob = new Blob([screenshot]);
+ const date = new Date();
+ const fileName = this.getBaseFileName() + "-" + date.getMonth() + "-" + date.getDate() + "-" + date.getFullYear();
+ this.screenshot((blob, format) => {
screenshotUrl = URL.createObjectURL(blob);
const a = this.createElement("a");
a.href = screenshotUrl;
- const date = new Date();
- a.download = this.getBaseFileName()+"-"+date.getMonth()+"-"+date.getDate()+"-"+date.getFullYear()+".png";
+ a.download = fileName + "." + format;
a.click();
hideMenu();
});
});
let screenMediaRecorder = null;
- const startScreenRecording = addButton("Start screen recording", false, () => {
+ const startScreenRecording = addButton("Start Screen Recording", false, () => {
if (screenMediaRecorder !== null) {
screenMediaRecorder.stop();
}
@@ -1285,7 +1503,7 @@ class EmulatorJS {
stopScreenRecording.removeAttribute("hidden");
hideMenu();
});
- const stopScreenRecording = addButton("Stop screen recording", true, () => {
+ const stopScreenRecording = addButton("Stop Screen Recording", true, () => {
if (screenMediaRecorder !== null) {
screenMediaRecorder.stop();
screenMediaRecorder = null;
@@ -1296,15 +1514,18 @@ class EmulatorJS {
});
const qSave = addButton("Quick Save", false, () => {
- const slot = this.settings['save-state-slot'] ? this.settings['save-state-slot'] : "1";
- this.gameManager.quickSave(slot);
- this.displayMessage(this.localization("SAVED STATE TO SLOT")+" "+slot);
+ const slot = this.getSettingValue("save-state-slot") ? this.getSettingValue("save-state-slot") : "1";
+ if (this.gameManager.quickSave(slot)) {
+ this.displayMessage(this.localization("SAVED STATE TO SLOT") + " " + slot);
+ } else {
+ this.displayMessage(this.localization("FAILED TO SAVE STATE"));
+ }
hideMenu();
});
const qLoad = addButton("Quick Load", false, () => {
- const slot = this.settings['save-state-slot'] ? this.settings['save-state-slot'] : "1";
+ const slot = this.getSettingValue("save-state-slot") ? this.getSettingValue("save-state-slot") : "1";
this.gameManager.quickLoad(slot);
- this.displayMessage(this.localization("LOADED STATE FROM SLOT")+" "+slot);
+ this.displayMessage(this.localization("LOADED STATE FROM SLOT") + " " + slot);
hideMenu();
});
this.elements.contextMenu = {
@@ -1314,15 +1535,18 @@ class EmulatorJS {
save: qSave,
load: qLoad
}
- addButton("EmulatorJS v"+this.ejs_version, false, () => {
+ addButton("EmulatorJS v" + this.ejs_version, false, () => {
hideMenu();
const body = this.createPopup("EmulatorJS", {
"Close": () => {
this.closePopup();
}
});
-
- const menu = this.createElement('div');
+
+ body.style.display = "flex";
+
+ const menu = this.createElement("div");
+ body.appendChild(menu);
menu.classList.add("ejs_list_selector");
const parent = this.createElement("ul");
const addButton = (title, hidden, functi0n) => {
@@ -1330,9 +1554,9 @@ class EmulatorJS {
if (hidden) li.hidden = true;
const a = this.createElement("a");
if (functi0n instanceof Function) {
- this.addEventListener(li, 'click', (e) => {
+ this.addEventListener(li, "click", (e) => {
e.preventDefault();
- functi0n();
+ functi0n(li);
});
}
a.href = "#";
@@ -1355,12 +1579,16 @@ class EmulatorJS {
body.appendChild(license);
body.appendChild(retroarch);
body.appendChild(coreLicense);
-
- let current = home;
- home.innerText = "EmulatorJS v"+this.ejs_version;
+
+ home.innerText = "EmulatorJS v" + this.ejs_version;
home.appendChild(this.createElement("br"));
home.appendChild(this.createElement("br"));
+ home.classList.add("ejs_context_menu_tab");
+ license.classList.add("ejs_context_menu_tab");
+ retroarch.classList.add("ejs_context_menu_tab");
+ coreLicense.classList.add("ejs_context_menu_tab");
+
this.createLink(home, "https://github.com/EmulatorJS/EmulatorJS", "View on GitHub", true);
this.createLink(home, "https://discord.gg/6akryGkETU", "Join the discord", true);
@@ -1383,34 +1611,37 @@ class EmulatorJS {
home.appendChild(this.createElement("br"));
menu.appendChild(parent);
- body.appendChild(menu);
- const setElem = (element) => {
+ let current = home;
+ const setElem = (element, li) => {
if (current === element) return;
if (current) {
current.style.display = "none";
}
+ let activeLi = li.parentElement.querySelector(".ejs_active_list_element");
+ if (activeLi) {
+ activeLi.classList.remove("ejs_active_list_element");
+ }
+ li.classList.add("ejs_active_list_element");
current = element;
element.style.display = "";
}
- addButton("Home", false, () => {
- setElem(home);
- })
- addButton("EmulatorJS License", false, () => {
- setElem(license);
- })
- addButton("RetroArch License", false, () => {
- setElem(retroarch);
- })
+ addButton("Home", false, (li) => {
+ setElem(home, li);
+ }).classList.add("ejs_active_list_element");
+ addButton("EmulatorJS License", false, (li) => {
+ setElem(license, li);
+ });
+ addButton("RetroArch License", false, (li) => {
+ setElem(retroarch, li);
+ });
if (this.coreName && this.license) {
- addButton(this.coreName + " License", false, () => {
- setElem(coreLicense);
+ addButton(this.coreName + " License", false, (li) => {
+ setElem(coreLicense, li);
})
- coreLicense.style['text-align'] = "center";
- coreLicense.style['padding'] = "10px";
coreLicense.innerText = this.license;
}
//Todo - Contributors.
-
+
retroarch.innerText = this.localization("This project is powered by") + " ";
const a = this.createElement("a");
a.href = "https://github.com/libretro/RetroArch";
@@ -1423,50 +1654,47 @@ class EmulatorJS {
licenseLink.innerText = this.localization("View the RetroArch license here");
a.appendChild(this.createElement("br"));
a.appendChild(licenseLink);
-
- license.style['text-align'] = "center";
- license.style['padding'] = "10px";
- //license.style["white-space"] = "pre-wrap";
- license.innerText = ' GNU GENERAL PUBLIC LICENSE\n Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. \n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n Preamble\n\n The GNU General Public License is a free, copyleft license for\nsoftware and other kinds of works.\n\n The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works. By contrast,\nthe GNU General Public License is intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users. We, the Free Software Foundation, use the\nGNU General Public License for most of our software; it applies also to\nany other work released this way by its authors. You can apply it to\nyour programs, too.\n\n When we speak of free software, we are referring to freedom, not\nprice. Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n To protect your rights, we need to prevent others from denying you\nthese rights or asking you to surrender the rights. Therefore, you have\ncertain responsibilities if you distribute copies of the software, or if\nyou modify it: responsibilities to respect the freedom of others.\n\n For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must pass on to the recipients the same\nfreedoms that you received. You must make sure that they, too, receive\nor can get the source code. And you must show them these terms so they\nknow their rights.\n\n Developers that use the GNU GPL protect your rights with two steps:\n(1) assert copyright on the software, and (2) offer you this License\ngiving you legal permission to copy, distribute and/or modify it.\n\n For the developers\' and authors\' protection, the GPL clearly explains\nthat there is no warranty for this free software. For both users\' and\nauthors\' sake, the GPL requires that modified versions be marked as\nchanged, so that their problems will not be attributed erroneously to\nauthors of previous versions.\n\n Some devices are designed to deny users access to install or run\nmodified versions of the software inside them, although the manufacturer\ncan do so. This is fundamentally incompatible with the aim of\nprotecting users\' freedom to change the software. The systematic\npattern of such abuse occurs in the area of products for individuals to\nuse, which is precisely where it is most unacceptable. Therefore, we\nhave designed this version of the GPL to prohibit the practice for those\nproducts. If such problems arise substantially in other domains, we\nstand ready to extend this provision to those domains in future versions\nof the GPL, as needed to protect the freedom of users.\n\n Finally, every program is threatened constantly by software patents.\nStates should not allow patents to restrict development and use of\nsoftware on general-purpose computers, but in those that do, we wish to\navoid the special danger that patents applied to a free program could\nmake it effectively proprietary. To prevent this, the GPL assures that\npatents cannot be used to render the program non-free.\n\n The precise terms and conditions for copying, distribution and\nmodification follow.\n\n TERMS AND CONDITIONS\n\n 0. Definitions.\n\n "This License" refers to version 3 of the GNU General Public License.\n\n "Copyright" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n "The Program" refers to any copyrightable work licensed under this\nLicense. Each licensee is addressed as "you". "Licensees" and\n"recipients" may be individuals or organizations.\n\n To "modify" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy. The resulting work is called a "modified version" of the\nearlier work or a work "based on" the earlier work.\n\n A "covered work" means either the unmodified Program or a work based\non the Program.\n\n To "propagate" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy. Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n To "convey" a work means any kind of propagation that enables other\nparties to make or receive copies. Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n An interactive user interface displays "Appropriate Legal Notices"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License. If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n 1. Source Code.\n\n The "source code" for a work means the preferred form of the work\nfor making modifications to it. "Object code" means any non-source\nform of a work.\n\n A "Standard Interface" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n The "System Libraries" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form. A\n"Major Component", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n The "Corresponding Source" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities. However, it does not include the work\'s\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work. For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n The Corresponding Source for a work in source code form is that\nsame work.\n\n 2. Basic Permissions.\n\n All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met. This License explicitly affirms your unlimited\npermission to run the unmodified Program. The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work. This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force. You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright. Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n Conveying under any other circumstances is permitted solely under\nthe conditions stated below. Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n 3. Protecting Users\' Legal Rights From Anti-Circumvention Law.\n\n No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work\'s\nusers, your or third parties\' legal rights to forbid circumvention of\ntechnological measures.\n\n 4. Conveying Verbatim Copies.\n\n You may convey verbatim copies of the Program\'s source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n 5. Conveying Modified Source Versions.\n\n You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n a) The work must carry prominent notices stating that you modified\n it, and giving a relevant date.\n\n b) The work must carry prominent notices stating that it is\n released under this License and any conditions added under section\n 7. This requirement modifies the requirement in section 4 to\n "keep intact all notices".\n\n c) You must license the entire work, as a whole, under this\n License to anyone who comes into possession of a copy. This\n License will therefore apply, along with any applicable section 7\n additional terms, to the whole of the work, and all its parts,\n regardless of how they are packaged. This License gives no\n permission to license the work in any other way, but it does not\n invalidate such permission if you have separately received it.\n\n d) If the work has interactive user interfaces, each must display\n Appropriate Legal Notices; however, if the Program has interactive\n interfaces that do not display Appropriate Legal Notices, your\n work need not make them do so.\n\n A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n"aggregate" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation\'s users\nbeyond what the individual works permit. Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n 6. Conveying Non-Source Forms.\n\n You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n a) Convey the object code in, or embodied in, a physical product\n (including a physical distribution medium), accompanied by the\n Corresponding Source fixed on a durable physical medium\n customarily used for software interchange.\n\n b) Convey the object code in, or embodied in, a physical product\n (including a physical distribution medium), accompanied by a\n written offer, valid for at least three years and valid for as\n long as you offer spare parts or customer support for that product\n model, to give anyone who possesses the object code either (1) a\n copy of the Corresponding Source for all the software in the\n product that is covered by this License, on a durable physical\n medium customarily used for software interchange, for a price no\n more than your reasonable cost of physically performing this\n conveying of source, or (2) access to copy the\n Corresponding Source from a network server at no charge.\n\n c) Convey individual copies of the object code with a copy of the\n written offer to provide the Corresponding Source. This\n alternative is allowed only occasionally and noncommercially, and\n only if you received the object code with such an offer, in accord\n with subsection 6b.\n\n d) Convey the object code by offering access from a designated\n place (gratis or for a charge), and offer equivalent access to the\n Corresponding Source in the same way through the same place at no\n further charge. You need not require recipients to copy the\n Corresponding Source along with the object code. If the place to\n copy the object code is a network server, the Corresponding Source\n may be on a different server (operated by you or a third party)\n that supports equivalent copying facilities, provided you maintain\n clear directions next to the object code saying where to find the\n Corresponding Source. Regardless of what server hosts the\n Corresponding Source, you remain obligated to ensure that it is\n available for as long as needed to satisfy these requirements.\n\n e) Convey the object code using peer-to-peer transmission, provided\n you inform other peers where the object code and Corresponding\n Source of the work are being offered to the general public at no\n charge under subsection 6d.\n\n A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n A "User Product" is either (1) a "consumer product", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling. In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage. For a particular\nproduct received by a particular user, "normally used" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product. A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n "Installation Information" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source. The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information. But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed. Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n 7. Additional Terms.\n\n "Additional permissions" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law. If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit. (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.) You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n a) Disclaiming warranty or limiting liability differently from the\n terms of sections 15 and 16 of this License; or\n\n b) Requiring preservation of specified reasonable legal notices or\n author attributions in that material or in the Appropriate Legal\n Notices displayed by works containing it; or\n\n c) Prohibiting misrepresentation of the origin of that material, or\n requiring that modified versions of such material be marked in\n reasonable ways as different from the original version; or\n\n d) Limiting the use for publicity purposes of names of licensors or\n authors of the material; or\n\n e) Declining to grant rights under trademark law for use of some\n trade names, trademarks, or service marks; or\n\n f) Requiring indemnification of licensors and authors of that\n material by anyone who conveys the material (or modified versions of\n it) with contractual assumptions of liability to the recipient, for\n any liability that these contractual assumptions directly impose on\n those licensors and authors.\n\n All other non-permissive additional terms are considered "further\nrestrictions" within the meaning of section 10. If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term. If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n 8. Termination.\n\n You may not propagate or modify a covered work except as expressly\nprovided under this License. Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License. If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n 9. Acceptance Not Required for Having Copies.\n\n You are not required to accept this License in order to receive or\nrun a copy of the Program. Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance. However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work. These actions infringe copyright if you do\nnot accept this License. Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n 10. Automatic Licensing of Downstream Recipients.\n\n Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License. You are not responsible\nfor enforcing compliance by third parties with this License.\n\n An "entity transaction" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations. If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party\'s predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License. For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n 11. Patents.\n\n A "contributor" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based. The\nwork thus licensed is called the contributor\'s "contributor version".\n\n A contributor\'s "essential patent claims" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version. For\npurposes of this definition, "control" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor\'s essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n In the following three paragraphs, a "patent license" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement). To "grant" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients. "Knowingly relying" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient\'s use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n A patent license is "discriminatory" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License. You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n 12. No Surrender of Others\' Freedom.\n\n If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License. If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all. For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n 13. Use with the GNU Affero General Public License.\n\n Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU Affero General Public License into a single\ncombined work, and to convey the resulting work. The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the special requirements of the GNU Affero General Public License,\nsection 13, concerning interaction through a network will apply to the\ncombination as such.\n\n 14. Revised Versions of this License.\n\n The Free Software Foundation may publish revised and/or new versions of\nthe GNU General Public License from time to time. Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n Each version is given a distinguishing version number. If the\nProgram specifies that a certain numbered version of the GNU General\nPublic License "or any later version" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation. If the Program does not specify a version number of the\nGNU General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n If the Program specifies that a proxy can decide which future\nversions of the GNU General Public License can be used, that proxy\'s\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n Later license versions may give you additional or different\npermissions. However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n 15. Disclaimer of Warranty.\n\n THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n 16. Limitation of Liability.\n\n IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n 17. Interpretation of Sections 15 and 16.\n\n If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n END OF TERMS AND CONDITIONS\n\n How to Apply These Terms to Your New Programs\n\n If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n To do so, attach the following notices to the program. It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe "copyright" line and a pointer to where the full notice is found.\n\n EmulatorJS: RetroArch on the web\n Copyright (C) 2023 Ethan O\'Brien\n\n This program is free software: you can redistribute it and/or modify\n it under the terms of the GNU General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n This program is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU General Public License for more details.\n\n You should have received a copy of the GNU General Public License\n along with this program. If not, see .\n\nAlso add information on how to contact you by electronic and paper mail.\n\n If the program does terminal interaction, make it output a short\nnotice like this when it starts in an interactive mode:\n\n EmulatorJS Copyright (C) 2023 Ethan O\'Brien\n This program comes with ABSOLUTELY NO WARRANTY; for details type `show w\'.\n This is free software, and you are welcome to redistribute it\n under certain conditions; type `show c\' for details.\n\nThe hypothetical commands `show w\' and `show c\' should show the appropriate\nparts of the General Public License. Of course, your program\'s commands\nmight be different; for a GUI interface, you would use an "about box".\n\n You should also get your employer (if you work as a programmer) or school,\nif any, to sign a "copyright disclaimer" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU GPL, see\n.\n\n The GNU General Public License does not permit incorporating your program\ninto proprietary programs. If your program is a subroutine library, you\nmay consider it more useful to permit linking proprietary applications with\nthe library. If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License. But first, please read\n.\n';
+
+ license.innerText = ' GNU GENERAL PUBLIC LICENSE\n Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. \n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n Preamble\n\n The GNU General Public License is a free, copyleft license for\nsoftware and other kinds of works.\n\n The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works. By contrast,\nthe GNU General Public License is intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users. We, the Free Software Foundation, use the\nGNU General Public License for most of our software; it applies also to\nany other work released this way by its authors. You can apply it to\nyour programs, too.\n\n When we speak of free software, we are referring to freedom, not\nprice. Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n To protect your rights, we need to prevent others from denying you\nthese rights or asking you to surrender the rights. Therefore, you have\ncertain responsibilities if you distribute copies of the software, or if\nyou modify it: responsibilities to respect the freedom of others.\n\n For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must pass on to the recipients the same\nfreedoms that you received. You must make sure that they, too, receive\nor can get the source code. And you must show them these terms so they\nknow their rights.\n\n Developers that use the GNU GPL protect your rights with two steps:\n(1) assert copyright on the software, and (2) offer you this License\ngiving you legal permission to copy, distribute and/or modify it.\n\n For the developers\' and authors\' protection, the GPL clearly explains\nthat there is no warranty for this free software. For both users\' and\nauthors\' sake, the GPL requires that modified versions be marked as\nchanged, so that their problems will not be attributed erroneously to\nauthors of previous versions.\n\n Some devices are designed to deny users access to install or run\nmodified versions of the software inside them, although the manufacturer\ncan do so. This is fundamentally incompatible with the aim of\nprotecting users\' freedom to change the software. The systematic\npattern of such abuse occurs in the area of products for individuals to\nuse, which is precisely where it is most unacceptable. Therefore, we\nhave designed this version of the GPL to prohibit the practice for those\nproducts. If such problems arise substantially in other domains, we\nstand ready to extend this provision to those domains in future versions\nof the GPL, as needed to protect the freedom of users.\n\n Finally, every program is threatened constantly by software patents.\nStates should not allow patents to restrict development and use of\nsoftware on general-purpose computers, but in those that do, we wish to\navoid the special danger that patents applied to a free program could\nmake it effectively proprietary. To prevent this, the GPL assures that\npatents cannot be used to render the program non-free.\n\n The precise terms and conditions for copying, distribution and\nmodification follow.\n\n TERMS AND CONDITIONS\n\n 0. Definitions.\n\n "This License" refers to version 3 of the GNU General Public License.\n\n "Copyright" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n "The Program" refers to any copyrightable work licensed under this\nLicense. Each licensee is addressed as "you". "Licensees" and\n"recipients" may be individuals or organizations.\n\n To "modify" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy. The resulting work is called a "modified version" of the\nearlier work or a work "based on" the earlier work.\n\n A "covered work" means either the unmodified Program or a work based\non the Program.\n\n To "propagate" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy. Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n To "convey" a work means any kind of propagation that enables other\nparties to make or receive copies. Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n An interactive user interface displays "Appropriate Legal Notices"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License. If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n 1. Source Code.\n\n The "source code" for a work means the preferred form of the work\nfor making modifications to it. "Object code" means any non-source\nform of a work.\n\n A "Standard Interface" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n The "System Libraries" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form. A\n"Major Component", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n The "Corresponding Source" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities. However, it does not include the work\'s\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work. For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n The Corresponding Source for a work in source code form is that\nsame work.\n\n 2. Basic Permissions.\n\n All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met. This License explicitly affirms your unlimited\npermission to run the unmodified Program. The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work. This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force. You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright. Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n Conveying under any other circumstances is permitted solely under\nthe conditions stated below. Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n 3. Protecting Users\' Legal Rights From Anti-Circumvention Law.\n\n No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work\'s\nusers, your or third parties\' legal rights to forbid circumvention of\ntechnological measures.\n\n 4. Conveying Verbatim Copies.\n\n You may convey verbatim copies of the Program\'s source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n 5. Conveying Modified Source Versions.\n\n You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n a) The work must carry prominent notices stating that you modified\n it, and giving a relevant date.\n\n b) The work must carry prominent notices stating that it is\n released under this License and any conditions added under section\n 7. This requirement modifies the requirement in section 4 to\n "keep intact all notices".\n\n c) You must license the entire work, as a whole, under this\n License to anyone who comes into possession of a copy. This\n License will therefore apply, along with any applicable section 7\n additional terms, to the whole of the work, and all its parts,\n regardless of how they are packaged. This License gives no\n permission to license the work in any other way, but it does not\n invalidate such permission if you have separately received it.\n\n d) If the work has interactive user interfaces, each must display\n Appropriate Legal Notices; however, if the Program has interactive\n interfaces that do not display Appropriate Legal Notices, your\n work need not make them do so.\n\n A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n"aggregate" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation\'s users\nbeyond what the individual works permit. Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n 6. Conveying Non-Source Forms.\n\n You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n a) Convey the object code in, or embodied in, a physical product\n (including a physical distribution medium), accompanied by the\n Corresponding Source fixed on a durable physical medium\n customarily used for software interchange.\n\n b) Convey the object code in, or embodied in, a physical product\n (including a physical distribution medium), accompanied by a\n written offer, valid for at least three years and valid for as\n long as you offer spare parts or customer support for that product\n model, to give anyone who possesses the object code either (1) a\n copy of the Corresponding Source for all the software in the\n product that is covered by this License, on a durable physical\n medium customarily used for software interchange, for a price no\n more than your reasonable cost of physically performing this\n conveying of source, or (2) access to copy the\n Corresponding Source from a network server at no charge.\n\n c) Convey individual copies of the object code with a copy of the\n written offer to provide the Corresponding Source. This\n alternative is allowed only occasionally and noncommercially, and\n only if you received the object code with such an offer, in accord\n with subsection 6b.\n\n d) Convey the object code by offering access from a designated\n place (gratis or for a charge), and offer equivalent access to the\n Corresponding Source in the same way through the same place at no\n further charge. You need not require recipients to copy the\n Corresponding Source along with the object code. If the place to\n copy the object code is a network server, the Corresponding Source\n may be on a different server (operated by you or a third party)\n that supports equivalent copying facilities, provided you maintain\n clear directions next to the object code saying where to find the\n Corresponding Source. Regardless of what server hosts the\n Corresponding Source, you remain obligated to ensure that it is\n available for as long as needed to satisfy these requirements.\n\n e) Convey the object code using peer-to-peer transmission, provided\n you inform other peers where the object code and Corresponding\n Source of the work are being offered to the general public at no\n charge under subsection 6d.\n\n A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n A "User Product" is either (1) a "consumer product", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling. In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage. For a particular\nproduct received by a particular user, "normally used" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product. A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n "Installation Information" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source. The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information. But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed. Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n 7. Additional Terms.\n\n "Additional permissions" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law. If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit. (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.) You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n a) Disclaiming warranty or limiting liability differently from the\n terms of sections 15 and 16 of this License; or\n\n b) Requiring preservation of specified reasonable legal notices or\n author attributions in that material or in the Appropriate Legal\n Notices displayed by works containing it; or\n\n c) Prohibiting misrepresentation of the origin of that material, or\n requiring that modified versions of such material be marked in\n reasonable ways as different from the original version; or\n\n d) Limiting the use for publicity purposes of names of licensors or\n authors of the material; or\n\n e) Declining to grant rights under trademark law for use of some\n trade names, trademarks, or service marks; or\n\n f) Requiring indemnification of licensors and authors of that\n material by anyone who conveys the material (or modified versions of\n it) with contractual assumptions of liability to the recipient, for\n any liability that these contractual assumptions directly impose on\n those licensors and authors.\n\n All other non-permissive additional terms are considered "further\nrestrictions" within the meaning of section 10. If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term. If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n 8. Termination.\n\n You may not propagate or modify a covered work except as expressly\nprovided under this License. Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License. If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n 9. Acceptance Not Required for Having Copies.\n\n You are not required to accept this License in order to receive or\nrun a copy of the Program. Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance. However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work. These actions infringe copyright if you do\nnot accept this License. Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n 10. Automatic Licensing of Downstream Recipients.\n\n Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License. You are not responsible\nfor enforcing compliance by third parties with this License.\n\n An "entity transaction" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations. If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party\'s predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License. For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n 11. Patents.\n\n A "contributor" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based. The\nwork thus licensed is called the contributor\'s "contributor version".\n\n A contributor\'s "essential patent claims" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version. For\npurposes of this definition, "control" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor\'s essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n In the following three paragraphs, a "patent license" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement). To "grant" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients. "Knowingly relying" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient\'s use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n A patent license is "discriminatory" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License. You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n 12. No Surrender of Others\' Freedom.\n\n If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License. If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all. For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n 13. Use with the GNU Affero General Public License.\n\n Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU Affero General Public License into a single\ncombined work, and to convey the resulting work. The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the special requirements of the GNU Affero General Public License,\nsection 13, concerning interaction through a network will apply to the\ncombination as such.\n\n 14. Revised Versions of this License.\n\n The Free Software Foundation may publish revised and/or new versions of\nthe GNU General Public License from time to time. Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n Each version is given a distinguishing version number. If the\nProgram specifies that a certain numbered version of the GNU General\nPublic License "or any later version" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation. If the Program does not specify a version number of the\nGNU General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n If the Program specifies that a proxy can decide which future\nversions of the GNU General Public License can be used, that proxy\'s\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n Later license versions may give you additional or different\npermissions. However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n 15. Disclaimer of Warranty.\n\n THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n 16. Limitation of Liability.\n\n IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n 17. Interpretation of Sections 15 and 16.\n\n If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n END OF TERMS AND CONDITIONS\n\n How to Apply These Terms to Your New Programs\n\n If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n To do so, attach the following notices to the program. It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe "copyright" line and a pointer to where the full notice is found.\n\n EmulatorJS: RetroArch on the web\n Copyright (C) 2022-2024 Ethan O\'Brien\n\n This program is free software: you can redistribute it and/or modify\n it under the terms of the GNU General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n This program is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU General Public License for more details.\n\n You should have received a copy of the GNU General Public License\n along with this program. If not, see .\n\nAlso add information on how to contact you by electronic and paper mail.\n\n If the program does terminal interaction, make it output a short\nnotice like this when it starts in an interactive mode:\n\n EmulatorJS Copyright (C) 2023-2025 Ethan O\'Brien\n This program comes with ABSOLUTELY NO WARRANTY; for details type `show w\'.\n This is free software, and you are welcome to redistribute it\n under certain conditions; type `show c\' for details.\n\nThe hypothetical commands `show w\' and `show c\' should show the appropriate\nparts of the General Public License. Of course, your program\'s commands\nmight be different; for a GUI interface, you would use an "about box".\n\n You should also get your employer (if you work as a programmer) or school,\nif any, to sign a "copyright disclaimer" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU GPL, see\n.\n\n The GNU General Public License does not permit incorporating your program\ninto proprietary programs. If your program is a subroutine library, you\nmay consider it more useful to permit linking proprietary applications with\nthe library. If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License. But first, please read\n.\n';
});
-
+
if (this.config.buttonOpts) {
- if (this.config.buttonOpts.screenshot === false) screenshot.setAttribute("hidden", "");
- if (this.config.buttonOpts.screenRecord === false) startScreenRecording.setAttribute("hidden", "");
- if (this.config.buttonOpts.quickSave === false) qSave.setAttribute("hidden", "");
- if (this.config.buttonOpts.quickLoad === false) qLoad.setAttribute("hidden", "");
+ if (this.config.buttonOpts.screenshot.visible === false) screenshot.setAttribute("hidden", "");
+ if (this.config.buttonOpts.screenRecord.visible === false) startScreenRecording.setAttribute("hidden", "");
+ if (this.config.buttonOpts.quickSave.visible === false) qSave.setAttribute("hidden", "");
+ if (this.config.buttonOpts.quickLoad.visible === false) qLoad.setAttribute("hidden", "");
}
-
+
this.elements.contextmenu.appendChild(parent);
-
+
this.elements.parent.appendChild(this.elements.contextmenu);
}
closePopup() {
if (this.currentPopup !== null) {
try {
this.currentPopup.remove();
- } catch(e){}
+ } catch(e) {}
this.currentPopup = null;
}
}
//creates a full box popup.
createPopup(popupTitle, buttons, hidden) {
if (!hidden) this.closePopup();
- const popup = this.createElement('div');
+ const popup = this.createElement("div");
popup.classList.add("ejs_popup_container");
this.elements.parent.appendChild(popup);
const title = this.createElement("h4");
title.innerText = this.localization(popupTitle);
const main = this.createElement("div");
main.classList.add("ejs_popup_body");
-
+
popup.appendChild(title);
popup.appendChild(main);
-
+
const padding = this.createElement("div");
padding.style["padding-top"] = "10px";
popup.appendChild(padding);
-
+
for (let k in buttons) {
const button = this.createElement("a");
if (buttons[k] instanceof Function) {
@@ -1484,7 +1712,7 @@ class EmulatorJS {
} else {
popup.style.display = "none";
}
-
+
return main;
}
selectFile() {
@@ -1506,7 +1734,7 @@ class EmulatorJS {
if (first === second) return true;
- if (adown.contains) {
+ if (adown.contains) {
return adown.contains(second);
}
@@ -1514,7 +1742,7 @@ class EmulatorJS {
}
createBottomMenuBar() {
this.elements.menu = this.createElement("div");
-
+
//prevent weird glitch on some devices
this.elements.menu.style.opacity = 0;
this.on("start", (e) => {
@@ -1522,22 +1750,20 @@ class EmulatorJS {
})
this.elements.menu.classList.add("ejs_menu_bar");
this.elements.menu.classList.add("ejs_menu_bar_hidden");
-
+
let timeout = null;
let ignoreEvents = false;
const hide = () => {
if (this.paused || this.settingsMenuOpen || this.disksMenuOpen) return;
this.elements.menu.classList.add("ejs_menu_bar_hidden");
}
-
- this.addEventListener(this.elements.parent, 'mousemove click', (e) => {
- if (e.pointerType === "touch") return;
- if (!this.started || ignoreEvents || document.pointerLockElement === this.canvas) return;
- if (this.isPopupOpen()) return;
+
+ const show = () => {
clearTimeout(timeout);
timeout = setTimeout(hide, 3000);
this.elements.menu.classList.remove("ejs_menu_bar_hidden");
- })
+ }
+
this.menu = {
close: () => {
clearTimeout(timeout);
@@ -1555,11 +1781,48 @@ class EmulatorJS {
if (this.elements.menu.classList.contains("ejs_menu_bar_hidden")) {
timeout = setTimeout(hide, 3000);
}
- this.elements.menu.classList.toggle("ejs_menu_bar_hidden");
+ this.elements.menu.classList.toggle("ejs_menu_bar_hidden");
+ }
+ }
+
+ this.createBottomMenuBarListeners = () => {
+ const clickListener = (e) => {
+ if (e.pointerType === "touch") return;
+ if (!this.started || ignoreEvents || document.pointerLockElement === this.canvas) return;
+ if (this.isPopupOpen()) return;
+ show();
+ }
+ const mouseListener = (e) => {
+ if (!this.started || ignoreEvents || document.pointerLockElement === this.canvas) return;
+ if (this.isPopupOpen()) return;
+ const deltaX = e.movementX;
+ const deltaY = e.movementY;
+ const threshold = this.elements.menu.offsetHeight + 30;
+ const mouseY = e.clientY;
+
+ if (mouseY >= window.innerHeight - threshold) {
+ show();
+ return;
+ }
+ let angle = Math.atan2(deltaY, deltaX) * (180 / Math.PI);
+ if (angle < 0) angle += 360;
+ if (angle < 85 || angle > 95) return;
+ show();
}
+ if (this.menu.mousemoveListener) this.removeEventListener(this.menu.mousemoveListener);
+
+ if ((this.preGetSetting("menubarBehavior") || "downward") === "downward") {
+ this.menu.mousemoveListener = this.addEventListener(this.elements.parent, "mousemove", mouseListener);
+ } else {
+ this.menu.mousemoveListener = this.addEventListener(this.elements.parent, "mousemove", clickListener);
+ }
+
+ this.addEventListener(this.elements.parent, "click", clickListener);
}
+ this.createBottomMenuBarListeners();
+
this.elements.parent.appendChild(this.elements.menu);
-
+
let tmout;
this.addEventListener(this.elements.parent, "mousedown touchstart", (e) => {
if (this.isChild(this.elements.menu, e.target) || this.isChild(this.elements.menuToggle, e.target)) return;
@@ -1573,22 +1836,21 @@ class EmulatorJS {
ignoreEvents = true;
this.menu.close();
})
-
-
+
let paddingSet = false;
//Now add buttons
- const addButton = (title, image, callback, element, both) => {
+ const addButton = (buttonConfig, callback, element, both) => {
const button = this.createElement("button");
button.type = "button";
- const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
+ const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
svg.setAttribute("role", "presentation");
svg.setAttribute("focusable", "false");
- svg.innerHTML = image;
+ svg.innerHTML = buttonConfig.icon;
const text = this.createElement("span");
- text.innerText = this.localization(title);
+ text.innerText = this.localization(buttonConfig.displayName);
if (paddingSet) text.classList.add("ejs_menu_text_right");
text.classList.add("ejs_menu_text");
-
+
button.classList.add("ejs_menu_button");
button.appendChild(svg);
button.appendChild(text);
@@ -1598,34 +1860,38 @@ class EmulatorJS {
this.elements.menu.appendChild(button);
}
if (callback instanceof Function) {
- this.addEventListener(button, 'click', callback);
+ this.addEventListener(button, "click", callback);
+ }
+
+ if (buttonConfig.callback instanceof Function) {
+ this.addEventListener(button, "click", buttonConfig.callback);
}
return both ? [button, svg, text] : button;
}
- const restartButton = addButton("Restart", '', () => {
+ const restartButton = addButton(this.config.buttonOpts.restart, () => {
if (this.isNetplay && this.netplay.owner) {
this.gameManager.restart();
this.netplay.reset();
- this.netplay.sendMessage({restart:true});
+ this.netplay.sendMessage({ restart: true });
this.play();
} else if (!this.isNetplay) {
this.gameManager.restart();
}
});
- const pauseButton = addButton("Pause", '', () => {
+ const pauseButton = addButton(this.config.buttonOpts.pause, () => {
if (this.isNetplay && this.netplay.owner) {
this.pause();
this.gameManager.saveSaveFiles();
- this.netplay.sendMessage({pause:true});
+ this.netplay.sendMessage({ pause: true });
} else if (!this.isNetplay) {
this.pause();
}
});
- const playButton = addButton("Play", '', () => {
+ const playButton = addButton(this.config.buttonOpts.play, () => {
if (this.isNetplay && this.netplay.owner) {
this.play();
- this.netplay.sendMessage({play:true});
+ this.netplay.sendMessage({ play: true });
} else if (!this.isNetplay) {
this.play();
}
@@ -1643,9 +1909,9 @@ class EmulatorJS {
}
}
this.gameManager.toggleMainLoop(this.paused ? 0 : 1);
-
+
//I now realize its not easy to pause it while the cursor is locked, just in case I guess
- if (this.defaultCoreOpts.supportsMouse) {
+ if (this.enableMouseLock) {
if (this.canvas.exitPointerLock) {
this.canvas.exitPointerLock();
} else if (this.canvas.mozExitPointerLock) {
@@ -1659,33 +1925,41 @@ class EmulatorJS {
this.pause = (dontUpdate) => {
if (!this.paused) this.togglePlaying(dontUpdate);
}
-
+
let stateUrl;
- const saveState = addButton("Save State", '', async () => {
- const state = this.gameManager.getState();
+ const saveState = addButton(this.config.buttonOpts.saveState, async () => {
+ let state;
+ try {
+ state = this.gameManager.getState();
+ } catch(e) {
+ this.displayMessage(this.localization("FAILED TO SAVE STATE"));
+ return;
+ }
+ const { screenshot, format } = await this.takeScreenshot(this.capture.photo.source, this.capture.photo.format, this.capture.photo.upscale);
const called = this.callEvent("saveState", {
- screenshot: await this.gameManager.screenshot(),
+ screenshot: screenshot,
+ format: format,
state: state
});
if (called > 0) return;
if (stateUrl) URL.revokeObjectURL(stateUrl);
- if (this.settings['save-state-location'] === "browser" && this.saveInBrowserSupported()) {
- this.storage.states.put(this.getBaseFileName()+".state", state);
+ if (this.getSettingValue("save-state-location") === "browser" && this.saveInBrowserSupported()) {
+ this.storage.states.put(this.getBaseFileName() + ".state", state);
this.displayMessage(this.localization("SAVE SAVED TO BROWSER"));
} else {
const blob = new Blob([state]);
stateUrl = URL.createObjectURL(blob);
const a = this.createElement("a");
a.href = stateUrl;
- a.download = this.getBaseFileName()+".state";
+ a.download = this.getBaseFileName() + ".state";
a.click();
}
});
- const loadState = addButton("Load State", '', async () => {
+ const loadState = addButton(this.config.buttonOpts.loadState, async () => {
const called = this.callEvent("loadState");
if (called > 0) return;
- if (this.settings['save-state-location'] === "browser" && this.saveInBrowserSupported()) {
- this.storage.states.get(this.getBaseFileName()+".state").then(e => {
+ if (this.getSettingValue("save-state-location") === "browser" && this.saveInBrowserSupported()) {
+ this.storage.states.get(this.getBaseFileName() + ".state").then(e => {
this.gameManager.loadState(e);
this.displayMessage(this.localization("SAVE LOADED FROM BROWSER"));
})
@@ -1695,24 +1969,27 @@ class EmulatorJS {
this.gameManager.loadState(state);
}
});
- const controlMenu = addButton("Control Settings", '', () => {
+ const controlMenu = addButton(this.config.buttonOpts.gamepad, () => {
this.controlMenu.style.display = "";
});
- const cheatMenu = addButton("Cheats", '', () => {
+ const cheatMenu = addButton(this.config.buttonOpts.cheat, () => {
this.cheatMenu.style.display = "";
});
-
- const cache = addButton("Cache Manager", '', () => {
+
+ const cache = addButton(this.config.buttonOpts.cacheManager, () => {
this.openCacheMenu();
});
+
if (this.config.disableDatabases) cache.style.display = "none";
-
+
let savUrl;
-
- const saveSavFiles = addButton("Export Save File", '', async () => {
+
+ const saveSavFiles = addButton(this.config.buttonOpts.saveSavFiles, async () => {
const file = await this.gameManager.getSaveFile();
+ const { screenshot, format } = await this.takeScreenshot(this.capture.photo.source, this.capture.photo.format, this.capture.photo.upscale);
const called = this.callEvent("saveSave", {
- screenshot: await this.gameManager.screenshot(),
+ screenshot: screenshot,
+ format: format,
save: file
});
if (called > 0) return;
@@ -1723,7 +2000,7 @@ class EmulatorJS {
a.download = this.gameManager.getSaveFilePath().split("/").pop();
a.click();
});
- const loadSavFiles = addButton("Import Save File", '', async () => {
+ const loadSavFiles = addButton(this.config.buttonOpts.loadSavFiles, async () => {
const called = this.callEvent("loadSave");
if (called > 0) return;
const file = await this.selectFile();
@@ -1731,33 +2008,43 @@ class EmulatorJS {
const path = this.gameManager.getSaveFilePath();
const paths = path.split("/");
let cp = "";
- for (let i=0; i', async () => {
+ const netplay = addButton(this.config.buttonOpts.netplay, async () => {
this.openNetplayMenu();
});
+ // add custom buttons
+ // get all elements from this.config.buttonOpts with custom: true
+ if (this.config.buttonOpts) {
+ for (const [key, value] of Object.entries(this.config.buttonOpts)) {
+ if (value.custom === true) {
+ const customBtn = addButton(value);
+ }
+ }
+ }
+
const spacer = this.createElement("span");
spacer.classList.add("ejs_menu_bar_spacer");
this.elements.menu.appendChild(spacer);
paddingSet = true;
-
+
const volumeSettings = this.createElement("div");
volumeSettings.classList.add("ejs_volume_parent");
- const muteButton = addButton("Mute", '', () => {
+ const muteButton = addButton(this.config.buttonOpts.mute, () => {
muteButton.style.display = "none";
unmuteButton.style.display = "";
this.muted = true;
this.setVolume(0);
}, volumeSettings);
- const unmuteButton = addButton("Unmute", '', () => {
+ const unmuteButton = addButton(this.config.buttonOpts.unmute, () => {
if (this.volume === 0) this.volume = 0.5;
muteButton.style.display = "";
unmuteButton.style.display = "none";
@@ -1765,7 +2052,7 @@ class EmulatorJS {
this.setVolume(this.volume);
}, volumeSettings);
unmuteButton.style.display = "none";
-
+
const volumeSlider = this.createElement("input");
volumeSlider.setAttribute("data-range", "volume");
volumeSlider.setAttribute("type", "range");
@@ -1777,14 +2064,14 @@ class EmulatorJS {
volumeSlider.setAttribute("aria-label", "Volume");
volumeSlider.setAttribute("aria-valuemin", 0);
volumeSlider.setAttribute("aria-valuemax", 100);
-
+
this.setVolume = (volume) => {
this.saveSettings();
this.muted = (volume === 0);
volumeSlider.value = volume;
- volumeSlider.setAttribute("aria-valuenow", volume*100);
- volumeSlider.setAttribute("aria-valuetext", (volume*100).toFixed(1) + "%");
- volumeSlider.setAttribute("style", "--value: "+volume*100+"%;margin-left: 5px;position: relative;z-index: 2;");
+ volumeSlider.setAttribute("aria-valuenow", volume * 100);
+ volumeSlider.setAttribute("aria-valuetext", (volume * 100).toFixed(1) + "%");
+ volumeSlider.setAttribute("style", "--value: " + volume * 100 + "%;margin-left: 5px;position: relative;z-index: 2;");
if (this.Module.AL && this.Module.AL.currentCtx && this.Module.AL.currentCtx.sources) {
this.Module.AL.currentCtx.sources.forEach(e => {
e.gain.gain.value = volume;
@@ -1795,7 +2082,7 @@ class EmulatorJS {
muteButton.style.display = (volume === 0) ? "none" : "";
}
}
-
+
this.addEventListener(volumeSlider, "change mousemove touchmove mousedown touchstart mouseup", (e) => {
setTimeout(() => {
const newVal = parseFloat(volumeSlider.value);
@@ -1811,21 +2098,21 @@ class EmulatorJS {
this.elements.menu.appendChild(volumeSettings);
- const contextMenuButton = addButton("Context Menu", '', () => {
+ const contextMenuButton = addButton(this.config.buttonOpts.contextMenu, () => {
if (this.elements.contextmenu.style.display === "none") {
this.elements.contextmenu.style.display = "block";
- this.elements.contextmenu.style.left = (getComputedStyle(this.elements.parent).width.split("px")[0]/2 - getComputedStyle(this.elements.contextmenu).width.split("px")[0]/2)+"px";
- this.elements.contextmenu.style.top = (getComputedStyle(this.elements.parent).height.split("px")[0]/2 - getComputedStyle(this.elements.contextmenu).height.split("px")[0]/2)+"px";
+ this.elements.contextmenu.style.left = (getComputedStyle(this.elements.parent).width.split("px")[0] / 2 - getComputedStyle(this.elements.contextmenu).width.split("px")[0] / 2) + "px";
+ this.elements.contextmenu.style.top = (getComputedStyle(this.elements.parent).height.split("px")[0] / 2 - getComputedStyle(this.elements.contextmenu).height.split("px")[0] / 2) + "px";
setTimeout(this.menu.close.bind(this), 20);
} else {
this.elements.contextmenu.style.display = "none";
}
});
-
+
this.diskParent = this.createElement("div");
this.diskParent.id = "ejs_disksMenu";
this.disksMenuOpen = false;
- const diskButton = addButton("Disks", '', () => {
+ const diskButton = addButton(this.config.buttonOpts.diskButton, () => {
this.disksMenuOpen = !this.disksMenuOpen;
diskButton[1].classList.toggle("ejs_svg_rotate", this.disksMenuOpen);
this.disksMenu.style.display = this.disksMenuOpen ? "" : "none";
@@ -1848,7 +2135,7 @@ class EmulatorJS {
this.settingParent = this.createElement("div");
this.settingsMenuOpen = false;
- const settingButton = addButton("Settings", '', () => {
+ const settingButton = addButton(this.config.buttonOpts.settings, () => {
this.settingsMenuOpen = !this.settingsMenuOpen;
settingButton[1].classList.toggle("ejs_svg_rotate", this.settingsMenuOpen);
this.settingsMenu.style.display = this.settingsMenuOpen ? "" : "none";
@@ -1871,7 +2158,7 @@ class EmulatorJS {
this.addEventListener(this.canvas, "click", (e) => {
if (e.pointerType === "touch") return;
- if (this.defaultCoreOpts.supportsMouse && !this.paused) {
+ if (this.enableMouseLock && !this.paused) {
if (this.canvas.requestPointerLock) {
this.canvas.requestPointerLock();
} else if (this.canvas.mozRequestPointerLock) {
@@ -1880,15 +2167,15 @@ class EmulatorJS {
this.menu.close();
}
})
-
- const enter = addButton("Enter Fullscreen", '', () => {
+
+ const enter = addButton(this.config.buttonOpts.enterFullscreen, () => {
this.toggleFullscreen(true);
});
- const exit = addButton("Exit Fullscreen", '', () => {
+ const exit = addButton(this.config.buttonOpts.exitFullscreen, () => {
this.toggleFullscreen(false);
});
exit.style.display = "none";
-
+
this.toggleFullscreen = (fullscreen) => {
if (fullscreen) {
if (this.elements.parent.requestFullscreen) {
@@ -1928,7 +2215,7 @@ class EmulatorJS {
}
let exitMenuIsOpen = false;
- const exitEmulation = addButton("Exit EmulatorJS", '', async () => {
+ const exitEmulation = addButton(this.config.buttonOpts.exitEmulation, async () => {
if (exitMenuIsOpen) return;
exitMenuIsOpen = true;
const popups = this.createSubPopup();
@@ -1981,8 +2268,7 @@ class EmulatorJS {
})
setTimeout(this.menu.close.bind(this), 20);
});
-
-
+
this.addEventListener(document, "webkitfullscreenchange mozfullscreenchange fullscreenchange", (e) => {
if (e.target !== this.elements.parent) return;
if (document.fullscreenElement === null) {
@@ -1994,14 +2280,14 @@ class EmulatorJS {
enter.style.display = "none";
}
})
-
+
const hasFullscreen = !!(this.elements.parent.requestFullscreen || this.elements.parent.mozRequestFullScreen || this.elements.parent.webkitRequestFullscreen || this.elements.parent.msRequestFullscreen);
-
+
if (!hasFullscreen) {
exit.style.display = "none";
enter.style.display = "none";
}
-
+
this.elements.bottomBar = {
playPause: [pauseButton, playButton],
restart: [restartButton],
@@ -2018,36 +2304,35 @@ class EmulatorJS {
netplay: [netplay],
exit: [exitEmulation]
}
-
-
+
if (this.config.buttonOpts) {
if (this.debug) console.log(this.config.buttonOpts);
- if (this.config.buttonOpts.playPause === false) {
+ if (this.config.buttonOpts.playPause.visible === false) {
pauseButton.style.display = "none";
playButton.style.display = "none";
}
- if (this.config.buttonOpts.contextMenuButton === false && this.config.buttonOpts.rightClick !== false && this.isMobile === false) contextMenuButton.style.display = "none"
- if (this.config.buttonOpts.restart === false) restartButton.style.display = "none"
- if (this.config.buttonOpts.settings === false) settingButton[0].style.display = "none"
- if (this.config.buttonOpts.fullscreen === false) {
+ if (this.config.buttonOpts.contextMenu.visible === false && this.config.buttonOpts.rightClick !== false && this.isMobile === false) contextMenuButton.style.display = "none"
+ if (this.config.buttonOpts.restart.visible === false) restartButton.style.display = "none"
+ if (this.config.buttonOpts.settings.visible === false) settingButton[0].style.display = "none"
+ if (this.config.buttonOpts.fullscreen.visible === false) {
enter.style.display = "none";
exit.style.display = "none";
}
- if (this.config.buttonOpts.mute === false) {
+ if (this.config.buttonOpts.mute.visible === false) {
muteButton.style.display = "none";
unmuteButton.style.display = "none";
}
- if (this.config.buttonOpts.saveState === false) saveState.style.display = "none";
- if (this.config.buttonOpts.loadState === false) loadState.style.display = "none";
- if (this.config.buttonOpts.saveSavFiles === false) saveSavFiles.style.display = "none";
- if (this.config.buttonOpts.loadSavFiles === false) loadSavFiles.style.display = "none";
- if (this.config.buttonOpts.gamepad === false) controlMenu.style.display = "none";
- if (this.config.buttonOpts.cheat === false) cheatMenu.style.display = "none";
- if (this.config.buttonOpts.cacheManager === false) cache.style.display = "none";
- if (this.config.buttonOpts.netplay === false) netplay.style.display = "none";
- if (this.config.buttonOpts.diskButton === false) diskButton[0].style.display = "none";
- if (this.config.buttonOpts.volumeSlider === false) volumeSlider.style.display = "none";
- if (this.config.buttonOpts.exitEmulation === false) exitEmulation.style.display = "none";
+ if (this.config.buttonOpts.saveState.visible === false) saveState.style.display = "none";
+ if (this.config.buttonOpts.loadState.visible === false) loadState.style.display = "none";
+ if (this.config.buttonOpts.saveSavFiles.visible === false) saveSavFiles.style.display = "none";
+ if (this.config.buttonOpts.loadSavFiles.visible === false) loadSavFiles.style.display = "none";
+ if (this.config.buttonOpts.gamepad.visible === false) controlMenu.style.display = "none";
+ if (this.config.buttonOpts.cheat.visible === false) cheatMenu.style.display = "none";
+ if (this.config.buttonOpts.cacheManager.visible === false) cache.style.display = "none";
+ if (this.config.buttonOpts.netplay.visible === false) netplay.style.display = "none";
+ if (this.config.buttonOpts.diskButton.visible === false) diskButton[0].style.display = "none";
+ if (this.config.buttonOpts.volumeSlider.visible === false) volumeSlider.style.display = "none";
+ if (this.config.buttonOpts.exitEmulation.visible === false) exitEmulation.style.display = "none";
}
this.menu.failedToStart = () => {
@@ -2078,6 +2363,9 @@ class EmulatorJS {
exitEmulation.style.display = "none";
this.elements.menu.style.opacity = "";
+ this.elements.menu.style.background = "transparent";
+ this.virtualGamepad.style.display = "none";
+ settingButton[0].classList.add("shadow");
this.menu.open(true);
}
}
@@ -2103,12 +2391,12 @@ class EmulatorJS {
list.style["text-align"] = "left";
body.appendChild(list);
list.appendChild(tbody);
- const getSize = function(size) {
+ const getSize = function (size) {
let i = -1;
do {
size /= 1024, i++;
} while (size > 1024);
- return Math.max(size, 0.1).toFixed(1) + [' kB', ' MB', ' GB', ' TB', 'PB', 'EB', 'ZB', 'YB'][i];
+ return Math.max(size, 0.1).toFixed(1) + [" kB", " MB", " GB", " TB", "PB", "EB", "ZB", "YB"][i];
}
for (const k in roms) {
const line = this.createElement("tr");
@@ -2118,7 +2406,7 @@ class EmulatorJS {
remove.style.cursor = "pointer";
name.innerText = k;
size.innerText = getSize(roms[k]);
-
+
const a = this.createElement("a");
a.innerText = this.localization("Remove");
this.addEventListener(remove, "click", () => {
@@ -2126,17 +2414,16 @@ class EmulatorJS {
line.remove();
})
remove.appendChild(a);
-
+
line.appendChild(name);
line.appendChild(size);
line.appendChild(remove);
tbody.appendChild(line);
}
-
})();
}
getControlScheme() {
- if (this.config.controlScheme && typeof this.config.controlScheme === 'string') {
+ if (this.config.controlScheme && typeof this.config.controlScheme === "string") {
return this.config.controlScheme;
} else {
return this.getCore(true);
@@ -2146,6 +2433,7 @@ class EmulatorJS {
let buttonListeners = [];
this.checkGamepadInputs = () => buttonListeners.forEach(elem => elem());
this.gamepadLabels = [];
+ this.gamepadSelection = [];
this.controls = JSON.parse(JSON.stringify(this.defaultControllers));
const body = this.createPopup("Control Settings", {
"Reset": () => {
@@ -2155,7 +2443,7 @@ class EmulatorJS {
this.saveSettings();
},
"Clear": () => {
- this.controls = {0:{},1:{},2:{},3:{}};
+ this.controls = { 0: {}, 1: {}, 2: {}, 3: {} };
this.setupKeys();
this.checkGamepadInputs();
this.saveSettings();
@@ -2167,351 +2455,374 @@ class EmulatorJS {
this.setupKeys();
this.controlMenu = body.parentElement;
body.classList.add("ejs_control_body");
-
+
let buttons;
if ("gb" === this.getControlScheme()) {
buttons = [
- {id: 8, label: this.localization('A')},
- {id: 0, label: this.localization('B')},
- {id: 2, label: this.localization('SELECT')},
- {id: 3, label: this.localization('START')},
- {id: 4, label: this.localization('UP')},
- {id: 5, label: this.localization('DOWN')},
- {id: 6, label: this.localization('LEFT')},
- {id: 7, label: this.localization('RIGHT')},
+ { id: 8, label: this.localization("A") },
+ { id: 0, label: this.localization("B") },
+ { id: 2, label: this.localization("SELECT") },
+ { id: 3, label: this.localization("START") },
+ { id: 4, label: this.localization("UP") },
+ { id: 5, label: this.localization("DOWN") },
+ { id: 6, label: this.localization("LEFT") },
+ { id: 7, label: this.localization("RIGHT") },
];
} else if ("nes" === this.getControlScheme()) {
buttons = [
- {id: 8, label: this.localization('A')},
- {id: 0, label: this.localization('B')},
- {id: 2, label: this.localization('SELECT')},
- {id: 3, label: this.localization('START')},
- {id: 4, label: this.localization('UP')},
- {id: 5, label: this.localization('DOWN')},
- {id: 6, label: this.localization('LEFT')},
- {id: 7, label: this.localization('RIGHT')},
- {id: 10, label: this.localization('EJECT')},//Famicon games only
- {id: 11, label: this.localization('SWAP DISKS')},
+ { id: 8, label: this.localization("A") },
+ { id: 0, label: this.localization("B") },
+ { id: 2, label: this.localization("SELECT") },
+ { id: 3, label: this.localization("START") },
+ { id: 4, label: this.localization("UP") },
+ { id: 5, label: this.localization("DOWN") },
+ { id: 6, label: this.localization("LEFT") },
+ { id: 7, label: this.localization("RIGHT") },
];
- } else if ('snes' === this.getControlScheme()) {
+ if (this.getCore() === "nestopia") {
+ buttons.push({ id: 10, label: this.localization("SWAP DISKS") });
+ } else {
+ buttons.push({ id: 10, label: this.localization("SWAP DISKS") });
+ buttons.push({ id: 11, label: this.localization("EJECT/INSERT DISK") });
+ }
+ } else if ("snes" === this.getControlScheme()) {
+ buttons = [
+ { id: 8, label: this.localization("A") },
+ { id: 0, label: this.localization("B") },
+ { id: 9, label: this.localization("X") },
+ { id: 1, label: this.localization("Y") },
+ { id: 2, label: this.localization("SELECT") },
+ { id: 3, label: this.localization("START") },
+ { id: 4, label: this.localization("UP") },
+ { id: 5, label: this.localization("DOWN") },
+ { id: 6, label: this.localization("LEFT") },
+ { id: 7, label: this.localization("RIGHT") },
+ { id: 10, label: this.localization("L") },
+ { id: 11, label: this.localization("R") },
+ ];
+ } else if ("n64" === this.getControlScheme()) {
buttons = [
- {id: 8, label: this.localization('A')},
- {id: 0, label: this.localization('B')},
- {id: 9, label: this.localization('X')},
- {id: 1, label: this.localization('Y')},
- {id: 2, label: this.localization('SELECT')},
- {id: 3, label: this.localization('START')},
- {id: 4, label: this.localization('UP')},
- {id: 5, label: this.localization('DOWN')},
- {id: 6, label: this.localization('LEFT')},
- {id: 7, label: this.localization('RIGHT')},
- {id: 10, label: this.localization('L')},
- {id: 11, label: this.localization('R')},
+ { id: 0, label: this.localization("A") },
+ { id: 1, label: this.localization("B") },
+ { id: 3, label: this.localization("START") },
+ { id: 4, label: this.localization("D-PAD UP") },
+ { id: 5, label: this.localization("D-PAD DOWN") },
+ { id: 6, label: this.localization("D-PAD LEFT") },
+ { id: 7, label: this.localization("D-PAD RIGHT") },
+ { id: 10, label: this.localization("L") },
+ { id: 11, label: this.localization("R") },
+ { id: 12, label: this.localization("Z") },
+ { id: 19, label: this.localization("STICK UP") },
+ { id: 18, label: this.localization("STICK DOWN") },
+ { id: 17, label: this.localization("STICK LEFT") },
+ { id: 16, label: this.localization("STICK RIGHT") },
+ { id: 23, label: this.localization("C-PAD UP") },
+ { id: 22, label: this.localization("C-PAD DOWN") },
+ { id: 21, label: this.localization("C-PAD LEFT") },
+ { id: 20, label: this.localization("C-PAD RIGHT") },
];
- } else if ('n64' === this.getControlScheme()) {
+ } else if ("gba" === this.getControlScheme()) {
buttons = [
- {id: 0, label: this.localization('A')},
- {id: 1, label: this.localization('B')},
- {id: 3, label: this.localization('START')},
- {id: 4, label: this.localization('D-PAD UP')},
- {id: 5, label: this.localization('D-PAD DOWN')},
- {id: 6, label: this.localization('D-PAD LEFT')},
- {id: 7, label: this.localization('D-PAD RIGHT')},
- {id: 10, label: this.localization('L')},
- {id: 11, label: this.localization('R')},
- {id: 12, label: this.localization('Z')},
- {id: 19, label: this.localization('STICK UP')},
- {id: 18, label: this.localization('STICK DOWN')},
- {id: 17, label: this.localization('STICK LEFT')},
- {id: 16, label: this.localization('STICK RIGHT')},
- {id: 23, label: this.localization('C-PAD UP')},
- {id: 22, label: this.localization('C-PAD DOWN')},
- {id: 21, label: this.localization('C-PAD LEFT')},
- {id: 20, label: this.localization('C-PAD RIGHT')},
+ { id: 8, label: this.localization("A") },
+ { id: 0, label: this.localization("B") },
+ { id: 10, label: this.localization("L") },
+ { id: 11, label: this.localization("R") },
+ { id: 2, label: this.localization("SELECT") },
+ { id: 3, label: this.localization("START") },
+ { id: 4, label: this.localization("UP") },
+ { id: 5, label: this.localization("DOWN") },
+ { id: 6, label: this.localization("LEFT") },
+ { id: 7, label: this.localization("RIGHT") },
];
- } else if ('gba' === this.getControlScheme()) {
+ } else if ("nds" === this.getControlScheme()) {
buttons = [
- {id: 8, label: this.localization('A')},
- {id: 0, label: this.localization('B')},
- {id: 10, label: this.localization('L')},
- {id: 11, label: this.localization('R')},
- {id: 2, label: this.localization('SELECT')},
- {id: 3, label: this.localization('START')},
- {id: 4, label: this.localization('UP')},
- {id: 5, label: this.localization('DOWN')},
- {id: 6, label: this.localization('LEFT')},
- {id: 7, label: this.localization('RIGHT')},
+ { id: 8, label: this.localization("A") },
+ { id: 0, label: this.localization("B") },
+ { id: 9, label: this.localization("X") },
+ { id: 1, label: this.localization("Y") },
+ { id: 2, label: this.localization("SELECT") },
+ { id: 3, label: this.localization("START") },
+ { id: 4, label: this.localization("UP") },
+ { id: 5, label: this.localization("DOWN") },
+ { id: 6, label: this.localization("LEFT") },
+ { id: 7, label: this.localization("RIGHT") },
+ { id: 10, label: this.localization("L") },
+ { id: 11, label: this.localization("R") },
+ { id: 14, label: this.localization("Microphone") },
];
- } else if ('nds' === this.getControlScheme()) {
+ } else if ("vb" === this.getControlScheme()) {
buttons = [
- {id: 8, label: this.localization('A')},
- {id: 0, label: this.localization('B')},
- {id: 9, label: this.localization('X')},
- {id: 1, label: this.localization('Y')},
- {id: 2, label: this.localization('SELECT')},
- {id: 3, label: this.localization('START')},
- {id: 4, label: this.localization('UP')},
- {id: 5, label: this.localization('DOWN')},
- {id: 6, label: this.localization('LEFT')},
- {id: 7, label: this.localization('RIGHT')},
- {id: 10, label: this.localization('L')},
- {id: 11, label: this.localization('R')},
- {id: 14, label: this.localization('Microphone')},
+ { id: 8, label: this.localization("A") },
+ { id: 0, label: this.localization("B") },
+ { id: 10, label: this.localization("L") },
+ { id: 11, label: this.localization("R") },
+ { id: 2, label: this.localization("SELECT") },
+ { id: 3, label: this.localization("START") },
+ { id: 4, label: this.localization("LEFT D-PAD UP") },
+ { id: 5, label: this.localization("LEFT D-PAD DOWN") },
+ { id: 6, label: this.localization("LEFT D-PAD LEFT") },
+ { id: 7, label: this.localization("LEFT D-PAD RIGHT") },
+ { id: 19, label: this.localization("RIGHT D-PAD UP") },
+ { id: 18, label: this.localization("RIGHT D-PAD DOWN") },
+ { id: 17, label: this.localization("RIGHT D-PAD LEFT") },
+ { id: 16, label: this.localization("RIGHT D-PAD RIGHT") },
];
- } else if ('vb' === this.getControlScheme()) {
+ } else if (["segaCD", "sega32x"].includes(this.getControlScheme())) {
buttons = [
- {id: 8, label: this.localization('A')},
- {id: 0, label: this.localization('B')},
- {id: 10, label: this.localization('L')},
- {id: 11, label: this.localization('R')},
- {id: 2, label: this.localization('SELECT')},
- {id: 3, label: this.localization('START')},
- {id: 4, label: this.localization('LEFT D-PAD UP')},
- {id: 5, label: this.localization('LEFT D-PAD DOWN')},
- {id: 6, label: this.localization('LEFT D-PAD LEFT')},
- {id: 7, label: this.localization('LEFT D-PAD RIGHT')},
- {id: 19, label: this.localization('RIGHT D-PAD UP')},
- {id: 18, label: this.localization('RIGHT D-PAD DOWN')},
- {id: 17, label: this.localization('RIGHT D-PAD LEFT')},
- {id: 16, label: this.localization('RIGHT D-PAD RIGHT')},
+ { id: 1, label: this.localization("A") },
+ { id: 0, label: this.localization("B") },
+ { id: 8, label: this.localization("C") },
+ { id: 10, label: this.localization("X") },
+ { id: 9, label: this.localization("Y") },
+ { id: 11, label: this.localization("Z") },
+ { id: 3, label: this.localization("START") },
+ { id: 2, label: this.localization("MODE") },
+ { id: 4, label: this.localization("UP") },
+ { id: 5, label: this.localization("DOWN") },
+ { id: 6, label: this.localization("LEFT") },
+ { id: 7, label: this.localization("RIGHT") },
];
- } else if (['segaMD', 'segaCD', 'sega32x'].includes(this.getControlScheme())) {
+ } else if ("segaMS" === this.getControlScheme()) {
buttons = [
- {id: 1, label: this.localization('A')},
- {id: 0, label: this.localization('B')},
- {id: 8, label: this.localization('C')},
- {id: 10, label: this.localization('X')},
- {id: 9, label: this.localization('Y')},
- {id: 11, label: this.localization('Z')},
- {id: 3, label: this.localization('START')},
- {id: 2, label: this.localization('MODE')},
- {id: 4, label: this.localization('UP')},
- {id: 5, label: this.localization('DOWN')},
- {id: 6, label: this.localization('LEFT')},
- {id: 7, label: this.localization('RIGHT')},
+ { id: 0, label: this.localization("BUTTON 1 / START") },
+ { id: 8, label: this.localization("BUTTON 2") },
+ { id: 4, label: this.localization("UP") },
+ { id: 5, label: this.localization("DOWN") },
+ { id: 6, label: this.localization("LEFT") },
+ { id: 7, label: this.localization("RIGHT") },
];
- } else if ('segaMS' === this.getControlScheme()) {
+ } else if ("segaGG" === this.getControlScheme()) {
buttons = [
- {id: 0, label: this.localization('BUTTON 1 / START')},
- {id: 8, label: this.localization('BUTTON 2')},
- {id: 4, label: this.localization('UP')},
- {id: 5, label: this.localization('DOWN')},
- {id: 6, label: this.localization('LEFT')},
- {id: 7, label: this.localization('RIGHT')},
+ { id: 0, label: this.localization("BUTTON 1") },
+ { id: 8, label: this.localization("BUTTON 2") },
+ { id: 3, label: this.localization("START") },
+ { id: 4, label: this.localization("UP") },
+ { id: 5, label: this.localization("DOWN") },
+ { id: 6, label: this.localization("LEFT") },
+ { id: 7, label: this.localization("RIGHT") },
];
- } else if ('segaGG' === this.getControlScheme()) {
+ } else if ("segaSaturn" === this.getControlScheme()) {
buttons = [
- {id: 0, label: this.localization('BUTTON 1')},
- {id: 8, label: this.localization('BUTTON 2')},
- {id: 3, label: this.localization('START')},
- {id: 4, label: this.localization('UP')},
- {id: 5, label: this.localization('DOWN')},
- {id: 6, label: this.localization('LEFT')},
- {id: 7, label: this.localization('RIGHT')},
+ { id: 1, label: this.localization("A") },
+ { id: 0, label: this.localization("B") },
+ { id: 8, label: this.localization("C") },
+ { id: 9, label: this.localization("X") },
+ { id: 10, label: this.localization("Y") },
+ { id: 11, label: this.localization("Z") },
+ { id: 12, label: this.localization("L") },
+ { id: 13, label: this.localization("R") },
+ { id: 3, label: this.localization("START") },
+ { id: 4, label: this.localization("UP") },
+ { id: 5, label: this.localization("DOWN") },
+ { id: 6, label: this.localization("LEFT") },
+ { id: 7, label: this.localization("RIGHT") },
];
- } else if ('segaSaturn' === this.getControlScheme()) {
+ } else if ("3do" === this.getControlScheme()) {
buttons = [
- {id: 1, label: this.localization('A')},
- {id: 0, label: this.localization('B')},
- {id: 8, label: this.localization('C')},
- {id: 9, label: this.localization('X')},
- {id: 10, label: this.localization('Y')},
- {id: 11, label: this.localization('Z')},
- {id: 12, label: this.localization('L')},
- {id: 13, label: this.localization('R')},
- {id: 3, label: this.localization('START')},
- {id: 4, label: this.localization('UP')},
- {id: 5, label: this.localization('DOWN')},
- {id: 6, label: this.localization('LEFT')},
- {id: 7, label: this.localization('RIGHT')},
+ { id: 1, label: this.localization("A") },
+ { id: 0, label: this.localization("B") },
+ { id: 8, label: this.localization("C") },
+ { id: 10, label: this.localization("L") },
+ { id: 11, label: this.localization("R") },
+ { id: 2, label: this.localization("X") },
+ { id: 3, label: this.localization("P") },
+ { id: 4, label: this.localization("UP") },
+ { id: 5, label: this.localization("DOWN") },
+ { id: 6, label: this.localization("LEFT") },
+ { id: 7, label: this.localization("RIGHT") },
];
- } else if ('3do' === this.getControlScheme()) {
+ } else if ("atari2600" === this.getControlScheme()) {
buttons = [
- {id: 1, label: this.localization('A')},
- {id: 0, label: this.localization('B')},
- {id: 8, label: this.localization('C')},
- {id: 10, label: this.localization('L')},
- {id: 11, label: this.localization('R')},
- {id: 2, label: this.localization('X')},
- {id: 3, label: this.localization('P')},
- {id: 4, label: this.localization('UP')},
- {id: 5, label: this.localization('DOWN')},
- {id: 6, label: this.localization('LEFT')},
- {id: 7, label: this.localization('RIGHT')},
+ { id: 0, label: this.localization("FIRE") },
+ { id: 2, label: this.localization("SELECT") },
+ { id: 3, label: this.localization("RESET") },
+ { id: 4, label: this.localization("UP") },
+ { id: 5, label: this.localization("DOWN") },
+ { id: 6, label: this.localization("LEFT") },
+ { id: 7, label: this.localization("RIGHT") },
+ { id: 10, label: this.localization("LEFT DIFFICULTY A") },
+ { id: 12, label: this.localization("LEFT DIFFICULTY B") },
+ { id: 11, label: this.localization("RIGHT DIFFICULTY A") },
+ { id: 13, label: this.localization("RIGHT DIFFICULTY B") },
+ { id: 14, label: this.localization("COLOR") },
+ { id: 15, label: this.localization("B/W") },
];
- } else if ('atari2600' === this.getControlScheme()) {
+ } else if ("atari7800" === this.getControlScheme()) {
buttons = [
- {id: 0, label: this.localization('FIRE')},
- {id: 2, label: this.localization('SELECT')},
- {id: 3, label: this.localization('RESET')},
- {id: 4, label: this.localization('UP')},
- {id: 5, label: this.localization('DOWN')},
- {id: 6, label: this.localization('LEFT')},
- {id: 7, label: this.localization('RIGHT')},
- {id: 10, label: this.localization('LEFT DIFFICULTY A')},
- {id: 12, label: this.localization('LEFT DIFFICULTY B')},
- {id: 11, label: this.localization('RIGHT DIFFICULTY A')},
- {id: 13, label: this.localization('RIGHT DIFFICULTY B')},
- {id: 14, label: this.localization('COLOR')},
- {id: 15, label: this.localization('B/W')},
+ { id: 0, label: this.localization("BUTTON 1") },
+ { id: 8, label: this.localization("BUTTON 2") },
+ { id: 2, label: this.localization("SELECT") },
+ { id: 3, label: this.localization("PAUSE") },
+ { id: 9, label: this.localization("RESET") },
+ { id: 4, label: this.localization("UP") },
+ { id: 5, label: this.localization("DOWN") },
+ { id: 6, label: this.localization("LEFT") },
+ { id: 7, label: this.localization("RIGHT") },
+ { id: 10, label: this.localization("LEFT DIFFICULTY") },
+ { id: 11, label: this.localization("RIGHT DIFFICULTY") },
];
- } else if ('atari7800' === this.getControlScheme()) {
+ } else if ("lynx" === this.getControlScheme()) {
buttons = [
- {id: 0, label: this.localization('BUTTON 1')},
- {id: 8, label: this.localization('BUTTON 2')},
- {id: 2, label: this.localization('SELECT')},
- {id: 3, label: this.localization('PAUSE')},
- {id: 9, label: this.localization('RESET')},
- {id: 4, label: this.localization('UP')},
- {id: 5, label: this.localization('DOWN')},
- {id: 6, label: this.localization('LEFT')},
- {id: 7, label: this.localization('RIGHT')},
- {id: 10, label: this.localization('LEFT DIFFICULTY')},
- {id: 11, label: this.localization('RIGHT DIFFICULTY')},
+ { id: 8, label: this.localization("A") },
+ { id: 0, label: this.localization("B") },
+ { id: 10, label: this.localization("OPTION 1") },
+ { id: 11, label: this.localization("OPTION 2") },
+ { id: 3, label: this.localization("START") },
+ { id: 4, label: this.localization("UP") },
+ { id: 5, label: this.localization("DOWN") },
+ { id: 6, label: this.localization("LEFT") },
+ { id: 7, label: this.localization("RIGHT") },
];
- } else if ('lynx' === this.getControlScheme()) {
+ } else if ("jaguar" === this.getControlScheme()) {
buttons = [
- {id: 8, label: this.localization('A')},
- {id: 0, label: this.localization('B')},
- {id: 10, label: this.localization('OPTION 1')},
- {id: 11, label: this.localization('OPTION 2')},
- {id: 3, label: this.localization('START')},
- {id: 4, label: this.localization('UP')},
- {id: 5, label: this.localization('DOWN')},
- {id: 6, label: this.localization('LEFT')},
- {id: 7, label: this.localization('RIGHT')},
+ { id: 8, label: this.localization("A") },
+ { id: 0, label: this.localization("B") },
+ { id: 1, label: this.localization("C") },
+ { id: 2, label: this.localization("PAUSE") },
+ { id: 3, label: this.localization("OPTION") },
+ { id: 4, label: this.localization("UP") },
+ { id: 5, label: this.localization("DOWN") },
+ { id: 6, label: this.localization("LEFT") },
+ { id: 7, label: this.localization("RIGHT") },
];
- } else if ('jaguar' === this.getControlScheme()) {
+ } else if ("pce" === this.getControlScheme()) {
buttons = [
- {id: 8, label: this.localization('A')},
- {id: 0, label: this.localization('B')},
- {id: 1, label: this.localization('C')},
- {id: 2, label: this.localization('PAUSE')},
- {id: 3, label: this.localization('OPTION')},
- {id: 4, label: this.localization('UP')},
- {id: 5, label: this.localization('DOWN')},
- {id: 6, label: this.localization('LEFT')},
- {id: 7, label: this.localization('RIGHT')},
+ { id: 8, label: this.localization("I") },
+ { id: 0, label: this.localization("II") },
+ { id: 2, label: this.localization("SELECT") },
+ { id: 3, label: this.localization("RUN") },
+ { id: 4, label: this.localization("UP") },
+ { id: 5, label: this.localization("DOWN") },
+ { id: 6, label: this.localization("LEFT") },
+ { id: 7, label: this.localization("RIGHT") },
];
- } else if ('pce' === this.getControlScheme()) {
+ } else if ("ngp" === this.getControlScheme()) {
buttons = [
- {id: 8, label: this.localization('I')},
- {id: 0, label: this.localization('II')},
- {id: 2, label: this.localization('SELECT')},
- {id: 3, label: this.localization('RUN')},
- {id: 4, label: this.localization('UP')},
- {id: 5, label: this.localization('DOWN')},
- {id: 6, label: this.localization('LEFT')},
- {id: 7, label: this.localization('RIGHT')},
+ { id: 0, label: this.localization("A") },
+ { id: 8, label: this.localization("B") },
+ { id: 3, label: this.localization("OPTION") },
+ { id: 4, label: this.localization("UP") },
+ { id: 5, label: this.localization("DOWN") },
+ { id: 6, label: this.localization("LEFT") },
+ { id: 7, label: this.localization("RIGHT") },
];
- } else if ('ngp' === this.getControlScheme()) {
+ } else if ("ws" === this.getControlScheme()) {
buttons = [
- {id: 0, label: this.localization('A')},
- {id: 8, label: this.localization('B')},
- {id: 3, label: this.localization('OPTION')},
- {id: 4, label: this.localization('UP')},
- {id: 5, label: this.localization('DOWN')},
- {id: 6, label: this.localization('LEFT')},
- {id: 7, label: this.localization('RIGHT')},
+ { id: 8, label: this.localization("A") },
+ { id: 0, label: this.localization("B") },
+ { id: 3, label: this.localization("START") },
+ { id: 4, label: this.localization("X UP") },
+ { id: 5, label: this.localization("X DOWN") },
+ { id: 6, label: this.localization("X LEFT") },
+ { id: 7, label: this.localization("X RIGHT") },
+ { id: 13, label: this.localization("Y UP") },
+ { id: 12, label: this.localization("Y DOWN") },
+ { id: 10, label: this.localization("Y LEFT") },
+ { id: 11, label: this.localization("Y RIGHT") },
];
- } else if ('ws' === this.getControlScheme()) {
+ } else if ("coleco" === this.getControlScheme()) {
buttons = [
- {id: 8, label: this.localization('A')},
- {id: 0, label: this.localization('B')},
- {id: 3, label: this.localization('START')},
- {id: 4, label: this.localization('X UP')},
- {id: 5, label: this.localization('X DOWN')},
- {id: 6, label: this.localization('X LEFT')},
- {id: 7, label: this.localization('X RIGHT')},
- {id: 13, label: this.localization('Y UP')},
- {id: 12, label: this.localization('Y DOWN')},
- {id: 10, label: this.localization('Y LEFT')},
- {id: 11, label: this.localization('Y RIGHT')},
+ { id: 8, label: this.localization("LEFT BUTTON") },
+ { id: 0, label: this.localization("RIGHT BUTTON") },
+ { id: 9, label: this.localization("1") },
+ { id: 1, label: this.localization("2") },
+ { id: 11, label: this.localization("3") },
+ { id: 10, label: this.localization("4") },
+ { id: 13, label: this.localization("5") },
+ { id: 12, label: this.localization("6") },
+ { id: 15, label: this.localization("7") },
+ { id: 14, label: this.localization("8") },
+ { id: 2, label: this.localization("*") },
+ { id: 3, label: this.localization("#") },
+ { id: 4, label: this.localization("UP") },
+ { id: 5, label: this.localization("DOWN") },
+ { id: 6, label: this.localization("LEFT") },
+ { id: 7, label: this.localization("RIGHT") },
];
- } else if ('coleco' === this.getControlScheme()) {
+ } else if ("pcfx" === this.getControlScheme()) {
buttons = [
- {id: 8, label: this.localization('LEFT BUTTON')},
- {id: 0, label: this.localization('RIGHT BUTTON')},
- {id: 9, label: this.localization('1')},
- {id: 1, label: this.localization('2')},
- {id: 11, label: this.localization('3')},
- {id: 10, label: this.localization('4')},
- {id: 13, label: this.localization('5')},
- {id: 12, label: this.localization('6')},
- {id: 15, label: this.localization('7')},
- {id: 14, label: this.localization('8')},
- {id: 2, label: this.localization('*')},
- {id: 3, label: this.localization('#')},
- {id: 4, label: this.localization('UP')},
- {id: 5, label: this.localization('DOWN')},
- {id: 6, label: this.localization('LEFT')},
- {id: 7, label: this.localization('RIGHT')},
+ { id: 8, label: this.localization("I") },
+ { id: 0, label: this.localization("II") },
+ { id: 9, label: this.localization("III") },
+ { id: 1, label: this.localization("IV") },
+ { id: 10, label: this.localization("V") },
+ { id: 11, label: this.localization("VI") },
+ { id: 3, label: this.localization("RUN") },
+ { id: 2, label: this.localization("SELECT") },
+ { id: 12, label: this.localization("MODE1") },
+ { id: 13, label: this.localization("MODE2") },
+ { id: 4, label: this.localization("UP") },
+ { id: 5, label: this.localization("DOWN") },
+ { id: 6, label: this.localization("LEFT") },
+ { id: 7, label: this.localization("RIGHT") },
];
- } else if ('pcfx' === this.getControlScheme()) {
+ } else if ("psp" === this.getControlScheme()) {
buttons = [
- {id: 8, label: this.localization('I')},
- {id: 0, label: this.localization('II')},
- {id: 9, label: this.localization('III')},
- {id: 1, label: this.localization('IV')},
- {id: 10, label: this.localization('V')},
- {id: 11, label: this.localization('VI')},
- {id: 3, label: this.localization('RUN')},
- {id: 2, label: this.localization('SELECT')},
- {id: 12, label: this.localization('MODE1')},
- {id: 13, label: this.localization('MODE2')},
- {id: 4, label: this.localization('UP')},
- {id: 5, label: this.localization('DOWN')},
- {id: 6, label: this.localization('LEFT')},
- {id: 7, label: this.localization('RIGHT')},
+ { id: 9, label: this.localization("\u25B3") }, // △
+ { id: 1, label: this.localization("\u25A1") }, // □
+ { id: 0, label: this.localization("\uFF58") }, // x
+ { id: 8, label: this.localization("\u25CB") }, // ○
+ { id: 2, label: this.localization("SELECT") },
+ { id: 3, label: this.localization("START") },
+ { id: 4, label: this.localization("UP") },
+ { id: 5, label: this.localization("DOWN") },
+ { id: 6, label: this.localization("LEFT") },
+ { id: 7, label: this.localization("RIGHT") },
+ { id: 10, label: this.localization("L") },
+ { id: 11, label: this.localization("R") },
+ { id: 19, label: this.localization("STICK UP") },
+ { id: 18, label: this.localization("STICK DOWN") },
+ { id: 17, label: this.localization("STICK LEFT") },
+ { id: 16, label: this.localization("STICK RIGHT") },
];
} else {
buttons = [
- {id: 0, label: this.localization('B')},
- {id: 1, label: this.localization('Y')},
- {id: 2, label: this.localization('SELECT')},
- {id: 3, label: this.localization('START')},
- {id: 4, label: this.localization('UP')},
- {id: 5, label: this.localization('DOWN')},
- {id: 6, label: this.localization('LEFT')},
- {id: 7, label: this.localization('RIGHT')},
- {id: 8, label: this.localization('A')},
- {id: 9, label: this.localization('X')},
- {id: 10, label: this.localization('L')},
- {id: 11, label: this.localization('R')},
- {id: 12, label: this.localization('L2')},
- {id: 13, label: this.localization('R2')},
- {id: 14, label: this.localization('L3')},
- {id: 15, label: this.localization('R3')},
- {id: 19, label: this.localization('L STICK UP')},
- {id: 18, label: this.localization('L STICK DOWN')},
- {id: 17, label: this.localization('L STICK LEFT')},
- {id: 16, label: this.localization('L STICK RIGHT')},
- {id: 23, label: this.localization('R STICK UP')},
- {id: 22, label: this.localization('R STICK DOWN')},
- {id: 21, label: this.localization('R STICK LEFT')},
- {id: 20, label: this.localization('R STICK RIGHT')},
+ { id: 0, label: this.localization("B") },
+ { id: 1, label: this.localization("Y") },
+ { id: 2, label: this.localization("SELECT") },
+ { id: 3, label: this.localization("START") },
+ { id: 4, label: this.localization("UP") },
+ { id: 5, label: this.localization("DOWN") },
+ { id: 6, label: this.localization("LEFT") },
+ { id: 7, label: this.localization("RIGHT") },
+ { id: 8, label: this.localization("A") },
+ { id: 9, label: this.localization("X") },
+ { id: 10, label: this.localization("L") },
+ { id: 11, label: this.localization("R") },
+ { id: 12, label: this.localization("L2") },
+ { id: 13, label: this.localization("R2") },
+ { id: 14, label: this.localization("L3") },
+ { id: 15, label: this.localization("R3") },
+ { id: 19, label: this.localization("L STICK UP") },
+ { id: 18, label: this.localization("L STICK DOWN") },
+ { id: 17, label: this.localization("L STICK LEFT") },
+ { id: 16, label: this.localization("L STICK RIGHT") },
+ { id: 23, label: this.localization("R STICK UP") },
+ { id: 22, label: this.localization("R STICK DOWN") },
+ { id: 21, label: this.localization("R STICK LEFT") },
+ { id: 20, label: this.localization("R STICK RIGHT") },
];
}
- if (['arcade', 'mame'].includes(this.getControlScheme())) {
+ if (["arcade", "mame"].includes(this.getControlScheme())) {
for (const buttonIdx in buttons) {
if (buttons[buttonIdx].id === 2) {
- buttons[buttonIdx].label = this.localization('INSERT COIN');
+ buttons[buttonIdx].label = this.localization("INSERT COIN");
}
}
}
buttons.push(
- {id: 24, label: this.localization('QUICK SAVE STATE')},
- {id: 25, label: this.localization('QUICK LOAD STATE')},
- {id: 26, label: this.localization('CHANGE STATE SLOT')},
- {id: 27, label: this.localization('FAST FORWARD')},
- {id: 29, label: this.localization('SLOW MOTION')},
- {id: 28, label: this.localization('REWIND')}
+ { id: 24, label: this.localization("QUICK SAVE STATE") },
+ { id: 25, label: this.localization("QUICK LOAD STATE") },
+ { id: 26, label: this.localization("CHANGE STATE SLOT") },
+ { id: 27, label: this.localization("FAST FORWARD") },
+ { id: 29, label: this.localization("SLOW MOTION") },
+ { id: 28, label: this.localization("REWIND") }
);
let nums = [];
- for (let i=0; i {
e.preventDefault();
players[selectedPlayer].classList.remove("ejs_control_selected");
playerDivs[selectedPlayer].setAttribute("hidden", "");
- selectedPlayer = i-1;
- players[i-1].classList.add("ejs_control_selected");
- playerDivs[i-1].removeAttribute("hidden");
+ selectedPlayer = i - 1;
+ players[i - 1].classList.add("ejs_control_selected");
+ playerDivs[i - 1].removeAttribute("hidden");
})
playerContainer.appendChild(player);
playerSelect.appendChild(playerContainer);
players.push(playerContainer);
}
body.appendChild(playerSelect);
-
+
const controls = this.createElement("div");
- for (let i=0; i<4; i++) {
+ for (let i = 0; i < 4; i++) {
if (!this.controls[i]) this.controls[i] = {};
const player = this.createElement("div");
const playerTitle = this.createElement("div");
-
+
const gamepadTitle = this.createElement("div");
- gamepadTitle.style = "font-size:12px;";
- gamepadTitle.innerText = this.localization("Connected Gamepad")+": ";
-
- const gamepadName = this.createElement("span");
+ gamepadTitle.innerText = this.localization("Connected Gamepad") + ": ";
+
+ const gamepadName = this.createElement("select");
+ gamepadName.classList.add("ejs_gamepad_dropdown");
+ gamepadName.setAttribute("title", "gamepad-" + i);
+ gamepadName.setAttribute("index", i);
this.gamepadLabels.push(gamepadName);
- gamepadName.innerText = "n/a";
+ this.gamepadSelection.push("");
+ this.addEventListener(gamepadName, "change", e => {
+ const controller = e.target.value;
+ const player = parseInt(e.target.getAttribute("index"));
+ if (controller === "notconnected") {
+ this.gamepadSelection[player] = "";
+ } else {
+ for (let i = 0; i < this.gamepadSelection.length; i++) {
+ if (player === i) continue;
+ if (this.gamepadSelection[i] === controller) {
+ this.gamepadSelection[i] = "";
+ }
+ }
+ this.gamepadSelection[player] = controller;
+ this.updateGamepadLabels();
+ }
+ });
+ const def = this.createElement("option");
+ def.setAttribute("value", "notconnected");
+ def.innerText = "Not Connected";
+ gamepadName.appendChild(def);
gamepadTitle.appendChild(gamepadName);
-
+ gamepadTitle.classList.add("ejs_gamepad_section");
+
const leftPadding = this.createElement("div");
leftPadding.style = "width:25%;float:left;";
leftPadding.innerHTML = " ";
-
+
const aboutParent = this.createElement("div");
aboutParent.style = "font-size:12px;width:50%;float:left;";
const gamepad = this.createElement("div");
@@ -2588,15 +2922,15 @@ class EmulatorJS {
keyboard.style = "text-align:center;width:50%;float:left;";
keyboard.innerText = this.localization("Keyboard");
aboutParent.appendChild(keyboard);
-
+
const headingPadding = this.createElement("div");
headingPadding.style = "clear:both;";
-
+
playerTitle.appendChild(gamepadTitle);
playerTitle.appendChild(leftPadding);
playerTitle.appendChild(aboutParent);
-
- if ((this.touch || navigator.maxTouchPoints > 0) && i === 0) {
+
+ if ((this.touch || this.hasTouchScreen) && i === 0) {
const vgp = this.createElement("div");
vgp.style = "width:25%;float:right;clear:none;padding:0;font-size: 11px;padding-left: 2.25rem;";
vgp.classList.add("ejs_control_row");
@@ -2613,21 +2947,20 @@ class EmulatorJS {
vgp.appendChild(label);
label.addEventListener("click", (e) => {
input.checked = !input.checked;
- this.changeSettingOption('virtual-gamepad', input.checked ? 'enabled' : "disabled");
+ this.changeSettingOption("virtual-gamepad", input.checked ? "enabled" : "disabled");
})
this.on("start", (e) => {
- if (this.settings["virtual-gamepad"] === "disabled") {
+ if (this.getSettingValue("virtual-gamepad") === "disabled") {
input.checked = false;
}
})
playerTitle.appendChild(vgp);
}
-
+
playerTitle.appendChild(headingPadding);
-
-
+
player.appendChild(playerTitle);
-
+
for (const buttonIdx in buttons) {
const k = buttons[buttonIdx].id;
const controlLabel = buttons[buttonIdx].label;
@@ -2638,17 +2971,16 @@ class EmulatorJS {
buttonText.setAttribute("data-label", controlLabel);
buttonText.style = "margin-bottom:10px;";
buttonText.classList.add("ejs_control_bar");
-
-
+
const title = this.createElement("div");
title.style = "width:25%;float:left;font-size:12px;";
const label = this.createElement("label");
- label.innerText = controlLabel+":";
+ label.innerText = controlLabel + ":";
title.appendChild(label);
-
+
const textBoxes = this.createElement("div");
textBoxes.style = "width:50%;float:left;";
-
+
const textBox1Parent = this.createElement("div");
textBox1Parent.style = "width:50%;float:left;padding: 0 5px;";
const textBox1 = this.createElement("input");
@@ -2657,7 +2989,7 @@ class EmulatorJS {
textBox1.setAttribute("readonly", "");
textBox1.setAttribute("placeholder", "");
textBox1Parent.appendChild(textBox1);
-
+
const textBox2Parent = this.createElement("div");
textBox2Parent.style = "width:50%;float:left;padding: 0 5px;";
const textBox2 = this.createElement("input");
@@ -2666,7 +2998,7 @@ class EmulatorJS {
textBox2.setAttribute("readonly", "");
textBox2.setAttribute("placeholder", "");
textBox2Parent.appendChild(textBox2);
-
+
buttonListeners.push(() => {
textBox2.value = "";
textBox1.value = "";
@@ -2680,15 +3012,15 @@ class EmulatorJS {
if (value2.includes(":")) {
value2 = value2.split(":");
value2 = this.localization(value2[0]) + ":" + this.localization(value2[1])
- } else if (!isNaN(value2)){
- value2 = this.localization("BUTTON")+" "+this.localization(value2);
+ } else if (!isNaN(value2)) {
+ value2 = this.localization("BUTTON") + " " + this.localization(value2);
} else {
value2 = this.localization(value2);
}
textBox1.value = value2;
}
})
-
+
if (this.controls[i][k] && this.controls[i][k].value) {
let value = this.keyMap[this.controls[i][k].value];
value = this.localization(value);
@@ -2699,42 +3031,42 @@ class EmulatorJS {
if (value2.includes(":")) {
value2 = value2.split(":");
value2 = this.localization(value2[0]) + ":" + this.localization(value2[1])
- } else if (!isNaN(value2)){
- value2 = this.localization("BUTTON")+" "+this.localization(value2);
+ } else if (!isNaN(value2)) {
+ value2 = this.localization("BUTTON") + " " + this.localization(value2);
} else {
value2 = this.localization(value2);
}
textBox1.value = value2;
}
-
+
textBoxes.appendChild(textBox1Parent);
textBoxes.appendChild(textBox2Parent);
-
+
const padding = this.createElement("div");
padding.style = "clear:both;";
textBoxes.appendChild(padding);
-
+
const setButton = this.createElement("div");
setButton.style = "width:25%;float:left;";
const button = this.createElement("a");
button.classList.add("ejs_control_set_button");
button.innerText = this.localization("Set");
setButton.appendChild(button);
-
+
const padding2 = this.createElement("div");
padding2.style = "clear:both;";
-
+
buttonText.appendChild(title);
buttonText.appendChild(textBoxes);
buttonText.appendChild(setButton);
buttonText.appendChild(padding2);
-
+
player.appendChild(buttonText);
-
+
this.addEventListener(buttonText, "mousedown", (e) => {
e.preventDefault();
this.controlPopup.parentElement.parentElement.removeAttribute("hidden");
- this.controlPopup.innerText = "[ " + controlLabel + " ]\n"+this.localization("Press Keyboard");
+ this.controlPopup.innerText = "[ " + controlLabel + " ]\n" + this.localization("Press Keyboard");
this.controlPopup.setAttribute("button-num", k);
this.controlPopup.setAttribute("player-num", i);
})
@@ -2744,14 +3076,12 @@ class EmulatorJS {
playerDivs.push(player);
}
body.appendChild(controls);
-
-
+
selectedPlayer = 0;
players[0].classList.add("ejs_control_selected");
playerDivs[0].removeAttribute("hidden");
-
-
- const popup = this.createElement('div');
+
+ const popup = this.createElement("div");
popup.classList.add("ejs_popup_container");
const popupMsg = this.createElement("div");
this.addEventListener(popup, "mousedown click touchstart", (e) => {
@@ -2783,115 +3113,114 @@ class EmulatorJS {
popupMsg.appendChild(this.createElement("br"));
popupMsg.appendChild(btn);
this.controlMenu.appendChild(popup);
-
}
initControlVars() {
this.defaultControllers = {
0: {
0: {
- 'value': 'x',
- 'value2': 'BUTTON_2'
+ "value": "x",
+ "value2": "BUTTON_2"
},
1: {
- 'value': 's',
- 'value2': 'BUTTON_4'
+ "value": "s",
+ "value2": "BUTTON_4"
},
2: {
- 'value': 'v',
- 'value2': 'SELECT'
+ "value": "v",
+ "value2": "SELECT"
},
3: {
- 'value': 'enter',
- 'value2': 'START'
+ "value": "enter",
+ "value2": "START"
},
4: {
- 'value': 'up arrow',
- 'value2': 'DPAD_UP'
+ "value": "up arrow",
+ "value2": "DPAD_UP"
},
5: {
- 'value': 'down arrow',
- 'value2': 'DPAD_DOWN'
+ "value": "down arrow",
+ "value2": "DPAD_DOWN"
},
6: {
- 'value': 'left arrow',
- 'value2': 'DPAD_LEFT'
+ "value": "left arrow",
+ "value2": "DPAD_LEFT"
},
7: {
- 'value': 'right arrow',
- 'value2': 'DPAD_RIGHT'
+ "value": "right arrow",
+ "value2": "DPAD_RIGHT"
},
8: {
- 'value': 'z',
- 'value2': 'BUTTON_1'
+ "value": "z",
+ "value2": "BUTTON_1"
},
9: {
- 'value': 'a',
- 'value2': 'BUTTON_3'
+ "value": "a",
+ "value2": "BUTTON_3"
},
10: {
- 'value': 'q',
- 'value2': 'LEFT_TOP_SHOULDER'
+ "value": "q",
+ "value2": "LEFT_TOP_SHOULDER"
},
11: {
- 'value': 'e',
- 'value2': 'RIGHT_TOP_SHOULDER'
+ "value": "e",
+ "value2": "RIGHT_TOP_SHOULDER"
},
12: {
- 'value': 'tab',
- 'value2': 'LEFT_BOTTOM_SHOULDER'
+ "value": "tab",
+ "value2": "LEFT_BOTTOM_SHOULDER"
},
13: {
- 'value': 'r',
- 'value2': 'RIGHT_BOTTOM_SHOULDER'
+ "value": "r",
+ "value2": "RIGHT_BOTTOM_SHOULDER"
},
14: {
- 'value': '',
- 'value2': 'LEFT_STICK',
+ "value": "",
+ "value2": "LEFT_STICK",
},
15: {
- 'value': '',
- 'value2': 'RIGHT_STICK',
+ "value": "",
+ "value2": "RIGHT_STICK",
},
16: {
- 'value': 'h',
- 'value2': 'LEFT_STICK_X:+1'
+ "value": "h",
+ "value2": "LEFT_STICK_X:+1"
},
17: {
- 'value': 'f',
- 'value2': 'LEFT_STICK_X:-1'
+ "value": "f",
+ "value2": "LEFT_STICK_X:-1"
},
18: {
- 'value': 'g',
- 'value2': 'LEFT_STICK_Y:+1'
+ "value": "g",
+ "value2": "LEFT_STICK_Y:+1"
},
19: {
- 'value': 't',
- 'value2': 'LEFT_STICK_Y:-1'
+ "value": "t",
+ "value2": "LEFT_STICK_Y:-1"
},
20: {
- 'value': 'l',
- 'value2': 'RIGHT_STICK_X:+1'
+ "value": "l",
+ "value2": "RIGHT_STICK_X:+1"
},
21: {
- 'value': 'j',
- 'value2': 'RIGHT_STICK_X:-1'
+ "value": "j",
+ "value2": "RIGHT_STICK_X:-1"
},
22: {
- 'value': 'k',
- 'value2': 'RIGHT_STICK_Y:+1'
+ "value": "k",
+ "value2": "RIGHT_STICK_Y:+1"
},
23: {
- 'value': 'i',
- 'value2': 'RIGHT_STICK_Y:-1'
+ "value": "i",
+ "value2": "RIGHT_STICK_Y:-1"
},
24: {
- 'value': '1'
+ "value": "1"
},
25: {
- 'value': '2'
+ "value": "2"
},
26: {
- 'value': '3'
+ "value": "3"
},
27: {},
28: {},
@@ -2902,116 +3231,116 @@ class EmulatorJS {
3: {}
}
this.keyMap = {
- 0: '',
- 8: 'backspace',
- 9: 'tab',
- 13: 'enter',
- 16: 'shift',
- 17: 'ctrl',
- 18: 'alt',
- 19: 'pause/break',
- 20: 'caps lock',
- 27: 'escape',
- 32: 'space',
- 33: 'page up',
- 34: 'page down',
- 35: 'end',
- 36: 'home',
- 37: 'left arrow',
- 38: 'up arrow',
- 39: 'right arrow',
- 40: 'down arrow',
- 45: 'insert',
- 46: 'delete',
- 48: '0',
- 49: '1',
- 50: '2',
- 51: '3',
- 52: '4',
- 53: '5',
- 54: '6',
- 55: '7',
- 56: '8',
- 57: '9',
- 65: 'a',
- 66: 'b',
- 67: 'c',
- 68: 'd',
- 69: 'e',
- 70: 'f',
- 71: 'g',
- 72: 'h',
- 73: 'i',
- 74: 'j',
- 75: 'k',
- 76: 'l',
- 77: 'm',
- 78: 'n',
- 79: 'o',
- 80: 'p',
- 81: 'q',
- 82: 'r',
- 83: 's',
- 84: 't',
- 85: 'u',
- 86: 'v',
- 87: 'w',
- 88: 'x',
- 89: 'y',
- 90: 'z',
- 91: 'left window key',
- 92: 'right window key',
- 93: 'select key',
- 96: 'numpad 0',
- 97: 'numpad 1',
- 98: 'numpad 2',
- 99: 'numpad 3',
- 100: 'numpad 4',
- 101: 'numpad 5',
- 102: 'numpad 6',
- 103: 'numpad 7',
- 104: 'numpad 8',
- 105: 'numpad 9',
- 106: 'multiply',
- 107: 'add',
- 109: 'subtract',
- 110: 'decimal point',
- 111: 'divide',
- 112: 'f1',
- 113: 'f2',
- 114: 'f3',
- 115: 'f4',
- 116: 'f5',
- 117: 'f6',
- 118: 'f7',
- 119: 'f8',
- 120: 'f9',
- 121: 'f10',
- 122: 'f11',
- 123: 'f12',
- 144: 'num lock',
- 145: 'scroll lock',
- 186: 'semi-colon',
- 187: 'equal sign',
- 188: 'comma',
- 189: 'dash',
- 190: 'period',
- 191: 'forward slash',
- 192: 'grave accent',
- 219: 'open bracket',
- 220: 'back slash',
- 221: 'close braket',
- 222: 'single quote'
+ 0: "",
+ 8: "backspace",
+ 9: "tab",
+ 13: "enter",
+ 16: "shift",
+ 17: "ctrl",
+ 18: "alt",
+ 19: "pause/break",
+ 20: "caps lock",
+ 27: "escape",
+ 32: "space",
+ 33: "page up",
+ 34: "page down",
+ 35: "end",
+ 36: "home",
+ 37: "left arrow",
+ 38: "up arrow",
+ 39: "right arrow",
+ 40: "down arrow",
+ 45: "insert",
+ 46: "delete",
+ 48: "0",
+ 49: "1",
+ 50: "2",
+ 51: "3",
+ 52: "4",
+ 53: "5",
+ 54: "6",
+ 55: "7",
+ 56: "8",
+ 57: "9",
+ 65: "a",
+ 66: "b",
+ 67: "c",
+ 68: "d",
+ 69: "e",
+ 70: "f",
+ 71: "g",
+ 72: "h",
+ 73: "i",
+ 74: "j",
+ 75: "k",
+ 76: "l",
+ 77: "m",
+ 78: "n",
+ 79: "o",
+ 80: "p",
+ 81: "q",
+ 82: "r",
+ 83: "s",
+ 84: "t",
+ 85: "u",
+ 86: "v",
+ 87: "w",
+ 88: "x",
+ 89: "y",
+ 90: "z",
+ 91: "left window key",
+ 92: "right window key",
+ 93: "select key",
+ 96: "numpad 0",
+ 97: "numpad 1",
+ 98: "numpad 2",
+ 99: "numpad 3",
+ 100: "numpad 4",
+ 101: "numpad 5",
+ 102: "numpad 6",
+ 103: "numpad 7",
+ 104: "numpad 8",
+ 105: "numpad 9",
+ 106: "multiply",
+ 107: "add",
+ 109: "subtract",
+ 110: "decimal point",
+ 111: "divide",
+ 112: "f1",
+ 113: "f2",
+ 114: "f3",
+ 115: "f4",
+ 116: "f5",
+ 117: "f6",
+ 118: "f7",
+ 119: "f8",
+ 120: "f9",
+ 121: "f10",
+ 122: "f11",
+ 123: "f12",
+ 144: "num lock",
+ 145: "scroll lock",
+ 186: "semi-colon",
+ 187: "equal sign",
+ 188: "comma",
+ 189: "dash",
+ 190: "period",
+ 191: "forward slash",
+ 192: "grave accent",
+ 219: "open bracket",
+ 220: "back slash",
+ 221: "close braket",
+ 222: "single quote"
}
}
setupKeys() {
- for (let i=0; i<4; i++) {
- for (let j=0; j<30; j++) {
+ for (let i = 0; i < 4; i++) {
+ for (let j = 0; j < 30; j++) {
if (this.controls[i][j]) {
this.controls[i][j].value = parseInt(this.keyLookup(this.controls[i][j].value));
if (this.controls[i][j].value === -1 && this.debug) {
delete this.controls[i][j].value;
- console.warn("Invalid key for control "+j+" player "+i);
+ console.warn("Invalid key for control " + j + " player " + i);
}
}
}
@@ -3043,20 +3372,24 @@ class EmulatorJS {
this.saveSettings();
return;
}
- if (this.settingsMenu.style.display !== "none" || this.isPopupOpen()) return;
+ if (this.settingsMenu.style.display !== "none" || this.isPopupOpen() || this.getSettingValue("keyboardInput") === "enabled") return;
e.preventDefault();
const special = [16, 17, 18, 19, 20, 21, 22, 23];
- for (let i=0; i<4; i++) {
- for (let j=0; j<30; j++) {
+ for (let i = 0; i < 4; i++) {
+ for (let j = 0; j < 30; j++) {
if (this.controls[i][j] && this.controls[i][j].value === e.keyCode) {
- this.gameManager.simulateInput(i, j, (e.type === 'keyup' ? 0 : (special.includes(j) ? 0x7fff : 1)));
+ this.gameManager.simulateInput(i, j, (e.type === "keyup" ? 0 : (special.includes(j) ? 0x7fff : 1)));
}
}
}
}
gamepadEvent(e) {
if (!this.started) return;
- const value = function(value) {
+ const gamepadIndex = this.gamepadSelection.indexOf(this.gamepad.gamepads[e.gamepadIndex].id + "_" + this.gamepad.gamepads[e.gamepadIndex].index);
+ if (gamepadIndex < 0) {
+ return; // Gamepad not set anywhere
+ }
+ const value = function (value) {
if (value > 0.5 || value < -0.5) {
return (value > 0) ? 1 : -1;
} else {
@@ -3064,10 +3397,10 @@ class EmulatorJS {
}
}(e.value || 0);
if (this.controlPopup.parentElement.parentElement.getAttribute("hidden") === null) {
- if ('buttonup' === e.type || (e.type === "axischanged" && value === 0)) return;
+ if ("buttonup" === e.type || (e.type === "axischanged" && value === 0)) return;
const num = this.controlPopup.getAttribute("button-num");
const player = parseInt(this.controlPopup.getAttribute("player-num"));
- if (e.gamepadIndex !== player) return;
+ if (gamepadIndex !== player) return;
if (!this.controls[player][num]) {
this.controls[player][num] = {};
}
@@ -3079,20 +3412,20 @@ class EmulatorJS {
}
if (this.settingsMenu.style.display !== "none" || this.isPopupOpen()) return;
const special = [16, 17, 18, 19, 20, 21, 22, 23];
- for (let i=0; i<4; i++) {
- if (e.gamepadIndex !== i) continue;
- for (let j=0; j<30; j++) {
+ for (let i = 0; i < 4; i++) {
+ if (gamepadIndex !== i) continue;
+ for (let j = 0; j < 30; j++) {
if (!this.controls[i][j] || this.controls[i][j].value2 === undefined) {
continue;
}
const controlValue = this.controls[i][j].value2;
- if (['buttonup', 'buttondown'].includes(e.type) && (controlValue === e.label || controlValue === e.index)) {
- this.gameManager.simulateInput(i, j, (e.type === 'buttonup' ? 0 : (special.includes(j) ? 0x7fff : 1)));
+ if (["buttonup", "buttondown"].includes(e.type) && (controlValue === e.label || controlValue === e.index)) {
+ this.gameManager.simulateInput(i, j, (e.type === "buttonup" ? 0 : (special.includes(j) ? 0x7fff : 1)));
} else if (e.type === "axischanged") {
- if (typeof controlValue === 'string' && controlValue.split(":")[0] === e.axis) {
+ if (typeof controlValue === "string" && controlValue.split(":")[0] === e.axis) {
if (special.includes(j)) {
- if (e.axis === 'LEFT_STICK_X') {
+ if (j === 16 || j === 17) {
if (e.value > 0) {
this.gameManager.simulateInput(i, 16, 0x7fff * e.value);
this.gameManager.simulateInput(i, 17, 0);
@@ -3100,7 +3433,7 @@ class EmulatorJS {
this.gameManager.simulateInput(i, 17, -0x7fff * e.value);
this.gameManager.simulateInput(i, 16, 0);
}
- } else if (e.axis === 'LEFT_STICK_Y') {
+ } else if (j === 18 || j === 19) {
if (e.value > 0) {
this.gameManager.simulateInput(i, 18, 0x7fff * e.value);
this.gameManager.simulateInput(i, 19, 0);
@@ -3108,7 +3441,7 @@ class EmulatorJS {
this.gameManager.simulateInput(i, 19, -0x7fff * e.value);
this.gameManager.simulateInput(i, 18, 0);
}
- } else if (e.axis === 'RIGHT_STICK_X') {
+ } else if (j === 20 || j === 21) {
if (e.value > 0) {
this.gameManager.simulateInput(i, 20, 0x7fff * e.value);
this.gameManager.simulateInput(i, 21, 0);
@@ -3116,12 +3449,12 @@ class EmulatorJS {
this.gameManager.simulateInput(i, 21, -0x7fff * e.value);
this.gameManager.simulateInput(i, 20, 0);
}
- } else if (e.axis === 'RIGHT_STICK_Y') {
+ } else if (j === 22 || j === 23) {
if (e.value > 0) {
this.gameManager.simulateInput(i, 22, 0x7fff * e.value);
this.gameManager.simulateInput(i, 23, 0);
} else {
- this.gameManager.simulateInput(i, 23, 0x7fff * e.value);
+ this.gameManager.simulateInput(i, 23, -0x7fff * e.value);
this.gameManager.simulateInput(i, 22, 0);
}
}
@@ -3142,15 +3475,15 @@ class EmulatorJS {
this.elements.parent.appendChild(this.virtualGamepad);
const speedControlButtons = [
- {"type":"button","text":"Fast","id":"speed_fast","location":"center","left":-35,"top":50,"fontSize":15,"block":true,"input_value":27},
- {"type":"button","text":"Slow","id":"speed_slow","location":"center","left":95,"top":50,"fontSize":15,"block":true,"input_value":29},
+ { "type": "button", "text": "Fast", "id": "speed_fast", "location": "center", "left": -35, "top": 50, "fontSize": 15, "block": true, "input_value": 27 },
+ { "type": "button", "text": "Slow", "id": "speed_slow", "location": "center", "left": 95, "top": 50, "fontSize": 15, "block": true, "input_value": 29 },
];
if (this.rewindEnabled) {
- speedControlButtons.push({"type":"button","text":"Rewind","id":"speed_rewind","location":"center","left":30,"top":50,"fontSize":15,"block":true,"input_value":28});
+ speedControlButtons.push({ "type": "button", "text": "Rewind", "id": "speed_rewind", "location": "center", "left": 30, "top": 50, "fontSize": 15, "block": true, "input_value": 28 });
}
let info;
- if (this.config.VirtualGamepadSettings && function(set) {
+ if (this.config.VirtualGamepadSettings && function (set) {
if (!Array.isArray(set)) {
console.warn("Virtual gamepad settings is not array! Using default gamepad settings");
return false;
@@ -3159,30 +3492,30 @@ class EmulatorJS {
console.warn("Virtual gamepad settings is empty! Using default gamepad settings");
return false;
}
- for (let i=0; i {
left.classList.toggle("ejs_virtualGamepad_left", !enabled);
right.classList.toggle("ejs_virtualGamepad_right", !enabled);
left.classList.toggle("ejs_virtualGamepad_right", enabled);
right.classList.toggle("ejs_virtualGamepad_left", enabled);
}
-
+
const leftHandedMode = false;
- const blockCSS = 'height:31px;text-align:center;border:1px solid #ccc;border-radius:5px;line-height:31px;';
- const controlSchemeCls = `cs_${this.getControlScheme()}`.split(/\s/g).join('_');
-
- for (let i=0; i {
e.preventDefault();
- if (e.type === 'touchend' || e.type === 'touchcancel') {
+ if (e.type === "touchend" || e.type === "touchcancel") {
e.target.classList.remove("ejs_virtualGamepad_button_down");
window.setTimeout(() => {
this.gameManager.simulateInput(0, value, 0);
})
} else {
e.target.classList.add("ejs_virtualGamepad_button_down");
- this.gameManager.simulateInput(0, value, 1);
+ this.gameManager.simulateInput(0, value, downValue);
}
})
}
}
-
+
const createDPad = (opts) => {
const container = opts.container;
const callback = opts.event;
@@ -3530,12 +3863,12 @@ class EmulatorJS {
bar1.classList.add("ejs_dpad_bar");
const bar2 = this.createElement("div");
bar2.classList.add("ejs_dpad_bar");
-
+
horizontal.appendChild(bar1);
vertical.appendChild(bar2);
dpadMain.appendChild(vertical);
dpadMain.appendChild(horizontal);
-
+
const updateCb = (e) => {
e.preventDefault();
const touch = e.targetTouches[0];
@@ -3548,14 +3881,14 @@ class EmulatorJS {
left = 0,
right = 0,
angle = Math.atan(x / y) / (Math.PI / 180);
-
+
if (y <= -10) {
up = 1;
}
if (y >= 10) {
down = 1;
}
-
+
if (x >= 10) {
right = 1;
left = 0;
@@ -3565,7 +3898,7 @@ class EmulatorJS {
up = (angle < 0 && angle >= -55 ? 1 : 0);
down = (angle > 0 && angle <= 55 ? 1 : 0);
}
-
+
if (x <= -10) {
right = 0;
left = 1;
@@ -3575,12 +3908,12 @@ class EmulatorJS {
up = (angle > 0 && angle <= 55 ? 1 : 0);
down = (angle < 0 && angle >= -55 ? 1 : 0);
}
-
+
dpadMain.classList.toggle("ejs_dpad_up_pressed", up);
dpadMain.classList.toggle("ejs_dpad_down_pressed", down);
dpadMain.classList.toggle("ejs_dpad_right_pressed", right);
dpadMain.classList.toggle("ejs_dpad_left_pressed", left);
-
+
callback(up, down, left, right);
}
const cancelCb = (e) => {
@@ -3589,21 +3922,21 @@ class EmulatorJS {
dpadMain.classList.remove("ejs_dpad_down_pressed");
dpadMain.classList.remove("ejs_dpad_right_pressed");
dpadMain.classList.remove("ejs_dpad_left_pressed");
-
+
callback(0, 0, 0, 0);
}
-
- this.addEventListener(dpadMain, 'touchstart touchmove', updateCb);
- this.addEventListener(dpadMain, 'touchend touchcancel', cancelCb);
-
-
+
+ this.addEventListener(dpadMain, "touchstart touchmove", updateCb);
+ this.addEventListener(dpadMain, "touchend touchcancel", cancelCb);
+
+
container.appendChild(dpadMain);
}
-
+
info.forEach((dpad, index) => {
- if (dpad.type !== 'dpad') return;
- if (leftHandedMode && ['left', 'right'].includes(dpad.location)) {
- dpad.location = (dpad.location==='left') ? 'right' : 'left';
+ if (dpad.type !== "dpad") return;
+ if (leftHandedMode && ["left", "right"].includes(dpad.location)) {
+ dpad.location = (dpad.location === "left") ? "right" : "left";
const amnt = JSON.parse(JSON.stringify(dpad));
if (amnt.left) {
dpad.right = amnt.left;
@@ -3613,15 +3946,15 @@ class EmulatorJS {
}
}
const elem = this.createElement("div");
- let style = '';
+ let style = "";
if (dpad.left) {
- style += 'left:'+dpad.left+';';
+ style += "left:" + dpad.left + ";";
}
if (dpad.right) {
- style += 'right:'+dpad.right+';';
+ style += "right:" + dpad.right + ";";
}
if (dpad.top) {
- style += 'top:'+dpad.top+';';
+ style += "top:" + dpad.top + ";";
}
elem.classList.add(controlSchemeCls);
if (dpad.id) {
@@ -3629,25 +3962,27 @@ class EmulatorJS {
}
elem.style = style;
elems[dpad.location].appendChild(elem);
- createDPad({container: elem, event: (up, down, left, right) => {
- if (dpad.joystickInput) {
- if (up === 1) up=0x7fff;
- if (down === 1) down=0x7fff;
- if (left === 1) left=0x7fff;
- if (right === 1) right=0x7fff;
+ createDPad({
+ container: elem,
+ event: (up, down, left, right) => {
+ if (dpad.joystickInput) {
+ if (up === 1) up = 0x7fff;
+ if (down === 1) down = 0x7fff;
+ if (left === 1) left = 0x7fff;
+ if (right === 1) right = 0x7fff;
+ }
+ this.gameManager.simulateInput(0, dpad.inputValues[0], up);
+ this.gameManager.simulateInput(0, dpad.inputValues[1], down);
+ this.gameManager.simulateInput(0, dpad.inputValues[2], left);
+ this.gameManager.simulateInput(0, dpad.inputValues[3], right);
}
- this.gameManager.simulateInput(0, dpad.inputValues[0], up);
- this.gameManager.simulateInput(0, dpad.inputValues[1], down);
- this.gameManager.simulateInput(0, dpad.inputValues[2], left);
- this.gameManager.simulateInput(0, dpad.inputValues[3], right);
- }});
+ });
})
-
-
+
info.forEach((zone, index) => {
- if (zone.type !== 'zone') return;
- if (leftHandedMode && ['left', 'right'].includes(zone.location)) {
- zone.location = (zone.location==='left') ? 'right' : 'left';
+ if (zone.type !== "zone") return;
+ if (leftHandedMode && ["left", "right"].includes(zone.location)) {
+ zone.location = (zone.location === "left") ? "right" : "left";
const amnt = JSON.parse(JSON.stringify(zone));
if (amnt.left) {
zone.right = amnt.left;
@@ -3666,21 +4001,21 @@ class EmulatorJS {
}
elems[zone.location].appendChild(elem);
const zoneObj = nipplejs.create({
- 'zone': elem,
- 'mode': 'static',
- 'position': {
- 'left': zone.left,
- 'top': zone.top
+ "zone": elem,
+ "mode": "static",
+ "position": {
+ "left": zone.left,
+ "top": zone.top
},
- 'color': zone.color || 'red'
+ "color": zone.color || "red"
});
- zoneObj.on('end', () => {
+ zoneObj.on("end", () => {
this.gameManager.simulateInput(0, zone.inputValues[0], 0);
this.gameManager.simulateInput(0, zone.inputValues[1], 0);
this.gameManager.simulateInput(0, zone.inputValues[2], 0);
this.gameManager.simulateInput(0, zone.inputValues[3], 0);
});
- zoneObj.on('move', (e, info) => {
+ zoneObj.on("move", (e, info) => {
const degree = info.angle.degree;
const distance = info.distance;
if (zone.joystickInput === true) {
@@ -3731,7 +4066,7 @@ class EmulatorJS {
this.gameManager.simulateInput(0, zone.inputValues[3], 0x7fff * -y);
this.gameManager.simulateInput(0, zone.inputValues[2], 0);
}
-
+
} else {
if (degree >= 30 && degree < 150) {
this.gameManager.simulateInput(0, zone.inputValues[0], 1);
@@ -3764,13 +4099,19 @@ class EmulatorJS {
}
});
})
-
- if (this.touch || navigator.maxTouchPoints > 0) {
+
+ if (this.touch || this.hasTouchScreen) {
const menuButton = this.createElement("div");
menuButton.innerHTML = '';
menuButton.classList.add("ejs_virtualGamepad_open");
menuButton.style.display = "none";
- this.on("start", () => menuButton.style.display = "");
+ this.on("start", () => {
+ menuButton.style.display = "";
+ if (matchMedia('(pointer:fine)').matches && this.getSettingValue("menu-bar-button") !== "visible") {
+ menuButton.style.opacity = 0;
+ this.changeSettingOption('menu-bar-button', 'hidden', true);
+ }
+ });
this.elements.parent.appendChild(menuButton);
let timeout;
let ready = true;
@@ -3786,7 +4127,7 @@ class EmulatorJS {
})
this.elements.menuToggle = menuButton;
}
-
+
this.virtualGamepad.style.display = "none";
}
handleResize() {
@@ -3804,30 +4145,26 @@ class EmulatorJS {
this.game.parentElement.classList.toggle("ejs_small_screen", positionInfo.width <= 575);
//This wouldnt work using :not()... strange.
this.game.parentElement.classList.toggle("ejs_big_screen", positionInfo.width > 575);
-
- if (!this.Module) return;
- const dpr = window.devicePixelRatio || 1;
- const width = positionInfo.width * dpr;
- const height = (positionInfo.height * dpr);
- this.Module.setCanvasSize(width, height);
+
if (!this.handleSettingsResize) return;
this.handleSettingsResize();
}
getElementSize(element) {
let elem = element.cloneNode(true);
- elem.style.position = 'absolute';
+ elem.style.position = "absolute";
elem.style.opacity = 0;
- elem.removeAttribute('hidden');
+ elem.removeAttribute("hidden");
element.parentNode.appendChild(elem);
const res = elem.getBoundingClientRect();
elem.remove();
return {
- 'width': res.width,
- 'height': res.height
+ "width": res.width,
+ "height": res.height
};
}
saveSettings() {
if (!window.localStorage || this.config.disableLocalStorage || !this.settingsLoaded) return;
+ if (!this.started && !this.failedToStart) return;
const coreSpecific = {
controlSettings: this.controls,
settings: this.settings,
@@ -3838,32 +4175,77 @@ class EmulatorJS {
muted: this.muted
}
localStorage.setItem("ejs-settings", JSON.stringify(ejs_settings));
- localStorage.setItem("ejs-"+this.getCore()+"-settings", JSON.stringify(coreSpecific));
+ localStorage.setItem(this.getLocalStorageKey(), JSON.stringify(coreSpecific));
+ }
+ getLocalStorageKey() {
+ let identifier = (this.config.gameId || 1) + "-" + this.getCore(true);
+ if (typeof this.config.gameName === "string") {
+ identifier += "-" + this.config.gameName;
+ } else if (typeof this.config.gameUrl === "string" && !this.config.gameUrl.toLowerCase().startsWith("blob:")) {
+ identifier += "-" + this.config.gameUrl;
+ } else if (this.config.gameUrl instanceof File) {
+ identifier += "-" + this.config.gameUrl.name;
+ } else if (typeof this.config.gameId !== "number") {
+ console.warn("gameId (EJS_gameID) is not set. This may result in settings persisting across games.");
+ }
+ return "ejs-" + identifier + "-settings";
}
preGetSetting(setting) {
- if (!window.localStorage || this.config.disableLocalStorage) {
- if (this.config.defaultOptions && this.config.defaultOptions[setting]) {
- return this.config.defaultOptions[setting];
+ if (window.localStorage && !this.config.disableLocalStorage) {
+ let coreSpecific = localStorage.getItem(this.getLocalStorageKey());
+ try {
+ coreSpecific = JSON.parse(coreSpecific);
+ if (coreSpecific && coreSpecific.settings) {
+ return coreSpecific.settings[setting];
+ }
+ } catch(e) {
+ console.warn("Could not load previous settings", e);
}
- return false;
}
- let coreSpecific = localStorage.getItem("ejs-"+this.getCore()+"-settings");
- try {
- coreSpecific = JSON.parse(coreSpecific);
- if (!coreSpecific || !coreSpecific.settings) {
- return false;
- }
- return coreSpecific.settings[setting];
- } catch (e) {
- console.warn("Could not load previous settings", e);
- return false;
+ if (this.config.defaultOptions && this.config.defaultOptions[setting]) {
+ return this.config.defaultOptions[setting];
+ }
+ return null;
+ }
+ getCoreSettings() {
+ if (!window.localStorage || this.config.disableLocalStorage) {
+ if (this.config.defaultOptions) {
+ let rv = "";
+ for (const k in this.config.defaultOptions) {
+ let value = isNaN(this.config.defaultOptions[k]) ? `"${this.config.defaultOptions[k]}"` : this.config.defaultOptions[k];
+ rv += `${k} = ${value}\n`;
+ }
+ return rv;
+ }
+ return "";
+ };
+ let coreSpecific = localStorage.getItem(this.getLocalStorageKey());
+ if (coreSpecific) {
+ try {
+ coreSpecific = JSON.parse(coreSpecific);
+ if (!(coreSpecific.settings instanceof Object)) throw new Error("Not a JSON object");
+ let rv = "";
+ for (const k in coreSpecific.settings) {
+ let value = isNaN(coreSpecific.settings[k]) ? `"${coreSpecific.settings[k]}"` : coreSpecific.settings[k];
+ rv += `${k} = ${value}\n`;
+ }
+ for (const k in this.config.defaultOptions) {
+ if (rv.includes(k)) continue;
+ let value = isNaN(this.config.defaultOptions[k]) ? `"${this.config.defaultOptions[k]}"` : this.config.defaultOptions[k];
+ rv += `${k} = ${value}\n`;
+ }
+ return rv;
+ } catch(e) {
+ console.warn("Could not load previous settings", e);
+ }
}
+ return "";
}
loadSettings() {
if (!window.localStorage || this.config.disableLocalStorage) return;
this.settingsLoaded = true;
let ejs_settings = localStorage.getItem("ejs-settings");
- let coreSpecific = localStorage.getItem("ejs-"+this.getCore()+"-settings");
+ let coreSpecific = localStorage.getItem(this.getLocalStorageKey());
if (coreSpecific) {
try {
coreSpecific = JSON.parse(coreSpecific);
@@ -3873,10 +4255,10 @@ class EmulatorJS {
for (const k in coreSpecific.settings) {
this.changeSettingOption(k, coreSpecific.settings[k]);
}
- for (let i=0; i {
if (this.isSlowMotion) this.gameManager.toggleSlowMotion(1);
}, 10);
- } else if (option === 'slowMotion') {
+ } else if (option === "slowMotion") {
if (value === "enabled") {
this.isSlowMotion = true;
this.gameManager.toggleSlowMotion(1);
@@ -3955,7 +4335,44 @@ class EmulatorJS {
}
} else if (option === "vsync") {
this.gameManager.setVSync(value === "enabled");
+ } else if (option === "videoRotation") {
+ value = parseInt(value);
+ if (this.videoRotationChanged === true || value !== 0) {
+ this.gameManager.setVideoRotation(value);
+ this.videoRotationChanged = true;
+ } else if (this.videoRotationChanged === true && value === 0) {
+ this.gameManager.setVideoRotation(0);
+ this.videoRotationChanged = true;
+ }
+ } else if (option === "save-save-interval") {
+ value = parseInt(value);
+ if (this.saveSaveInterval && this.saveSaveInterval !== null) {
+ clearInterval(this.saveSaveInterval);
+ this.saveSaveInterval = null;
+ }
+ // Disabled
+ if (value === 0 || isNaN(value)) return;
+ if (this.started) this.gameManager.saveSaveFiles();
+ if (this.debug) console.log("Saving every", value * 1000, "miliseconds");
+ this.saveSaveInterval = setInterval(() => {
+ if (this.started) this.gameManager.saveSaveFiles();
+ }, value * 1000);
+ } else if (option === "menubarBehavior") {
+ this.createBottomMenuBarListeners();
+ } else if (option === "keyboardInput") {
+ this.gameManager.setKeyboardEnabled(value === "enabled");
+ } else if (option === "altKeyboardInput") {
+ this.gameManager.setAltKeyEnabled(value === "enabled");
+ } else if (option === "lockMouse") {
+ this.enableMouseLock = (value === "enabled");
}
+ }
+ menuOptionChanged(option, value) {
+ this.saveSettings();
+ this.allSettings[option] = value;
+ if (this.debug) console.log(option, value);
+ if (!this.gameManager) return;
+ this.handleSpecialOptions(option, value);
this.gameManager.setVariable(option, value);
this.saveSettings();
}
@@ -3965,7 +4382,7 @@ class EmulatorJS {
const nested = this.createElement("div");
nested.classList.add("ejs_settings_transition");
this.disks = {};
-
+
const home = this.createElement("div");
home.style.overflow = "auto";
const menus = [];
@@ -3980,12 +4397,12 @@ class EmulatorJS {
let w2 = this.diskParent.parentElement.getBoundingClientRect().width;
let disksX = this.diskParent.getBoundingClientRect().x;
if (w2 > window.innerWidth) disksX += (w2 - window.innerWidth);
- const onTheRight = disksX > (w2-15)/2;
+ const onTheRight = disksX > (w2 - 15) / 2;
if (height > 375) height = 375;
- home.style['max-height'] = (height - 95) + "px";
- nested.style['max-height'] = (height - 95) + "px";
- for (let i=0; i e(title));
}
let allOpts = {};
-
+
+ // TODO - Why is this duplicated?
const addToMenu = (title, id, options, defaultOption) => {
const span = this.createElement("span");
span.innerText = title;
-
+
const current = this.createElement("div");
current.innerText = "";
current.classList.add("ejs_settings_main_bar_selected");
span.appendChild(current);
-
+
const menu = this.createElement("div");
menus.push(menu);
- menu.style.overflow = "auto";
menu.setAttribute("hidden", "");
+ menu.classList.add("ejs_parent_option_div");
const button = this.createElement("button");
const goToHome = () => {
const homeSize = this.getElementSize(home);
- nested.style.width = (homeSize.width+20) + "px";
+ nested.style.width = (homeSize.width + 20) + "px";
nested.style.height = homeSize.height + "px";
menu.setAttribute("hidden", "");
home.removeAttribute("hidden");
}
this.addEventListener(button, "click", goToHome);
-
+
button.type = "button";
button.classList.add("ejs_back_button");
menu.appendChild(button);
@@ -4034,29 +4452,29 @@ class EmulatorJS {
pageTitle.innerText = title;
pageTitle.classList.add("ejs_menu_text_a");
button.appendChild(pageTitle);
-
+
const optionsMenu = this.createElement("div");
optionsMenu.classList.add("ejs_setting_menu");
-
+
let buttons = [];
let opts = options;
if (Array.isArray(options)) {
opts = {};
- for (let i=0; i {
if (id !== title) return;
- for (let j=0; j {
this.disks[id] = opt;
- for (let j=0; j 1) {
const diskLabels = {};
let isM3U = false;
let disks = {};
if (this.fileName.split(".").pop() === "m3u") {
- disks = this.gameManager.Module.FS.readFile(this.fileName, { encoding: 'utf8' }).split("\n");
+ disks = this.gameManager.Module.FS.readFile(this.fileName, { encoding: "utf8" }).split("\n");
isM3U = true;
}
- for (let i=0; i {
+ const rv = this.createElement("div");
+ rv.classList.add("ejs_setting_menu");
+
+ if (child) {
+ const menuOption = this.createElement("div");
+ menuOption.classList.add("ejs_settings_main_bar");
+ const span = this.createElement("span");
+ span.innerText = title;
+
+ menuOption.appendChild(span);
+ parentElement.appendChild(menuOption);
+
+ const menu = this.createElement("div");
+ const menuChild = this.createElement("div");
+ menus.push(menu);
+ parentMenuCt++;
+ menu.setAttribute("hidden", "");
+ menuChild.classList.add("ejs_parent_option_div");
+ const button = this.createElement("button");
+ const goToHome = () => {
+ const homeSize = this.getElementSize(parentElement);
+ nested.style.width = (homeSize.width + 20) + "px";
+ nested.style.height = homeSize.height + "px";
+ menu.setAttribute("hidden", "");
+ parentElement.removeAttribute("hidden");
+ }
+ this.addEventListener(menuOption, "click", (e) => {
+ const targetSize = this.getElementSize(menu);
+ nested.style.width = (targetSize.width + 20) + "px";
+ nested.style.height = targetSize.height + "px";
+ menu.removeAttribute("hidden");
+ rv.scrollTo(0, 0);
+ parentElement.setAttribute("hidden", "");
+ })
+ const observer = new MutationObserver((list) => {
+ for (const k of list) {
+ for (const removed of k.removedNodes) {
+ if (removed === menu) {
+ menuOption.remove();
+ observer.disconnect();
+ const index = menus.indexOf(menu);
+ if (index !== -1) menus.splice(index, 1);
+ this.settingsMenu.style.display = "";
+ const homeSize = this.getElementSize(parentElement);
+ nested.style.width = (homeSize.width + 20) + "px";
+ nested.style.height = homeSize.height + "px";
+ // This SHOULD always be called before the game started - this SHOULD never be an issue
+ this.settingsMenu.style.display = "none";
+ }
+ }
+ }
+ });
+ this.addEventListener(button, "click", goToHome);
+
+ button.type = "button";
+ button.classList.add("ejs_back_button");
+ menuChild.appendChild(button);
+ const pageTitle = this.createElement("span");
+ pageTitle.innerText = title;
+ pageTitle.classList.add("ejs_menu_text_a");
+ button.appendChild(pageTitle);
+
+ // const optionsMenu = this.createElement("div");
+ // optionsMenu.classList.add("ejs_setting_menu");
+ // menu.appendChild(optionsMenu);
+
+ menuChild.appendChild(rv);
+ menu.appendChild(menuChild);
+ nested.appendChild(menu);
+ observer.observe(nested, {
+ childList: true,
+ subtree: true,
+ });
+ }
+
+ return rv;
+ }
+
+ const checkForEmptyMenu = (element) => {
+ if (element.firstChild === null) {
+ element.parentElement.remove(); // No point in keeping an empty menu
+ parentMenuCt--;
+ }
+ }
+
+ const home = createSettingParent();
+
this.handleSettingsResize = () => {
let needChange = false;
if (this.settingsMenu.style.display !== "") {
@@ -4165,12 +4674,12 @@ class EmulatorJS {
let w2 = this.settingParent.parentElement.getBoundingClientRect().width;
let settingsX = this.settingParent.getBoundingClientRect().x;
if (w2 > window.innerWidth) settingsX += (w2 - window.innerWidth);
- const onTheRight = settingsX > (w2-15)/2;
+ const onTheRight = settingsX > (w2 - 15) / 2;
if (height > 375) height = 375;
- home.style['max-height'] = (height - 95) + "px";
- nested.style['max-height'] = (height - 95) + "px";
- for (let i=0; i {
- this.settings[title] = newValue;
+ let settings = {};
+ this.changeSettingOption = (title, newValue, startup) => {
+ this.allSettings[title] = newValue;
+ if (startup !== true) {
+ this.settings[title] = newValue;
+ }
+ settings[title] = newValue;
funcs.forEach(e => e(title));
}
let allOpts = {};
-
- const addToMenu = (title, id, options, defaultOption) => {
+
+ const addToMenu = (title, id, options, defaultOption, parentElement, useParentParent) => {
+ if (Array.isArray(this.config.hideSettings) && this.config.hideSettings.includes(id)) {
+ return;
+ }
+ parentElement = parentElement || home;
+ const transitionElement = useParentParent ? parentElement.parentElement.parentElement : parentElement;
const menuOption = this.createElement("div");
menuOption.classList.add("ejs_settings_main_bar");
const span = this.createElement("span");
span.innerText = title;
-
+
const current = this.createElement("div");
current.innerText = "";
current.classList.add("ejs_settings_main_bar_selected");
span.appendChild(current);
-
+
menuOption.appendChild(span);
- home.appendChild(menuOption);
-
+ parentElement.appendChild(menuOption);
+
const menu = this.createElement("div");
menus.push(menu);
- menu.style.overflow = "auto";
+ const menuChild = this.createElement("div");
menu.setAttribute("hidden", "");
+ menuChild.classList.add("ejs_parent_option_div");
+
+ const optionsMenu = this.createElement("div");
+ optionsMenu.classList.add("ejs_setting_menu");
+
const button = this.createElement("button");
const goToHome = () => {
- const homeSize = this.getElementSize(home);
- nested.style.width = (homeSize.width+20) + "px";
- nested.style.height = homeSize.height + "px";
+ transitionElement.removeAttribute("hidden");
menu.setAttribute("hidden", "");
- home.removeAttribute("hidden");
+ const homeSize = this.getElementSize(transitionElement);
+ nested.style.width = (homeSize.width + 20) + "px";
+ nested.style.height = homeSize.height + "px";
+ transitionElement.removeAttribute("hidden");
}
this.addEventListener(menuOption, "click", (e) => {
const targetSize = this.getElementSize(menu);
- nested.style.width = (targetSize.width+20) + "px";
+ nested.style.width = (targetSize.width + 20) + "px";
nested.style.height = targetSize.height + "px";
menu.removeAttribute("hidden");
- home.setAttribute("hidden", "");
+ optionsMenu.scrollTo(0, 0);
+ transitionElement.setAttribute("hidden", "");
+ transitionElement.setAttribute("hidden", "");
})
this.addEventListener(button, "click", goToHome);
-
+
button.type = "button";
button.classList.add("ejs_back_button");
- menu.appendChild(button);
+ menuChild.appendChild(button);
const pageTitle = this.createElement("span");
pageTitle.innerText = title;
pageTitle.classList.add("ejs_menu_text_a");
button.appendChild(pageTitle);
-
- const optionsMenu = this.createElement("div");
- optionsMenu.classList.add("ejs_setting_menu");
-
+
let buttons = [];
let opts = options;
if (Array.isArray(options)) {
opts = {};
- for (let i=0; i {
if (id !== title) return;
- for (let j=0; j {
- this.settings[id] = opt;
- for (let j=0; j 1) {
+ addToMenu(this.localization("Core" + " (" + this.localization("Requires restart") + ")"), "retroarch_core", core, this.getCore(), home);
+ }
+ if (typeof window.SharedArrayBuffer === "function" && !this.requiresThreads(this.getCore())) {
+ addToMenu(this.localization("Threads"), "ejs_threads", {
+ "enabled": this.localization("Enabled"),
+ "disabled": this.localization("Disabled")
+ }, this.config.threads ? "enabled" : "disabled", home);
+ }
+
+ const graphicsOptions = createSettingParent(true, "Graphics Settings", home);
if (this.config.shaders) {
const builtinShaders = {
- '2xScaleHQ.glslp': this.localization("2xScaleHQ"),
- '4xScaleHQ.glslp': this.localization("4xScaleHQ"),
- 'crt-aperture.glslp': this.localization('CRT aperture'),
- 'crt-beam': this.localization('CRT beam'),
- 'crt-caligari': this.localization('CRT caligari'),
- 'crt-easymode.glslp': this.localization('CRT easymode'),
- 'crt-geom.glslp': this.localization('CRT geom'),
- 'crt-lottes': this.localization('CRT lottes'),
- 'crt-mattias.glslp': this.localization('CRT mattias'),
- 'crt-yeetron': this.localization('CRT yeetron'),
- 'crt-zfast': this.localization('CRT zfast'),
- 'sabr': this.localization('SABR'),
- 'bicubic': this.localization('Bicubic'),
- 'mix-frames': this.localization('Mix frames'),
+ "2xScaleHQ.glslp": this.localization("2xScaleHQ"),
+ "4xScaleHQ.glslp": this.localization("4xScaleHQ"),
+ "crt-aperture.glslp": this.localization("CRT aperture"),
+ "crt-beam": this.localization("CRT beam"),
+ "crt-caligari": this.localization("CRT caligari"),
+ "crt-easymode.glslp": this.localization("CRT easymode"),
+ "crt-geom.glslp": this.localization("CRT geom"),
+ "crt-lottes": this.localization("CRT lottes"),
+ "crt-mattias.glslp": this.localization("CRT mattias"),
+ "crt-yeetron": this.localization("CRT yeetron"),
+ "crt-zfast": this.localization("CRT zfast"),
+ "sabr": this.localization("SABR"),
+ "bicubic": this.localization("Bicubic"),
+ "mix-frames": this.localization("Mix frames"),
};
let shaderMenu = {
- 'disabled': this.localization("Disabled"),
+ "disabled": this.localization("Disabled"),
};
for (const shaderName in this.config.shaders) {
if (builtinShaders[shaderName]) {
@@ -4318,123 +4855,305 @@ class EmulatorJS {
shaderMenu[shaderName] = shaderName;
}
}
- addToMenu(this.localization('Shaders'), 'shader', shaderMenu, 'disabled');
+ addToMenu(this.localization("Shaders"), "shader", shaderMenu, "disabled", graphicsOptions, true);
}
- if (this.supportsWebgl2) {
- addToMenu(this.localization('WebGL2') + " (" + this.localization('Requires page reload') + ")", 'webgl2Enabled', {
- 'enabled': this.localization("Enabled"),
- 'disabled': this.localization("Disabled")
- }, this.webgl2Enabled ? "enabled" : "disabled");
+ if (this.supportsWebgl2 && !this.requiresWebGL2(this.getCore())) {
+ addToMenu(this.localization("WebGL2") + " (" + this.localization("Requires restart") + ")", "webgl2Enabled", {
+ "enabled": this.localization("Enabled"),
+ "disabled": this.localization("Disabled")
+ }, this.webgl2Enabled ? "enabled" : "disabled", graphicsOptions, true);
}
-
- addToMenu(this.localization('FPS'), 'fps', {
- 'show': this.localization("show"),
- 'hide': this.localization("hide")
- }, 'hide');
-
+
+ addToMenu(this.localization("FPS"), "fps", {
+ "show": this.localization("show"),
+ "hide": this.localization("hide")
+ }, "hide", graphicsOptions, true);
+
addToMenu(this.localization("VSync"), "vsync", {
- 'enabled': this.localization("Enabled"),
- 'disabled': this.localization("Disabled")
- }, "enabled");
-
- addToMenu(this.localization('Fast Forward Ratio'), 'ff-ratio', [
+ "enabled": this.localization("Enabled"),
+ "disabled": this.localization("Disabled")
+ }, "enabled", graphicsOptions, true);
+
+ addToMenu(this.localization("Video Rotation"), "videoRotation", {
+ "0": "0 deg",
+ "1": "90 deg",
+ "2": "180 deg",
+ "3": "270 deg"
+ }, this.videoRotation.toString(), graphicsOptions, true);
+
+ const screenCaptureOptions = createSettingParent(true, "Screen Capture", home);
+
+ addToMenu(this.localization("Screenshot Source"), "screenshotSource", {
+ "canvas": "canvas",
+ "retroarch": "retroarch"
+ }, this.capture.photo.source, screenCaptureOptions, true);
+
+ let screenshotFormats = {
+ "png": "png",
+ "jpeg": "jpeg",
+ "webp": "webp"
+ }
+ if (this.isSafari) {
+ delete screenshotFormats["webp"];
+ }
+ if (!(this.capture.photo.format in screenshotFormats)) {
+ this.capture.photo.format = "png";
+ }
+ addToMenu(this.localization("Screenshot Format"), "screenshotFormat", screenshotFormats, this.capture.photo.format, screenCaptureOptions, true);
+
+ const screenshotUpscale = this.capture.photo.upscale.toString();
+ let screenshotUpscales = {
+ "0": "native",
+ "1": "1x",
+ "2": "2x",
+ "3": "3x"
+ }
+ if (!(screenshotUpscale in screenshotUpscales)) {
+ screenshotUpscales[screenshotUpscale] = screenshotUpscale + "x";
+ }
+ addToMenu(this.localization("Screenshot Upscale"), "screenshotUpscale", screenshotUpscales, screenshotUpscale, screenCaptureOptions, true);
+
+ const screenRecordFPS = this.capture.video.fps.toString();
+ let screenRecordFPSs = {
+ "30": "30",
+ "60": "60"
+ }
+ if (!(screenRecordFPS in screenRecordFPSs)) {
+ screenRecordFPSs[screenRecordFPS] = screenRecordFPS;
+ }
+ addToMenu(this.localization("Screen Recording FPS"), "screenRecordFPS", screenRecordFPSs, screenRecordFPS, screenCaptureOptions, true);
+
+ let screenRecordFormats = {
+ "mp4": "mp4",
+ "webm": "webm"
+ }
+ for (const format in screenRecordFormats) {
+ if (!MediaRecorder.isTypeSupported("video/" + format)) {
+ delete screenRecordFormats[format];
+ }
+ }
+ if (!(this.capture.video.format in screenRecordFormats)) {
+ this.capture.video.format = Object.keys(screenRecordFormats)[0];
+ }
+ addToMenu(this.localization("Screen Recording Format"), "screenRecordFormat", screenRecordFormats, this.capture.video.format, screenCaptureOptions, true);
+
+ const screenRecordUpscale = this.capture.video.upscale.toString();
+ let screenRecordUpscales = {
+ "1": "1x",
+ "2": "2x",
+ "3": "3x",
+ "4": "4x"
+ }
+ if (!(screenRecordUpscale in screenRecordUpscales)) {
+ screenRecordUpscales[screenRecordUpscale] = screenRecordUpscale + "x";
+ }
+ addToMenu(this.localization("Screen Recording Upscale"), "screenRecordUpscale", screenRecordUpscales, screenRecordUpscale, screenCaptureOptions, true);
+
+ const screenRecordVideoBitrate = this.capture.video.videoBitrate.toString();
+ let screenRecordVideoBitrates = {
+ "1048576": "1 Mbit/sec",
+ "2097152": "2 Mbit/sec",
+ "2621440": "2.5 Mbit/sec",
+ "3145728": "3 Mbit/sec",
+ "4194304": "4 Mbit/sec"
+ }
+ if (!(screenRecordVideoBitrate in screenRecordVideoBitrates)) {
+ screenRecordVideoBitrates[screenRecordVideoBitrate] = screenRecordVideoBitrate + " Bits/sec";
+ }
+ addToMenu(this.localization("Screen Recording Video Bitrate"), "screenRecordVideoBitrate", screenRecordVideoBitrates, screenRecordVideoBitrate, screenCaptureOptions, true);
+
+ const screenRecordAudioBitrate = this.capture.video.audioBitrate.toString();
+ let screenRecordAudioBitrates = {
+ "65536": "64 Kbit/sec",
+ "131072": "128 Kbit/sec",
+ "196608": "192 Kbit/sec",
+ "262144": "256 Kbit/sec",
+ "327680": "320 Kbit/sec"
+ }
+ if (!(screenRecordAudioBitrate in screenRecordAudioBitrates)) {
+ screenRecordAudioBitrates[screenRecordAudioBitrate] = screenRecordAudioBitrate + " Bits/sec";
+ }
+ addToMenu(this.localization("Screen Recording Audio Bitrate"), "screenRecordAudioBitrate", screenRecordAudioBitrates, screenRecordAudioBitrate, screenCaptureOptions, true);
+
+ checkForEmptyMenu(screenCaptureOptions);
+
+ const speedOptions = createSettingParent(true, "Speed Options", home);
+
+ addToMenu(this.localization("Fast Forward"), "fastForward", {
+ "enabled": this.localization("Enabled"),
+ "disabled": this.localization("Disabled")
+ }, "disabled", speedOptions, true);
+
+ addToMenu(this.localization("Fast Forward Ratio"), "ff-ratio", [
"1.5", "2.0", "2.5", "3.0", "3.5", "4.0", "4.5", "5.0", "5.5", "6.0", "6.5", "7.0", "7.5", "8.0", "8.5", "9.0", "9.5", "10.0", "unlimited"
- ], "3.0");
+ ], "3.0", speedOptions, true);
- addToMenu(this.localization('Slow Motion Ratio'), 'sm-ratio', [
+ addToMenu(this.localization("Slow Motion"), "slowMotion", {
+ "enabled": this.localization("Enabled"),
+ "disabled": this.localization("Disabled")
+ }, "disabled", speedOptions, true);
+
+ addToMenu(this.localization("Slow Motion Ratio"), "sm-ratio", [
"1.5", "2.0", "2.5", "3.0", "3.5", "4.0", "4.5", "5.0", "5.5", "6.0", "6.5", "7.0", "7.5", "8.0", "8.5", "9.0", "9.5", "10.0"
- ], "3.0");
+ ], "3.0", speedOptions, true);
+
+ addToMenu(this.localization("Rewind Enabled" + " (" + this.localization("Requires restart") + ")"), "rewindEnabled", {
+ "enabled": this.localization("Enabled"),
+ "disabled": this.localization("Disabled")
+ }, "disabled", speedOptions, true);
+
+ if (this.rewindEnabled) {
+ addToMenu(this.localization("Rewind Granularity"), "rewind-granularity", [
+ "1", "3", "6", "12", "25", "50", "100"
+ ], "6", speedOptions, true);
+ }
+
+ const inputOptions = createSettingParent(true, "Input Options", home);
- addToMenu(this.localization('Fast Forward'), 'fastForward', {
- 'enabled': this.localization("Enabled"),
- 'disabled': this.localization("Disabled")
- }, "disabled");
+ addToMenu(this.localization("Menubar Mouse Trigger"), "menubarBehavior", {
+ "downward": this.localization("Downward Movement"),
+ "anywhere": this.localization("Movement Anywhere"),
+ }, "downward", inputOptions, true);
- addToMenu(this.localization('Slow Motion'), 'slowMotion', {
- 'enabled': this.localization("Enabled"),
- 'disabled': this.localization("Disabled")
- }, "disabled");
+ addToMenu(this.localization("Direct Keyboard Input"), "keyboardInput", {
+ "disabled": this.localization("Disabled"),
+ "enabled": this.localization("Enabled"),
+ }, ((this.defaultCoreOpts && this.defaultCoreOpts.useKeyboard === true) ? "enabled" : "disabled"), inputOptions, true);
- addToMenu(this.localization('Rewind Enabled (requires restart)'), 'rewindEnabled', {
- 'enabled': this.localization("Enabled"),
- 'disabled': this.localization("Disabled")
- }, 'disabled');
+ addToMenu(this.localization("Forward Alt key"), "altKeyboardInput", {
+ "disabled": this.localization("Disabled"),
+ "enabled": this.localization("Enabled"),
+ }, "disabled", inputOptions, true);
- addToMenu(this.localization('Rewind Granularity'), 'rewind-granularity', [
- '1', '3', '6', '12', '25', '50', '100'
- ], '6');
+ addToMenu(this.localization("Lock Mouse"), "lockMouse", {
+ "disabled": this.localization("Disabled"),
+ "enabled": this.localization("Enabled"),
+ }, (this.enableMouseLock === true ? "enabled" : "disabled"), inputOptions, true);
+
+ checkForEmptyMenu(inputOptions);
if (this.saveInBrowserSupported()) {
- addToMenu(this.localization('Save State Slot'), 'save-state-slot', ["1", "2", "3", "4", "5", "6", "7", "8", "9"], "1");
- addToMenu(this.localization('Save State Location'), 'save-state-location', {
- 'download': this.localization("Download"),
- 'browser': this.localization("Keep in Browser")
- }, 'download');
- }
-
- addToMenu(this.localization('Video Rotation (requires restart)'), 'videoRotation', {
- '0': "0 deg",
- '1': "90 deg",
- '2': "180 deg",
- '3': "270 deg"
- }, this.videoRotation.toString());
-
- if (this.touch || navigator.maxTouchPoints > 0) {
- addToMenu(this.localization('Virtual Gamepad'), 'virtual-gamepad', {
- 'enabled': this.localization("Enabled"),
- 'disabled': this.localization("Disabled")
- }, this.isMobile ? 'enabled' : 'disabled');
- addToMenu(this.localization('Left Handed Mode'), 'virtual-gamepad-left-handed-mode', {
- 'enabled': this.localization("Enabled"),
- 'disabled': this.localization("Disabled")
- }, 'disabled');
+ const saveStateOpts = createSettingParent(true, "Save States", home);
+ addToMenu(this.localization("Save State Slot"), "save-state-slot", ["1", "2", "3", "4", "5", "6", "7", "8", "9"], "1", saveStateOpts, true);
+ addToMenu(this.localization("Save State Location"), "save-state-location", {
+ "download": this.localization("Download"),
+ "browser": this.localization("Keep in Browser")
+ }, "download", saveStateOpts, true);
+ addToMenu(this.localization("System Save interval"), "save-save-interval", {
+ "0": "Disabled",
+ "30": "30 seconds",
+ "60": "1 minute",
+ "300": "5 minutes",
+ "600": "10 minutes",
+ "900": "15 minutes",
+ "1800": "30 minutes"
+ }, "300", saveStateOpts, true);
+ checkForEmptyMenu(saveStateOpts);
+ }
+
+ if (this.touch || this.hasTouchScreen) {
+ const virtualGamepad = createSettingParent(true, "Virtual Gamepad", home);
+ addToMenu(this.localization("Virtual Gamepad"), "virtual-gamepad", {
+ "enabled": this.localization("Enabled"),
+ "disabled": this.localization("Disabled")
+ }, this.isMobile ? "enabled" : "disabled", virtualGamepad, true);
+ addToMenu(this.localization("Menu Bar Button"), "menu-bar-button", {
+ "visible": this.localization("visible"),
+ "hidden": this.localization("hidden")
+ }, "visible", virtualGamepad, true);
+ addToMenu(this.localization("Left Handed Mode"), "virtual-gamepad-left-handed-mode", {
+ "enabled": this.localization("Enabled"),
+ "disabled": this.localization("Disabled")
+ }, "disabled", virtualGamepad, true);
+ checkForEmptyMenu(virtualGamepad);
}
+
let coreOpts;
try {
coreOpts = this.gameManager.getCoreOptions();
- } catch(e){}
+ } catch(e) {}
if (coreOpts) {
- coreOpts.split('\n').forEach((line, index) => {
- let option = line.split('; ');
+ const coreOptions = createSettingParent(true, "Backend Core Options", home);
+ coreOpts.split("\n").forEach((line, index) => {
+ let option = line.split("; ");
let name = option[0];
- let options = option[1].split('|'),
- optionName = name.split("|")[0].replace(/_/g, ' ').replace(/.+\-(.+)/, '$1');
+ let options = option[1].split("|"),
+ optionName = name.split("|")[0].replace(/_/g, " ").replace(/.+\-(.+)/, "$1");
options.slice(1, -1);
if (options.length === 1) return;
let availableOptions = {};
- for (let i=0; i 1) ? name.split("|")[1] : options[0].replace('(Default) ', ''));
+ addToMenu(this.localization(optionName, this.config.settingsLanguage),
+ name.split("|")[0], availableOptions,
+ (name.split("|").length > 1) ? name.split("|")[1] : options[0].replace("(Default) ", ""),
+ coreOptions,
+ true);
})
+ checkForEmptyMenu(coreOptions);
}
-
+
+ /*
+ this.retroarchOpts = [
+ {
+ title: "Audio Latency", // String
+ name: "audio_latency", // String - value to be set in retroarch.cfg
+ // options should ALWAYS be strings here...
+ options: ["8", "16", "32", "64", "128"], // values
+ options: {"8": "eight", "16": "sixteen", "32": "thirty-two", "64": "sixty-four", "128": "one hundred-twenty-eight"}, // This also works
+ default: "128", // Default
+ isString: false // Surround value with quotes in retroarch.cfg file?
+ }
+ ];*/
+
+ if (this.retroarchOpts && Array.isArray(this.retroarchOpts)) {
+ const retroarchOptsMenu = createSettingParent(true, "RetroArch Options" + " (" + this.localization("Requires restart") + ")", home);
+ this.retroarchOpts.forEach(option => {
+ addToMenu(this.localization(option.title, this.config.settingsLanguage),
+ option.name,
+ option.options,
+ option.default,
+ retroarchOptsMenu,
+ true);
+ })
+ checkForEmptyMenu(retroarchOptsMenu);
+ }
+
+ checkForEmptyMenu(graphicsOptions);
+ checkForEmptyMenu(speedOptions);
+
this.settingsMenu.appendChild(nested);
-
+
this.settingParent.appendChild(this.settingsMenu);
this.settingParent.style.position = "relative";
-
+
+ this.settingsMenu.style.display = "";
const homeSize = this.getElementSize(home);
- nested.style.width = (homeSize.width+20) + "px";
+ nested.style.width = (homeSize.width + 20) + "px";
nested.style.height = homeSize.height + "px";
-
+
this.settingsMenu.style.display = "none";
-
+
if (this.debug) {
console.log("Available core options", allOpts);
}
-
+
if (this.config.defaultOptions) {
for (const k in this.config.defaultOptions) {
- this.changeSettingOption(k, this.config.defaultOptions[k]);
+ this.changeSettingOption(k, this.config.defaultOptions[k], true);
}
}
+
+ if (parentMenuCt === 0) {
+ this.on("start", () => {
+ this.elements.bottomBar.settings[0][0].style.display = "none";
+ });
+ }
}
createSubPopup(hidden) {
- const popup = this.createElement('div');
+ const popup = this.createElement("div");
popup.classList.add("ejs_popup_container");
popup.classList.add("ejs_popup_container_box");
const popupMsg = this.createElement("div");
@@ -4481,12 +5200,11 @@ class EmulatorJS {
addToHeader("").style.width = "80px"; //"join" button
table.appendChild(thead);
const tbody = this.createElement("tbody");
-
+
table.appendChild(tbody);
rooms.appendChild(title);
rooms.appendChild(table);
-
-
+
const joined = this.createElement("div");
const title2 = this.createElement("strong");
title2.innerText = "{roomname}";
@@ -4510,16 +5228,16 @@ class EmulatorJS {
addToHeader2("").style.width = "80px"; //"join" button
table2.appendChild(thead2);
const tbody2 = this.createElement("tbody");
-
+
table2.appendChild(tbody2);
joined.appendChild(title2);
joined.appendChild(password);
joined.appendChild(table2);
-
+
joined.style.display = "none";
body.appendChild(rooms);
body.appendChild(joined);
-
+
this.openNetplayMenu = () => {
this.netplayMenu.style.display = "";
if (!this.netplay || (this.netplay && !this.netplay.name)) {
@@ -4535,14 +5253,14 @@ class EmulatorJS {
this.netplayMenu.appendChild(popups[0]);
popups[1].classList.add("ejs_cheat_parent"); //Hehe
const popup = popups[1];
-
+
const header = this.createElement("div");
const title = this.createElement("h2");
title.innerText = this.localization("Set Player Name");
title.classList.add("ejs_netplay_name_heading");
header.appendChild(title);
popup.appendChild(header);
-
+
const main = this.createElement("div");
main.classList.add("ejs_netplay_header");
const head = this.createElement("strong");
@@ -4550,12 +5268,12 @@ class EmulatorJS {
const input = this.createElement("input");
input.type = "text";
input.setAttribute("maxlength", 20);
-
+
main.appendChild(head);
main.appendChild(this.createElement("br"));
main.appendChild(input);
popup.appendChild(main);
-
+
popup.appendChild(this.createElement("br"));
const submit = this.createElement("button");
submit.classList.add("ejs_button_button");
@@ -4575,17 +5293,17 @@ class EmulatorJS {
defineNetplayFunctions() {
function guidGenerator() {
const S4 = function() {
- return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
+ return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
};
- return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4());
+ return (S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4());
}
this.netplay.url = this.config.netplayUrl;
while (this.netplay.url.endsWith("/")) {
- this.netplay.url = this.netplay.url.substring(0, this.netplay.url.length-1);
+ this.netplay.url = this.netplay.url.substring(0, this.netplay.url.length - 1);
}
this.netplay.current_frame = 0;
this.netplay.getOpenRooms = async () => {
- return JSON.parse(await (await fetch(this.netplay.url+"/list?domain="+window.location.host+"&game_id="+this.config.gameId)).text());
+ return JSON.parse(await (await fetch(this.netplay.url + "/list?domain=" + window.location.host + "&game_id=" + this.config.gameId)).text());
}
this.netplay.updateTableList = async () => {
const addToTable = (id, name, current, max) => {
@@ -4601,7 +5319,7 @@ class EmulatorJS {
}
addToHeader(name).style["text-align"] = "left";
addToHeader(current + "/" + max).style.width = "80px";
-
+
const parent = addToHeader("");
parent.style.width = "80px";
this.netplay.table.appendChild(row);
@@ -4630,23 +5348,23 @@ class EmulatorJS {
this.netplayMenu.appendChild(popups[0]);
popups[1].classList.add("ejs_cheat_parent"); //Hehe
const popup = popups[1];
-
+
const header = this.createElement("div");
const title = this.createElement("h2");
title.innerText = this.localization("Create a room");
title.classList.add("ejs_netplay_name_heading");
header.appendChild(title);
popup.appendChild(header);
-
+
const main = this.createElement("div");
-
+
main.classList.add("ejs_netplay_header");
const rnhead = this.createElement("strong");
rnhead.innerText = this.localization("Room Name");
const rninput = this.createElement("input");
rninput.type = "text";
rninput.setAttribute("maxlength", 20);
-
+
const maxhead = this.createElement("strong");
maxhead.innerText = this.localization("Max Players");
const maxinput = this.createElement("select");
@@ -4663,28 +5381,27 @@ class EmulatorJS {
maxinput.appendChild(val2);
maxinput.appendChild(val3);
maxinput.appendChild(val4);
-
-
+
const pwhead = this.createElement("strong");
pwhead.innerText = this.localization("Password (optional)");
const pwinput = this.createElement("input");
pwinput.type = "text";
pwinput.setAttribute("maxlength", 20);
-
+
main.appendChild(rnhead);
main.appendChild(this.createElement("br"));
main.appendChild(rninput);
-
+
main.appendChild(maxhead);
main.appendChild(this.createElement("br"));
main.appendChild(maxinput);
-
+
main.appendChild(pwhead);
main.appendChild(this.createElement("br"));
main.appendChild(pwinput);
-
+
popup.appendChild(main);
-
+
popup.appendChild(this.createElement("br"));
const submit = this.createElement("button");
submit.classList.add("ejs_button_button");
@@ -4737,7 +5454,7 @@ class EmulatorJS {
}
this.netplay.players[this.netplay.playerID] = this.netplay.extra;
this.netplay.users = {};
-
+
this.netplay.startSocketIO((error) => {
this.netplay.socket.emit("open-room", {
extra: this.netplay.extra,
@@ -4768,7 +5485,7 @@ class EmulatorJS {
sessionid: sessionid
}
this.netplay.players[this.netplay.playerID] = this.netplay.extra;
-
+
this.netplay.startSocketIO((error) => {
this.netplay.socket.emit("join-room", {
extra: this.netplay.extra//,
@@ -4795,7 +5512,7 @@ class EmulatorJS {
this.netplay.tabs[1].style.display = "";
if (password) {
this.netplay.passwordElem.style.display = "";
- this.netplay.passwordElem.innerText = this.localization("Password")+": "+password
+ this.netplay.passwordElem.innerText = this.localization("Password") + ": " + password
} else {
this.netplay.passwordElem.style.display = "none";
}
@@ -4848,7 +5565,7 @@ class EmulatorJS {
addToHeader("").style.width = "80px"; //"join" button
table.appendChild(row);
}
- let i=1;
+ let i = 1;
for (const k in this.netplay.players) {
addToTable(i, this.netplay.players[k].player_name);
i++;
@@ -4899,7 +5616,7 @@ class EmulatorJS {
syncing = false;
}
this.netplay.getUserIndex = (user) => {
- let i=0;
+ let i = 0;
for (const k in this.netplay.players) {
if (k === user) return i;
i++;
@@ -4907,7 +5624,7 @@ class EmulatorJS {
return -1;
}
this.netplay.getUserCount = () => {
- let i=0;
+ let i = 0;
for (const k in this.netplay.players) i++;
return i;
}
@@ -4922,7 +5639,7 @@ class EmulatorJS {
this.netplay.setLoading(true);
this.pause(true);
this.gameManager.loadState(new Uint8Array(data.state));
- this.netplay.sendMessage({ready:true});
+ this.netplay.sendMessage({ ready: true });
}
if (data.play && !this.owner) {
this.play(true);
@@ -4933,7 +5650,7 @@ class EmulatorJS {
if (data.ready && this.netplay.owner) {
this.netplay.ready++;
if (this.netplay.ready === this.netplay.getUserCount()) {
- this.netplay.sendMessage({readyready:true});
+ this.netplay.sendMessage({ readyready: true });
this.netplay.reset();
setTimeout(() => this.play(true), 48);
this.netplay.setLoading(false);
@@ -4980,7 +5697,7 @@ class EmulatorJS {
this.play(true);
}
if (frame + 10 <= inFrame && inFrame > this.netplay.init_frame + 100) {
- this.netplay.sendMessage({shortPause:this.netplay.playerID});
+ this.netplay.sendMessage({ shortPause: this.netplay.playerID });
}
}
});
@@ -5008,7 +5725,7 @@ class EmulatorJS {
} else {
this.netplay.sendMessage({
"sync-control": [{
- frame: frame+10,
+ frame: frame + 10,
connected_input: [player, index, value]
}]
})
@@ -5031,19 +5748,18 @@ class EmulatorJS {
//fps = 1000 / (newTime - lastTime);
//console.log(fps);
//lastTime = newTime;
-
//frame syncing - working
//control syncing - broken
this.netplay.currentFrame = parseInt(this.gameManager.getFrameNum()) - this.netplay.init_frame;
if (!this.isNetplay) return;
if (this.netplay.owner) {
let to_send = [];
- let i = this.netplay.currentFrame-1;
+ let i = this.netplay.currentFrame - 1;
this.netplay.inputsData[i] ? this.netplay.inputsData[i].forEach((value) => {
- value.frame+=10;
+ value.frame += 10;
to_send.push(value);
- }) : to_send.push({frame: i+10});
- this.netplay.sendMessage({"sync-control": to_send});
+ }) : to_send.push({ frame: i + 10 });
+ this.netplay.sendMessage({ "sync-control": to_send });
} else {
if (this.netplay.currentFrame <= 0 || this.netplay.inputsData[this.netplay.currentFrame]) {
this.netplay.wait = false;
@@ -5056,7 +5772,7 @@ class EmulatorJS {
} else if (!this.netplay.syncing) {
console.log("sync");
this.pause(true);
- this.netplay.sendMessage({sync:true});
+ this.netplay.sendMessage({ sync: true });
this.netplay.syncing = true;
}
}
@@ -5068,10 +5784,8 @@ class EmulatorJS {
}
})
}
-
-
}
-
+
this.netplay.updateList = {
start: () => {
this.netplay.updateList.interval = setInterval(this.netplay.updateTableList.bind(this), 1000);
@@ -5102,7 +5816,7 @@ class EmulatorJS {
this.addEventListener(close, "click", (e) => {
popups[0].remove();
})
-
+
const main = this.createElement("div");
main.classList.add("ejs_cheat_main");
const header3 = this.createElement("strong");
@@ -5125,7 +5839,7 @@ class EmulatorJS {
main.appendChild(mainText2);
main.appendChild(this.createElement("br"));
popup.appendChild(main);
-
+
const footer = this.createElement("footer");
const submit = this.createElement("button");
const closeButton = this.createElement("button");
@@ -5142,7 +5856,7 @@ class EmulatorJS {
footer.appendChild(span);
footer.appendChild(closeButton);
popup.appendChild(footer);
-
+
this.addEventListener(submit, "click", (e) => {
if (!mainText.value.trim() || !mainText2.value.trim()) return;
popups[0].remove();
@@ -5157,7 +5871,6 @@ class EmulatorJS {
this.addEventListener(closeButton, "click", (e) => {
popups[0].remove();
})
-
},
"Close": () => {
this.cheatMenu.style.display = "none";
@@ -5178,7 +5891,7 @@ class EmulatorJS {
updateCheatUI() {
if (!this.gameManager) return;
this.elements.cheatRows.innerHTML = "";
-
+
const addToMenu = (desc, checked, code, is_permanent, i) => {
const row = this.createElement("div");
row.classList.add("ejs_cheat_row");
@@ -5186,10 +5899,10 @@ class EmulatorJS {
input.type = "checkbox";
input.checked = checked;
input.value = i;
- input.id = "ejs_cheat_switch_"+i;
+ input.id = "ejs_cheat_switch_" + i;
row.appendChild(input);
const label = this.createElement("label");
- label.for = "ejs_cheat_switch_"+i;
+ label.for = "ejs_cheat_switch_" + i;
label.innerText = desc;
row.appendChild(label);
label.addEventListener("click", (e) => {
@@ -5214,7 +5927,7 @@ class EmulatorJS {
this.cheatChanged(checked, code, i);
}
this.gameManager.resetCheat();
- for (let i=0; i {
- this.Module.FS.writeFile(`/shader/${resource.name}`, resource.type === 'base64' ? atob(resource.value) : resource.value, {}, 'w+');
+ this.Module.FS.writeFile(`/shader/${resource.name}`, resource.type === "base64" ? atob(resource.value) : resource.value, {}, "w+");
});
}
}
@@ -5251,13 +5964,113 @@ class EmulatorJS {
this.gameManager.toggleShader(1);
}
+ screenshot(callback, source, format, upscale) {
+ const imageFormat = format || this.getSettingValue("screenshotFormat") || this.capture.photo.format;
+ const imageUpscale = upscale || parseInt(this.getSettingValue("screenshotUpscale") || this.capture.photo.upscale);
+ const screenshotSource = source || this.getSettingValue("screenshotSource") || this.capture.photo.source;
+ const videoRotation = parseInt(this.getSettingValue("videoRotation") || 0);
+ const aspectRatio = this.gameManager.getVideoDimensions("aspect") || 1.333333;
+ const gameWidth = this.gameManager.getVideoDimensions("width") || 256;
+ const gameHeight = this.gameManager.getVideoDimensions("height") || 224;
+ const videoTurned = (videoRotation === 1 || videoRotation === 3);
+ let width = this.canvas.width;
+ let height = this.canvas.height;
+ let scaleHeight = imageUpscale;
+ let scaleWidth = imageUpscale;
+ let scale = 1;
+
+ if (screenshotSource === "retroarch") {
+ if (width >= height) {
+ width = height * aspectRatio;
+ } else if (width < height) {
+ height = width / aspectRatio;
+ }
+ this.gameManager.screenshot().then(screenshot => {
+ const blob = new Blob([screenshot], { type: "image/png" });
+ if (imageUpscale === 0) {
+ callback(blob, "png");
+ } else if (imageUpscale > 1) {
+ scale = imageUpscale;
+ const img = new Image();
+ const screenshotUrl = URL.createObjectURL(blob);
+ img.src = screenshotUrl;
+ img.onload = () => {
+ const canvas = document.createElement("canvas");
+ canvas.width = width * scale;
+ canvas.height = height * scale;
+ const ctx = canvas.getContext("2d", { alpha: false });
+ ctx.imageSmoothingEnabled = false;
+ ctx.scale(scaleWidth, scaleHeight);
+ ctx.drawImage(img, 0, 0, width, height);
+ canvas.toBlob((blob) => {
+ callback(blob, imageFormat);
+ img.remove();
+ URL.revokeObjectURL(screenshotUrl);
+ canvas.remove();
+ }, "image/" + imageFormat, 1);
+ }
+ }
+ });
+ } else if (screenshotSource === "canvas") {
+ if (width >= height && !videoTurned) {
+ width = height * aspectRatio;
+ } else if (width < height && !videoTurned) {
+ height = width / aspectRatio;
+ } else if (width >= height && videoTurned) {
+ width = height * (1/aspectRatio);
+ } else if (width < height && videoTurned) {
+ width = height / (1/aspectRatio);
+ }
+ if (imageUpscale === 0) {
+ scale = gameHeight / height;
+ scaleHeight = scale;
+ scaleWidth = scale;
+ } else if (imageUpscale > 1) {
+ scale = imageUpscale;
+ }
+ const captureCanvas = document.createElement("canvas");
+ captureCanvas.width = width * scale;
+ captureCanvas.height = height * scale;
+ captureCanvas.style.display = "none";
+ const captureCtx = captureCanvas.getContext("2d", { alpha: false });
+ captureCtx.imageSmoothingEnabled = false;
+ captureCtx.scale(scale, scale);
+ const imageAspect = this.canvas.width / this.canvas.height;
+ const canvasAspect = width / height;
+ let offsetX = 0;
+ let offsetY = 0;
+
+ if (imageAspect > canvasAspect) {
+ offsetX = (this.canvas.width - width) / -2;
+ } else if (imageAspect < canvasAspect) {
+ offsetY = (this.canvas.height - height) / -2;
+ }
+ const drawNextFrame = () => {
+ captureCtx.drawImage(this.canvas, offsetX, offsetY, this.canvas.width, this.canvas.height);
+ captureCanvas.toBlob((blob) => {
+ callback(blob, imageFormat);
+ captureCanvas.remove();
+ }, "image/" + imageFormat, 1);
+ };
+ requestAnimationFrame(drawNextFrame);
+ }
+ }
+
+ async takeScreenshot(source, format, upscale) {
+ return new Promise((resolve) => {
+ this.screenshot((blob, format) => {
+ resolve({ blob, format });
+ }, source, format, upscale);
+ });
+ }
+
collectScreenRecordingMediaTracks(canvasEl, fps) {
let videoTrack = null;
const videoTracks = canvasEl.captureStream(fps).getVideoTracks();
if (videoTracks.length !== 0) {
videoTrack = videoTracks[0];
} else {
- console.error('Unable to capture video stream');
+ console.error("Unable to capture video stream");
return null;
}
@@ -5284,44 +6097,67 @@ class EmulatorJS {
}
const stream = new MediaStream();
- if (videoTrack && videoTrack.readyState === 'live') {
+ if (videoTrack && videoTrack.readyState === "live") {
stream.addTrack(videoTrack);
}
- if (audioTrack && audioTrack.readyState === 'live') {
+ if (audioTrack && audioTrack.readyState === "live") {
stream.addTrack(audioTrack);
}
return stream;
}
screenRecord() {
- const captureScreenWidth= (this.config.screenRecording && (typeof this.config.screenRecording.width == "number")) ? this.config.screenRecording.width : 800;
- const captureScreenHeight = (this.config.screenRecording && (typeof this.config.screenRecording.height == "number")) ? this.config.screenRecording.height : 600;
- const captureFps = (this.config.screenRecording && (typeof this.config.screenRecording.fps == "number")) ? this.config.screenRecording.fps : 30;
- const captureVideoBitrate = (this.config.screenRecording && (typeof this.config.screenRecording.videoBitrate == "number")) ? this.config.screenRecording.videoBitrate : 2 * 1024 * 1014;
- const captureAudioBitrate = (this.config.screenRecording && (typeof this.config.screenRecording.audioBitrate == "number")) ? this.config.screenRecording.audioBitrate : 256 * 1024;
-
- const captureCanvas = document.createElement('canvas');
- captureCanvas.width = captureScreenWidth;
- captureCanvas.height = captureScreenHeight;
- captureCanvas.style.position = 'absolute';
- captureCanvas.style.top = '-999px';
- captureCanvas.style.bottom = '-999px';
- document.getElementsByTagName('body')[0].append(captureCanvas);
-
- const captureCtx = captureCanvas.getContext('2d', { alpha: false });
- captureCtx.fillStyle = '#000';
+ const captureFps = this.getSettingValue("screenRecordingFPS") || this.capture.video.fps;
+ const captureFormat = this.getSettingValue("screenRecordFormat") || this.capture.video.format;
+ const captureUpscale = this.getSettingValue("screenRecordUpscale") || this.capture.video.upscale;
+ const captureVideoBitrate = this.getSettingValue("screenRecordVideoBitrate") || this.capture.video.videoBitrate;
+ const captureAudioBitrate = this.getSettingValue("screenRecordAudioBitrate") || this.capture.video.audioBitrate;
+ const aspectRatio = this.gameManager.getVideoDimensions("aspect") || 1.333333;
+ const videoRotation = parseInt(this.getSettingValue("videoRotation") || 0);
+ const videoTurned = (videoRotation === 1 || videoRotation === 3);
+ let width = 800;
+ let height = 600;
+ let frameAspect = this.canvas.width / this.canvas.height;
+ let canvasAspect = width / height;
+ let offsetX = 0;
+ let offsetY = 0;
+
+ const captureCanvas = document.createElement("canvas");
+ const captureCtx = captureCanvas.getContext("2d", { alpha: false });
+ captureCtx.fillStyle = "#000";
+ captureCtx.imageSmoothingEnabled = false;
+ const updateSize = () => {
+ width = this.canvas.width;
+ height = this.canvas.height;
+ frameAspect = width / height
+ if (width >= height && !videoTurned) {
+ width = height * aspectRatio;
+ } else if (width < height && !videoTurned) {
+ height = width / aspectRatio;
+ } else if (width >= height && videoTurned) {
+ width = height * (1/aspectRatio);
+ } else if (width < height && videoTurned) {
+ width = height / (1/aspectRatio);
+ }
+ canvasAspect = width / height;
+ captureCanvas.width = width * captureUpscale;
+ captureCanvas.height = height * captureUpscale;
+ captureCtx.scale(captureUpscale, captureUpscale);
+ if (frameAspect > canvasAspect) {
+ offsetX = (this.canvas.width - width) / -2;
+ } else if (frameAspect < canvasAspect) {
+ offsetY = (this.canvas.height - height) / -2;
+ }
+ }
+ updateSize();
+ this.addEventListener(this.canvas, "resize", () => {
+ updateSize();
+ });
let animation = true;
const drawNextFrame = () => {
- const scaleX = captureScreenWidth / this.canvas.width;
- const scaleY = captureScreenHeight / this.canvas.height;
- const scale = Math.max(scaleY, scaleX);
- const width = this.canvas.width * scale;
- const height = this.canvas.height * scale;
- const startX = (captureScreenWidth - width) / 2;
- const startY = (captureScreenHeight - height) / 2;
- captureCtx.drawImage(this.canvas, Math.round(startX), Math.round(startY), Math.round(width), Math.round(height));
+ captureCtx.drawImage(this.canvas, offsetX, offsetY, this.canvas.width, this.canvas.height);
if (animation) {
requestAnimationFrame(drawNextFrame);
}
@@ -5333,17 +6169,18 @@ class EmulatorJS {
const recorder = new MediaRecorder(tracks, {
videoBitsPerSecond: captureVideoBitrate,
audioBitsPerSecond: captureAudioBitrate,
+ mimeType: "video/" + captureFormat
});
- recorder.addEventListener('dataavailable', e => {
+ recorder.addEventListener("dataavailable", e => {
chunks.push(e.data);
});
- recorder.addEventListener('stop', () => {
+ recorder.addEventListener("stop", () => {
const blob = new Blob(chunks);
const url = URL.createObjectURL(blob);
const date = new Date();
- const a = document.createElement('a');
+ const a = document.createElement("a");
a.href = url;
- a.download = this.getBaseFileName()+"-"+date.getMonth()+"-"+date.getDate()+"-"+date.getFullYear()+".webm";
+ a.download = this.getBaseFileName() + "-" + date.getMonth() + "-" + date.getDate() + "-" + date.getFullYear() + "." + captureFormat;
a.click();
animation = false;
@@ -5353,6 +6190,5 @@ class EmulatorJS {
return recorder;
}
-
}
window.EmulatorJS = EmulatorJS;
diff --git a/data/src/gamepad.js b/data/src/gamepad.js
index 9a1d82c4..22095ab1 100644
--- a/data/src/gamepad.js
+++ b/data/src/gamepad.js
@@ -1,4 +1,7 @@
class GamepadHandler {
+ gamepads;
+ timeout;
+ listeners;
constructor() {
this.buttonLabels = {
0: 'BUTTON_1',
@@ -34,7 +37,16 @@ class GamepadHandler {
this.timeout = setTimeout(this.loop.bind(this), 10);
}
updateGamepadState() {
- const gamepads = Array.from(this.getGamepads());
+ let gamepads = Array.from(this.getGamepads());
+ if (!gamepads) return;
+ if (!Array.isArray(gamepads) && gamepads.length) {
+ let gp = [];
+ for (let i=0; i {
if (!gamepad) return;
let hasGamepad = false;
@@ -47,13 +59,15 @@ class GamepadHandler {
id: oldGamepad.id
}
hasGamepad = true;
-
+
oldGamepad.axes.forEach((axis, axisIndex) => {
const val = (axis < 0.01 && axis > -0.01) ? 0 : axis;
const newVal = (gamepad.axes[axisIndex] < 0.01 && gamepad.axes[axisIndex] > -0.01) ? 0 : gamepad.axes[axisIndex];
if (newVal !== val) {
- const axis = ['LEFT_STICK_X', 'LEFT_STICK_Y', 'RIGHT_STICK_X', 'RIGHT_STICK_Y'][axisIndex];
- if (!axis) return;
+ let axis = ['LEFT_STICK_X', 'LEFT_STICK_Y', 'RIGHT_STICK_X', 'RIGHT_STICK_Y'][axisIndex];
+ if (!axis) {
+ axis = "EXTRA_STICK_" + axisIndex;
+ }
this.dispatchEvent('axischanged', {
axis: axis,
value: newVal,
@@ -64,7 +78,7 @@ class GamepadHandler {
}
gamepadToSave.axes[axisIndex] = newVal;
})
-
+
gamepad.buttons.forEach((button, buttonIndex) => {
let pressed = oldGamepad.buttons[buttonIndex] === 1.0;
if (typeof oldGamepad.buttons[buttonIndex] === "object") {
@@ -82,16 +96,22 @@ class GamepadHandler {
this.dispatchEvent('buttonup', {index: buttonIndex, label:this.getButtonLabel(buttonIndex), gamepadIndex: gamepad.index});
}
}
-
+
})
this.gamepads[oldIndex] = gamepadToSave;
})
if (!hasGamepad) {
this.gamepads.push(gamepads[index]);
+ this.gamepads.sort((a, b) => {
+ if (a == null && b == null) return 0;
+ if (a == null) return 1;
+ if (b == null) return -1;
+ return a.index - b.index;
+ });
this.dispatchEvent('connected', {gamepadIndex: gamepad.index});
}
});
-
+
for (let j=0; j=0&&this._handlers_[t].splice(this._handlers_[t].indexOf(i),1),this},_.prototype.trigger=function(t,i){var e,o=this,n=t.split(/[ ,]+/g);o._handlers_=o._handlers_||{};for(var s=0;ss&&n<3*s&&!t.lockX?i="up":n>-s&&n<=s&&!t.lockY?i="left":n>3*-s&&n<=-s&&!t.lockX?i="down":t.lockY||(i="right"),t.lockY||(e=n>-r&&n0?"up":"down"),t.force>this.options.threshold){var d,a={};for(d in this.direction)this.direction.hasOwnProperty(d)&&(a[d]=this.direction[d]);var p={};for(d in this.direction={x:e,y:o,angle:i},t.direction=this.direction,a)a[d]===this.direction[d]&&(p[d]=!0);if(p.x&&p.y&&p.angle)return t;p.x&&p.y||this.trigger("plain",t),p.x||this.trigger("plain:"+e,t),p.y||this.trigger("plain:"+o,t),p.angle||this.trigger("dir dir:"+i,t)}else this.resetDirection();return t};var P=k;function E(t,i){this.nipples=[],this.idles=[],this.actives=[],this.ids=[],this.pressureIntervals={},this.manager=t,this.id=E.id,E.id+=1,this.defaults={zone:document.body,multitouch:!1,maxNumberOfNipples:10,mode:"dynamic",position:{top:0,left:0},catchDistance:200,size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:.5,lockX:!1,lockY:!1,shape:"circle",dynamicPage:!1,follow:!1},this.config(i),"static"!==this.options.mode&&"semi"!==this.options.mode||(this.options.multitouch=!1),this.options.multitouch||(this.options.maxNumberOfNipples=1);var e=getComputedStyle(this.options.zone.parentElement);return e&&"flex"===e.display&&(this.parentIsFlex=!0),this.updateBox(),this.prepareNipples(),this.bindings(),this.begin(),this.nipples}E.prototype=new T,E.constructor=E,E.id=0,E.prototype.prepareNipples=function(){var t=this.nipples;t.on=this.on.bind(this),t.off=this.off.bind(this),t.options=this.options,t.destroy=this.destroy.bind(this),t.ids=this.ids,t.id=this.id,t.processOnMove=this.processOnMove.bind(this),t.processOnEnd=this.processOnEnd.bind(this),t.get=function(i){if(void 0===i)return t[0];for(var e=0,o=t.length;e0&&e.pressureFn(t,i,i.identifier),e.processOnMove(t)};if((i=e.idles.indexOf(a))>=0&&e.idles.splice(i,1),e.actives.push(a),e.ids.push(a.identifier),"semi"!==o.mode)p(a);else{if(!(n(d,a.position)<=o.catchDistance))return a.destroy(),void e.processOnStart(t);p(a)}return a},E.prototype.getOrCreate=function(t,i){var e,o=this.options;return/(semi|static)/.test(o.mode)?(e=this.idles[0])?(this.idles.splice(0,1),e):"semi"===o.mode?this.createNipple(i,t):(console.warn("Coudln't find the needed nipple."),!1):e=this.createNipple(i,t)},E.prototype.processOnMove=function(t){var i=this.options,e=this.manager.getIdentifier(t),o=this.nipples.get(e),d=this.manager.scroll;if(function(t){return isNaN(t.buttons)?0!==t.pressure:0!==t.buttons}(t)){if(!o)return console.error("Found zombie joystick with ID "+e),void this.manager.removeIdentifier(e);if(i.dynamicPage){var a=o.el.getBoundingClientRect();o.position={x:d.x+a.left,y:d.y+a.top}}o.identifier=e;var p=o.options.size/2,c={x:t.pageX,y:t.pageY};i.lockX&&(c.y=o.position.y),i.lockY&&(c.x=o.position.x);var l,h,u,f,y,m,v,g,b,x,O=n(c,o.position),w=(l=c,h=o.position,u=h.x-l.x,f=h.y-l.y,r(Math.atan2(f,u))),_=s(w),T=O/p,k={distance:O,position:c};if("circle"===o.options.shape?(y=Math.min(O,p),v=o.position,g=y,x={x:0,y:0},b=s(b=w),x.x=v.x-g*Math.cos(b),x.y=v.y-g*Math.sin(b),m=x):(m=function(t,i,e){return{x:Math.min(Math.max(t.x,i.x-e),i.x+e),y:Math.min(Math.max(t.y,i.y-e),i.y+e)}}(c,o.position,p),y=n(m,o.position)),i.follow){if(O>p){var P=c.x-m.x,E=c.y-m.y;o.position.x+=P,o.position.y+=E,o.el.style.top=o.position.y-(this.box.top+d.y)+"px",o.el.style.left=o.position.x-(this.box.left+d.x)+"px",O=n(c,o.position)}}else c=m,O=y;var I=c.x-o.position.x,z=c.y-o.position.y;o.frontPosition={x:I,y:z},i.dataOnly||(o.ui.front.style.transform="translate("+I+"px,"+z+"px)");var D={identifier:o.identifier,position:c,force:T,pressure:t.force||t.pressure||t.webkitForce||0,distance:O,angle:{radian:_,degree:w},vector:{x:I/p,y:-z/p},raw:k,instance:o,lockX:i.lockX,lockY:i.lockY};(D=o.computeDirection(D)).angle={radian:s(180-w),degree:180-w},o.trigger("move",D),this.trigger("move "+o.id+":move",D)}else this.processOnEnd(t)},E.prototype.processOnEnd=function(t){var i=this,e=i.options,o=i.manager.getIdentifier(t),n=i.nipples.get(o),s=i.manager.removeIdentifier(n.identifier);n&&(e.dataOnly||n.hide((function(){"dynamic"===e.mode&&(n.trigger("removed",n),i.trigger("removed "+n.id+":removed",n),i.manager.trigger("removed "+n.id+":removed",n),n.destroy())})),clearInterval(i.pressureIntervals[n.identifier]),n.resetDirection(),n.trigger("end",n),i.trigger("end "+n.id+":end",n),i.ids.indexOf(n.identifier)>=0&&i.ids.splice(i.ids.indexOf(n.identifier),1),i.actives.indexOf(n)>=0&&i.actives.splice(i.actives.indexOf(n),1),/(semi|static)/.test(e.mode)?i.idles.push(n):i.nipples.indexOf(n)>=0&&i.nipples.splice(i.nipples.indexOf(n),1),i.manager.unbindDocument(),/(semi|static)/.test(e.mode)&&(i.manager.ids[s.id]=s.identifier))},E.prototype.onDestroyed=function(t,i){this.nipples.indexOf(i)>=0&&this.nipples.splice(this.nipples.indexOf(i),1),this.actives.indexOf(i)>=0&&this.actives.splice(this.actives.indexOf(i),1),this.idles.indexOf(i)>=0&&this.idles.splice(this.idles.indexOf(i),1),this.ids.indexOf(i.identifier)>=0&&this.ids.splice(this.ids.indexOf(i.identifier),1),this.manager.removeIdentifier(i.identifier),this.manager.unbindDocument()},E.prototype.destroy=function(){for(var t in this.unbindEvt(this.options.zone,"start"),this.nipples.forEach((function(t){t.destroy()})),this.pressureIntervals)this.pressureIntervals.hasOwnProperty(t)&&clearInterval(this.pressureIntervals[t]);this.trigger("destroyed",this.nipples),this.manager.unbindDocument(),this.off()};var I=E;function z(t){var i=this;i.ids={},i.index=0,i.collections=[],i.scroll=h(),i.config(t),i.prepareCollections();var e=function(){var t;i.collections.forEach((function(e){e.forEach((function(e){t=e.el.getBoundingClientRect(),e.position={x:i.scroll.x+t.left,y:i.scroll.y+t.top}}))}))};p(window,"resize",(function(){a(e)}));var o=function(){i.scroll=h()};return p(window,"scroll",(function(){a(o)})),i.collections}z.prototype=new T,z.constructor=z,z.prototype.prepareCollections=function(){var t=this;t.collections.create=t.create.bind(t),t.collections.on=t.on.bind(t),t.collections.off=t.off.bind(t),t.collections.destroy=t.destroy.bind(t),t.collections.get=function(i){var e;return t.collections.every((function(t){return!(e=t.get(i))})),e}},z.prototype.create=function(t){return this.createCollection(t)},z.prototype.createCollection=function(t){var i=new I(this,t);return this.bindCollection(i),this.collections.push(i),i},z.prototype.bindCollection=function(t){var i,e=this,o=function(t,o){i=t.type+" "+o.id+":"+t.type,e.trigger(i,o)};t.on("destroyed",e.onDestroyed.bind(e)),t.on("shown hidden rested dir plain",o),t.on("dir:up dir:right dir:down dir:left",o),t.on("plain:up plain:right plain:down plain:left",o)},z.prototype.bindDocument=function(){this.binded||(this.bindEvt(document,"move").bindEvt(document,"end"),this.binded=!0)},z.prototype.unbindDocument=function(t){Object.keys(this.ids).length&&!0!==t||(this.unbindEvt(document,"move").unbindEvt(document,"end"),this.binded=!1)},z.prototype.getIdentifier=function(t){var i;return t?void 0===(i=void 0===t.identifier?t.pointerId:t.identifier)&&(i=this.latest||0):i=this.index,void 0===this.ids[i]&&(this.ids[i]=this.index,this.index+=1),this.latest=i,this.ids[i]},z.prototype.removeIdentifier=function(t){var i={};for(var e in this.ids)if(this.ids[e]===t){i.id=e,i.identifier=this.ids[e],delete this.ids[e];break}return i},z.prototype.onmove=function(t){return this.onAny("move",t),!1},z.prototype.onend=function(t){return this.onAny("end",t),!1},z.prototype.oncancel=function(t){return this.onAny("end",t),!1},z.prototype.onAny=function(t,i){var e,o=this,n="processOn"+t.charAt(0).toUpperCase()+t.slice(1);i=l(i);var s=function(t,i,e){e.ids.indexOf(i)>=0&&(e[n](t),t._found_=!0)};return v(i,(function(t){e=o.getIdentifier(t),v(o.collections,s.bind(null,t,e)),t._found_||o.removeIdentifier(e)})),!1},z.prototype.destroy=function(){this.unbindDocument(!0),this.ids={},this.index=0,this.collections.forEach((function(t){t.destroy()})),this.off()},z.prototype.onDestroyed=function(t,i){if(this.collections.indexOf(i)<0)return!1;this.collections.splice(this.collections.indexOf(i),1)};var D=new z;i.default={create:function(t){return D.create(t)},factory:D}}]).default}));
\ No newline at end of file
+!function(t,i){"object"==typeof exports&&"object"==typeof module?module.exports=i():"function"==typeof define&&define.amd?define("nipplejs",[],i):"object"==typeof exports?exports.nipplejs=i():t.nipplejs=i()}(window,function(){return function(t){var i={};function e(o){if(i[o])return i[o].exports;var n=i[o]={i:o,l:!1,exports:{}};return t[o].call(n.exports,n,n.exports,e),n.l=!0,n.exports}return e.m=t,e.c=i,e.d=function(t,i,o){e.o(t,i)||Object.defineProperty(t,i,{enumerable:!0,get:o})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,i){if(1&i&&(t=e(t)),8&i)return t;if(4&i&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(e.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&i&&"string"!=typeof t)for(var n in t)e.d(o,n,function(i){return t[i]}.bind(null,n));return o},e.n=function(t){var i=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(i,"a",i),i},e.o=function(t,i){return Object.prototype.hasOwnProperty.call(t,i)},e.p="",e(e.s=0)}([function(t,i,e){"use strict";e.r(i);var o,n=function(t,i){var e=i.x-t.x,o=i.y-t.y;return Math.sqrt(e*e+o*o)},s=function(t){return t*(Math.PI/180)},r=function(t){return t*(180/Math.PI)},d=new Map,a=function(t){d.has(t)&&clearTimeout(d.get(t)),d.set(t,setTimeout(t,100))},p=function(t,i,e){for(var o,n=i.split(/[ ,]+/g),s=0;s=0&&this._handlers_[t].splice(this._handlers_[t].indexOf(i),1),this},_.prototype.trigger=function(t,i){var e,o=this,n=t.split(/[ ,]+/g);o._handlers_=o._handlers_||{};for(var s=0;ss&&n<3*s&&!t.lockX?i="up":n>-s&&n<=s&&!t.lockY?i="left":n>3*-s&&n<=-s&&!t.lockX?i="down":t.lockY||(i="right"),t.lockY||(e=n>-r&&n0?"up":"down"),t.force>this.options.threshold){var d,a={};for(d in this.direction)this.direction.hasOwnProperty(d)&&(a[d]=this.direction[d]);var p={};for(d in this.direction={x:e,y:o,angle:i},t.direction=this.direction,a)a[d]===this.direction[d]&&(p[d]=!0);if(p.x&&p.y&&p.angle)return t;p.x&&p.y||this.trigger("plain",t),p.x||this.trigger("plain:"+e,t),p.y||this.trigger("plain:"+o,t),p.angle||this.trigger("dir dir:"+i,t)}else this.resetDirection();return t};var P=k;function E(t,i){this.nipples=[],this.idles=[],this.actives=[],this.ids=[],this.pressureIntervals={},this.manager=t,this.id=E.id,E.id+=1,this.defaults={zone:document.body,multitouch:!1,maxNumberOfNipples:10,mode:"dynamic",position:{top:0,left:0},catchDistance:200,size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:.5,lockX:!1,lockY:!1,shape:"circle",dynamicPage:!1,follow:!1},this.config(i),"static"!==this.options.mode&&"semi"!==this.options.mode||(this.options.multitouch=!1),this.options.multitouch||(this.options.maxNumberOfNipples=1);var e=getComputedStyle(this.options.zone.parentElement);return e&&"flex"===e.display&&(this.parentIsFlex=!0),this.updateBox(),this.prepareNipples(),this.bindings(),this.begin(),this.nipples}E.prototype=new T,E.constructor=E,E.id=0,E.prototype.prepareNipples=function(){var t=this.nipples;t.on=this.on.bind(this),t.off=this.off.bind(this),t.options=this.options,t.destroy=this.destroy.bind(this),t.ids=this.ids,t.id=this.id,t.processOnMove=this.processOnMove.bind(this),t.processOnEnd=this.processOnEnd.bind(this),t.get=function(i){if(void 0===i)return t[0];for(var e=0,o=t.length;e0&&e.pressureFn(t,i,i.identifier),e.processOnMove(t)};if((i=e.idles.indexOf(a))>=0&&e.idles.splice(i,1),e.actives.push(a),e.ids.push(a.identifier),"semi"!==o.mode)p(a);else{if(!(n(d,a.position)<=o.catchDistance))return a.destroy(),void e.processOnStart(t);p(a)}return a},E.prototype.getOrCreate=function(t,i){var e,o=this.options;return/(semi|static)/.test(o.mode)?(e=this.idles[0])?(this.idles.splice(0,1),e):"semi"===o.mode?this.createNipple(i,t):(console.warn("Coudln't find the needed nipple."),!1):e=this.createNipple(i,t)},E.prototype.processOnMove=function(t){var i=this.options,e=this.manager.getIdentifier(t),o=this.nipples.get(e),d=this.manager.scroll;if(function(t){return isNaN(t.buttons)?0!==t.pressure:0!==t.buttons}(t)){if(!o)return console.error("Found zombie joystick with ID "+e),void this.manager.removeIdentifier(e);if(i.dynamicPage){var a=o.el.getBoundingClientRect();o.position={x:d.x+a.left,y:d.y+a.top}}o.identifier=e;var p=o.options.size/2,c={x:t.pageX,y:t.pageY};i.lockX&&(c.y=o.position.y),i.lockY&&(c.x=o.position.x);var l,h,u,f,y,m,v,g,b,x,O=n(c,o.position),w=(l=c,h=o.position,u=h.x-l.x,f=h.y-l.y,r(Math.atan2(f,u))),_=s(w),T=O/p,k={distance:O,position:c};if("circle"===o.options.shape?(y=Math.min(O,p),v=o.position,g=y,x={x:0,y:0},b=s(b=w),x.x=v.x-g*Math.cos(b),x.y=v.y-g*Math.sin(b),m=x):(m=function(t,i,e){return{x:Math.min(Math.max(t.x,i.x-e),i.x+e),y:Math.min(Math.max(t.y,i.y-e),i.y+e)}}(c,o.position,p),y=n(m,o.position)),i.follow){if(O>p){var P=c.x-m.x,E=c.y-m.y;o.position.x+=P,o.position.y+=E,o.el.style.top=o.position.y-(this.box.top+d.y)+"px",o.el.style.left=o.position.x-(this.box.left+d.x)+"px",O=n(c,o.position)}}else c=m,O=y;var I=c.x-o.position.x,z=c.y-o.position.y;o.frontPosition={x:I,y:z},i.dataOnly||(o.ui.front.style.transform="translate("+I+"px,"+z+"px)");var D={identifier:o.identifier,position:c,force:T,pressure:t.force||t.pressure||t.webkitForce||0,distance:O,angle:{radian:_,degree:w},vector:{x:I/p,y:-z/p},raw:k,instance:o,lockX:i.lockX,lockY:i.lockY};(D=o.computeDirection(D)).angle={radian:s(180-w),degree:180-w},o.trigger("move",D),this.trigger("move "+o.id+":move",D)}else this.processOnEnd(t)},E.prototype.processOnEnd=function(t){var i=this,e=i.options,o=i.manager.getIdentifier(t),n=i.nipples.get(o),s=i.manager.removeIdentifier(n.identifier);n&&(e.dataOnly||n.hide(function(){"dynamic"===e.mode&&(n.trigger("removed",n),i.trigger("removed "+n.id+":removed",n),i.manager.trigger("removed "+n.id+":removed",n),n.destroy())}),clearInterval(i.pressureIntervals[n.identifier]),n.resetDirection(),n.trigger("end",n),i.trigger("end "+n.id+":end",n),i.ids.indexOf(n.identifier)>=0&&i.ids.splice(i.ids.indexOf(n.identifier),1),i.actives.indexOf(n)>=0&&i.actives.splice(i.actives.indexOf(n),1),/(semi|static)/.test(e.mode)?i.idles.push(n):i.nipples.indexOf(n)>=0&&i.nipples.splice(i.nipples.indexOf(n),1),i.manager.unbindDocument(),/(semi|static)/.test(e.mode)&&(i.manager.ids[s.id]=s.identifier))},E.prototype.onDestroyed=function(t,i){this.nipples.indexOf(i)>=0&&this.nipples.splice(this.nipples.indexOf(i),1),this.actives.indexOf(i)>=0&&this.actives.splice(this.actives.indexOf(i),1),this.idles.indexOf(i)>=0&&this.idles.splice(this.idles.indexOf(i),1),this.ids.indexOf(i.identifier)>=0&&this.ids.splice(this.ids.indexOf(i.identifier),1),this.manager.removeIdentifier(i.identifier),this.manager.unbindDocument()},E.prototype.destroy=function(){for(var t in this.unbindEvt(this.options.zone,"start"),this.nipples.forEach(function(t){t.destroy()}),this.pressureIntervals)this.pressureIntervals.hasOwnProperty(t)&&clearInterval(this.pressureIntervals[t]);this.trigger("destroyed",this.nipples),this.manager.unbindDocument(),this.off()};var I=E;function z(t){var i=this;i.ids={},i.index=0,i.collections=[],i.scroll=h(),i.config(t),i.prepareCollections();var e=function(){var t;i.collections.forEach(function(e){e.forEach(function(e){t=e.el.getBoundingClientRect(),e.position={x:i.scroll.x+t.left,y:i.scroll.y+t.top}})})};p(window,"resize",function(){a(e)});var o=function(){i.scroll=h()};return p(window,"scroll",function(){a(o)}),i.collections}z.prototype=new T,z.constructor=z,z.prototype.prepareCollections=function(){var t=this;t.collections.create=t.create.bind(t),t.collections.on=t.on.bind(t),t.collections.off=t.off.bind(t),t.collections.destroy=t.destroy.bind(t),t.collections.get=function(i){var e;return t.collections.every(function(t){return!(e=t.get(i))}),e}},z.prototype.create=function(t){return this.createCollection(t)},z.prototype.createCollection=function(t){var i=new I(this,t);return this.bindCollection(i),this.collections.push(i),i},z.prototype.bindCollection=function(t){var i,e=this,o=function(t,o){i=t.type+" "+o.id+":"+t.type,e.trigger(i,o)};t.on("destroyed",e.onDestroyed.bind(e)),t.on("shown hidden rested dir plain",o),t.on("dir:up dir:right dir:down dir:left",o),t.on("plain:up plain:right plain:down plain:left",o)},z.prototype.bindDocument=function(){this.binded||(this.bindEvt(document,"move").bindEvt(document,"end"),this.binded=!0)},z.prototype.unbindDocument=function(t){Object.keys(this.ids).length&&!0!==t||(this.unbindEvt(document,"move").unbindEvt(document,"end"),this.binded=!1)},z.prototype.getIdentifier=function(t){var i;return t?void 0===(i=void 0===t.identifier?t.pointerId:t.identifier)&&(i=this.latest||0):i=this.index,void 0===this.ids[i]&&(this.ids[i]=this.index,this.index+=1),this.latest=i,this.ids[i]},z.prototype.removeIdentifier=function(t){var i={};for(var e in this.ids)if(this.ids[e]===t){i.id=e,i.identifier=this.ids[e],delete this.ids[e];break}return i},z.prototype.onmove=function(t){return this.onAny("move",t),!1},z.prototype.onend=function(t){return this.onAny("end",t),!1},z.prototype.oncancel=function(t){return this.onAny("end",t),!1},z.prototype.onAny=function(t,i){var e,o=this,n="processOn"+t.charAt(0).toUpperCase()+t.slice(1);i=l(i);return v(i,function(t){e=o.getIdentifier(t),v(o.collections,function(t,i,e){e.ids.indexOf(i)>=0&&(e[n](t),t._found_=!0)}.bind(null,t,e)),t._found_||o.removeIdentifier(e)}),!1},z.prototype.destroy=function(){this.unbindDocument(!0),this.ids={},this.index=0,this.collections.forEach(function(t){t.destroy()}),this.off()},z.prototype.onDestroyed=function(t,i){if(this.collections.indexOf(i)<0)return!1;this.collections.splice(this.collections.indexOf(i),1)};var D=new z;i.default={create:function(t){return D.create(t)},factory:D}}]).default});
diff --git a/data/src/socket.io.min.js b/data/src/socket.io.min.js
index 4bd0ea7a..c72110d7 100644
--- a/data/src/socket.io.min.js
+++ b/data/src/socket.io.min.js
@@ -1,7 +1,7 @@
/*!
- * Socket.IO v4.7.0
- * (c) 2014-2023 Guillermo Rauch
+ * Socket.IO v4.8.1
+ * (c) 2014-2024 Guillermo Rauch
* Released under the MIT License.
*/
-!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).io=e()}(this,(function(){"use strict";function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){for(var n=0;nt.length)&&(e=t.length);for(var n=0,r=new Array(e);n=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw o}}}}var m=Object.create(null);m.open="0",m.close="1",m.ping="2",m.pong="3",m.message="4",m.upgrade="5",m.noop="6";var k=Object.create(null);Object.keys(m).forEach((function(t){k[m[t]]=t}));var b,w={type:"error",data:"parser error"},_="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),O="function"==typeof ArrayBuffer,A=function(t){return"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer instanceof ArrayBuffer},E=function(t,e,n){var r=t.type,i=t.data;return _&&i instanceof Blob?e?n(i):R(i,n):O&&(i instanceof ArrayBuffer||A(i))?e?n(i):R(new Blob([i]),n):n(m[r]+(i||""))},R=function(t,e){var n=new FileReader;return n.onload=function(){var t=n.result.split(",")[1];e("b"+(t||""))},n.readAsDataURL(t)};function T(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}for(var C="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",B="undefined"==typeof Uint8Array?[]:new Uint8Array(256),S=0;S1?{type:k[n],data:t.substring(1)}:{type:k[n]}:w},P=function(t,e){if(N){var n=function(t){var e,n,r,i,o,s=.75*t.length,a=t.length,c=0;"="===t[t.length-1]&&(s--,"="===t[t.length-2]&&s--);var u=new ArrayBuffer(s),h=new Uint8Array(u);for(e=0;e>4,h[c++]=(15&r)<<4|i>>2,h[c++]=(3&i)<<6|63&o;return u}(t);return j(n,e)}return{base64:!0,data:t}},j=function(t,e){return"blob"===e?t instanceof Blob?t:new Blob([t]):t instanceof ArrayBuffer?t:t.buffer},q=String.fromCharCode(30);function I(t){if(t)return function(t){for(var e in I.prototype)t[e]=I.prototype[e];return t}(t)}I.prototype.on=I.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},I.prototype.once=function(t,e){function n(){this.off(t,n),e.apply(this,arguments)}return n.fn=e,this.on(t,n),this},I.prototype.off=I.prototype.removeListener=I.prototype.removeAllListeners=I.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+t];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var i=0;i1?e-1:0),r=1;r1&&void 0!==arguments[1]?arguments[1]:{};return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(e)}},{key:"_hostname",value:function(){var t=this.opts.hostname;return-1===t.indexOf(":")?t:"["+t+"]"}},{key:"_port",value:function(){return this.opts.port&&(this.opts.secure&&Number(443!==this.opts.port)||!this.opts.secure&&80!==Number(this.opts.port))?":"+this.opts.port:""}},{key:"_query",value:function(t){var e=function(t){var e="";for(var n in t)t.hasOwnProperty(n)&&(e.length&&(e+="&"),e+=encodeURIComponent(n)+"="+encodeURIComponent(t[n]));return e}(t);return e.length?"?"+e:""}}]),i}(I),z="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),J={},$=0,Q=0;function X(t){var e="";do{e=z[t%64]+e,t=Math.floor(t/64)}while(t>0);return e}function G(){var t=X(+new Date);return t!==K?($=0,K=t):t+"."+X($++)}for(;Q<64;Q++)J[z[Q]]=Q;var Z=!1;try{Z="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(t){}var tt=Z;function et(t){var e=t.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!e||tt))return new XMLHttpRequest}catch(t){}if(!e)try{return new(D[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(t){}}function nt(){}var rt=null!=new et({xdomain:!1}).responseType,it=function(t){o(s,t);var n=p(s);function s(t){var r;if(e(this,s),(r=n.call(this,t)).polling=!1,"undefined"!=typeof location){var i="https:"===location.protocol,o=location.port;o||(o=i?"443":"80"),r.xd="undefined"!=typeof location&&t.hostname!==location.hostname||o!==t.port}var a=t&&t.forceBase64;return r.supportsBinary=rt&&!a,r.opts.withCredentials&&(r.cookieJar=void 0),r}return r(s,[{key:"name",get:function(){return"polling"}},{key:"doOpen",value:function(){this.poll()}},{key:"pause",value:function(t){var e=this;this.readyState="pausing";var n=function(){e.readyState="paused",t()};if(this.polling||!this.writable){var r=0;this.polling&&(r++,this.once("pollComplete",(function(){--r||n()}))),this.writable||(r++,this.once("drain",(function(){--r||n()})))}else n()}},{key:"poll",value:function(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}},{key:"onData",value:function(t){var e=this;(function(t,e){for(var n=t.split(q),r=[],i=0;i0&&void 0!==arguments[0]?arguments[0]:{};return i(t,{xd:this.xd,cookieJar:this.cookieJar},this.opts),new ot(this.uri(),t)}},{key:"doWrite",value:function(t,e){var n=this,r=this.request({method:"POST",data:t});r.on("success",e),r.on("error",(function(t,e){n.onError("xhr post error",t,e)}))}},{key:"doPoll",value:function(){var t=this,e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(function(e,n){t.onError("xhr poll error",e,n)})),this.pollXhr=e}}]),s}(W),ot=function(t){o(i,t);var n=p(i);function i(t,r){var o;return e(this,i),V(f(o=n.call(this)),r),o.opts=r,o.method=r.method||"GET",o.uri=t,o.data=void 0!==r.data?r.data:null,o.create(),o}return r(i,[{key:"create",value:function(){var t,e=this,n=F(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");n.xdomain=!!this.opts.xd;var r=this.xhr=new et(n);try{r.open(this.method,this.uri,!0);try{if(this.opts.extraHeaders)for(var o in r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0),this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(o)&&r.setRequestHeader(o,this.opts.extraHeaders[o])}catch(t){}if("POST"===this.method)try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(t){}try{r.setRequestHeader("Accept","*/*")}catch(t){}null===(t=this.opts.cookieJar)||void 0===t||t.addCookies(r),"withCredentials"in r&&(r.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(r.timeout=this.opts.requestTimeout),r.onreadystatechange=function(){var t;3===r.readyState&&(null===(t=e.opts.cookieJar)||void 0===t||t.parseCookies(r)),4===r.readyState&&(200===r.status||1223===r.status?e.onLoad():e.setTimeoutFn((function(){e.onError("number"==typeof r.status?r.status:0)}),0))},r.send(this.data)}catch(t){return void this.setTimeoutFn((function(){e.onError(t)}),0)}"undefined"!=typeof document&&(this.index=i.requestsCount++,i.requests[this.index]=this)}},{key:"onError",value:function(t){this.emitReserved("error",t,this.xhr),this.cleanup(!0)}},{key:"cleanup",value:function(t){if(void 0!==this.xhr&&null!==this.xhr){if(this.xhr.onreadystatechange=nt,t)try{this.xhr.abort()}catch(t){}"undefined"!=typeof document&&delete i.requests[this.index],this.xhr=null}}},{key:"onLoad",value:function(){var t=this.xhr.responseText;null!==t&&(this.emitReserved("data",t),this.emitReserved("success"),this.cleanup())}},{key:"abort",value:function(){this.cleanup()}}]),i}(I);if(ot.requestsCount=0,ot.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",st);else if("function"==typeof addEventListener){addEventListener("onpagehide"in D?"pagehide":"unload",st,!1)}function st(){for(var t in ot.requests)ot.requests.hasOwnProperty(t)&&ot.requests[t].abort()}var at="function"==typeof Promise&&"function"==typeof Promise.resolve?function(t){return Promise.resolve().then(t)}:function(t,e){return e(t,0)},ct=D.WebSocket||D.MozWebSocket,ut="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase(),ht=function(t){o(i,t);var n=p(i);function i(t){var r;return e(this,i),(r=n.call(this,t)).supportsBinary=!t.forceBase64,r}return r(i,[{key:"name",get:function(){return"websocket"}},{key:"doOpen",value:function(){if(this.check()){var t=this.uri(),e=this.opts.protocols,n=ut?{}:F(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=ut?new ct(t,e,n):e?new ct(t,e):new ct(t)}catch(t){return this.emitReserved("error",t)}this.ws.binaryType=this.socket.binaryType||"arraybuffer",this.addEventListeners()}}},{key:"addEventListeners",value:function(){var t=this;this.ws.onopen=function(){t.opts.autoUnref&&t.ws._socket.unref(),t.onOpen()},this.ws.onclose=function(e){return t.onClose({description:"websocket connection closed",context:e})},this.ws.onmessage=function(e){return t.onData(e.data)},this.ws.onerror=function(e){return t.onError("websocket error",e)}}},{key:"write",value:function(t){var e=this;this.writable=!1;for(var n=function(n){var r=t[n],i=n===t.length-1;E(r,e.supportsBinary,(function(t){try{e.ws.send(t)}catch(t){}i&&at((function(){e.writable=!0,e.emitReserved("drain")}),e.setTimeoutFn)}))},r=0;r54;return x(r?t:L.decode(t),n)}(o,n,"arraybuffer")),n=!1):n=!0,e())}))}();var i=t.query.sid?'0{"sid":"'.concat(t.query.sid,'"}'):"0";t.writer.write((new TextEncoder).encode(i)).then((function(){return t.onOpen()}))}))})))}},{key:"write",value:function(t){var e=this;this.writable=!1;for(var n=function(n){var r=t[n],i=n===t.length-1;!function(t,e){_&&t.data instanceof Blob?t.data.arrayBuffer().then(T).then(e):O&&(t.data instanceof ArrayBuffer||A(t.data))?e(T(t.data)):E(t,!1,(function(t){b||(b=new TextEncoder),e(b.encode(t))}))}(r,(function(t){(function(t,e){return"message"===t.type&&"string"!=typeof t.data&&e[0]>=48&&e[0]<=54})(r,t)&&e.writer.write(Uint8Array.of(54)),e.writer.write(t).then((function(){i&&at((function(){e.writable=!0,e.emitReserved("drain")}),e.setTimeoutFn)}))}))},r=0;r1&&void 0!==arguments[1]?arguments[1]:{};return e(this,a),(r=s.call(this)).writeBuffer=[],n&&"object"===t(n)&&(o=n,n=null),n?(n=yt(n),o.hostname=n.host,o.secure="https"===n.protocol||"wss"===n.protocol,o.port=n.port,n.query&&(o.query=n.query)):o.host&&(o.hostname=yt(o.host).host),V(f(r),o),r.secure=null!=o.secure?o.secure:"undefined"!=typeof location&&"https:"===location.protocol,o.hostname&&!o.port&&(o.port=r.secure?"443":"80"),r.hostname=o.hostname||("undefined"!=typeof location?location.hostname:"localhost"),r.port=o.port||("undefined"!=typeof location&&location.port?location.port:r.secure?"443":"80"),r.transports=o.transports||["polling","websocket","webtransport"],r.writeBuffer=[],r.prevBufferLen=0,r.opts=i({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!0},o),r.opts.path=r.opts.path.replace(/\/$/,"")+(r.opts.addTrailingSlash?"/":""),"string"==typeof r.opts.query&&(r.opts.query=H(r.opts.query)),r.id=null,r.upgrades=null,r.pingInterval=null,r.pingTimeout=null,r.pingTimeoutTimer=null,"function"==typeof addEventListener&&(r.opts.closeOnBeforeunload&&(r.beforeunloadEventListener=function(){r.transport&&(r.transport.removeAllListeners(),r.transport.close())},addEventListener("beforeunload",r.beforeunloadEventListener,!1)),"localhost"!==r.hostname&&(r.offlineEventListener=function(){r.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",r.offlineEventListener,!1))),r.open(),r}return r(a,[{key:"createTransport",value:function(t){var e=i({},this.opts.query);e.EIO=4,e.transport=t,this.id&&(e.sid=this.id);var n=i({},this.opts.transportOptions[t],this.opts,{query:e,socket:this,hostname:this.hostname,secure:this.secure,port:this.port});return new lt[t](n)}},{key:"open",value:function(){var t,e=this;if(this.opts.rememberUpgrade&&a.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))t="websocket";else{if(0===this.transports.length)return void this.setTimeoutFn((function(){e.emitReserved("error","No transports available")}),0);t=this.transports[0]}this.readyState="opening";try{t=this.createTransport(t)}catch(t){return this.transports.shift(),void this.open()}t.open(),this.setTransport(t)}},{key:"setTransport",value:function(t){var e=this;this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",(function(t){return e.onClose("transport close",t)}))}},{key:"probe",value:function(t){var e=this,n=this.createTransport(t),r=!1;a.priorWebsocketSuccess=!1;var i=function(){r||(n.send([{type:"ping",data:"probe"}]),n.once("packet",(function(t){if(!r)if("pong"===t.type&&"probe"===t.data){if(e.upgrading=!0,e.emitReserved("upgrading",n),!n)return;a.priorWebsocketSuccess="websocket"===n.name,e.transport.pause((function(){r||"closed"!==e.readyState&&(f(),e.setTransport(n),n.send([{type:"upgrade"}]),e.emitReserved("upgrade",n),n=null,e.upgrading=!1,e.flush())}))}else{var i=new Error("probe error");i.transport=n.name,e.emitReserved("upgradeError",i)}})))};function o(){r||(r=!0,f(),n.close(),n=null)}var s=function(t){var r=new Error("probe error: "+t);r.transport=n.name,o(),e.emitReserved("upgradeError",r)};function c(){s("transport closed")}function u(){s("socket closed")}function h(t){n&&t.name!==n.name&&o()}var f=function(){n.removeListener("open",i),n.removeListener("error",s),n.removeListener("close",c),e.off("close",u),e.off("upgrading",h)};n.once("open",i),n.once("error",s),n.once("close",c),this.once("close",u),this.once("upgrading",h),-1!==this.upgrades.indexOf("webtransport")&&"webtransport"!==t?this.setTimeoutFn((function(){r||n.open()}),200):n.open()}},{key:"onOpen",value:function(){if(this.readyState="open",a.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush(),"open"===this.readyState&&this.opts.upgrade)for(var t=0,e=this.upgrades.length;t1))return this.writeBuffer;for(var t,e=1,n=0;n=57344?n+=3:(r++,n+=4);return n}(t):Math.ceil(1.33*(t.byteLength||t.size))),n>0&&e>this.maxPayload)return this.writeBuffer.slice(0,n);e+=2}return this.writeBuffer}},{key:"write",value:function(t,e,n){return this.sendPacket("message",t,e,n),this}},{key:"send",value:function(t,e,n){return this.sendPacket("message",t,e,n),this}},{key:"sendPacket",value:function(t,e,n,r){if("function"==typeof e&&(r=e,e=void 0),"function"==typeof n&&(r=n,n=null),"closing"!==this.readyState&&"closed"!==this.readyState){(n=n||{}).compress=!1!==n.compress;var i={type:t,data:e,options:n};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),r&&this.once("flush",r),this.flush()}}},{key:"close",value:function(){var t=this,e=function(){t.onClose("forced close"),t.transport.close()},n=function n(){t.off("upgrade",n),t.off("upgradeError",n),e()},r=function(){t.once("upgrade",n),t.once("upgradeError",n)};return"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",(function(){t.upgrading?r():e()})):this.upgrading?r():e()),this}},{key:"onError",value:function(t){a.priorWebsocketSuccess=!1,this.emitReserved("error",t),this.onClose("transport error",t)}},{key:"onClose",value:function(t,e){"opening"!==this.readyState&&"open"!==this.readyState&&"closing"!==this.readyState||(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),"function"==typeof removeEventListener&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",t,e),this.writeBuffer=[],this.prevBufferLen=0)}},{key:"filterUpgrades",value:function(t){for(var e=[],n=0,r=t.length;n=0&&e.num1?e-1:0),r=1;r1?n-1:0),i=1;in._opts.retries&&(n._queue.shift(),e&&e(t));else if(n._queue.shift(),e){for(var o=arguments.length,s=new Array(o>1?o-1:0),a=1;a0&&void 0!==arguments[0]&&arguments[0];if(this.connected&&0!==this._queue.length){var e=this._queue[0];e.pending&&!t||(e.pending=!0,e.tryCount++,this.flags=e.flags,this.emit.apply(this,e.args))}}},{key:"packet",value:function(t){t.nsp=this.nsp,this.io._packet(t)}},{key:"onopen",value:function(){var t=this;"function"==typeof this.auth?this.auth((function(e){t._sendConnectPacket(e)})):this._sendConnectPacket(this.auth)}},{key:"_sendConnectPacket",value:function(t){this.packet({type:Tt.CONNECT,data:this._pid?i({pid:this._pid,offset:this._lastOffset},t):t})}},{key:"onerror",value:function(t){this.connected||this.emitReserved("connect_error",t)}},{key:"onclose",value:function(t,e){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,e)}},{key:"onpacket",value:function(t){if(t.nsp===this.nsp)switch(t.type){case Tt.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case Tt.EVENT:case Tt.BINARY_EVENT:this.onevent(t);break;case Tt.ACK:case Tt.BINARY_ACK:this.onack(t);break;case Tt.DISCONNECT:this.ondisconnect();break;case Tt.CONNECT_ERROR:this.destroy();var e=new Error(t.data.message);e.data=t.data.data,this.emitReserved("connect_error",e)}}},{key:"onevent",value:function(t){var e=t.data||[];null!=t.id&&e.push(this.ack(t.id)),this.connected?this.emitEvent(e):this.receiveBuffer.push(Object.freeze(e))}},{key:"emitEvent",value:function(t){if(this._anyListeners&&this._anyListeners.length){var e,n=g(this._anyListeners.slice());try{for(n.s();!(e=n.n()).done;){e.value.apply(this,t)}}catch(t){n.e(t)}finally{n.f()}}y(s(a.prototype),"emit",this).apply(this,t),this._pid&&t.length&&"string"==typeof t[t.length-1]&&(this._lastOffset=t[t.length-1])}},{key:"ack",value:function(t){var e=this,n=!1;return function(){if(!n){n=!0;for(var r=arguments.length,i=new Array(r),o=0;o0&&t.jitter<=1?t.jitter:0,this.attempts=0}It.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),n=Math.floor(e*this.jitter*t);t=0==(1&Math.floor(10*e))?t-n:t+n}return 0|Math.min(t,this.max)},It.prototype.reset=function(){this.attempts=0},It.prototype.setMin=function(t){this.ms=t},It.prototype.setMax=function(t){this.max=t},It.prototype.setJitter=function(t){this.jitter=t};var Dt=function(n){o(s,n);var i=p(s);function s(n,r){var o,a;e(this,s),(o=i.call(this)).nsps={},o.subs=[],n&&"object"===t(n)&&(r=n,n=void 0),(r=r||{}).path=r.path||"/socket.io",o.opts=r,V(f(o),r),o.reconnection(!1!==r.reconnection),o.reconnectionAttempts(r.reconnectionAttempts||1/0),o.reconnectionDelay(r.reconnectionDelay||1e3),o.reconnectionDelayMax(r.reconnectionDelayMax||5e3),o.randomizationFactor(null!==(a=r.randomizationFactor)&&void 0!==a?a:.5),o.backoff=new It({min:o.reconnectionDelay(),max:o.reconnectionDelayMax(),jitter:o.randomizationFactor()}),o.timeout(null==r.timeout?2e4:r.timeout),o._readyState="closed",o.uri=n;var c=r.parser||xt;return o.encoder=new c.Encoder,o.decoder=new c.Decoder,o._autoConnect=!1!==r.autoConnect,o._autoConnect&&o.open(),o}return r(s,[{key:"reconnection",value:function(t){return arguments.length?(this._reconnection=!!t,this):this._reconnection}},{key:"reconnectionAttempts",value:function(t){return void 0===t?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}},{key:"reconnectionDelay",value:function(t){var e;return void 0===t?this._reconnectionDelay:(this._reconnectionDelay=t,null===(e=this.backoff)||void 0===e||e.setMin(t),this)}},{key:"randomizationFactor",value:function(t){var e;return void 0===t?this._randomizationFactor:(this._randomizationFactor=t,null===(e=this.backoff)||void 0===e||e.setJitter(t),this)}},{key:"reconnectionDelayMax",value:function(t){var e;return void 0===t?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,null===(e=this.backoff)||void 0===e||e.setMax(t),this)}},{key:"timeout",value:function(t){return arguments.length?(this._timeout=t,this):this._timeout}},{key:"maybeReconnectOnOpen",value:function(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}},{key:"open",value:function(t){var e=this;if(~this._readyState.indexOf("open"))return this;this.engine=new vt(this.uri,this.opts);var n=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;var i=Pt(n,"open",(function(){r.onopen(),t&&t()})),o=function(n){e.cleanup(),e._readyState="closed",e.emitReserved("error",n),t?t(n):e.maybeReconnectOnOpen()},s=Pt(n,"error",o);if(!1!==this._timeout){var a=this._timeout,c=this.setTimeoutFn((function(){i(),o(new Error("timeout")),n.close()}),a);this.opts.autoUnref&&c.unref(),this.subs.push((function(){e.clearTimeoutFn(c)}))}return this.subs.push(i),this.subs.push(s),this}},{key:"connect",value:function(t){return this.open(t)}},{key:"onopen",value:function(){this.cleanup(),this._readyState="open",this.emitReserved("open");var t=this.engine;this.subs.push(Pt(t,"ping",this.onping.bind(this)),Pt(t,"data",this.ondata.bind(this)),Pt(t,"error",this.onerror.bind(this)),Pt(t,"close",this.onclose.bind(this)),Pt(this.decoder,"decoded",this.ondecoded.bind(this)))}},{key:"onping",value:function(){this.emitReserved("ping")}},{key:"ondata",value:function(t){try{this.decoder.add(t)}catch(t){this.onclose("parse error",t)}}},{key:"ondecoded",value:function(t){var e=this;at((function(){e.emitReserved("packet",t)}),this.setTimeoutFn)}},{key:"onerror",value:function(t){this.emitReserved("error",t)}},{key:"socket",value:function(t,e){var n=this.nsps[t];return n?this._autoConnect&&!n.active&&n.connect():(n=new qt(this,t,e),this.nsps[t]=n),n}},{key:"_destroy",value:function(t){for(var e=0,n=Object.keys(this.nsps);e=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{var n=this.backoff.duration();this._reconnecting=!0;var r=this.setTimeoutFn((function(){e.skipReconnect||(t.emitReserved("reconnect_attempt",e.backoff.attempts),e.skipReconnect||e.open((function(n){n?(e._reconnecting=!1,e.reconnect(),t.emitReserved("reconnect_error",n)):e.onreconnect()})))}),n);this.opts.autoUnref&&r.unref(),this.subs.push((function(){t.clearTimeoutFn(r)}))}}},{key:"onreconnect",value:function(){var t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}]),s}(I),Ft={};function Ut(e,n){"object"===t(e)&&(n=e,e=void 0);var r,i=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2?arguments[2]:void 0,r=t;n=n||"undefined"!=typeof location&&location,null==t&&(t=n.protocol+"//"+n.host),"string"==typeof t&&("/"===t.charAt(0)&&(t="/"===t.charAt(1)?n.protocol+t:n.host+t),/^(https?|wss?):\/\//.test(t)||(t=void 0!==n?n.protocol+"//"+t:"https://"+t),r=yt(t)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";var i=-1!==r.host.indexOf(":")?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+i+":"+r.port+e,r.href=r.protocol+"://"+i+(n&&n.port===r.port?"":":"+r.port),r}(e,(n=n||{}).path||"/socket.io"),o=i.source,s=i.id,a=i.path,c=Ft[s]&&a in Ft[s].nsps;return n.forceNew||n["force new connection"]||!1===n.multiplex||c?r=new Dt(o,n):(Ft[s]||(Ft[s]=new Dt(o,n)),r=Ft[s]),i.query&&!n.query&&(n.query=i.queryKey),r.socket(i.path,n)}return i(Ut,{Manager:Dt,Socket:qt,io:Ut,connect:Ut}),Ut}));
+!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(t="undefined"!=typeof globalThis?globalThis:t||self).io=n()}(this,(function(){"use strict";function t(t,n){(null==n||n>t.length)&&(n=t.length);for(var i=0,r=Array(n);i=n.length?{done:!0}:{done:!1,value:n[e++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,u=!0,h=!1;return{s:function(){r=r.call(n)},n:function(){var t=r.next();return u=t.done,t},e:function(t){h=!0,s=t},f:function(){try{u||null==r.return||r.return()}finally{if(h)throw s}}}}function e(){return e=Object.assign?Object.assign.bind():function(t){for(var n=1;n1?{type:l[i],data:t.substring(1)}:{type:l[i]}:d},N=function(t,n){if(B){var i=function(t){var n,i,r,e,o,s=.75*t.length,u=t.length,h=0;"="===t[t.length-1]&&(s--,"="===t[t.length-2]&&s--);var f=new ArrayBuffer(s),c=new Uint8Array(f);for(n=0;n>4,c[h++]=(15&r)<<4|e>>2,c[h++]=(3&e)<<6|63&o;return f}(t);return C(i,n)}return{base64:!0,data:t}},C=function(t,n){return"blob"===n?t instanceof Blob?t:new Blob([t]):t instanceof ArrayBuffer?t:t.buffer},T=String.fromCharCode(30);function U(){return new TransformStream({transform:function(t,n){!function(t,n){y&&t.data instanceof Blob?t.data.arrayBuffer().then(k).then(n):b&&(t.data instanceof ArrayBuffer||w(t.data))?n(k(t.data)):g(t,!1,(function(t){p||(p=new TextEncoder),n(p.encode(t))}))}(t,(function(i){var r,e=i.length;if(e<126)r=new Uint8Array(1),new DataView(r.buffer).setUint8(0,e);else if(e<65536){r=new Uint8Array(3);var o=new DataView(r.buffer);o.setUint8(0,126),o.setUint16(1,e)}else{r=new Uint8Array(9);var s=new DataView(r.buffer);s.setUint8(0,127),s.setBigUint64(1,BigInt(e))}t.data&&"string"!=typeof t.data&&(r[0]|=128),n.enqueue(r),n.enqueue(i)}))}})}function M(t){return t.reduce((function(t,n){return t+n.length}),0)}function x(t,n){if(t[0].length===n)return t.shift();for(var i=new Uint8Array(n),r=0,e=0;e1?n-1:0),r=1;r1&&void 0!==arguments[1]?arguments[1]:{};return t+"://"+this.i()+this.o()+this.opts.path+this.u(n)},i.i=function(){var t=this.opts.hostname;return-1===t.indexOf(":")?t:"["+t+"]"},i.o=function(){return this.opts.port&&(this.opts.secure&&Number(443!==this.opts.port)||!this.opts.secure&&80!==Number(this.opts.port))?":"+this.opts.port:""},i.u=function(t){var n=function(t){var n="";for(var i in t)t.hasOwnProperty(i)&&(n.length&&(n+="&"),n+=encodeURIComponent(i)+"="+encodeURIComponent(t[i]));return n}(t);return n.length?"?"+n:""},n}(I),X=function(t){function n(){var n;return(n=t.apply(this,arguments)||this).h=!1,n}s(n,t);var r=n.prototype;return r.doOpen=function(){this.v()},r.pause=function(t){var n=this;this.readyState="pausing";var i=function(){n.readyState="paused",t()};if(this.h||!this.writable){var r=0;this.h&&(r++,this.once("pollComplete",(function(){--r||i()}))),this.writable||(r++,this.once("drain",(function(){--r||i()})))}else i()},r.v=function(){this.h=!0,this.doPoll(),this.emitReserved("poll")},r.onData=function(t){var n=this;(function(t,n){for(var i=t.split(T),r=[],e=0;e0&&void 0!==arguments[0]?arguments[0]:{};return e(t,{xd:this.xd},this.opts),new Y(tt,this.uri(),t)},n}(K);function tt(t){var n=t.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!n||z))return new XMLHttpRequest}catch(t){}if(!n)try{return new(L[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(t){}}var nt="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase(),it=function(t){function n(){return t.apply(this,arguments)||this}s(n,t);var r=n.prototype;return r.doOpen=function(){var t=this.uri(),n=this.opts.protocols,i=nt?{}:_(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(i.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(t,n,i)}catch(t){return this.emitReserved("error",t)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()},r.addEventListeners=function(){var t=this;this.ws.onopen=function(){t.opts.autoUnref&&t.ws.C.unref(),t.onOpen()},this.ws.onclose=function(n){return t.onClose({description:"websocket connection closed",context:n})},this.ws.onmessage=function(n){return t.onData(n.data)},this.ws.onerror=function(n){return t.onError("websocket error",n)}},r.write=function(t){var n=this;this.writable=!1;for(var i=function(){var i=t[r],e=r===t.length-1;g(i,n.supportsBinary,(function(t){try{n.doWrite(i,t)}catch(t){}e&&R((function(){n.writable=!0,n.emitReserved("drain")}),n.setTimeoutFn)}))},r=0;rMath.pow(2,21)-1){u.enqueue(d);break}e=v*Math.pow(2,32)+a.getUint32(4),r=3}else{if(M(i)t){u.enqueue(d);break}}}})}(Number.MAX_SAFE_INTEGER,t.socket.binaryType),r=n.readable.pipeThrough(i).getReader(),e=U();e.readable.pipeTo(n.writable),t.U=e.writable.getWriter();!function n(){r.read().then((function(i){var r=i.done,e=i.value;r||(t.onPacket(e),n())})).catch((function(t){}))}();var o={type:"open"};t.query.sid&&(o.data='{"sid":"'.concat(t.query.sid,'"}')),t.U.write(o).then((function(){return t.onOpen()}))}))}))},r.write=function(t){var n=this;this.writable=!1;for(var i=function(){var i=t[r],e=r===t.length-1;n.U.write(i).then((function(){e&&R((function(){n.writable=!0,n.emitReserved("drain")}),n.setTimeoutFn)}))},r=0;r8e3)throw"URI too long";var n=t,i=t.indexOf("["),r=t.indexOf("]");-1!=i&&-1!=r&&(t=t.substring(0,i)+t.substring(i,r).replace(/:/g,";")+t.substring(r,t.length));for(var e,o,s=ut.exec(t||""),u={},h=14;h--;)u[ht[h]]=s[h]||"";return-1!=i&&-1!=r&&(u.source=n,u.host=u.host.substring(1,u.host.length-1).replace(/;/g,":"),u.authority=u.authority.replace("[","").replace("]","").replace(/;/g,":"),u.ipv6uri=!0),u.pathNames=function(t,n){var i=/\/{2,9}/g,r=n.replace(i,"/").split("/");"/"!=n.slice(0,1)&&0!==n.length||r.splice(0,1);"/"==n.slice(-1)&&r.splice(r.length-1,1);return r}(0,u.path),u.queryKey=(e=u.query,o={},e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,(function(t,n,i){n&&(o[n]=i)})),o),u}var ct="function"==typeof addEventListener&&"function"==typeof removeEventListener,at=[];ct&&addEventListener("offline",(function(){at.forEach((function(t){return t()}))}),!1);var vt=function(t){function n(n,i){var r;if((r=t.call(this)||this).binaryType="arraybuffer",r.writeBuffer=[],r.M=0,r.I=-1,r.R=-1,r.L=-1,r._=1/0,n&&"object"===c(n)&&(i=n,n=null),n){var o=ft(n);i.hostname=o.host,i.secure="https"===o.protocol||"wss"===o.protocol,i.port=o.port,o.query&&(i.query=o.query)}else i.host&&(i.hostname=ft(i.host).host);return $(r,i),r.secure=null!=i.secure?i.secure:"undefined"!=typeof location&&"https:"===location.protocol,i.hostname&&!i.port&&(i.port=r.secure?"443":"80"),r.hostname=i.hostname||("undefined"!=typeof location?location.hostname:"localhost"),r.port=i.port||("undefined"!=typeof location&&location.port?location.port:r.secure?"443":"80"),r.transports=[],r.D={},i.transports.forEach((function(t){var n=t.prototype.name;r.transports.push(n),r.D[n]=t})),r.opts=e({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},i),r.opts.path=r.opts.path.replace(/\/$/,"")+(r.opts.addTrailingSlash?"/":""),"string"==typeof r.opts.query&&(r.opts.query=function(t){for(var n={},i=t.split("&"),r=0,e=i.length;r1))return this.writeBuffer;for(var t,n=1,i=0;i=57344?i+=3:(r++,i+=4);return i}(t):Math.ceil(1.33*(t.byteLength||t.size))),i>0&&n>this.L)return this.writeBuffer.slice(0,i);n+=2}return this.writeBuffer},i.W=function(){var t=this;if(!this._)return!0;var n=Date.now()>this._;return n&&(this._=0,R((function(){t.F("ping timeout")}),this.setTimeoutFn)),n},i.write=function(t,n,i){return this.J("message",t,n,i),this},i.send=function(t,n,i){return this.J("message",t,n,i),this},i.J=function(t,n,i,r){if("function"==typeof n&&(r=n,n=void 0),"function"==typeof i&&(r=i,i=null),"closing"!==this.readyState&&"closed"!==this.readyState){(i=i||{}).compress=!1!==i.compress;var e={type:t,data:n,options:i};this.emitReserved("packetCreate",e),this.writeBuffer.push(e),r&&this.once("flush",r),this.flush()}},i.close=function(){var t=this,n=function(){t.F("forced close"),t.transport.close()},i=function i(){t.off("upgrade",i),t.off("upgradeError",i),n()},r=function(){t.once("upgrade",i),t.once("upgradeError",i)};return"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",(function(){t.upgrading?r():n()})):this.upgrading?r():n()),this},i.B=function(t){if(n.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&"opening"===this.readyState)return this.transports.shift(),this.q();this.emitReserved("error",t),this.F("transport error",t)},i.F=function(t,n){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState){if(this.clearTimeoutFn(this.Y),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),ct&&(this.P&&removeEventListener("beforeunload",this.P,!1),this.$)){var i=at.indexOf(this.$);-1!==i&&at.splice(i,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,n),this.writeBuffer=[],this.M=0}},n}(I);vt.protocol=4;var lt=function(t){function n(){var n;return(n=t.apply(this,arguments)||this).Z=[],n}s(n,t);var i=n.prototype;return i.onOpen=function(){if(t.prototype.onOpen.call(this),"open"===this.readyState&&this.opts.upgrade)for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{},r="object"===c(n)?n:i;return(!r.transports||r.transports&&"string"==typeof r.transports[0])&&(r.transports=(r.transports||["polling","websocket","webtransport"]).map((function(t){return st[t]})).filter((function(t){return!!t}))),t.call(this,n,r)||this}return s(n,t),n}(lt);pt.protocol;var dt="function"==typeof ArrayBuffer,yt=function(t){return"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(t):t.buffer instanceof ArrayBuffer},bt=Object.prototype.toString,wt="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===bt.call(Blob),gt="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===bt.call(File);function mt(t){return dt&&(t instanceof ArrayBuffer||yt(t))||wt&&t instanceof Blob||gt&&t instanceof File}function kt(t,n){if(!t||"object"!==c(t))return!1;if(Array.isArray(t)){for(var i=0,r=t.length;i=0&&t.num1?e-1:0),s=1;s1?i-1:0),e=1;ei.l.retries&&(i.it.shift(),n&&n(t));else if(i.it.shift(),n){for(var e=arguments.length,o=new Array(e>1?e-1:0),s=1;s0&&void 0!==arguments[0]&&arguments[0];if(this.connected&&0!==this.it.length){var n=this.it[0];n.pending&&!t||(n.pending=!0,n.tryCount++,this.flags=n.flags,this.emit.apply(this,n.args))}},o.packet=function(t){t.nsp=this.nsp,this.io.ct(t)},o.onopen=function(){var t=this;"function"==typeof this.auth?this.auth((function(n){t.vt(n)})):this.vt(this.auth)},o.vt=function(t){this.packet({type:Bt.CONNECT,data:this.lt?e({pid:this.lt,offset:this.dt},t):t})},o.onerror=function(t){this.connected||this.emitReserved("connect_error",t)},o.onclose=function(t,n){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,n),this.yt()},o.yt=function(){var t=this;Object.keys(this.acks).forEach((function(n){if(!t.sendBuffer.some((function(t){return String(t.id)===n}))){var i=t.acks[n];delete t.acks[n],i.withError&&i.call(t,new Error("socket has been disconnected"))}}))},o.onpacket=function(t){if(t.nsp===this.nsp)switch(t.type){case Bt.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case Bt.EVENT:case Bt.BINARY_EVENT:this.onevent(t);break;case Bt.ACK:case Bt.BINARY_ACK:this.onack(t);break;case Bt.DISCONNECT:this.ondisconnect();break;case Bt.CONNECT_ERROR:this.destroy();var n=new Error(t.data.message);n.data=t.data.data,this.emitReserved("connect_error",n)}},o.onevent=function(t){var n=t.data||[];null!=t.id&&n.push(this.ack(t.id)),this.connected?this.emitEvent(n):this.receiveBuffer.push(Object.freeze(n))},o.emitEvent=function(n){if(this.bt&&this.bt.length){var i,e=r(this.bt.slice());try{for(e.s();!(i=e.n()).done;){i.value.apply(this,n)}}catch(t){e.e(t)}finally{e.f()}}t.prototype.emit.apply(this,n),this.lt&&n.length&&"string"==typeof n[n.length-1]&&(this.dt=n[n.length-1])},o.ack=function(t){var n=this,i=!1;return function(){if(!i){i=!0;for(var r=arguments.length,e=new Array(r),o=0;o0&&t.jitter<=1?t.jitter:0,this.attempts=0}_t.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var n=Math.random(),i=Math.floor(n*this.jitter*t);t=1&Math.floor(10*n)?t+i:t-i}return 0|Math.min(t,this.max)},_t.prototype.reset=function(){this.attempts=0},_t.prototype.setMin=function(t){this.ms=t},_t.prototype.setMax=function(t){this.max=t},_t.prototype.setJitter=function(t){this.jitter=t};var Dt=function(t){function n(n,i){var r,e;(r=t.call(this)||this).nsps={},r.subs=[],n&&"object"===c(n)&&(i=n,n=void 0),(i=i||{}).path=i.path||"/socket.io",r.opts=i,$(r,i),r.reconnection(!1!==i.reconnection),r.reconnectionAttempts(i.reconnectionAttempts||1/0),r.reconnectionDelay(i.reconnectionDelay||1e3),r.reconnectionDelayMax(i.reconnectionDelayMax||5e3),r.randomizationFactor(null!==(e=i.randomizationFactor)&&void 0!==e?e:.5),r.backoff=new _t({min:r.reconnectionDelay(),max:r.reconnectionDelayMax(),jitter:r.randomizationFactor()}),r.timeout(null==i.timeout?2e4:i.timeout),r.st="closed",r.uri=n;var o=i.parser||xt;return r.encoder=new o.Encoder,r.decoder=new o.Decoder,r.et=!1!==i.autoConnect,r.et&&r.open(),r}s(n,t);var i=n.prototype;return i.reconnection=function(t){return arguments.length?(this.kt=!!t,t||(this.skipReconnect=!0),this):this.kt},i.reconnectionAttempts=function(t){return void 0===t?this.At:(this.At=t,this)},i.reconnectionDelay=function(t){var n;return void 0===t?this.jt:(this.jt=t,null===(n=this.backoff)||void 0===n||n.setMin(t),this)},i.randomizationFactor=function(t){var n;return void 0===t?this.Et:(this.Et=t,null===(n=this.backoff)||void 0===n||n.setJitter(t),this)},i.reconnectionDelayMax=function(t){var n;return void 0===t?this.Ot:(this.Ot=t,null===(n=this.backoff)||void 0===n||n.setMax(t),this)},i.timeout=function(t){return arguments.length?(this.Bt=t,this):this.Bt},i.maybeReconnectOnOpen=function(){!this.ot&&this.kt&&0===this.backoff.attempts&&this.reconnect()},i.open=function(t){var n=this;if(~this.st.indexOf("open"))return this;this.engine=new pt(this.uri,this.opts);var i=this.engine,r=this;this.st="opening",this.skipReconnect=!1;var e=It(i,"open",(function(){r.onopen(),t&&t()})),o=function(i){n.cleanup(),n.st="closed",n.emitReserved("error",i),t?t(i):n.maybeReconnectOnOpen()},s=It(i,"error",o);if(!1!==this.Bt){var u=this.Bt,h=this.setTimeoutFn((function(){e(),o(new Error("timeout")),i.close()}),u);this.opts.autoUnref&&h.unref(),this.subs.push((function(){n.clearTimeoutFn(h)}))}return this.subs.push(e),this.subs.push(s),this},i.connect=function(t){return this.open(t)},i.onopen=function(){this.cleanup(),this.st="open",this.emitReserved("open");var t=this.engine;this.subs.push(It(t,"ping",this.onping.bind(this)),It(t,"data",this.ondata.bind(this)),It(t,"error",this.onerror.bind(this)),It(t,"close",this.onclose.bind(this)),It(this.decoder,"decoded",this.ondecoded.bind(this)))},i.onping=function(){this.emitReserved("ping")},i.ondata=function(t){try{this.decoder.add(t)}catch(t){this.onclose("parse error",t)}},i.ondecoded=function(t){var n=this;R((function(){n.emitReserved("packet",t)}),this.setTimeoutFn)},i.onerror=function(t){this.emitReserved("error",t)},i.socket=function(t,n){var i=this.nsps[t];return i?this.et&&!i.active&&i.connect():(i=new Lt(this,t,n),this.nsps[t]=i),i},i.wt=function(t){for(var n=0,i=Object.keys(this.nsps);n=this.At)this.backoff.reset(),this.emitReserved("reconnect_failed"),this.ot=!1;else{var i=this.backoff.duration();this.ot=!0;var r=this.setTimeoutFn((function(){n.skipReconnect||(t.emitReserved("reconnect_attempt",n.backoff.attempts),n.skipReconnect||n.open((function(i){i?(n.ot=!1,n.reconnect(),t.emitReserved("reconnect_error",i)):n.onreconnect()})))}),i);this.opts.autoUnref&&r.unref(),this.subs.push((function(){t.clearTimeoutFn(r)}))}},i.onreconnect=function(){var t=this.backoff.attempts;this.ot=!1,this.backoff.reset(),this.emitReserved("reconnect",t)},n}(I),Pt={};function $t(t,n){"object"===c(t)&&(n=t,t=void 0);var i,r=function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",i=arguments.length>2?arguments[2]:void 0,r=t;i=i||"undefined"!=typeof location&&location,null==t&&(t=i.protocol+"//"+i.host),"string"==typeof t&&("/"===t.charAt(0)&&(t="/"===t.charAt(1)?i.protocol+t:i.host+t),/^(https?|wss?):\/\//.test(t)||(t=void 0!==i?i.protocol+"//"+t:"https://"+t),r=ft(t)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";var e=-1!==r.host.indexOf(":")?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+e+":"+r.port+n,r.href=r.protocol+"://"+e+(i&&i.port===r.port?"":":"+r.port),r}(t,(n=n||{}).path||"/socket.io"),e=r.source,o=r.id,s=r.path,u=Pt[o]&&s in Pt[o].nsps;return n.forceNew||n["force new connection"]||!1===n.multiplex||u?i=new Dt(e,n):(Pt[o]||(Pt[o]=new Dt(e,n)),i=Pt[o]),r.query&&!n.query&&(n.query=r.queryKey),i.socket(r.path,n)}return e($t,{Manager:Dt,Socket:Lt,io:$t,connect:$t}),$t}));
//# sourceMappingURL=socket.io.min.js.map
diff --git a/data/src/storage.js b/data/src/storage.js
index d7da6885..7b60c909 100644
--- a/data/src/storage.js
+++ b/data/src/storage.js
@@ -34,7 +34,7 @@ class EJS_STORAGE {
};
openRequest.onupgradeneeded = () => {
let db = openRequest.result;
- if (! db.objectStoreNames.contains(this.storeName)) {
+ if (!db.objectStoreNames.contains(this.storeName)) {
db.createObjectStore(this.storeName);
};
};
@@ -58,7 +58,7 @@ class EJS_STORAGE {
};
openRequest.onupgradeneeded = () => {
let db = openRequest.result;
- if (! db.objectStoreNames.contains(this.storeName)) {
+ if (!db.objectStoreNames.contains(this.storeName)) {
db.createObjectStore(this.storeName);
};
};
@@ -80,7 +80,7 @@ class EJS_STORAGE {
};
openRequest.onupgradeneeded = () => {
let db = openRequest.result;
- if (! db.objectStoreNames.contains(this.storeName)) {
+ if (!db.objectStoreNames.contains(this.storeName)) {
db.createObjectStore(this.storeName);
};
};
@@ -92,7 +92,7 @@ class EJS_STORAGE {
const keys = await this.get("?EJS_KEYS!");
if (!keys) return resolve({});
let rv = {};
- for (let i=0; i
-
\ No newline at end of file
+
diff --git a/docs/contributors.json b/docs/contributors.json
new file mode 100644
index 00000000..d1eebe70
--- /dev/null
+++ b/docs/contributors.json
@@ -0,0 +1,46 @@
+{
+ "ignore": [
+ "ethanaobrien",
+ "allancoding",
+ "michael-j-green",
+ "ElectronicsArchiver"
+ ],
+ "missing": [
+ {
+ "login": "jurcaalexandrucristian",
+ "contributions": 1,
+ "avatar_url": "https://avatars.githubusercontent.com/u/74395896?v=4",
+ "html_url": "https://github.com/jurcaalexandrucristian"
+ },
+ {
+ "login": "Grey41",
+ "contributions": 2,
+ "avatar_url": "https://avatars.githubusercontent.com/u/85015029?v=4",
+ "html_url": "https://github.com/Grey41"
+ },
+ {
+ "login": "eric183",
+ "contributions": 1,
+ "avatar_url": "https://avatars.githubusercontent.com/u/10773980?v=4",
+ "html_url": "https://github.com/eric183"
+ },
+ {
+ "login": "Protektor-Desura",
+ "contributions": 1,
+ "avatar_url": "https://avatars.githubusercontent.com/u/1195496?v=4",
+ "html_url": "https://github.com/Protektor-Desura"
+ },
+ {
+ "login": "cheesykyle",
+ "contributions": 1,
+ "avatar_url": "https://avatars.githubusercontent.com/u/17484761?v=4",
+ "html_url": "https://github.com/cheesykyle"
+ },
+ {
+ "login": "imneckro",
+ "contributions": 1,
+ "avatar_url": "https://avatars.githubusercontent.com/u/42493772?v=4",
+ "html_url": "https://github.com/imneckro"
+ }
+ ]
+}
diff --git a/docs/Contributors.md b/docs/contributors.md
similarity index 55%
rename from docs/Contributors.md
rename to docs/contributors.md
index 40c18634..d12e7243 100644
--- a/docs/Contributors.md
+++ b/docs/contributors.md
@@ -27,7 +27,7 @@
**![Badge Allan GitHub]**
-**![Badge Allan Website]**
+**![Badge Allan Website]**