From 2fd0f545285151524262cc799efef6d996d7c6c1 Mon Sep 17 00:00:00 2001 From: Ethan O'Brien Date: Thu, 18 Aug 2022 08:40:50 -0500 Subject: [PATCH] Add ability to customize virtual gamepad. Fix shader not set on start. --- data/emu-main.js | 666 +++++++++++++++++++++++++++++++++---------- data/emulator.min.js | 2 +- data/loader.js | 3 +- data/version.json | 2 +- 4 files changed, 519 insertions(+), 154 deletions(-) diff --git a/data/emu-main.js b/data/emu-main.js index 683502e..7dcd887 100644 --- a/data/emu-main.js +++ b/data/emu-main.js @@ -3460,102 +3460,464 @@ window.EJS_main = function(_0xa88a13, _0x17edbf, _0x2c1832) { } }, 'toggleVirtualGamepad': function(_0x1ed80b) { - var _0xa88a13 = this; - if (null === _0x378b5c.virtualGamepadContainer) { - _0x378b5c.virtualGamepadContainer = _0x428003('div', { - 'class': _0x449eac({ - 'ejs-virtual-gamepad': true - }), - 'hidden': '' - }); - this.elements.container.appendChild(_0x378b5c.virtualGamepadContainer); - var blockCSS = 'height:31px;text-align:center;border:1px solid #ccc;border-radius:5px;line-height:31px;'; - var html = ''; - if (['snes', 'nds'].includes(_0xa88a13.system)) { - var elements = { - order: ['X','Y','A','B'], - orderCSS: ['left:40px;', 'top:40px;', 'left:81px;top:40px;', 'left:40px;top:80px;'], - LandR: true - } - } else if (['gba', 'gb', 'vb', 'nes'].includes(_0xa88a13.system)) { - var elements = { - order: ['B','A'], - orderCSS: ['left:-10px;top:70px;', 'left:60px;top:70px;'], - LandR: (_0xa88a13.system === 'gba') - } - } else if (['n64'].includes(_0xa88a13.system)) { - var elements = { - order: ['B','A'], - orderCSS: ['left:-10px;top:95px;', 'left:40px;top:150px;'], - LandR: true - } - } else { - var elements = { - order: ['Y','X','B','A'], - orderCSS: ['left:40px;', 'top:40px;', 'left:81px;top:40px;', 'left:40px;top:80px;'], - LandR: true - } - } - html += '
'; - - html += '
'; - if (elements.LandR === true) { - if (_0xa88a13.system === 'n64') { - html += '
L
'; - html += '
Z
'; - html += '
R
'; - } else { - html += '
L
'; - html += '
R
'; - } - } - html += '
'; - - html += '
'; - - html += '
'; - if (_0xa88a13.system === 'n64') { - html += '
'+_0xa88a13.localization('Start')+'
'; - } else { - html += '
'+_0xa88a13.localization('Start')+'
'; - html += '
'+_0xa88a13.localization('Select')+'
'; - } - html += '
'; - - html += '
'; - - if (_0xa88a13.system === 'n64') { - html += '
'; - html += '
'; - html += '
'; - html += '
'; - } - - for (var i=0; i'+elements.order[i]+'
'; - } - - html += '
'; - - _0x378b5c.virtualGamepadContainer.innerHTML = html; + var _this = this; + if (null !== _0x378b5c.virtualGamepadContainer) { _0x132da7(_0x378b5c.virtualGamepadContainer, !_0x1ed80b); + return + } + _0x378b5c.virtualGamepadContainer = _0x428003('div', { + 'class': _0x449eac({ + 'ejs-virtual-gamepad': true + }), + 'hidden': '' + }); + this.elements.container.appendChild(_0x378b5c.virtualGamepadContainer); + var blockCSS = 'height:31px;text-align:center;border:1px solid #ccc;border-radius:5px;line-height:31px;'; + var html = ''; + var info; + + if (_this.config.VirtualGamepadSettings && function(set) { + if (!Array.isArray(set)) { + console.warn("Vritual gamepad settings is not array! Using default gamepad settings"); + return false; + } + if (!set.length) { + console.warn("Vritual gamepad settings is empty! Using default gamepad settings"); + return false; + } + for (var i=0; i'; + html += '
'; + for (var i=0; i'+info[i].text+'
'; + } + } + html += ''; + html += '
'; + for (var i=0; i'+info[i].text+'
'; + } + } + html += ''; + html += '
'; + for (var i=0; i'+info[i].text+'
'; + } + } + html += ''; + html += '
'; + for (var i=0; i'+info[i].text+'
'; + } + } + html += ''; + _0x378b5c.virtualGamepadContainer.innerHTML = html; + _0x132da7(_0x378b5c.virtualGamepadContainer, !_0x1ed80b); + + var _0x2c1832 = _0x449eac({ + 'virtual-gamepad': true + }), + _0x2ec721 = _0x449eac({ + 'touch': true + }); + if (! _0x59aa33.isIos) { + _0x1093f4.call(this, _0x530042.call(this, '.' .concat(_0x2c1832)), 'touchmove', function(event) { + event.stopPropagation(); + }); + } + + var zone; + for (var i=0; i { - _0x1093f4.call(this, _0x530042.call(this, '.'.concat(_0x2c1832, ' .').concat(_0x449eac(a.id))), - 'touchstart touchend', function(e) { - ['touchend'].includes(e.type) ? (_0x3a8e2f(e.target, _0x2ec721, false), window.setTimeout(function() { + keys.push({id: opts, number: value}); + } + keys.forEach((a) => { + var element = _0x530042.call(_this, '.'.concat(_0x2c1832, ' .').concat(_0x449eac(a.id))); + if (!element) return; + _0x1093f4.call(_this, element, 'touchstart touchend', function(e) { + if (e.type === 'touchend') { + _0x3a8e2f(e.target, _0x2ec721, false); + window.setTimeout(function() { _0x378b5c.syncInput(0, a.number, 0); - }, 30)) : (_0x3a8e2f(e.target, _0x2ec721, true), _0x378b5c.syncInput(0, a.number, 1)), e.stopPropagation(); - }) - }); - var menuButton = _0x428003('div', { - 'class': _0x449eac({ - 'ejs__widget': true, - 'ejs__widget_controls_toggle': true - }) - }, ''); - menuButton.innerHTML = ''; - _0x530042.call(this, ".".concat(_0x449eac({ejs__widgets: true}))).appendChild(menuButton); - var hideTimeout; - _0x1093f4.call(this, menuButton, 'mousedown touchstart', function(e) { - _0x3a8e2f(e.target, _0x2ec721, true); - clearTimeout(hideTimeout); - _0x5ab74d.toggleControls.call(_0xa88a13, true); - hideTimeout = setTimeout(function() { - _0x5ab74d.toggleControls.call(_0xa88a13, false); - }, 5000) - }); - } else _0x132da7(_0x378b5c.virtualGamepadContainer, !_0x1ed80b); + }, 30) + } else { + _0x3a8e2f(e.target, _0x2ec721, true); + _0x378b5c.syncInput(0, a.number, 1) + } + e.stopPropagation(); + }) + }); + + var menuButton = _0x428003('div', { + 'class': _0x449eac({ + 'ejs__widget': true, + 'ejs__widget_controls_toggle': true + }) + }, ''); + menuButton.innerHTML = ''; + _0x530042.call(this, ".".concat(_0x449eac({ejs__widgets: true}))).appendChild(menuButton); + var hideTimeout; + _0x1093f4.call(this, menuButton, 'mousedown touchstart', function(e) { + _0x3a8e2f(e.target, _0x2ec721, true); + clearTimeout(hideTimeout); + _0x5ab74d.toggleControls.call(_this, true); + hideTimeout = setTimeout(function() { + _0x5ab74d.toggleControls.call(_this, false); + }, 5000) + }); }, 'setup': function() { var _0xa88a13 = this; @@ -3834,12 +4189,10 @@ window.EJS_main = function(_0xa88a13, _0x17edbf, _0x2c1832) { }; } _0x378b5c.setVariable = _0x27f4c4.Module.cwrap('set_variable', 'null', ['string', 'string']); - _0x378b5c.simulateInput = _0x27f4c4.Module.cwrap('simulate_input', 'null', ['number', 'number', 'number']); - /* _0x378b5c.simulateInputFn = _0x27f4c4.Module.cwrap('simulate_input', 'null', ['number', 'number', 'number']); _0x378b5c.simulateInput = function(_0x249751, _0x480d05, _0x50f784) { _0x378b5c.disableInput || _0x378b5c.simulateInputFn(_0x249751, _0x480d05, _0x50f784); - };*/ + }; _0x378b5c.syncInput = _0x378b5c.simulateInput; window.simulateInput = _0x378b5c.simulateInput; var _0x762355 = _0x27f4c4.Module.cwrap('shader_enable', 'null', ['number']); @@ -4961,16 +5314,24 @@ window.EJS_main = function(_0xa88a13, _0x17edbf, _0x2c1832) { var _0xa88a13 = this, _0x17edbf = this, _0x2c1832 = {}; - _0x2c1832.orientation = _0x7f9f36.storage.get('orientation'), _0x2c1832.shader = _0x7f9f36.storage.get('shader'), _0x17edbf.touch ? (_0x2c1832['virtual-gamepad'] = _0x7f9f36.storage.get('virtual-gamepad'), _0x1093f4.call(_0x17edbf, _0x17edbf.elements.container, 'start-game', function() { + _0x2c1832.orientation = _0x7f9f36.storage.get('orientation'); + _0x2c1832.shader = _0x7f9f36.storage.get('shader'); + _0x17edbf.touch ? (_0x2c1832['virtual-gamepad'] = _0x7f9f36.storage.get('virtual-gamepad'), _0x1093f4.call(_0x17edbf, _0x17edbf.elements.container, 'start-game', function() { ('enabled' === _0x2c1832['virtual-gamepad'] || _0x1e2c68.empty(_0x2c1832['virtual-gamepad'])) && _0xdcec2a.toggleVirtualGamepad.call(_0x17edbf, true); - })) : delete _0x7f9f36.normalOptions['virtual-gamepad'], _0x7f9f36.setOptionMenuItem.call(this, _0x7f9f36.normalOptions, _0x2c1832), _0x1093f4.call(_0x17edbf, _0x17edbf.elements.container, 'start-game', function() { + })) : delete _0x7f9f36.normalOptions['virtual-gamepad']; + _0x7f9f36.setOptionMenuItem.call(this, _0x7f9f36.normalOptions, _0x2c1832); + _0x1093f4.call(_0x17edbf, _0x17edbf.elements.container, 'start-game', function() { + var shader = _0x7f9f36.storage.get('shader'); + if (shader !== 'disabled') { + _0xdcec2a.setShader(shader); + } var _0x2c1832 = _0xa88a13, _0x42a7b1 = {}; _0xdcec2a.getGameCoreOptions && _0xdcec2a.getGameCoreOptions().split('\n').forEach(function(_0x4a987e, _0x10bd7a) { var _0x2c1832 = _0x4a987e.split('; '), - _0x1ddc5f = _0x2c1832[0x0]; - if (0x0 === _0x1ddc5f.indexOf('fba-dipswitch-')/* || _0x17edbf.coreVer === 2*/) { - var _0xbd808 = _0x2c1832[0x1].split('|'), + _0x1ddc5f = _0x2c1832[0]; + if (0 === _0x1ddc5f.indexOf('fba-dipswitch-') || _0x17edbf.coreVer === 2) { + var _0xbd808 = _0x2c1832[1].split('|'), _0x3c4b1a = _0x1ddc5f.split("|")[0].replace(/_/g, ' ').replace(/.+\-(.+)/, '$1'); _0xbd808.slice(1, -1); if (_0xbd808.length === 1) return; @@ -4983,9 +5344,12 @@ window.EJS_main = function(_0xa88a13, _0x17edbf, _0x2c1832) { } }); var _0x27d859 = _0x7f9f36.storage.get('core-options'); - _0x7f9f36.coreOptionsValues = _0x27d859 || {}, _0x7f9f36.setOptionMenuItem.call(_0x17edbf, _0x42a7b1, _0x7f9f36.coreOptionsValues), Object.keys(_0x7f9f36.coreOptionsValues).forEach(function(_0x51fc4e, _0x4b3613) { + _0x7f9f36.coreOptionsValues = _0x27d859 || {}; + _0x7f9f36.setOptionMenuItem.call(_0x17edbf, _0x42a7b1, _0x7f9f36.coreOptionsValues); + Object.keys(_0x7f9f36.coreOptionsValues).forEach(function(_0x51fc4e, _0x4b3613) { _0x7f9f36.updateCoreOptions.call(_0x2c1832, _0x51fc4e, _0x7f9f36.coreOptionsValues[_0x51fc4e]); - }), 'nds' == _0x17edbf.system && (_0x27f4c4.Module._fast_forward_2 ? _0x27f4c4.Module._fast_forward_2(0x1) : _0x27f4c4.Module._fast_forward && _0x27f4c4.Module._fast_forward(0x1)); + }); + 'nds' == _0x17edbf.system && (_0x27f4c4.Module._fast_forward_2 ? _0x27f4c4.Module._fast_forward_2(1) : _0x27f4c4.Module._fast_forward && _0x27f4c4.Module._fast_forward(1)); }); }, 'updateCoreOptionMenuItems': function() { @@ -5964,7 +6328,7 @@ window.EJS_main = function(_0xa88a13, _0x17edbf, _0x2c1832) { } return path } - this.version = '2.2.9'; + this.version = '2.3.0'; this.system = ''; this.adUrl = null; this.gameName = null; diff --git a/data/emulator.min.js b/data/emulator.min.js index 4e539a0..f42ce34 100644 --- a/data/emulator.min.js +++ b/data/emulator.min.js @@ -1 +1 @@ -var EJS=function(a){window.EJS_MODULES=a;var n={},o=[];function i(e){if(n[e])return n[e].exports;o.push(e);var t=n[e]={i:e,l:!1,exports:{}};return a[e].call(t.exports,t,t.exports,i),t.l=!0,t.exports}return window.getUsedModules=function(){return o.sort(function(e,t){return t'+n.localization("CORS Error")+"":t.innerHTML=''+n.localization("Network Error")+""}},null,null,null,null,null,function(e){function t(){if(!(navigator.getGamepads||navigator.webkitGetGamepads))throw new Error("get gamepads not found!");if(this.rAF=window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.requestAnimationFrame,!this.rAF)throw new Error("request animation frame was not found!");this.loop()}t.prototype={gamepads:[],rAF:null,getGamepads:function(){return navigator.getGamepads?navigator.getGamepads():navigator.webkitGetGamepads?navigator.webkitGetGamepads():[]},loop:async function(){this.updateGamepadState(),this.rAF.call(null,this.loop.bind(this))},updateGamepadState:function(){for(var n=this.getGamepads(),a=0;athis.options.threshold){var r={};for(l in this.direction)this.direction.hasOwnProperty(l)&&(r[l]=this.direction[l]);var l,c={};for(l in this.direction={x:n,y:a,angle:t},e.direction=this.direction,r)r[l]===this.direction[l]&&(c[l]=!0);if(c.x&&c.y&&c.angle)return e;c.x&&c.y||this.trigger("plain",e),c.x||this.trigger("plain:"+n,e),c.y||this.trigger("plain:"+a,e),c.angle||this.trigger("dir dir:"+t,e)}return e},a.prototype=new e,(a.constructor=a).id=0,a.prototype.prepareNipples=function(){var e=this,a=e.nipples;a.on=e.on.bind(e),a.off=e.off.bind(e),a.options=e.options,a.destroy=e.destroy.bind(e),a.ids=e.ids,a.id=e.id,a.processOnMove=e.processOnMove.bind(e),a.processOnEnd=e.processOnEnd.bind(e),a.get=function(e){if(void 0===e)return a[0];for(var t=0,n=a.length;t