re-write gamepad handler

This commit is contained in:
Ethan O'Brien 2022-08-15 18:52:09 -05:00
parent 4372ea79aa
commit 496504d0d7
5 changed files with 185 additions and 499 deletions

View file

@ -3279,146 +3279,26 @@ window.EJS_main = function(_0xa88a13, _0x17edbf, _0x2c1832) {
'initGamepad': function() {
var _0xa88a13 = this,
_0x17edbf = this,
_0x2c1832 = this.elements.dialogs.gamepad.querySelector('.' .concat(_0x378b5c.classNames.overlay)),
_0x181250 = new _0x4ad1c6.Gamepad();
_0x378b5c.gamepad = _0x181250;
if (!_0x181250.init()) {
_0x2c1832 = this.elements.dialogs.gamepad.querySelector('.' .concat(_0x378b5c.classNames.overlay));
var gamepad;
try {
gamepad = new _0x4ad1c6();
} catch(e) {
console.warn('gamepad not supported');
return;
}
_0x181250.bind(_0x4ad1c6.Gamepad.Event.TICK, function(_0x2fe35d) {
_0x2fe35d.forEach(function(_0x2b21f8) {
var _0x17edbf;
if (_0x2b21f8 && _0x2b21f8.axes && _0x2b21f8.axes[9]) {
(_0x17edbf = _0x2b21f8.axes[9]) < 3.28571 ? 1 == _0x17edbf ? (_0x2b21f8.extra_buttons[12].pressed || (_0x2b21f8.extra_buttons[12] = {
'pressed': true,
'value': 1
}, _0x181250._fire(_0x4ad1c6.Gamepad.Event.BUTTON_DOWN, {
'index': 12,
'gamepad': _0x2b21f8,
'gamepadIndex': _0x2b21f8.index
})), _0x2b21f8.extra_buttons[14].pressed || (_0x2b21f8.extra_buttons[14] = {
'pressed': true,
'value': 1
}, _0x181250._fire(_0x4ad1c6.Gamepad.Event.BUTTON_DOWN, {
'index': 14,
'gamepad': _0x2b21f8,
'gamepadIndex': _0x2b21f8.index
}))) : _0x17edbf <= -0.7142857 && _0x17edbf >= -0.714291 ? (_0x2b21f8.extra_buttons[12].pressed || (_0x2b21f8.extra_buttons[12] = {
'pressed': true,
'value': 1
}, _0x181250._fire(_0x4ad1c6.Gamepad.Event.BUTTON_DOWN, {
'index': 12,
'gamepad': _0x2b21f8,
'gamepadIndex': _0x2b21f8.index
})), _0x2b21f8.extra_buttons[15].pressed || (_0x2b21f8.extra_buttons[15] = {
'pressed': true,
'value': 1
}, _0x181250._fire(_0x4ad1c6.Gamepad.Event.BUTTON_DOWN, {
'index': 15,
'gamepad': _0x2b21f8,
'gamepadIndex': _0x2b21f8.index
}))) : _0x17edbf >= 0.42856 && _0x17edbf <= 0.42858 ? (_0x2b21f8.extra_buttons[13].pressed || (_0x2b21f8.extra_buttons[13] = {
'pressed': true,
'value': 1
}, _0x181250._fire(_0x4ad1c6.Gamepad.Event.BUTTON_DOWN, {
'index': 13,
'gamepad': _0x2b21f8,
'gamepadIndex': _0x2b21f8.index
})), _0x2b21f8.extra_buttons[14].pressed || (_0x2b21f8.extra_buttons[14] = {
'pressed': true,
'value': 1
}, _0x181250._fire(_0x4ad1c6.Gamepad.Event.BUTTON_DOWN, {
'index': 14,
'gamepad': _0x2b21f8,
'gamepadIndex': _0x2b21f8.index
}))) : _0x17edbf >= -0.14287 && _0x17edbf <= -0.14285 ? (_0x2b21f8.extra_buttons[13].pressed || (_0x2b21f8.extra_buttons[13] = {
'pressed': true,
'value': 1
}, _0x181250._fire(_0x4ad1c6.Gamepad.Event.BUTTON_DOWN, {
'index': 13,
'gamepad': _0x2b21f8,
'gamepadIndex': _0x2b21f8.index
})), _0x2b21f8.extra_buttons[15].pressed || (_0x2b21f8.extra_buttons[15] = {
'pressed': true,
'value': 1
}, _0x181250._fire(_0x4ad1c6.Gamepad.Event.BUTTON_DOWN, {
'index': 15,
'gamepad': _0x2b21f8,
'gamepadIndex': _0x2b21f8.index
}))) : _0x17edbf <= -1 && _0x17edbf >= -1.01 ? _0x2b21f8.extra_buttons[12].pressed || (_0x2b21f8.extra_buttons[12] = {
'pressed': true,
'value': 1
}, _0x181250._fire(_0x4ad1c6.Gamepad.Event.BUTTON_DOWN, {
'index': 12,
'gamepad': _0x2b21f8,
'gamepadIndex': _0x2b21f8.index
})) : _0x17edbf >= 0.142857 && _0x17edbf <= 0.142858 ? _0x2b21f8.extra_buttons[13].pressed || (_0x2b21f8.extra_buttons[13] = {
'pressed': true,
'value': 1
}, _0x181250._fire(_0x4ad1c6.Gamepad.Event.BUTTON_DOWN, {
'index': 13,
'gamepad': _0x2b21f8,
'gamepadIndex': _0x2b21f8.index
})) : _0x17edbf >= 0.7142857 && _0x17edbf <= 0.7142858 ? _0x2b21f8.extra_buttons[14].pressed || (_0x2b21f8.extra_buttons[14] = {
'pressed': true,
'value': 1
}, _0x181250._fire(_0x4ad1c6.Gamepad.Event.BUTTON_DOWN, {
'index': 14,
'gamepad': _0x2b21f8,
'gamepadIndex': _0x2b21f8.index
})) : _0x17edbf <= -0.42857 && _0x17edbf >= -0.42858 && (_0x2b21f8.extra_buttons[15].pressed || (_0x2b21f8.extra_buttons[15] = {
'pressed': true,
'value': 1
}, _0x181250._fire(_0x4ad1c6.Gamepad.Event.BUTTON_DOWN, {
'index': 15,
'gamepad': _0x2b21f8,
'gamepadIndex': _0x2b21f8.index
}))) : (_0x2b21f8.extra_buttons[12].pressed && (_0x2b21f8.extra_buttons[12] = {
'pressed': false,
'value': 0
}, _0x181250._fire(_0x4ad1c6.Gamepad.Event.BUTTON_UP, {
'index': 12,
'gamepad': _0x2b21f8,
'gamepadIndex': _0x2b21f8.index
})), _0x2b21f8.extra_buttons[13].pressed && (_0x2b21f8.extra_buttons[13] = {
'pressed': false,
'value': 0
}, _0x181250._fire(_0x4ad1c6.Gamepad.Event.BUTTON_UP, {
'index': 13,
'gamepad': _0x2b21f8,
'gamepadIndex': _0x2b21f8.index
})), _0x2b21f8.extra_buttons[14].pressed && (_0x2b21f8.extra_buttons[14] = {
'pressed': false,
'value': 0
}, _0x181250._fire(_0x4ad1c6.Gamepad.Event.BUTTON_UP, {
'index': 14,
'gamepad': _0x2b21f8,
'gamepadIndex': _0x2b21f8.index
})), _0x2b21f8.extra_buttons[15].pressed && (_0x2b21f8.extra_buttons[15] = {
'pressed': false,
'value': 0
}, _0x181250._fire(_0x4ad1c6.Gamepad.Event.BUTTON_UP, {
'index': 15,
'gamepad': _0x2b21f8,
'gamepadIndex': _0x2b21f8.index
})));
}
});
});
_0x181250.bind(_0x4ad1c6.Gamepad.Event.BUTTON_DOWN, function(_0x15761a) {
console.log(_0x15761a.gamepad)
_0x378b5c.gamepad = gamepad;
gamepad.on('buttondown', function(event) {
if (!_0xa88a13.elements.dialogs.gamepad.hidden && !_0x2c1832.hidden) {
var _0x387018, _0xdd4205 = parseInt(_0x2c1832.getAttribute('data-index'), 0xa),
_0x1f4ee2 = _0x2c1832.getAttribute('data-id');
if (_0x15761a.gamepad.index === parseInt(_0xdd4205, 0xa)) {
for (var _0x211087 = 0x0; _0x211087 < 0x20 && ((_0x387018 = _0x15761a.gamepad.buttons[_0x211087]) || (_0x387018 = _0x15761a.gamepad.extra_buttons[_0x211087]), !_0x387018 || !('number' == typeof _0x387018 && 0x1 === _0x387018 || 'number' == typeof _0x387018.value && 0x1 === _0x387018.value)); _0x211087 += 0x1);
if (event.gamepadIndex === parseInt(_0xdd4205, 0xa)) {
var _0x126d2d = null;
(_0x126d2d = _0x17edbf.elements.dialogs.gamepad.querySelector('[data-id="' .concat(_0x1f4ee2, '"][data-index="').concat(_0xdd4205, '"][data-type="2"]'))).setAttribute('data-value', _0x15761a.index), _0x126d2d.value = 'button ' .concat(_0x15761a.index + 0x1), _0x132da7(_0x2c1832, true);
(_0x126d2d = _0x17edbf.elements.dialogs.gamepad.querySelector('[data-id="' .concat(_0x1f4ee2, '"][data-index="').concat(_0xdd4205, '"][data-type="2"]'))).setAttribute('data-value', event.index), _0x126d2d.value = 'button ' .concat(event.index + 0x1), _0x132da7(_0x2c1832, true);
}
} else Object.keys(_0x378b5c.controllers[_0x15761a.gamepad.index.toString()]).forEach(function(_0x3cf4d3) {
var _0x5cf388 = _0x15761a.gamepad.index.toString();
if (parseInt(_0x378b5c.controllers[_0x5cf388][_0x3cf4d3].value2, 0xa) === parseInt(_0x15761a.index, 0xa) && ['24', '25', '26'].includes(_0x3cf4d3)) {
} else Object.keys(_0x378b5c.controllers[event.gamepadIndex.toString()]).forEach(function(_0x3cf4d3) {
var _0x5cf388 = event.gamepadIndex.toString();
if (parseInt(_0x378b5c.controllers[_0x5cf388][_0x3cf4d3].value2, 0xa) === parseInt(event.index, 0xa) && ['24', '25', '26'].includes(_0x3cf4d3)) {
if (_0x3cf4d3 == '24') {//save
_0x378b5c.quickSaveState()
} else if (_0x3cf4d3 == '25') {//load
@ -3427,29 +3307,31 @@ window.EJS_main = function(_0xa88a13, _0x17edbf, _0x2c1832) {
_0x378b5c.changeStateSlot()
}
}
parseInt(_0x378b5c.controllers[_0x5cf388][_0x3cf4d3].value2, 0xa) === parseInt(_0x15761a.index, 0xa) && parseInt(_0x5cf388, 0xa) === parseInt(_0x15761a.gamepad.index, 0xa) && _0x378b5c.simulateInput(_0x5cf388, _0x3cf4d3, 0x1);
parseInt(_0x378b5c.controllers[_0x5cf388][_0x3cf4d3].value2, 0xa) === parseInt(event.index, 0xa) && parseInt(_0x5cf388, 0xa) === parseInt(event.gamepadIndex, 0xa) && _0x378b5c.simulateInput(_0x5cf388, _0x3cf4d3, 0x1);
});
}), _0x181250.bind(_0x4ad1c6.Gamepad.Event.BUTTON_UP, function(_0x3220b3) {
});
gamepad.on('buttonup', function(event) {
Object.keys(_0x378b5c.controllers).forEach(function(_0x302c3e) {
Object.keys(_0x378b5c.controllers[_0x302c3e]).forEach(function(_0x14eb8a) {
parseInt(_0x378b5c.controllers[_0x302c3e][_0x14eb8a].value2, 0xa) === parseInt(_0x3220b3.index, 0xa) && parseInt(_0x302c3e, 0xa) === parseInt(_0x3220b3.gamepad.index, 0xa) && _0x378b5c.simulateInput(_0x302c3e, _0x14eb8a, 0x0);
parseInt(_0x378b5c.controllers[_0x302c3e][_0x14eb8a].value2, 0xa) === parseInt(event.index, 0xa) && parseInt(_0x302c3e, 0xa) === parseInt(event.gamepadIndex, 0xa) && _0x378b5c.simulateInput(_0x302c3e, _0x14eb8a, 0x0);
});
});
}), _0x181250.bind(_0x4ad1c6.Gamepad.Event.AXIS_CHANGED, function(_0x31f017) {
});
gamepad.on('axischanged', function(event) {
var value = function(value) {
if (value > 0.5 || value < -0.5) {
return (value > 0) ? 1 : -1;
} else {
return 0;
}
}(_0x31f017.value);
}(event.value);
if (!_0xa88a13.elements.dialogs.gamepad.hidden && !_0x2c1832.hidden) {
if (value !== 0) {
var _0x1f4ee2 = _0x2c1832.getAttribute('data-id'),
_0xdd4205 = parseInt(_0x2c1832.getAttribute('data-index'), 0xa);
var _0x126d2d = _0xa88a13.elements.dialogs.gamepad.querySelector('[data-id="' .concat(_0x1f4ee2, '"][data-index="').concat(_0xdd4205, '"][data-type="2"]'))
_0x126d2d.setAttribute('data-value', _0x31f017.axis + ':' + value)
_0x126d2d.value = _0x31f017.axis + ':' + value
_0x126d2d.setAttribute('data-value', event.axis + ':' + value)
_0x126d2d.value = event.axis + ':' + value
_0x132da7(_0x2c1832, true)
}
} else {
@ -3457,12 +3339,12 @@ window.EJS_main = function(_0xa88a13, _0x17edbf, _0x2c1832) {
_0x378b5c.prevButtons = {}
}
var quit = false
var _0x5cf388 = _0x31f017.gamepad.index.toString();
var _0x5cf388 = event.gamepadIndex.toString();
if (! _0x378b5c.prevButtons[_0x5cf388]) {
_0x378b5c.prevButtons[_0x5cf388] = {}
}
if (! _0x378b5c.prevButtons[_0x5cf388][_0x31f017.axis]) {
_0x378b5c.prevButtons[_0x5cf388][_0x31f017.axis] = 0
if (! _0x378b5c.prevButtons[_0x5cf388][event.axis]) {
_0x378b5c.prevButtons[_0x5cf388][event.axis] = 0
}
if (! _0x378b5c.prevButtons[_0x5cf388].buttonID) {
_0x378b5c.prevButtons[_0x5cf388].buttonID = 0
@ -3472,7 +3354,7 @@ window.EJS_main = function(_0xa88a13, _0x17edbf, _0x2c1832) {
if (! _0x378b5c.controllers[_0x5cf388][_0x3cf4d3].value2) {
continue
}
if (_0x378b5c.controllers[_0x5cf388][_0x3cf4d3].value2.split(':')[0] === _0x31f017.axis && parseInt(_0x378b5c.controllers[_0x5cf388][_0x3cf4d3].value2.split(':')[1]) === value && ['24', '25', '26'].includes(_0x3cf4d3)) {
if (_0x378b5c.controllers[_0x5cf388][_0x3cf4d3].value2.split(':')[0] === event.axis && parseInt(_0x378b5c.controllers[_0x5cf388][_0x3cf4d3].value2.split(':')[1]) === value && ['24', '25', '26'].includes(_0x3cf4d3)) {
if (_0x3cf4d3 == '24') {//save
quit = true
_0x378b5c.quickSaveState()
@ -3485,19 +3367,19 @@ window.EJS_main = function(_0xa88a13, _0x17edbf, _0x2c1832) {
}
if (value === 0) {
// button up
if (_0x378b5c.controllers[_0x5cf388][_0x3cf4d3].value2.split(':')[0] === _0x31f017.axis) {
_0x378b5c.prevButtons[_0x5cf388][_0x31f017.axis] = value
if (_0x378b5c.controllers[_0x5cf388][_0x3cf4d3].value2.split(':')[0] === event.axis) {
_0x378b5c.prevButtons[_0x5cf388][event.axis] = value
_0x378b5c.prevButtons[_0x5cf388].buttonID = _0x3cf4d3
_0x378b5c.simulateInput(_0x5cf388, _0x3cf4d3, 0x0)
}
} else {
//button down
if ((1 === _0x378b5c.prevButtons[_0x5cf388][_0x31f017.axis] && value === -1) ||
(-1 === _0x378b5c.prevButtons[_0x5cf388][_0x31f017.axis] && value === 1)) {
if ((1 === _0x378b5c.prevButtons[_0x5cf388][event.axis] && value === -1) ||
(-1 === _0x378b5c.prevButtons[_0x5cf388][event.axis] && value === 1)) {
_0x378b5c.simulateInput(_0x5cf388, _0x378b5c.prevButtons[_0x5cf388].buttonID, 0x0)
}
if (_0x378b5c.controllers[_0x5cf388][_0x3cf4d3].value2.split(':')[0] === _0x31f017.axis && parseInt(_0x378b5c.controllers[_0x5cf388][_0x3cf4d3].value2.split(':')[1]) === value) {
_0x378b5c.prevButtons[_0x5cf388][_0x31f017.axis] = value
if (_0x378b5c.controllers[_0x5cf388][_0x3cf4d3].value2.split(':')[0] === event.axis && parseInt(_0x378b5c.controllers[_0x5cf388][_0x3cf4d3].value2.split(':')[1]) === value) {
_0x378b5c.prevButtons[_0x5cf388][event.axis] = value
_0x378b5c.prevButtons[_0x5cf388].buttonID = _0x3cf4d3
quit = true
_0x378b5c.simulateInput(_0x5cf388, _0x3cf4d3, 0x1)
@ -3511,18 +3393,52 @@ window.EJS_main = function(_0xa88a13, _0x17edbf, _0x2c1832) {
return
}
}
Math.abs(_0x31f017.value) <= 0.1 && (_0x31f017.value = 0x0);
var _0x17edbf = _0x31f017.gamepad.index;
'LEFT_STICK_X' === _0x31f017.axis && (_0x31f017.value > 0x0 ? (_0x378b5c.simulateInput(_0x17edbf, 0x10, 0x7fff * _0x31f017.value), _0x378b5c.simulateInput(_0x17edbf, 0x11, 0x0)) : (_0x378b5c.simulateInput(_0x17edbf, 0x11, 0x7fff * _0x31f017.value), _0x378b5c.simulateInput(_0x17edbf, 0x10, 0x0))), 'LEFT_STICK_Y' === _0x31f017.axis && (_0x31f017.value > 0x0 ? (_0x378b5c.simulateInput(_0x17edbf, 0x12, 0x7fff * _0x31f017.value), _0x378b5c.simulateInput(_0x17edbf, 0x13, 0x0)) : (_0x378b5c.simulateInput(_0x17edbf, 0x13, 0x7fff * _0x31f017.value), _0x378b5c.simulateInput(_0x17edbf, 0x12, 0x0))), 'RIGHT_STICK_X' === _0x31f017.axis && (_0x31f017.value > 0x0 ? (_0x378b5c.simulateInput(_0x17edbf, 0x14, 0x7fff * _0x31f017.value), _0x378b5c.simulateInput(_0x17edbf, 0x15, 0x0)) : (_0x378b5c.simulateInput(_0x17edbf, 0x15, 0x7fff * _0x31f017.value), _0x378b5c.simulateInput(_0x17edbf, 0x14, 0x0))), 'RIGHT_STICK_Y' === _0x31f017.axis && (_0x31f017.value > 0x0 ? (_0x378b5c.simulateInput(_0x17edbf, 0x16, 0x7fff * _0x31f017.value), _0x378b5c.simulateInput(_0x17edbf, 0x17, 0x0)) : (_0x378b5c.simulateInput(_0x17edbf, 0x17, 0x7fff * _0x31f017.value), _0x378b5c.simulateInput(_0x17edbf, 0x16, 0x0)));
}), _0x181250.bind(_0x4ad1c6.Gamepad.Event.DISCONNECTED, function(_0x1c996a) {
[0x0, 0x1, 0x2, 0x3].forEach(function(_0x429f30) {
var _0x2c1832 = _0x181250.gamepads[_0x429f30];
Math.abs(event.value) <= 0.1 && (event.value = 0);
var _0x17edbf = event.gamepadIndex;
var coreVer = _0xa88a13.coreVer;
if (event.axis === 'LEFT_STICK_X') {
if (event.value > 0) {
_0x378b5c.simulateInput(_0x17edbf, 16, 0x7fff * event.value);
_0x378b5c.simulateInput(_0x17edbf, 17, 0);
} else {
_0x378b5c.simulateInput(_0x17edbf, 17, -0x7fff * event.value);
_0x378b5c.simulateInput(_0x17edbf, 16, 0);
}
} else if (event.axis === 'LEFT_STICK_Y') {
if (event.value > 0) {
_0x378b5c.simulateInput(_0x17edbf, 18, 0x7fff * event.value);
_0x378b5c.simulateInput(_0x17edbf, 19, 0);
} else {
_0x378b5c.simulateInput(_0x17edbf, 19, -0x7fff * event.value);
_0x378b5c.simulateInput(_0x17edbf, 18, 0);
}
} else if (event.axis === 'RIGHT_STICK_X') {
if (event.value > 0) {
_0x378b5c.simulateInput(_0x17edbf, 20, 0x7fff * event.value);
_0x378b5c.simulateInput(_0x17edbf, 21, 0);
} else {
_0x378b5c.simulateInput(_0x17edbf, 21, -0x7fff * event.value);
_0x378b5c.simulateInput(_0x17edbf, 20, 0);
}
} else if (event.axis === 'RIGHT_STICK_Y') {
if (event.value > 0) {
_0x378b5c.simulateInput(_0x17edbf, 22, 0x7fff * event.value);
_0x378b5c.simulateInput(_0x17edbf, 23, 0);
} else {
_0x378b5c.simulateInput(_0x17edbf, 23, 0x7fff * event.value);
_0x378b5c.simulateInput(_0x17edbf, 22, 0);
}
}
});
gamepad.on('disconnected', function(event) {
[0, 1, 2, 3].forEach(function(_0x429f30) {
var _0x2c1832 = gamepad.gamepads[_0x429f30];
_0x17edbf.elements.dialogs.gamepad.querySelector('#controls-' .concat(_0x429f30, ' .gamepad-name')).innerHTML = _0x2c1832 ? _0x2c1832.id : 'n/a';
});
}), _0x181250.bind(_0x4ad1c6.Gamepad.Event.CONNECTED, function(_0x748f24) {
Object.keys(_0x181250.gamepads).forEach(function(_0x327c74) {
var _0x2c1832 = _0x181250.gamepads[_0x327c74];
});
gamepad.on('connected', function(event) {
Object.keys(gamepad.gamepads).forEach(function(_0x327c74) {
var _0x2c1832 = gamepad.gamepads[_0x327c74];
_0x17edbf.elements.dialogs.gamepad.querySelector('#controls-' .concat(_0x327c74, ' .gamepad-name')).innerHTML = _0x2c1832 ? _0x2c1832.id : 'n/a';
});
});
@ -6050,7 +5966,7 @@ window.EJS_main = function(_0xa88a13, _0x17edbf, _0x2c1832) {
}
return path
}
this.version = '2.2.7';
this.version = '2.2.8';
this.system = '';
this.adUrl = null;
this.gameName = null;

View file

@ -83,344 +83,114 @@ var EJS = function(_0x574f5e) {
element.innerHTML = '<strong style="color:#f00;text-shadow: 0px 0px 3px;">'+_this.localization('Network Error')+'</strong>';
}
}
}, null, null, null, null, null, function(_0x3982a1, _0x519c5e, _0x21c4c0) {
! function(_0x36fa8f) {
'use strict';
var _0x519c5e = function() {},
_0x21c4c0 = {
'getType': function() {
return 'null';
},
'isSupported': function() {
return !0x1;
},
'update': _0x519c5e
},
_0x51f790 = function(_0x961a83) {
var _0x21c4c0 = this,
_0x55f0e2 = window;
this.update = _0x519c5e, this.requestAnimationFrame = _0x961a83 || _0x55f0e2.requestAnimationFrame || _0x55f0e2.webkitRequestAnimationFrame || _0x55f0e2.mozRequestAnimationFrame, this.tickFunction = function() {
_0x21c4c0.update(), _0x21c4c0.startTicker();
}, this.startTicker = function() {
_0x21c4c0.requestAnimationFrame.apply(_0x55f0e2, [_0x21c4c0.tickFunction]);
};
};
_0x51f790.prototype.start = function(_0x17a8e5) {
this.update = _0x17a8e5 || _0x519c5e, this.startTicker();
};
var _0x594d89 = function() {};
_0x594d89.prototype.update = _0x519c5e, _0x594d89.prototype.start = function(_0x39fdd2) {
this.update = _0x39fdd2 || _0x519c5e;
};
var _0x2ff982 = function(_0x2b1a98, _0x4f87ba) {
this.listener = _0x2b1a98, this.gamepadGetter = _0x4f87ba, this.knownGamepads = [];
};
_0x2ff982.factory = function(_0xc62323) {
var _0x519c5e = _0x21c4c0,
_0x2c02e1 = window && window.navigator;
return _0x2c02e1 && (void 0x0 !== _0x2c02e1.getGamepads ? _0x519c5e = new _0x2ff982(_0xc62323, function() {
return _0x2c02e1.getGamepads();
}) : void 0x0 !== _0x2c02e1.webkitGamepads ? _0x519c5e = new _0x2ff982(_0xc62323, function() {
return _0x2c02e1.webkitGamepads();
}) : void 0x0 !== _0x2c02e1.webkitGetGamepads && (_0x519c5e = new _0x2ff982(_0xc62323, function() {
return _0x2c02e1.webkitGetGamepads();
}))), _0x519c5e;
}, _0x2ff982.getType = function() {
return 'WebKit';
}, _0x2ff982.prototype.getType = function() {
return _0x2ff982.getType();
}, _0x2ff982.prototype.isSupported = function() {
return true;
}, _0x2ff982.prototype.update = function() {
var _0x36fa8f, _0x519c5e, _0x21c4c0 = Array.prototype.slice.call(this.gamepadGetter(), 0x0);
for (_0x519c5e = this.knownGamepads.length - 0x1; _0x519c5e >= 0x0; _0x519c5e--) _0x36fa8f = this.knownGamepads[_0x519c5e], _0x21c4c0.indexOf(_0x36fa8f) < 0x0 && (this.knownGamepads.splice(_0x519c5e, 0x1), this.listener._disconnect(_0x36fa8f));
for (_0x519c5e = 0x0; _0x519c5e < _0x21c4c0.length; _0x519c5e++)(_0x36fa8f = _0x21c4c0[_0x519c5e]) && this.knownGamepads.indexOf(_0x36fa8f) < 0x0 && (this.knownGamepads.push(_0x36fa8f), this.listener._connect(_0x36fa8f));
};
var _0x2f4e6b = function(_0x3d65fc) {
this.listener = _0x3d65fc, window.addEventListener('gamepadconnected', function(_0x44ea49) {
_0x3d65fc._connect(_0x44ea49.gamepad);
}), window.addEventListener('gamepaddisconnected', function(_0xfb7aa0) {
_0x3d65fc._disconnect(_0xfb7aa0.gamepad);
});
};
_0x2f4e6b.factory = function(_0x4c832a) {
var _0x519c5e = _0x21c4c0;
return window && void 0x0 !== window.addEventListener && (_0x519c5e = new _0x2f4e6b(_0x4c832a)), _0x519c5e;
}, _0x2f4e6b.getType = function() {
return 'Firefox';
}, _0x2f4e6b.prototype.getType = function() {
return _0x2f4e6b.getType();
}, _0x2f4e6b.prototype.isSupported = function() {
return -0x1 !== (window && window.navigator).userAgent.indexOf('Firefox');
}, _0x2f4e6b.prototype.update = _0x519c5e;
var _0x5633cb = function(_0x1f6314) {
this.updateStrategy = _0x1f6314 || new _0x51f790(), this.gamepads = [], this.listeners = {}, this.platform = _0x21c4c0, this.deadzone = 0.03, this.maximizeThreshold = 0.97;
};
_0x5633cb.UpdateStrategies = {
'AnimFrameUpdateStrategy': _0x51f790,
'ManualUpdateStrategy': _0x594d89
}, _0x5633cb.PlatformFactories = [_0x2f4e6b.factory, _0x2ff982.factory], _0x5633cb.Type = {
'N64': 'n64',
'PLAYSTATION': 'playstation',
'LOGITECH': 'logitech',
'XBOX': 'xbox',
'ECKA': 'ecka',
'UNKNOWN': 'unknown'
}, _0x5633cb.Event = {
'CONNECTED': 'connected',
'UNSUPPORTED': 'unsupported',
'DISCONNECTED': 'disconnected',
'TICK': 'tick',
'BUTTON_DOWN': 'button-down',
'BUTTON_UP': 'button-up',
'AXIS_CHANGED': 'axis-changed'
}, _0x5633cb.StandardButtons = ['BUTTON_1', 'BUTTON_2', 'BUTTON_3', 'BUTTON_4', 'LEFT_TOP_SHOULDER', 'RIGHT_TOP_SHOULDER', 'LEFT_BOTTOM_SHOULDER', 'RIGHT_BOTTOM_SHOULDER', 'SELECT_BACK', 'START_FORWARD', 'LEFT_STICK', 'RIGHT_STICK', 'DPAD_UP', 'DPAD_DOWN', 'DPAD_LEFT', 'DPAD_RIGHT', 'HOME'], _0x5633cb.StandardAxes = ['LEFT_STICK_X', 'LEFT_STICK_Y', 'RIGHT_STICK_X', 'RIGHT_STICK_Y'];
var _0x11b15e, _0x1380fc = function(_0x2a091d, _0x396791, _0x49a80e) {
return _0x396791 < _0x2a091d.length ? _0x2a091d[_0x396791] : _0x49a80e + (_0x396791 - _0x2a091d.length + 0x1);
};
_0x5633cb.StandardMapping = {
'env': {},
'buttons': {
'byButton': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
},
'axes': {
'byAxis': [0x0, 0x1, 0x2, 0x3]
}
}, _0x5633cb.Mappings = [{
'env': {
'platform': _0x2f4e6b.getType(),
'type': _0x5633cb.Type.N64
},
'buttons': {
'byButton': [0x2, 0x1, 0x3, 0x0, 0x4, 0x5, -0x1, -0x1, 0x8, 0x9, -0x1, -0x1, 0xc, 0xd, 0xe, 0xf, -0x1]
},
'axes': {
'byAxis': [0x1, 0x2, -0x1, -0x1]
}
}, {
'env': {
'platform': _0x2ff982.getType(),
'type': _0x5633cb.Type.N64
},
'buttons': {
'byButton': [0x2, 0x1, 0x3, 0x0, 0x4, 0x5, -0x1, -0x1, 0x8, 0x9, -0x1, -0x1, 0xc, 0xd, 0xe, 0xf, -0x1]
},
'axes': {
'byAxis': [0x0, 0x1, -0x1, -0x1]
}
}, {
'env': {
'platform': _0x2f4e6b.getType(),
'type': _0x5633cb.Type.XBOX
},
'buttons': {
'byButton': [0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0xf, 0x10, 0x9, 0x8, 0x6, 0x7, 0xb, 0xc, 0xd, 0xe, 0xa]
},
'axes': {
'byAxis': [0x0, 0x1, 0x2, 0x3]
}
}, {
'env': {
'platform': _0x2f4e6b.getType(),
'type': _0x5633cb.Type.PLAYSTATION
},
'buttons': {
'byButton': [0xe, 0xd, 0xf, 0xc, 0xa, 0xb, 0x8, 0x9, 0x0, 0x3, 0x1, 0x2, 0x4, 0x6, 0x7, 0x5, 0x10]
},
'axes': {
'byAxis': [0x0, 0x1, 0x2, 0x3]
}
}, {
'env': {
'platform': _0x2ff982.getType(),
'type': _0x5633cb.Type.LOGITECH
},
'buttons': {
'byButton': [0x1, 0x2, 0x0, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xb, 0xc, 0xd, 0xe, 0xa]
},
'axes': {
'byAxis': [0x0, 0x1, 0x2, 0x3]
}
}, {
'env': {
'platform': _0x2f4e6b.getType(),
'type': _0x5633cb.Type.LOGITECH
},
'buttons': {
'byButton': [0, 1, 2, 3, 4, 5, -1, -1, 6, 7, 8, 9, 11, 12, 13, 14, 10],
'byAxis': [-0x1, -0x1, -0x1, -0x1, -0x1, -0x1, [0x2, 0x0, 0x1],
[0x2, 0x0, -0x1]
]
},
'axes': {
'byAxis': [0x0, 0x1, 0x3, 0x4]
}
}, {
'env': {
'platform': _0x2ff982.getType(),
'type': _0x5633cb.Type.ECKA
},
'buttons': {
'byButton': [0x2, 0x1, 0x3, 0x0, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xb, 0xc, 0xd, 0xe, 0xa],
'byAxis': [-0x1, -0x1, -0x1, -0x1, -0x1, -0x1, [0x2, 0x0, 0x1],
[0x2, 0x0, -0x1]
]
},
'axes': {
'byAxis': [0x0, 0x1, 0x3, 0x4]
}
}, {
'env': {
'platform': _0x2ff982.getType(),
'type': _0x5633cb.Type.UNKNOWN
},
'buttons': {
'byButton': [0x0, 0x1, 0x2, 0x3, 0x4, 0x5, -0x1, -0x1, 0x6, 0x7, 0x8, 0x9, 0xb, 0xc, 0xd, 0xe, 0xf, 0x10, 0x11, 0xa]
},
'axes': {
'byAxis': [0x0, 0x1, 0x2, 0x5]
}
}], _0x5633cb.prototype.init = function() {
var _0x36fa8f = _0x5633cb.resolvePlatform(this),
_0x519c5e = this;
return this.platform = _0x36fa8f, this.updateStrategy.start(function() {
_0x519c5e._update();
}), this.buttonState = [], this.extraButtonState = [], _0x36fa8f.isSupported();
}, _0x5633cb.prototype.bind = function(_0x1ad7a3, _0x381962) {
return void 0x0 === this.listeners[_0x1ad7a3] && (this.listeners[_0x1ad7a3] = []), this.listeners[_0x1ad7a3].push(_0x381962), this;
}, _0x5633cb.prototype.unbind = function(_0x1e8e29, _0x14faad) {
if (void 0x0 !== _0x1e8e29) {
if (void 0x0 !== _0x14faad) {
if (void 0x0 === this.listeners[_0x1e8e29]) return !0x1;
for (var _0x21c4c0 = 0x0; _0x21c4c0 < this.listeners[_0x1e8e29].length; _0x21c4c0++)
if (this.listeners[_0x1e8e29][_0x21c4c0] === _0x14faad) return this.listeners[_0x1e8e29].splice(_0x21c4c0, 0x1), true;
return !0x1;
}, null, null, null, null, null, function(module) {
//I wrote this myself -- theres bound to be bugs
function Gamepad() {
var gp = navigator.getGamepads || navigator.webkitGetGamepads;
if (!gp) {
throw new Error("get gamepads not found!");
}
this.rAF = window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.requestAnimationFrame;
if (!this.rAF) {
throw new Error("request animation frame was not found!");
}
this.loop();
}
Gamepad.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() {
var gamepads = this.getGamepads();
for (var i=0; i<gamepads.length; i++) {
if (!gamepads[i]) continue;
var hasGamepad = false;
for (var j=0; j<this.gamepads.length; j++) {
if (!this.gamepads[j]) continue;
if (this.gamepads[j].id === gamepads[i].id) {
hasGamepad = true;
if (typeof this.onaxischanged == 'function') {
for (var q=0; q<this.gamepads[j].axes.length; q++) {
if (gamepads[i].axes[q] !== this.gamepads[j].axes[q]) {
var 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 '';
}
}(q);
if (!axis) continue;
this.onaxischanged({axis:axis, value:gamepads[i].axes[q], index:i, gamepadIndex:gamepads[i].index});
}
}
}
for (var q=0; q<this.gamepads[j].buttons.length; q++) {
let pressed = this.gamepads[j].buttons[q] == 1.0;
if (typeof(this.gamepads[j].buttons[q]) == "object") {
pressed = this.gamepads[j].buttons[q].pressed;
}
let pressed2 = gamepads[i].buttons[q] == 1.0;
if (typeof(gamepads[i].buttons[q]) == "object") {
pressed2 = gamepads[i].buttons[q].pressed;
}
if (pressed !== pressed2) {
if (pressed2) {
if (typeof this.onbuttondown == 'function') {
this.onbuttondown({index:q, gamepadIndex:gamepads[i].index});
}
} else {
if (typeof this.onbuttonup == 'function') {
this.onbuttonup({index:q, gamepadIndex:gamepads[i].index});
}
}
}
}
this.gamepads[j] = gamepads[i];
}
}
if (!hasGamepad) {
this.gamepads.push(gamepads[i]);
if (typeof this.onconnected == 'function') {
this.onconnected();
}
}
this.listeners[_0x1e8e29] = [];
} else this.listeners = {};
}, _0x5633cb.prototype.count = function() {
return this.gamepads.length;
}, _0x5633cb.prototype._fire = function(_0x4ccbe8, _0x5d1f53) {
if (void 0x0 !== this.listeners[_0x4ccbe8]) {
for (var _0x21c4c0 = 0x0; _0x21c4c0 < this.listeners[_0x4ccbe8].length; _0x21c4c0++) this.listeners[_0x4ccbe8][_0x21c4c0].apply(this.listeners[_0x4ccbe8][_0x21c4c0], [_0x5d1f53]);
var _0x2be19b = this;
_0x5d1f53.gamepad && _0x5d1f53.gamepad.extra_buttons && _0x5d1f53.gamepad.extra_buttons.forEach(function(_0xef3dc7, _0x4315f4) {
_0x2be19b.extraButtonState[_0x5d1f53.gamepad.index] || (_0x2be19b.extraButtonState[_0x5d1f53.gamepad.index] = []), _0x2be19b.extraButtonState[_0x5d1f53.gamepad.index][_0x4315f4] = _0xef3dc7;
});
}
}, _0x5633cb.getNullPlatform = function() {
return Object.create(_0x21c4c0);
}, _0x5633cb.resolvePlatform = function(_0x3528ec) {
var _0x519c5e, _0x1ff0c4 = _0x21c4c0;
for (_0x519c5e = 0x0; !_0x1ff0c4.isSupported() && _0x519c5e < _0x5633cb.PlatformFactories.length; _0x519c5e++) _0x1ff0c4 = _0x5633cb.PlatformFactories[_0x519c5e](_0x3528ec);
return _0x1ff0c4;
}, _0x5633cb.prototype._connect = function(_0x1606a1) {
var _0x519c5e, _0x21c4c0, _0x3108dc = this._resolveMapping(_0x1606a1);
for (_0x1606a1.state = {}, _0x1606a1.lastState = {}, _0x1606a1.updater = [], this.buttonState[_0x1606a1.index] || (this.buttonState[_0x1606a1.index] = []), this.extraButtonState[_0x1606a1.index] || (this.extraButtonState[_0x1606a1.index] = []), _0x519c5e = _0x3108dc.buttons.byButton.length, _0x21c4c0 = 0x0; _0x21c4c0 < _0x519c5e; _0x21c4c0++) this._addButtonUpdater(_0x1606a1, _0x3108dc, _0x21c4c0);
for (_0x519c5e = _0x3108dc.axes.byAxis.length, _0x21c4c0 = 0x0; _0x21c4c0 < _0x519c5e; _0x21c4c0++) this._addAxisUpdater(_0x1606a1, _0x3108dc, _0x21c4c0);
if (this.gamepads[_0x1606a1.index] = _0x1606a1, !this.gamepads[_0x1606a1.index].extra_buttons)
for (this.gamepads[_0x1606a1.index].extra_buttons = [], _0x21c4c0 = _0x1606a1.buttons.length; _0x21c4c0 < 0x10; _0x21c4c0++) this.extraButtonState[_0x1606a1.index][_0x21c4c0] ? this.gamepads[_0x1606a1.index].extra_buttons[_0x21c4c0] = this.extraButtonState[_0x1606a1.index][_0x21c4c0] : this.gamepads[_0x1606a1.index].extra_buttons[_0x21c4c0] = {
'pressed': !0x1,
'value': 0x0
};
this._fire(_0x5633cb.Event.CONNECTED, _0x1606a1);
}, _0x5633cb.prototype._addButtonUpdater = function(_0x19541b, _0x3a8718, _0x2e14e2) {
var _0x14879d, _0x49f481 = _0x1380fc(_0x5633cb.StandardButtons, _0x2e14e2, 'EXTRA_BUTTON_'),
_0x220cd5 = this._createButtonGetter(_0x19541b, _0x3a8718.buttons, _0x2e14e2),
_0x1fe059 = this,
_0x2ff716 = {
'gamepad': _0x19541b,
'control': _0x49f481,
'index': _0x2e14e2,
'gamepadIndex': _0x19541b.index
};
_0x19541b.state[_0x49f481] = 0x0, _0x19541b.lastState[_0x49f481] = 0x0, null == this.buttonState[_0x19541b.index][_0x49f481] && (this.buttonState[_0x19541b.index][_0x49f481] = 0x0), _0x14879d = function() {
var _0x3a8718 = _0x220cd5(),
_0x2e14e2 = _0x19541b.lastState[_0x49f481],
_0x11e126 = _0x3a8718 > 0.5,
_0x1078e7 = _0x2e14e2 > 0.5;
_0x19541b.state[_0x49f481] = _0x3a8718, _0x11e126 && !_0x1078e7 ? _0x1fe059._fire(_0x5633cb.Event.BUTTON_DOWN, Object.create(_0x2ff716)) : !_0x11e126 && _0x1078e7 ? _0x1fe059._fire(_0x5633cb.Event.BUTTON_UP, Object.create(_0x2ff716)) : _0x1fe059.buttonState[_0x19541b.index][_0x49f481] != _0x3a8718 && _0x1fe059._fire(_0x5633cb.Event.BUTTON_UP, Object.create(_0x2ff716)), 0x0 !== _0x3a8718 && 0x1 !== _0x3a8718 && _0x3a8718 !== _0x2e14e2 && _0x1fe059._fireAxisChangedEvent(_0x19541b, _0x49f481, _0x3a8718), _0x19541b.lastState[_0x49f481] = _0x3a8718, _0x1fe059.buttonState[_0x19541b.index][_0x49f481] = _0x3a8718;
}, _0x19541b.updater.push(_0x14879d);
}, _0x5633cb.prototype._addAxisUpdater = function(_0x54e7b0, _0x2a7b73, _0x8f3c6d) {
var _0x180376, _0x32658f = _0x1380fc(_0x5633cb.StandardAxes, _0x8f3c6d, 'EXTRA_AXIS_'),
_0x4a1dfc = this._createAxisGetter(_0x54e7b0, _0x2a7b73.axes, _0x8f3c6d),
_0x11e62a = this;
_0x54e7b0.state[_0x32658f] = 0x0, _0x54e7b0.lastState[_0x32658f] = 0x0, null == this.buttonState[_0x54e7b0.index][_0x32658f] && (this.buttonState[_0x54e7b0.index][_0x32658f] = 0x0), _0x180376 = function() {
var _0x2a7b73 = _0x4a1dfc(),
_0x8f3c6d = _0x11e62a.buttonState[_0x54e7b0.index][_0x32658f];
_0x54e7b0.state[_0x32658f] = _0x2a7b73, _0x2a7b73 !== _0x8f3c6d && _0x11e62a._fireAxisChangedEvent(_0x54e7b0, _0x32658f, _0x2a7b73), _0x54e7b0.lastState[_0x32658f] = _0x2a7b73, _0x11e62a.buttonState[_0x54e7b0.index][_0x32658f] = _0x2a7b73;
}, _0x54e7b0.updater.push(_0x180376);
}, _0x5633cb.prototype._fireAxisChangedEvent = function(_0x1b1af6, _0x297863, _0x310ce0) {
var _0x181122 = {
'gamepad': _0x1b1af6,
'axis': _0x297863,
'value': _0x310ce0
};
this._fire(_0x5633cb.Event.AXIS_CHANGED, _0x181122);
}, _0x5633cb.prototype._createButtonGetter = (_0x11b15e = function() {
return 0x0;
}, function(_0x8afe40, _0x4912fb, _0x78724a) {
var _0x57e1d5, _0x2126da, _0xbc04b4 = _0x11b15e,
_0x4f004d = this;
return -0x1 !== (_0x57e1d5 = _0x4912fb.byButton[_0x78724a]) ? 'number' == typeof _0x57e1d5 && _0x57e1d5 < _0x8afe40.buttons.length && (_0xbc04b4 = function() {
var _0x4912fb = _0x8afe40.buttons[_0x57e1d5];
return 'number' == typeof _0x4912fb ? _0x4912fb : 'number' == typeof _0x4912fb.value ? _0x4912fb.value : 0x0;
}) : _0x4912fb.byAxis && _0x78724a < _0x4912fb.byAxis.length && (_0x57e1d5 = _0x4912fb.byAxis[_0x78724a], _0x2126da = _0x57e1d5, '[object Array]' === Object.prototype.toString.call(_0x2126da) && 0x3 == _0x57e1d5.length && _0x57e1d5[0x0] < _0x8afe40.axes.length && (_0xbc04b4 = function(_0x41d3e7, _0xfe6d41, _0x1c883a) {
var _0x23be26 = _0x11b15e;
return _0xfe6d41 < _0x1c883a ? _0x23be26 = function() {
var _0x5bba97 = _0x1c883a - _0xfe6d41,
_0x23be85 = _0x41d3e7();
return (_0x23be85 = (_0x23be85 - _0xfe6d41) / _0x5bba97) < 0x0 ? 0x0 : _0x23be85;
} : _0x1c883a < _0xfe6d41 && (_0x23be26 = function() {
var _0xd24650 = _0xfe6d41 - _0x1c883a,
_0x183f73 = _0x41d3e7();
return (_0x183f73 = (_0x183f73 - _0x1c883a) / _0xd24650) > 0x1 ? 0x0 : 0x1 - _0x183f73;
}), _0x23be26;
}(_0xbc04b4 = function() {
var _0x4912fb = _0x8afe40.axes[_0x57e1d5[0x0]];
return _0x4f004d._applyDeadzoneMaximize(_0x4912fb);
}, _0x57e1d5[0x1], _0x57e1d5[0x2]))), _0xbc04b4;
}), _0x5633cb.prototype._createAxisGetter = function() {
var _0x36fa8f = function() {
return 0x0;
};
return function(_0x2d14b3, _0x6afd0e, _0x20eff1) {
var _0x1b8acf, _0x2b1b0a = _0x36fa8f,
_0x101060 = this;
return -0x1 !== (_0x1b8acf = _0x6afd0e.byAxis[_0x20eff1]) && 'number' == typeof _0x1b8acf && _0x1b8acf < _0x2d14b3.axes.length && (_0x2b1b0a = function() {
var _0x36fa8f = _0x2d14b3.axes[_0x1b8acf];
return _0x101060._applyDeadzoneMaximize(_0x36fa8f);
}), _0x2b1b0a;
};
}(), _0x5633cb.prototype._disconnect = function(_0x116fb9) {
var _0x519c5e, _0x21c4c0 = [];
for (void 0x0 !== this.gamepads[_0x116fb9.index] && delete this.gamepads[_0x116fb9.index], _0x519c5e = 0x0; _0x519c5e < this.gamepads.length; _0x519c5e++) void 0x0 !== this.gamepads[_0x519c5e] && (_0x21c4c0[_0x519c5e] = this.gamepads[_0x519c5e]);
this.gamepads = _0x21c4c0, this._fire(_0x5633cb.Event.DISCONNECTED, _0x116fb9);
}, _0x5633cb.prototype._resolveControllerType = function(_0x582727) {
return -0x1 !== (_0x582727 = _0x582727.toLowerCase().replace(/\s+/g, ' ').replace(/^\s+|\s+$/g, '')).indexOf('playstation') ? _0x5633cb.Type.PLAYSTATION : -0x1 !== _0x582727.indexOf('logitech') || -0x1 !== _0x582727.indexOf('wireless gamepad') ? _0x5633cb.Type.LOGITECH : -0x1 !== _0x582727.indexOf('xbox') || -0x1 !== _0x582727.indexOf('360') ? _0x5633cb.Type.XBOX : -0x1 !== _0x582727.indexOf('79-6-generic') && -0x1 !== _0x582727.indexOf('joystick') || -0x1 !== _0x582727.indexOf('vendor: 0079 product: 0006') && -0x1 !== _0x582727.indexOf('generic usb joystick') ? _0x5633cb.Type.N64 : 'usb joystick (vendor: 0e8f product: 0002)' === _0x582727 ? _0x5633cb.Type.ECKA : _0x5633cb.Type.UNKNOWN;
}, _0x5633cb.prototype._resolveMapping = function(_0x13e45d) {
var _0x519c5e, _0x21c4c0, _0x4d3f81 = _0x5633cb.Mappings,
_0x1d4264 = null,
_0xebffe5 = {
'platform': this.platform.getType(),
'type': this._resolveControllerType(_0x13e45d.id)
};
for (_0x519c5e = 0x0; !_0x1d4264 && _0x519c5e < _0x4d3f81.length; _0x519c5e++) _0x21c4c0 = _0x4d3f81[_0x519c5e], _0x5633cb.envMatchesFilter(_0x21c4c0.env, _0xebffe5) && (_0x1d4264 = _0x21c4c0);
return _0x1d4264 || _0x5633cb.StandardMapping;
}, _0x5633cb.envMatchesFilter = function(_0x26e73d, _0x55c334) {
var _0x21c4c0, _0x514a3a = true;
for (_0x21c4c0 in _0x26e73d) _0x26e73d[_0x21c4c0] !== _0x55c334[_0x21c4c0] && (_0x514a3a = !0x1);
return _0x514a3a;
}, _0x5633cb.prototype._update = function() {
this.platform.update(), this.gamepads.forEach(function(_0x415bf6) {
_0x415bf6 && _0x415bf6.updater.forEach(function(_0x39f57c) {
_0x39f57c();
});
}), this.gamepads.length > 0x0 && this._fire(_0x5633cb.Event.TICK, this.gamepads);
}, _0x5633cb.prototype._applyDeadzoneMaximize = function(_0x5b561d, _0x55976e, _0x5df97a) {
return _0x55976e = void 0x0 !== _0x55976e ? _0x55976e : this.deadzone, _0x5df97a = void 0x0 !== _0x5df97a ? _0x5df97a : this.maximizeThreshold, _0x5b561d >= 0x0 ? _0x5b561d < _0x55976e ? _0x5b561d = 0x0 : _0x5b561d > _0x5df97a && (_0x5b561d = 0x1) : _0x5b561d > -_0x55976e ? _0x5b561d = 0x0 : _0x5b561d < -_0x5df97a && (_0x5b561d = -0x1), _0x5b561d;
}, _0x36fa8f.Gamepad = _0x5633cb;
}(_0x3982a1.exports || window);
for (var j=0; j<this.gamepads.length; j++) {
if (!this.gamepads[j]) continue;
var has = false;
for (var i=0; i<gamepads.length; i++) {
if (!gamepads[i]) continue;
if (this.gamepads[j].id === gamepads[i].id) {
has = true;
}
}
if (!has) {
this.gamepads.splice(j, 1);
j--;
if (typeof this.ondisconnected == 'function') {
this.ondisconnected();
}
}
}
},
on: function(name, cb) {
this["on"+name.toLowerCase()] = cb;
}
}
module.exports = Gamepad;
}, null, null, null, null, function(module, _0x4f5203, _0x5028a6) {
var _0x33171 = function(url, opts) {
var url;

File diff suppressed because one or more lines are too long

View file

@ -1,5 +1,5 @@
(async function() {
var VERSION = 2.7;
var VERSION = 2.8;
if ((window.location && ['localhost', '127.0.0.1'].includes(location.hostname)) ||
'undefined' != typeof EJS_DEBUG_XX && true === EJS_DEBUG_XX) {
fetch('https://raw.githack.com/ethanaobrien/emulatorjs/main/data/version.json').then(response => {

View file

@ -1 +1 @@
{ "current_version": 2.7 }
{ "current_version": 2.8 }