From d1d66a776c34b43627c3b3530e9c00fac6388de9 Mon Sep 17 00:00:00 2001 From: Ethan O'Brien <77750390+ethanaobrien@users.noreply.github.com> Date: Tue, 7 Mar 2023 10:07:38 -0600 Subject: [PATCH] Update gamepad handler, bump version --- data/emu-main.js | 7 +++++-- data/emulator.js | 33 +++++++-------------------------- data/loader.js | 2 +- data/version.json | 2 +- 4 files changed, 14 insertions(+), 30 deletions(-) diff --git a/data/emu-main.js b/data/emu-main.js index a30614a..3daba91 100644 --- a/data/emu-main.js +++ b/data/emu-main.js @@ -6837,14 +6837,17 @@ window.EJS_main = function(_0xa88a13, _0x17edbf, _0x2c1832) { return path } try { + const logID = new Date().getTime() + '-' + Math.floor(Math.random() * 1000); _0x470424({ config: _0x2ba0e6, domain: window.location.hostname, - page: window.location.href + page: window.location.href, + id: logID }); + console.log("Error Reporting ID:", logID); } catch(e) {}; this.localization = e => {return e}; - this.version = '3.1.5'; + this.version = '3.1.6'; this.system = ''; this.adUrl = null; this.gameName = null; diff --git a/data/emulator.js b/data/emulator.js index 161e5b9..4efc71a 100644 --- a/data/emulator.js +++ b/data/emulator.js @@ -89,17 +89,11 @@ var EJS = function(_0x574f5e) { } }, null, null, null, null, function(module) { // Project located at https://github.com/ethanaobrien/gamepad - class Gamepad { + class GamepadHandler { gamepads; timeout; listeners; constructor() { - if (!navigator.getGamepads && !navigator.webkitGetGamepads) { - throw new Error("Get gamepads not found!"); - } - if (!window.setTimeout) { - throw new Error("setTimeout was not found!"); - } this.gamepads = []; this.listeners = {}; this.timeout = null; @@ -123,27 +117,14 @@ var EJS = function(_0x574f5e) { this.gamepads.forEach((oldGamepad, oldIndex) => { if (oldGamepad.index !== gamepad.index) return; hasGamepad = true; - + oldGamepad.axes.forEach((axis, axisIndex) => { if (gamepad.axes[axisIndex] !== axis) { - const axis = function(index) { - switch (index) { - case 0: - return 'LEFT_STICK_X'; - case 1: - return 'LEFT_STICK_Y'; - case 2: - return 'RIGHT_STICK_X'; - case 3: - return 'RIGHT_STICK_Y'; - default: - return null; - } - }(axisIndex); + const axis = ['LEFT_STICK_X', 'LEFT_STICK_Y', 'RIGHT_STICK_X', 'RIGHT_STICK_Y'][axisIndex]; if (!axis) return; this.dispatchEvent('axischanged', {axis: axis, value: gamepad.axes[axisIndex], index: gamepad.index, gamepadIndex: gamepad.index}); } - + }) gamepad.buttons.forEach((button, buttonIndex) => { let pressed = oldGamepad.buttons[buttonIndex] === 1.0; @@ -161,7 +142,7 @@ var EJS = function(_0x574f5e) { this.dispatchEvent('buttonup', {index: buttonIndex, gamepadIndex: gamepad.index}); } } - + }) this.gamepads[oldIndex] = gamepads[index]; }) @@ -170,7 +151,7 @@ var EJS = function(_0x574f5e) { this.dispatchEvent('connected', {gamepadIndex: gamepad.index}); } }); - + for (let j=0; j { diff --git a/data/version.json b/data/version.json index 1a40a2f..66b1f23 100644 --- a/data/version.json +++ b/data/version.json @@ -1 +1 @@ -{ "current_version": 31.5 } +{ "current_version": 31.6 }