{"version":3,"sources":["webpack://MergedInput/webpack/universalModuleDefinition","webpack://MergedInput/./main.js","webpack://MergedInput/./configs/bearings.js","webpack://MergedInput/./controlManager.js","webpack://MergedInput/./configs/pad_generic.js","webpack://MergedInput/./configs/pad_unlicensedSNES.js","webpack://MergedInput/./configs/pad_xbox360.js","webpack://MergedInput/./configs/pad_dualshock.js","webpack://MergedInput/./ButtonCombo.js","webpack://MergedInput/../node_modules/phaser/src/input/keyboard/combo/AdvanceKeyCombo.js","webpack://MergedInput/../node_modules/phaser/src/input/keyboard/combo/ResetKeyCombo.js","webpack://MergedInput/webpack/bootstrap"],"names":["root","factory","exports","module","define","amd","window","MergedInput","scene","pluginManager","players","gamepads","keys","bearings","dpadMappings","axisThreshold","controlManager","this","eventEmitter","systems","events","Phaser","Events","EventEmitter","game","on","Core","PRE_STEP","preupdate","POST_STEP","postupdate","BLUR","loseFocus","input","gamepad","thisGamepad","refreshGamepads","setupGamepad","refreshPads","total","emit","gamepadButtonDown","gamepadButtonUp","keyboard","keyboardKeyDown","keyboardKeyUp","mouse","disableContextMenu","thisPlayer","pointer","BEARING","BEARING_DEGREES","ANGLE","direction","mapDirectionsToBearing","BEARING_LAST","DEGREES","parseFloat","mapBearingToDegrees","DEGREES_LAST","direction_secondary","checkKeyboardInput","checkGamepadInput","checkPointerInput","clearBuffer","interaction","pressed","length","internal","fakedpadPressed","buffer","interaction_mapped","fakedpadReleased","released","thisKey","reset","device","id","player","index","action","addPlayer","thisButton","gamepadID","toLowerCase","mappedPad","mapGamepad","gamepadMapping","gamepadType","padType","buttons_mapped","value","filter","el","entries","fakedpad","buttons","numberOfButtons","Number","isInteger","newPlayer","setupControls","addPlayerHelperFunctions","push","pointerMove","pointerDown","pointerUp","isPressed","button","matchedButtons","Array","x","includes","isDown","matchedDirections","matchedPointer","matchedAll","isReleased","checkDown","duration","includeFirst","undefined","downButtons","t","timers","_tick","Math","Snap","Floor","sys","time","now","once","unmappedButtons","unmappedButton","getUnmappedButton","map","getMappedButton","setDevice","key","actions","Object","buttonID","toString","replace","find","mappedButton","buttonNo","dpadMapping","append","getPlayerActions","addKey","Input","Keyboard","KeyCodes","thisValue","TIMESTAMP","event","keyCode","playerIndex","getPlayerIndexFromKey","playerAction","getPlayerButtonFromKey","getPlayer","state","last","lastPressed","lastReleased","pad","fakedpadBuffer","Gamepad","Button","leftStick","y","UP","abs","gamepadFakeDPadPress","DOWN","up","down","LEFT","RIGHT","left","right","gamepadFakeDPadRelease","rightStick","b","threshold","angleToPointer","distance","pointerDirection","getBearingFromAngle","angle","position","Angle","Between","worldX","worldY","pointerAngle","leftButtonDown","rightButtonDown","middleButtonDown","backButtonDown","forwardButtonDown","moveTime","leftButtonReleased","rightButtonReleased","middleButtonReleased","backButtonReleased","forwardButtonReleased","config","ButtonCombo","numDirections","snap_interval","PI2","angleSnap","To","angleSnapDeg","RadToDeg","bearing","thisDirection","toUpperCase","directions","shutdown","debug","i","axes","a","axis","getValue","Plugins","ScenePlugin","padConfig","pad_generic","pad_unlicensedSNES","pad_xbox360","pad_dualshock","RC_S","RC_E","RC_W","RC_N","START","SELECT","LB","RB","LT","RT","LS","RS","LC_N","LC_S","LC_W","LC_E","MENU","controls","getBaseControls","thisPointer","setPosition","padID","TOUCH","mergedInput","keyCodes","onButtonDown","current","matched","enabled","ProcessButtonCombo","combo","resetOnMatch","deleteOnMatch","destroy","timeStamp","buttonMatch","comboMatched","keyMatched","maxKeyDelay","timeLimit","timeLastMatched","resetOnWrongKey","timeMatched","off","KeyCombo","size","installedModules","__webpack_require__","m","modules","c","d","name","getter","o","defineProperty","enumerable","get","r","Symbol","toStringTag","mode","__esModule","ns","create","bind","n","object","property","prototype","hasOwnProperty","call","p","s","moduleId","l"],"mappings":"AAAA,UAA2CA,EAAMC,GAC1B,UAAnB,OAAOC,SAA0C,UAAlB,OAAOC,OACxCA,OAAOD,QAAUD,EAAQ,EACA,YAAlB,OAAOG,QAAyBA,OAAOC,IAC9CD,OAAO,cAAe,GAAIH,CAAO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M,GAA4B,UAAhB,OAAO/M,EAAmB,IAAI,IAAIgD,KAAOhD,EAAOiM,EAAoBI,EAAEY,EAAIjK,EAAK,SAASA,GAAO,OAAOhD,EAAMgD,EAAM,EAAEmK,KAAK,KAAMnK,CAAG,CAAC,EAClJ,OAAOiK,CACR,EAGAhB,EAAoBmB,EAAI,SAAS5S,GAChC,IAAI+R,EAAS/R,GAAUA,EAAOwS,WAC7B,WAAwB,OAAOxS,EAAgB,OAAG,EAClD,WAA8B,OAAOA,CAAQ,EAE9C,OADAyR,EAAoBI,EAAEE,EAAQ,IAAKA,CAAM,EAClCA,CACR,EAGAN,EAAoBO,EAAI,SAASa,EAAQC,GAAY,OAAOpK,OAAOqK,UAAUC,eAAeC,KAAKJ,EAAQC,CAAQ,CAAG,EAGpHrB,EAAoByB,EAAI,GAIjBzB,EAAoBA,EAAoB0B,EAAI,CAAC,EA9EpD,SAAS1B,EAAoB2B,GAG5B,IAIIpT,EAJJ,OAAGwR,EAAiB4B,KAIhBpT,EAASwR,EAAiB4B,GAAY,CACzCtF,EAAGsF,EACHC,EAAG,GACHtT,QAAS,EACV,EAGA4R,EAAQyB,GAAUH,KAAKjT,EAAOD,QAASC,EAAQA,EAAOD,QAAS0R,CAAmB,EAGlFzR,EAAOqT,EAAI,GAGJrT,IAhB4BD,OAiBpC,C,MAxBIyR,C","file":"MergedInput.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"MergedInput\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"MergedInput\"] = factory();\n\telse\n\t\troot[\"MergedInput\"] = factory();\n})(window, function() {\nreturn ","import bearings from './configs/bearings'\nimport controlManager from './controlManager'\nimport ButtonCombo from './ButtonCombo'\n\nexport default class MergedInput extends Phaser.Plugins.ScenePlugin {\n\n\t/**\n\t * The Merged Input plugin is designed to run in the background and handle input.\n\t * Upon detecting a keypress or gamepad interaction, the plugin will update a player object and emit global events.\n\t *\n\t * @extends Phaser.Plugins.ScenePlugin\n\t * @param {*} scene\n\t * @param {*} pluginManager\n\t */\n\tconstructor(scene, pluginManager) {\n\t\tsuper(scene, pluginManager);\n\t\tthis.scene = scene;\n\n\t\t// Players\n\t\tthis.players = [];\n\t\t// Gamepads\n\t\tthis.gamepads = [];\n\t\t// Keys object to store Phaser key objects. We'll check these during update\n\t\tthis.keys = {};\n\n\t\tthis.bearings = bearings;\n\n\t\tthis.dpadMappings = {\n\t\t\t'UP': 12,\n\t\t\t'DOWN': 13,\n\t\t\t'LEFT': 14,\n\t\t\t'RIGHT': 15\n\t\t}\n\n\t\tthis.axisThreshold = this.axisThreshold;\n\n\t\tthis.controlManager = new controlManager()\n\t}\n\n\tboot() {\n\t\t// Scene event emitter\n\t\tthis.eventEmitter = this.systems.events;\n\t\t// Plugin event emitter\n\t\tthis.events = new Phaser.Events.EventEmitter();\n\n\t\tthis.game.events.on(Phaser.Core.Events.PRE_STEP, this.preupdate, this);\n\t\tthis.game.events.on(Phaser.Core.Events.POST_STEP, this.postupdate, this);\n\t\t// Handle the game losing focus\n\t\tthis.game.events.on(Phaser.Core.Events.BLUR, () => {\n\t\t\tthis.loseFocus()\n\t\t})\n\n\t\t// Gamepad\n\t\tif (typeof this.systems.input.gamepad !== 'undefined') {\n\t\t\tthis.systems.input.gamepad.on('connected', function (thisGamepad) {\n\t\t\t\tthis.refreshGamepads();\n\t\t\t\tthis.setupGamepad(thisGamepad)\n\t\t\t}, this);\n\n\t\t\t// Check to see if the gamepad has already been setup by the browser\n\t\t\tthis.systems.input.gamepad.refreshPads();\n\t\t\tif (this.systems.input.gamepad.total) {\n\t\t\t\tthis.refreshGamepads();\n\t\t\t\tfor (const thisGamepad of this.gamepads) {\n\t\t\t\t\tthis.systems.input.gamepad.emit('connected', thisGamepad);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.systems.input.gamepad.on('down', this.gamepadButtonDown, this);\n\t\t\tthis.systems.input.gamepad.on('up', this.gamepadButtonUp, this);\n\t\t}\n\n\t\t// Keyboard\n\t\tthis.systems.input.keyboard.on('keydown', this.keyboardKeyDown, this);\n\t\tthis.systems.input.keyboard.on('keyup', this.keyboardKeyUp, this);\n\n\n\t\t// Pointer\n\t\tthis.systems.input.mouse.disableContextMenu();\n\t}\n\n\tpreupdate() {\n\t\t// Loop through players and handle input\n\t\tfor (let thisPlayer of this.players) {\n\t\t\t// If the pointer hasn't moved, and the scene has changed, this can end up as undefined\n\t\t\tthisPlayer.pointer.BEARING = typeof thisPlayer.pointer.BEARING != 'undefined' ? thisPlayer.pointer.BEARING : '';\n\t\t\tthisPlayer.pointer.BEARING_DEGREES = typeof thisPlayer.pointer.BEARING_DEGREES != 'undefined' ? thisPlayer.pointer.BEARING_DEGREES : 0;\n\t\t\tthisPlayer.pointer.ANGLE = typeof thisPlayer.pointer.ANGLE != 'undefined' ? thisPlayer.pointer.ANGLE : '';\n\n\n\t\t\tthisPlayer.direction.BEARING = this.mapDirectionsToBearing(thisPlayer.direction);\n\t\t\tthisPlayer.direction.BEARING_LAST = thisPlayer.direction.BEARING != '' ? thisPlayer.direction.BEARING : thisPlayer.direction.BEARING_LAST;\n\t\t\tthisPlayer.direction.DEGREES = thisPlayer.direction.BEARING != '' ? parseFloat(this.mapBearingToDegrees(thisPlayer.direction.BEARING)) : 0;\n\t\t\tthisPlayer.direction.DEGREES_LAST = thisPlayer.direction.BEARING_LAST != '' ? parseFloat(this.mapBearingToDegrees(thisPlayer.direction.BEARING_LAST)) : 0;\n\t\t\tthisPlayer.direction_secondary.BEARING = this.mapDirectionsToBearing(thisPlayer.direction_secondary);\n\t\t\tthisPlayer.direction_secondary.BEARING_LAST = thisPlayer.direction_secondary.BEARING != '' ? thisPlayer.direction_secondary.BEARING : thisPlayer.direction_secondary.BEARING_LAST;\n\t\t\tthisPlayer.direction_secondary.DEGREES = thisPlayer.direction_secondary.BEARING != '' ? parseFloat(this.mapBearingToDegrees(thisPlayer.direction_secondary.BEARING)) : 0;\n\t\t\tthisPlayer.direction_secondary.DEGREES_LAST = thisPlayer.direction_secondary.BEARING_LAST != '' ? parseFloat(this.mapBearingToDegrees(thisPlayer.direction_secondary.BEARING_LAST)) : 0;\n\t\t}\n\n\t\tthis.checkKeyboardInput();\n\t\tthis.checkGamepadInput();\n\t\tthis.checkPointerInput();\n\t}\n\n\tpostupdate() {\n\t\t// Loop through players and manage buffered input\n\t\tfor (let thisPlayer of this.players) {\n\t\t\t// Clear the interaction buffer\n\t\t\tthis.clearBuffer(thisPlayer);\n\t\t}\n\t}\n\n\t/**\n\t * Clear the interaction buffer for the given player\n\t * In the case of 'fake' DPad presses, we're using some convoluted buffers to keep the 'pressed' and 'released' values around for an extra tick\n\t * As they're created in this update loop, they're otherwise cleared before the consumer can use them.\n\t * @param {*} thisPlayer\n\t */\n\tclearBuffer(thisPlayer) {\n\t\tif (thisPlayer.interaction.pressed.length > 0 && thisPlayer.internal.fakedpadPressed.length == 0) {\n\t\t\tthisPlayer.interaction.buffer = [];\n\t\t}\n\t\tif (thisPlayer.interaction.buffer.length == 0) {\n\t\t\tthisPlayer.interaction.pressed = [];\n\t\t\tthisPlayer.interaction_mapped.pressed = [];\n\t\t\tif (thisPlayer.internal.fakedpadReleased.length == 0) {\n\t\t\t\tthisPlayer.interaction.released = [];\n\t\t\t\tthisPlayer.interaction_mapped.released = [];\n\t\t\t}\n\t\t}\n\n\t\tthisPlayer.internal.fakedpadPressed = [];\n\t\tthisPlayer.internal.fakedpadReleased = [];\n\t}\n\n\t/**\n\t * Function to run when the game loses focus\n\t * We want to fake releasing the buttons here, so that they're not stuck down without an off event when focus returns to the game\n\t */\n\tloseFocus() {\n\t\t// Loop through defined keys and reset them\n\t\tfor (let thisKey in this.keys) {\n\t\t\tthis.keys[thisKey].reset();\n\t\t}\n\t}\n\n\t/**\n\t * Set up the gamepad and associate with a player object\n\t */\n\tsetupGamepad(thisGamepad) {\n\t\tthis.eventEmitter.emit('mergedInput', { device: 'gamepad', id: thisGamepad.id, player: thisGamepad.index, action: 'Connected' });\n\t\tthis.events.emit('gamepad_connected', thisGamepad)\n\n\t\tif (typeof this.players[thisGamepad.index] === 'undefined') {\n\t\t\tthis.addPlayer();\n\t\t}\n\n\t\tlet gamepadID = thisGamepad.id.toLowerCase();\n\t\tthis.players[thisGamepad.index].gamepad = thisGamepad;\n\n\t\t// Map the gamepad buttons\n\t\tlet mappedPad = this.controlManager.mapGamepad(gamepadID);\n\t\tthis.players[thisGamepad.index].gamepadMapping = mappedPad.gamepadMapping;\n\t\tthis.players[thisGamepad.index].interaction_mapped.gamepadType = mappedPad.padType;\n\t\tfor (let thisButton in this.players[thisGamepad.index].gamepadMapping) {\n\t\t\tthis.players[thisGamepad.index].buttons_mapped[thisButton] = 0;\n\t\t}\n\t}\n\n\t/**\n\t * Set a threshold (between 0 and 1) below which analog stick input will be ignored\n\t * @param {*} value\n\t * @returns\n\t */\n\tsetAxisThreshold(value) {\n\t\tthis.axisThreshold = value;\n\t\treturn this;\n\t}\n\n\n\trefreshGamepads() {\n\t\t// Sometimes, gamepads are undefined. For some reason.\n\t\tthis.gamepads = this.systems.input.gamepad.gamepads.filter(function (el) {\n\t\t\treturn el != null;\n\t\t});\n\n\t\tfor (const [index, thisGamepad] of this.gamepads.entries()) {\n\t\t\tthisGamepad.index = index; // Overwrite the gamepad index, in case we had undefined gamepads earlier\n\n\t\t\t/**\n\t\t\t * Some cheap gamepads use the first axis as a dpad, in which case we won't have the dpad buttons 12-15\n\t\t\t */\n\t\t\tthisGamepad.fakedpad = thisGamepad.buttons.length < 15;\n\t\t}\n\t}\n\n\t/**\n\t * Add a new player object to the players array\n\t * @param {number} index Player index - if a player object at this index already exists, it will be returned instead of creating a new player object\n\t * @param {number} numberOfButtons The number of buttons to assign to the player object. Defaults to 16. Fewer than 16 is not recommended, as gamepad DPads typically map to buttons 12-15\n\t */\n\taddPlayer(index, numberOfButtons) {\n\t\tnumberOfButtons = numberOfButtons || 16;\n\t\tif (typeof Number.isInteger(index) && typeof this.players[index] !== 'undefined') {\n\t\t\treturn this.players[index];\n\t\t}\n\t\telse {\n\t\t\t// Set up player object\n\t\t\tlet newPlayer = this.controlManager.setupControls(numberOfButtons);\n\n\t\t\t// Add helper functions to the player object\n\t\t\tthis.addPlayerHelperFunctions(newPlayer);\n\n\t\t\t// Push new player to players array\n\t\t\tthis.players.push(newPlayer);\n\n\t\t\tthis.players[this.players.length - 1].index = this.players.length - 1;\n\n\t\t\t// If this is the first player, add the pointer events\n\t\t\tif (this.players.length == 1) {\n\t\t\t\tthis.systems.input.on('pointermove', function (pointer) {\n\t\t\t\t\tthis.pointerMove(pointer);\n\t\t\t\t}, this);\n\n\t\t\t\tthis.systems.input.on('pointerdown', function (pointer) {\n\t\t\t\t\tthis.pointerDown(pointer);\n\t\t\t\t}, this);\n\n\t\t\t\tthis.systems.input.on('pointerup', function (pointer) {\n\t\t\t\t\tthis.pointerUp(pointer);\n\t\t\t\t}, this);\n\t\t\t}\n\n\t\t\treturn this.players[this.players.length - 1];\n\t\t}\n\t}\n\n\t/**\n\t * Add helper functions to the player object\n\t * @param {*} player\n\t */\n\taddPlayerHelperFunctions(player) {\n\t\t/**\n\t\t * Pass a button name, or an array of button names to check if any were pressed in this update step.\n\t\t * This will only fire once per button press. If you need to check for a button being held down, use isDown instead.\n\t\t * Returns the name of the matched button(s), in case you need it.\n\t\t */\n\t\tplayer.interaction.isPressed = (button) => {\n\t\t\tbutton = (typeof button === 'string') ? Array(button) : button;\n\t\t\tlet matchedButtons = button.filter(x => player.interaction.pressed.includes(x))\n\t\t\treturn matchedButtons.length ? matchedButtons : false;\n\t\t},\n\n\t\t/**\n\t\t * Pass a button name, or an array of button names to check if any are currently pressed in this update step.\n\t\t * This differs from the isPressed function in that it will return true if the button is currently pressed, even if it was pressed in a previous update step.\n\t\t * Returns the name of the matched button(s), in case you need it.\n\t\t */\n\t\tplayer.interaction.isDown = (button) => {\n\t\t\tbutton = (typeof button === 'string') ? Array(button) : button;\n\t\t\tlet matchedButtons = button.filter(x => player.buttons[x])\n\t\t\tlet matchedDirections = button.filter(x => player.direction[x])\n\t\t\tlet matchedPointer = button.filter(x => player.pointer[x])\n\t\t\tlet matchedAll = [...matchedButtons, ...matchedDirections, ...matchedPointer];\n\n\t\t\treturn matchedAll.length ? matchedAll : false;\n\t\t},\n\n\t\t/**\n\t\t * Pass a button name, or an array of button names to check if any were released in this update step.\n\t\t * Returns the name of the matched button(s), in case you need it.\n\t\t */\n\t\tplayer.interaction.isReleased = (button) => {\n\t\t\tbutton = (typeof button === 'string') ? Array(button) : button;\n\t\t\tlet matchedButtons = button.filter(x => player.interaction.released.includes(x))\n\t\t\treturn matchedButtons.length ? matchedButtons : false;\n\t\t}\n\n\t\t/**\n\t\t * Pass a mapped button name, or an array of mapped button names to check if any were pressed in this update step.\n\t\t * This will only fire once per button press. If you need to check for a button being held down, use isDown instead.\n\t\t * Returns the name of the matched mapped button(s), in case you need it.\n\t\t */\n\t\tplayer.interaction_mapped.isPressed = (button) => {\n\t\t\tbutton = (typeof button === 'string') ? Array(button) : button;\n\t\t\tlet matchedButtons = button.filter(x => player.interaction_mapped.pressed.includes(x))\n\t\t\treturn matchedButtons.length ? matchedButtons : false;\n\t\t},\n\n\t\t/**\n\t\t * Pass a mapped button name, or an array of mapped button names to check if any are currently pressed in this update step.\n\t\t * This differs from the isPressed function in that it will return true if the button is currently pressed, even if it was pressed in a previous update step.\n\t\t * Returns the name of the matched button(s), in case you need it.\n\t\t */\n\t\tplayer.interaction_mapped.isDown = (button) => {\n\t\t\tbutton = (typeof button === 'string') ? Array(button) : button;\n\t\t\tlet matchedButtons = button.filter(x => player.buttons_mapped[x])\n\t\t\treturn matchedButtons.length ? matchedButtons : false;\n\t\t},\n\n\t\t/**\n\t\t * Pass a mapped button name, or an array of mapped button names to check if any were released in this update step.\n\t\t * Returns the name of the matched mapped button(s), in case you need it.\n\t\t */\n\t\tplayer.interaction_mapped.isReleased = (button) => {\n\t\t\tbutton = (typeof button === 'string') ? Array(button) : button;\n\t\t\tlet matchedButtons = button.filter(x => player.interaction_mapped.released.includes(x))\n\t\t\treturn matchedButtons.length ? matchedButtons : false;\n\t\t}\n\n\t\t/**\n\t\t * Pass a button name, or an array of button names to check if any are currently pressed in this update step.\n\t\t * Similar to Phaser's keyboard plugin, the checkDown function can accept a 'duration' parameter, and will only register a press once every X milliseconds.\n\t\t * Returns the name of the matched button(s)\n\t\t *\n\t\t * @param {string|array} button Array of buttons to check\n\t\t * @param {number} duration The duration which must have elapsed before this button is considered as being down.\n\t\t * @param {boolean} includeFirst - When true, the initial press of the button will be included in the results. Defaults to false.\n\t\t */\n\t\tplayer.interaction.checkDown = (button, duration, includeFirst) => {\n\t\t\tif (includeFirst === undefined) { includeFirst = false; }\n\t\t\tif (duration === undefined) { duration = 0; }\n\n\t\t\tlet matchedButtons = [];\n\t\t\tlet downButtons = player.interaction.isDown(button)\n\t\t\tif (downButtons.length) {\n\n\t\t\t\tfor (let thisButton of downButtons) {\n\t\t\t\t\tif (typeof player.timers[thisButton]._tick === 'undefined') {\n\t\t\t\t\t\tplayer.timers[thisButton]._tick = 0;\n\t\t\t\t\t\tif (includeFirst) {\n\t\t\t\t\t\t\tmatchedButtons.push(thisButton);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tlet t = Phaser.Math.Snap.Floor(this.scene.sys.time.now - player.timers[thisButton].pressed, duration);\n\t\t\t\t\tif (t > player.timers[thisButton]._tick) {\n\t\t\t\t\t\tthis.game.events.once(Phaser.Core.Events.POST_STEP, ()=>{\n\t\t\t\t\t\t\tplayer.timers[thisButton]._tick = t;\n\t\t\t\t\t\t});\n\t\t\t\t\t\tmatchedButtons.push(thisButton);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn matchedButtons.length ? matchedButtons : false;\n\t\t},\n\n\t\t/**\n\t\t * Mapped version of the checkDown version - resolves mapped button names and calls the checkDown function\n\t\t */\n\t\t\tplayer.interaction_mapped.checkDown = (button, duration, includeFirst) => {\n\t\t\tif (includeFirst === undefined) { includeFirst = false; }\n\t\t\tlet unmappedButtons = [];\n\n\t\t\t// Resolve the unmapped button names to a new array\n\t\t\tfor (let thisButton of button) {\n\t\t\t\tlet unmappedButton = this.getUnmappedButton(player, thisButton);\n\n\t\t\t\tif (unmappedButton) {\n\t\t\t\t\tunmappedButtons.push(unmappedButton)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet downButtons = player.interaction.checkDown(unmappedButtons, duration, includeFirst);\n\t\t\treturn downButtons.length ? downButtons.map(x => this.getMappedButton(player, x)) : false;\n \t\t}\n\n\n\t\t/**\n\t\t * The previous functions are specific to the interaction and interaction_mapped definition of buttons.\n\t\t * In general you would pick a definition scheme and query that object (interaction or interaction_mapped), just for ease though, we'll add some functions that accept either type of convention\n\t\t */\n\n\t\t/**\n\t\t * Pass a button name, or an array of button names to check if any were pressed in this update step.\n\t\t * This will only fire once per button press. If you need to check for a button being held down, use isDown instead.\n\t\t * Returns the name of the matched button(s), in case you need it.\n\t\t */\n\t\tplayer.isPressed = (button) => {\n\t\t\tlet interaction = player.interaction.isPressed(button) || [];\n\t\t\tlet interaction_mapped = player.interaction_mapped.isPressed(button) || [];\n\t\t\tlet matchedButtons = [...interaction, ...interaction_mapped];\n\t\t\treturn matchedButtons.length ? matchedButtons : false\n\t\t},\n\n\t\t/**\n\t\t * Pass a button name, or an array of button names to check if any are currently pressed in this update step.\n\t\t * This differs from the isPressed function in that it will return true if the button is currently pressed, even if it was pressed in a previous update step.\n\t\t * Returns the name of the button(s), in case you need it.\n\t\t */\n\t\tplayer.isDown = (button) => {\n\t\t\tlet interaction = player.interaction.isDown(button) || [];\n\t\t\tlet interaction_mapped = player.interaction_mapped.isDown(button) || [];\n\t\t\tlet matchedButtons = [...interaction, ...interaction_mapped];\n\t\t\treturn matchedButtons.length ? matchedButtons : false\n\t\t},\n\n\t\t/**\n\t\t * Pass a button name, or an array of button names to check if any were released in this update step.\n\t\t * Returns the name of the matched button(s), in case you need it.\n\t\t */\n\t\tplayer.isReleased = (button) => {\n\t\t\tlet interaction = player.interaction.isReleased(button) || [];\n\t\t\tlet interaction_mapped = player.interaction_mapped.isReleased(button) || [];\n\t\t\tlet matchedButtons = [...interaction, ...interaction_mapped];\n\t\t\treturn matchedButtons.length ? matchedButtons : false\n\t\t}\n\n\n\t\t/**\n\t\t * Pass a button name, or an array of button names to check if any are currently pressed in this update step.\n\t\t * Similar to Phaser's keyboard plugin, the checkDown function can accept a 'duration' parameter, and will only register a press once every X milliseconds.\n\t\t * Returns the name of the matched button(s)\n\t\t *\n\t\t * @param {string|array} button Array of buttons to check\n\t\t * @param {number} - The duration which must have elapsed before this button is considered as being down.\n\t\t */\n\t\tplayer.checkDown = (button, duration, includeFirst) => {\n\t\t\tif (includeFirst === undefined) { includeFirst = false; }\n\t\t\tlet interaction = player.interaction.checkDown(button, duration, includeFirst) || [];\n\t\t\tlet interaction_mapped = player.interaction_mapped.checkDown(button, duration, includeFirst) || [];\n\t\t\tlet matchedButtons = [...interaction, ...interaction_mapped];\n\t\t\treturn matchedButtons.length ? matchedButtons : false\n\t\t}\n\n\n\t\tplayer.setDevice = (device) => {\n\t\t\tif (player.interaction.device != device) {\n\t\t\t\tthis.eventEmitter.emit('mergedInput', { device: device, player: player.index, action: 'Device Changed' });\n\t\t\t\tthis.events.emit('device_changed', { player: player.index, device: device });\n\t\t\t}\n\t\t\tplayer.interaction.device = device;\n\n\t\t\treturn this;\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Get player object\n\t * @param {number} index Player index\n\t */\n\tgetPlayer(index) {\n\t\treturn typeof this.players[index] !== 'undefined' ? this.players[index] : ''\n\t}\n\n\tgetPlayerIndexFromKey(key) {\n\t\tfor (let thisPlayer of this.players) {\n\t\t\t// Loop through all the keys assigned to this player\n\t\t\tfor (var thisKey in thisPlayer.keys) {\n\t\t\t\tfor (var thisValue of thisPlayer.keys[thisKey]) {\n\t\t\t\t\tif (thisValue == key) {\n\t\t\t\t\t\treturn thisPlayer.index;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn -1;\n\t}\n\n\tgetPlayerButtonFromKey(key) {\n\t\tfor (let thisPlayer of this.players) {\n\t\t\t// Loop through all the keys assigned to this player\n\t\t\tfor (var thisKey in thisPlayer.keys) {\n\t\t\t\tfor (var thisValue of thisPlayer.keys[thisKey]) {\n\t\t\t\t\tif (thisValue == key) {\n\t\t\t\t\t\t// Now we have a matching button value, check to see if it's in our mapped buttons, in which case we want to return the button number it matches to\n\t\t\t\t\t\tif (typeof thisPlayer.gamepadMapping[thisKey] !== \"undefined\") {\n\t\t\t\t\t\t\treturn 'B' + thisPlayer.gamepadMapping[thisKey];\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\treturn thisKey;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn '';\n\t}\n\n\n\t/**\n\t * Return an array of actions that a player may use\n\t * @param {number} player\n\t * @returns\n\t */\n\tgetPlayerActions(player) {\n\t\tlet actions = ['UP', 'DOWN', 'LEFT', 'RIGHT', 'ALT_UP', 'ALT_DOWN', 'ALT_LEFT', 'ALT_RIGHT'];\n\t\tactions.push(...Object.keys(this.players[player].gamepadMapping));\n\t\tactions.push(...Object.keys(this.players[player].buttons));\n\n\t\treturn actions;\n\t}\n\n\t/**\n\t * Given a player and a button ID, return the mapped button name, e.g. 0 = 'RC_S' (Right cluster, South - X on an xbox gamepad)\n\t * @param {*} player\n\t * @param {*} buttonID\n\t */\n\tgetMappedButton(player, buttonID) {\n\t\tbuttonID = buttonID.toString().replace(/\\D/g, '');\n\t\treturn Object.keys(player.gamepadMapping).find(key => player.gamepadMapping[key] == buttonID);\n\t}\n\n\t/**\n\t * Given a player and a mapped button name, return the button ID that it resolves to, e.g. 'RC_S' (Right cluster, South - X on an xbox gamepad) = B0.\n\t * This takes directions into account and will thus return 'LEFT' for LC_W, instead of the button ID that can be found in the gamepadMapping.\n\t * @param {*} player\n\t * @param {*} mappedButton\n\t */\n\tgetUnmappedButton(player, mappedButton) {\n\t\tlet buttonNo = player.gamepadMapping[mappedButton];\n\t\tlet dpadMapping = this.dpadMappings;\n\t\tlet direction = Object.keys(dpadMapping).find(key => dpadMapping[key] == buttonNo);\n\n\t\treturn direction ? direction : 'B' + player.gamepadMapping[mappedButton];\n\t}\n\n\t// Keyboard functions\n\n\t/**\n\t * Define a key for a player/action combination\n\t * @param {number} player The player on which we're defining a key\n\t * @param {string} action The action to define\n\t * @param {string} value The key to use\n\t * @param {boolean} append When true, this key definition will be appended to the existing key(s) for this action\n\t */\n\tdefineKey(player = 0, action, value, append = false) {\n\t\t// Set up a new player if none defined\n\t\tif (typeof this.players[player] === 'undefined') {\n\t\t\tthis.addPlayer();\n\t\t}\n\n\t\tif (this.getPlayerActions(player).includes(action)) {\n\t\t\tif (append && (typeof this.players[player].keys[action] !== 'undefined')) {\n\t\t\t\tthis.players[player].keys[action].push([value]);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthis.players[player].keys[action] = [];\n\t\t\t\tthis.players[player].keys[action].push([value]);\n\t\t\t}\n\n\t\t\tthis.keys[[value]] = this.systems.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes[value]);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Iterate through players and check for interaction with defined keys\n\t */\n\tcheckKeyboardInput() {\n\t\t// Loop through players and check for keypresses\n\t\tfor (let thisPlayer of this.players) {\n\t\t\t// Loop through all the keys assigned to this player\n\t\t\tfor (var thisKey in thisPlayer.keys) {\n\t\t\t\tlet action = 0;\n\t\t\t\tfor (var thisValue of thisPlayer.keys[thisKey]) {\n\t\t\t\t\t// Check if the key is down\n\t\t\t\t\taction = (this.keys[thisValue].isDown) ? 1 : action;\n\t\t\t\t}\n\n\t\t\t\t// Set the action in the player object\n\n\t\t\t\t// Dpad\n\t\t\t\tif (['UP', 'DOWN', 'LEFT', 'RIGHT'].includes(thisKey)) {\n\t\t\t\t\tthisPlayer.direction[thisKey] = action;\n\t\t\t\t\tthisPlayer.direction.TIMESTAMP = this.scene.sys.time.now;\n\t\t\t\t}\n\t\t\t\t// Alternative direction\n\t\t\t\telse if (['ALT_UP', 'ALT_DOWN', 'ALT_LEFT', 'ALT_RIGHT'].includes(thisKey)) {\n\t\t\t\t\tthisPlayer.direction_secondary[thisKey.replace('ALT_', '')] = action;\n\t\t\t\t\tif (action == 1) {\n\t\t\t\t\t\tthisPlayer.direction_secondary.TIMESTAMP = this.scene.sys.time.now;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// Friendly button names\n\t\t\t\telse if (thisKey in thisPlayer.gamepadMapping) {\n\t\t\t\t\t// Get the button number from the gamepad mapping\n\t\t\t\t\tthisPlayer.buttons['B' + thisPlayer.gamepadMapping[thisKey]] = action;\n\t\t\t\t\tthisPlayer.buttons_mapped[thisKey] = action;\n\t\t\t\t\tif (action == 1) {\n\t\t\t\t\t\tthisPlayer.buttons.TIMESTAMP = this.scene.sys.time.now;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// Numbered buttons\n\t\t\t\telse {\n\t\t\t\t\tthisPlayer.buttons[thisKey] = action;\n\t\t\t\t\tif (action == 1) {\n\t\t\t\t\t\tthisPlayer.buttons.TIMESTAMP = this.scene.sys.time.now;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Set the latest interaction flag\n\t\t\t\tif (action == 1) {\n\t\t\t\t\tthisPlayer.setDevice('keyboard');\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * When a keyboard button is pressed down, this function will emit a mergedInput event in the global registry.\n\t * The event contains a reference to the player assigned to the key, and passes a mapped action and value\n\t */\n\tkeyboardKeyDown(event) {\n\t\tlet keyCode = Object.keys(Phaser.Input.Keyboard.KeyCodes).find(key => Phaser.Input.Keyboard.KeyCodes[key] === event.keyCode);\n\t\tlet playerIndex = this.getPlayerIndexFromKey(keyCode);\n\t\tlet playerAction = this.getPlayerButtonFromKey(keyCode);\n\n\t\tif (playerIndex > -1 && playerAction != '') {\n\t\t\tlet thisPlayer = this.getPlayer(playerIndex);\n\t\t\tthis.eventEmitter.emit('mergedInput', { device: 'keyboard', value: 1, player: playerIndex, action: keyCode, state: 'DOWN' });\n\t\t\tthis.events.emit('keyboard_keydown', { player: playerIndex, key: keyCode });\n\n\t\t\tthisPlayer.setDevice('keyboard');\n\t\t\tthisPlayer.interaction.pressed.push(playerAction);\n\t\t\tthisPlayer.interaction.buffer.push(playerAction);\n\t\t\tthisPlayer.interaction.last = playerAction;\n\t\t\tthisPlayer.interaction.lastPressed = playerAction;\n\n\t\t\t// Update timers\n\t\t\tthisPlayer.timers[playerAction].pressed = this.scene.sys.time.now;\n\t\t\tthisPlayer.timers[playerAction].released = 0;\n\t\t\tthisPlayer.timers[playerAction].duration = 0;\n\n\t\t\t// Update mapped button object\n\t\t\tif (typeof this.dpadMappings[playerAction] !== \"undefined\") {\n\t\t\t\tplayerAction = 'B' + this.dpadMappings[playerAction];\n\t\t\t}\n\t\t\tif (typeof thisPlayer.buttons[playerAction] !== \"undefined\") {\n\t\t\t\tlet mappedButton = this.getMappedButton(thisPlayer, playerAction);\n\t\t\t\tif (typeof mappedButton !== \"undefined\") {\n\t\t\t\t\tthisPlayer.buttons_mapped[mappedButton] = 1;\n\t\t\t\t\tthisPlayer.interaction_mapped.pressed.push(mappedButton);\n\t\t\t\t\tthisPlayer.interaction_mapped.last = mappedButton;\n\t\t\t\t\tthisPlayer.interaction_mapped.lastPressed = mappedButton;\n\t\t\t\t\tthisPlayer.interaction_mapped.gamepadType = 'keyboard';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * When a keyboard button is released, this function will emit a mergedInput event in the global registry.\n\t * The event contains a reference to the player assigned to the key, and passes a mapped action and value\n\t */\n\tkeyboardKeyUp(event) {\n\t\tlet keyCode = Object.keys(Phaser.Input.Keyboard.KeyCodes).find(key => Phaser.Input.Keyboard.KeyCodes[key] === event.keyCode);\n\t\tlet playerIndex = this.getPlayerIndexFromKey(keyCode);\n\t\tlet playerAction = this.getPlayerButtonFromKey(keyCode);\n\n\t\tif (playerIndex > -1 && playerAction != '') {\n\t\t\tlet thisPlayer = this.getPlayer(playerIndex);\n\t\t\tthis.eventEmitter.emit('mergedInput', { device: 'keyboard', value: 1, player: playerIndex, action: keyCode, state: 'UP' });\n\t\t\tthis.events.emit('keyboard_keyup', { player: playerIndex, key: keyCode });\n\n\t\t\tthisPlayer.setDevice('keyboard');\n\t\t\tthisPlayer.interaction.released.push(playerAction);\n\t\t\tthisPlayer.interaction.lastReleased = playerAction;\n\n\t\t\t// Update timers\n\t\t\tthisPlayer.timers[playerAction].released = this.scene.sys.time.now;\n\t\t\tthisPlayer.timers[playerAction].duration = thisPlayer.timers[playerAction].released - thisPlayer.timers[playerAction].pressed;\n\t\t\tdelete thisPlayer.timers[playerAction]._tick;\n\n\t\t\t// Update mapped button object\n\t\t\tif (typeof this.dpadMappings[playerAction] !== \"undefined\") {\n\t\t\t\tplayerAction = 'B' + this.dpadMappings[playerAction];\n\t\t\t}\n\t\t\tif (typeof thisPlayer.buttons[playerAction] !== \"undefined\") {\n\t\t\t\tlet mappedButton = this.getMappedButton(thisPlayer, playerAction);\n\t\t\t\tif (typeof mappedButton !== \"undefined\") {\n\t\t\t\t\tthisPlayer.buttons_mapped[mappedButton] = 0;\n\t\t\t\t\tthisPlayer.interaction_mapped.released = mappedButton;\n\t\t\t\t\tthisPlayer.interaction_mapped.lastReleased = mappedButton;\n\t\t\t\t\tthisPlayer.interaction_mapped.gamepadType = 'keyboard';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\n\t/**\n\t * Iterate through players and check for interaction with defined pointer buttons\n\t */\n\tcheckPointerInput() {\n\t\t// Loop through players and check for button presses\n\t\tfor (let thisPlayer of this.players) {\n\t\t\t// Loop through all the keys assigned to this player\n\t\t\tfor (var thisKey in thisPlayer.keys) {\n\t\t\t\tfor (var thisValue of thisPlayer.keys[thisKey]) { // Each definition for this key action\n\t\t\t\t\tif (['M1', 'M2', 'M3', 'M4', 'M5'].includes(thisValue[0])) {\n\t\t\t\t\t\t// Check to see if button is pressed (stored in P1, can't have two mice...)\n\t\t\t\t\t\tif (this.players[0].pointer[thisValue] == 1) {\n\t\t\t\t\t\t\tthisPlayer.buttons[thisKey] = 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\n\t// Gamepad functions\n\n\t/**\n\t * When a gamepad button is pressed down, this function will emit a mergedInput event in the global registry.\n\t * The event contains a reference to the player assigned to the gamepad, and passes a mapped action and value\n\t * @param {number} index Button index\n\t * @param {number} value Button value\n\t * @param {Phaser.Input.Gamepad.Button} button Phaser Button object\n\t */\n\tgamepadButtonDown(pad, button, value) {\n\t\tthis.players[pad.index].setDevice('gamepad');\n\t\tthis.players[pad.index].buttons.TIMESTAMP = this.scene.sys.time.now;\n\t\tthis.eventEmitter.emit('mergedInput', { device: 'gamepad', value: value, player: pad.index, action: 'B' + button.index, state: 'DOWN' });\n\t\tthis.events.emit('gamepad_buttondown', { player: pad.index, button: `B${button.index}` });\n\n\t\t// Buttons\n\t\tif (![12, 13, 14, 15].includes(button.index)) {\n\t\t\tlet playerAction = 'B' + button.index;\n\n\t\t\t// Update the last button state\n\t\t\tthis.players[pad.index].interaction.pressed.push(playerAction);\n\t\t\tthis.players[pad.index].interaction.last = playerAction;\n\t\t\tthis.players[pad.index].interaction.lastPressed = playerAction;\n\t\t\tthis.players[pad.index].interaction.buffer.push(playerAction);\n\n\t\t\t// Update timers\n\t\t\tthis.players[pad.index].timers[playerAction].pressed = this.scene.sys.time.now;\n\t\t\tthis.players[pad.index].timers[playerAction].released = 0;\n\t\t\tthis.players[pad.index].timers[playerAction].duration = 0;\n\n\t\t\t// Update mapped button object\n\t\t\tlet mappedButton = this.getMappedButton(this.players[pad.index], button.index);\n\t\t\tif (typeof mappedButton !== \"undefined\") {\n\t\t\t\tthis.players[pad.index].interaction_mapped.pressed.push(mappedButton);\n\t\t\t\tthis.players[pad.index].interaction_mapped.last = mappedButton;\n\t\t\t\tthis.players[pad.index].interaction_mapped.lastPressed = mappedButton;\n\t\t\t}\n\t\t}\n\t\t// DPad\n\t\telse {\n\t\t\tlet dpadMapping = this.dpadMappings;\n\t\t\tlet direction = Object.keys(dpadMapping).find(key => dpadMapping[key] == button.index);\n\t\t\tthis.eventEmitter.emit('mergedInput', { device: 'gamepad', value: 1, player: pad.index, action: direction, state: 'DOWN' });\n\t\t\tthis.events.emit('gamepad_directiondown', { player: pad.index, button: direction });\n\n\t\t\tthis.players[pad.index].interaction.pressed.push(direction);\n\t\t\tthis.players[pad.index].interaction.last = direction;\n\t\t\tthis.players[pad.index].interaction.lastPressed = direction;\n\t\t\tthis.players[pad.index].interaction.buffer.push(direction);\n\t\t\tthis.players[pad.index].direction.TIMESTAMP = this.scene.sys.time.now;\n\n\t\t\t// Update timers\n\t\t\tthis.players[pad.index].timers[direction].pressed = this.scene.sys.time.now;\n\t\t\tthis.players[pad.index].timers[direction].released = 0;\n\t\t\tthis.players[pad.index].timers[direction].duration = 0;\n\n\n\t\t\t// Update mapped button object\n\t\t\tlet mappedButton = this.getMappedButton(this.players[pad.index], button.index);\n\t\t\tif (typeof mappedButton !== \"undefined\") {\n\t\t\t\tthis.players[pad.index].interaction_mapped.pressed.push(mappedButton);\n\t\t\t\tthis.players[pad.index].interaction_mapped.last = mappedButton;\n\t\t\t\tthis.players[pad.index].interaction_mapped.lastPressed = mappedButton;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * When a gamepad button is released, this function will emit a mergedInput event in the global registry.\n\t * The event contains a reference to the player assigned to the gamepad, and passes a mapped action and value\n\t * @param {number} index Button index\n\t * @param {number} value Button value\n\t * @param {Phaser.Input.Gamepad.Button} button Phaser Button object\n\t */\n\tgamepadButtonUp(pad, button, value) {\n\t\tthis.players[pad.index].setDevice('gamepad');\n\t\tthis.players[pad.index].buttons.TIMESTAMP = this.scene.sys.time.now;\n\n\t\tthis.eventEmitter.emit('mergedInput', { device: 'gamepad', value: value, player: pad.index, action: 'B' + button.index, state: 'UP' });\n\t\tthis.events.emit('gamepad_buttonup', { player: pad.index, button: `B${button.index}` });\n\n\t\t// Buttons\n\t\tif (![12, 13, 14, 15].includes(button.index)) {\n\t\t\tlet playerAction = 'B' + button.index;\n\n\t\t\t// Update the last button state\n\t\t\tthis.players[pad.index].interaction.released.push(playerAction);\n\t\t\tthis.players[pad.index].interaction.lastReleased = playerAction;\n\n\t\t\t// Update timers\n\t\t\tthis.players[pad.index].timers[playerAction].released = this.scene.sys.time.now;\n\t\t\tthis.players[pad.index].timers[playerAction].duration = this.players[pad.index].timers[playerAction].released - this.players[pad.index].timers[playerAction].pressed;\n\t\t\tdelete this.players[pad.index].timers[playerAction]._tick;\n\n\t\t\t// Update mapped button object\n\t\t\tlet mappedButton = this.getMappedButton(this.players[pad.index], button.index);\n\t\t\tif (typeof mappedButton !== \"undefined\") {\n\t\t\t\tthis.players[pad.index].interaction_mapped.released = mappedButton;\n\t\t\t\tthis.players[pad.index].interaction_mapped.lastReleased = mappedButton;\n\t\t\t}\n\t\t}\n\t\t// DPad\n\t\telse {\n\t\t\tlet dpadMapping = this.dpadMappings;\n\t\t\tlet direction = Object.keys(dpadMapping).find(key => dpadMapping[key] == button.index);\n\t\t\tthis.eventEmitter.emit('mergedInput', { device: 'gamepad', value: 1, player: pad.index, action: direction, state: 'UP' });\n\t\t\tthis.events.emit('gamepad_directionup', { player: pad.index, button: direction });\n\n\t\t\tthis.players[pad.index].interaction.released.push(direction);\n\t\t\tthis.players[pad.index].interaction.lastReleased = direction;\n\n\t\t\t// Update timers\n\t\t\tthis.players[pad.index].timers[direction].released = this.scene.sys.time.now;\n\t\t\tthis.players[pad.index].timers[direction].duration = this.players[pad.index].timers[direction].released - this.players[pad.index].timers[direction].pressed;\n\t\t\tdelete this.players[pad.index].timers[direction]._tick;\n\n\t\t\t// Update mapped button object\n\t\t\tlet mappedButton = this.getMappedButton(this.players[pad.index], button.index);\n\t\t\tif (typeof mappedButton !== \"undefined\") {\n\t\t\t\tthis.players[pad.index].interaction_mapped.released = mappedButton;\n\t\t\t\tthis.players[pad.index].interaction_mapped.lastReleased = mappedButton;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Some gamepads map dpads to axis, which are handled differently to buttons.\n\t * This function mimics a gamepad push and fires an event.\n\t * We also insert the direction into a buffer so that we know what buttons are pressed in the gamepadFakeDPadRelease function\n\t * We use an array for the buffer and pressed vars, as more than one button may be pressed at the same time, within the same step.\n\t */\n\tgamepadFakeDPadPress(gamepad, direction) {\n\t\tif (!this.players[gamepad.index].internal.fakedpadBuffer.includes(direction)) {\n\t\t\tthis.players[gamepad.index].internal.fakedpadBuffer.push(direction);\n\t\t\tthis.players[gamepad.index].internal.fakedpadPressed.push(direction);\n\n\t\t\tlet thisButton = new Phaser.Input.Gamepad.Button(gamepad, this.dpadMappings[direction])\n\t\t\tthisButton.value = 1;\n\t\t\tthisButton.pressed = true;\n\t\t\tthisButton.events.emit('down', gamepad, thisButton, 1)\n\t\t}\n\t}\n\n\t/**\n\t * When the axis is blank, we know we've released all buttons.\n\t */\n\tgamepadFakeDPadRelease(gamepad) {\n\t\tif (this.players[gamepad.index].internal.fakedpadBuffer.length > 0) {\n\n\t\t\tfor (let direction of this.players[gamepad.index].internal.fakedpadBuffer) {\n\t\t\t\tthis.players[gamepad.index].internal.fakedpadReleased = direction;\n\n\t\t\t\tlet thisButton = new Phaser.Input.Gamepad.Button(gamepad, this.dpadMappings[direction])\n\t\t\t\tthisButton.value = 0;\n\t\t\t\tthisButton.pressed = false;\n\t\t\t\tthisButton.events.emit('up', gamepad, thisButton, 0)\n\t\t\t}\n\n\t\t\tthis.players[gamepad.index].internal.fakedpadBuffer = [];\n\t\t}\n\t}\n\n\t/**\n\t * Iterate through gamepads and handle interactions\n\t */\n\tcheckGamepadInput() {\n\t\t// Check for gamepad input\n\t\tfor (var thisGamepad of this.gamepads) {\n\n\t\t\t// Set up a player if we don't have one, presumably due to race conditions in detecting gamepads\n\t\t\tif (typeof this.players[thisGamepad.index] === 'undefined') {\n\t\t\t\tthis.addPlayer();\n\t\t\t}\n\n\t\t\tlet direction = '';\n\n\t\t\t// Directions\n\t\t\tif (thisGamepad.leftStick.y < -this.axisThreshold) {\n\t\t\t\tthis.players[thisGamepad.index].direction.UP = Math.abs(thisGamepad.leftStick.y)\n\t\t\t\tthis.players[thisGamepad.index].direction.TIMESTAMP = this.scene.sys.time.now;\n\n\t\t\t\tif (thisGamepad.fakedpad) {\n\t\t\t\t\tthis.gamepadFakeDPadPress(thisGamepad, 'UP');\n\t\t\t\t\tdirection = 'UP'\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (thisGamepad.leftStick.y > this.axisThreshold) {\n\t\t\t\tthis.players[thisGamepad.index].direction.DOWN = thisGamepad.leftStick.y\n\t\t\t\tthis.players[thisGamepad.index].direction.TIMESTAMP = this.scene.sys.time.now;\n\n\t\t\t\tif (thisGamepad.fakedpad) {\n\t\t\t\t\tthis.gamepadFakeDPadPress(thisGamepad, 'DOWN');\n\t\t\t\t\tdirection = 'DOWN'\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (this.players[thisGamepad.index].interaction.device === 'gamepad') {\n\t\t\t\t// DPad\n\t\t\t\tthis.players[thisGamepad.index].direction.UP = thisGamepad.up ? 1 : 0;\n\t\t\t\tthis.players[thisGamepad.index].direction.DOWN = thisGamepad.down ? 1 : 0;\n\t\t\t}\n\n\t\t\tif (thisGamepad.leftStick.x < -this.axisThreshold) {\n\t\t\t\tthis.players[thisGamepad.index].direction.LEFT = Math.abs(thisGamepad.leftStick.x)\n\t\t\t\tthis.players[thisGamepad.index].direction.TIMESTAMP = this.scene.sys.time.now;\n\n\t\t\t\tif (thisGamepad.fakedpad) {\n\t\t\t\t\tthis.gamepadFakeDPadPress(thisGamepad, 'LEFT');\n\t\t\t\t\tdirection = 'LEFT'\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (thisGamepad.leftStick.x > this.axisThreshold) {\n\t\t\t\tthis.players[thisGamepad.index].direction.RIGHT = thisGamepad.leftStick.x\n\t\t\t\tthis.players[thisGamepad.index].direction.TIMESTAMP = this.scene.sys.time.now;\n\n\t\t\t\tif (thisGamepad.fakedpad) {\n\t\t\t\t\tthis.gamepadFakeDPadPress(thisGamepad, 'RIGHT');\n\t\t\t\t\tdirection = 'RIGHT'\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (this.players[thisGamepad.index].interaction.device === 'gamepad') {\n\t\t\t\t// DPad\n\t\t\t\tthis.players[thisGamepad.index].direction.LEFT = thisGamepad.left ? 1 : 0;\n\t\t\t\tthis.players[thisGamepad.index].direction.RIGHT = thisGamepad.right ? 1 : 0;\n\t\t\t}\n\n\t\t\tif (thisGamepad.fakedpad && direction == '') {\n\t\t\t\tthis.gamepadFakeDPadRelease(thisGamepad);\n\t\t\t}\n\n\t\t\t// Secondary\n\t\t\tif (thisGamepad.rightStick.y < -this.axisThreshold) {\n\t\t\t\tthis.players[thisGamepad.index].direction_secondary.UP = Math.abs(thisGamepad.rightStick.y)\n\t\t\t\tthis.players[thisGamepad.index].direction_secondary.TIMESTAMP = this.scene.sys.time.now;\n\t\t\t}\n\t\t\telse if (thisGamepad.rightStick.y > this.axisThreshold) {\n\t\t\t\tthis.players[thisGamepad.index].direction_secondary.DOWN = thisGamepad.rightStick.y\n\t\t\t\tthis.players[thisGamepad.index].direction_secondary.TIMESTAMP = this.scene.sys.time.now;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthis.players[thisGamepad.index].direction_secondary.UP = 0;\n\t\t\t\tthis.players[thisGamepad.index].direction_secondary.DOWN = 0;\n\t\t\t}\n\n\t\t\tif (thisGamepad.rightStick.x < -this.axisThreshold) {\n\t\t\t\tthis.players[thisGamepad.index].direction_secondary.LEFT = Math.abs(thisGamepad.rightStick.x)\n\t\t\t\tthis.players[thisGamepad.index].direction_secondary.TIMESTAMP = this.scene.sys.time.now;\n\t\t\t}\n\t\t\telse if (thisGamepad.rightStick.x > this.axisThreshold) {\n\t\t\t\tthis.players[thisGamepad.index].direction_secondary.RIGHT = thisGamepad.rightStick.x\n\t\t\t\tthis.players[thisGamepad.index].direction_secondary.TIMESTAMP = this.scene.sys.time.now;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthis.players[thisGamepad.index].direction_secondary.LEFT = 0;\n\t\t\t\tthis.players[thisGamepad.index].direction_secondary.RIGHT = 0;\n\t\t\t}\n\n\t\t\tif (this.players[thisGamepad.index].interaction.device === 'gamepad') {\n\t\t\t\t// Buttons\n\t\t\t\tfor (var b = 0; b < thisGamepad.buttons.length; b++) {\n\t\t\t\t\tlet button = thisGamepad.buttons[b];\n\t\t\t\t\tthis.players[thisGamepad.index].buttons['B' + b] = button.value;\n\t\t\t\t\t// Get mapped name for this button number and artificially update the relevant buttons_mapped key\n\t\t\t\t\tlet mappedButton = this.getMappedButton(this.players[thisGamepad.index], b);\n\t\t\t\t\tif (typeof mappedButton !== \"undefined\") {\n\t\t\t\t\t\tthis.players[thisGamepad.index].buttons_mapped[mappedButton] = button.value;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// If we're faking the d-pad, we won't have the extra buttons so we'll have to manually update the button objects\n\t\t\t\tif (thisGamepad.fakedpad) {\n\t\t\t\t\tif (direction == '') {\n\t\t\t\t\t\tthis.players[thisGamepad.index].buttons['B12'] = 0;\n\t\t\t\t\t\tthis.players[thisGamepad.index].buttons['B13'] = 0;\n\t\t\t\t\t\tthis.players[thisGamepad.index].buttons['B14'] = 0;\n\t\t\t\t\t\tthis.players[thisGamepad.index].buttons['B15'] = 0;\n\t\t\t\t\t\tthis.players[thisGamepad.index].buttons_mapped[this.getMappedButton(this.players[thisGamepad.index], 'B12')] = 0;\n\t\t\t\t\t\tthis.players[thisGamepad.index].buttons_mapped[this.getMappedButton(this.players[thisGamepad.index], 'B13')] = 0;\n\t\t\t\t\t\tthis.players[thisGamepad.index].buttons_mapped[this.getMappedButton(this.players[thisGamepad.index], 'B14')] = 0;\n\t\t\t\t\t\tthis.players[thisGamepad.index].buttons_mapped[this.getMappedButton(this.players[thisGamepad.index], 'B15')] = 0;\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tthis.players[thisGamepad.index].buttons['B' + this.dpadMappings[direction]] = 1;\n\t\t\t\t\t\tlet mappedButton = this.getMappedButton(this.players[thisGamepad.index], 'B' + this.dpadMappings[direction]);\n\t\t\t\t\t\tthis.players[thisGamepad.index].buttons_mapped[mappedButton] = 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\n\t/**\n\t * Function to run on pointer move.\n\t * @param {*} pointer - The pointer object\n\t */\n\tpointerMove(pointer, threshold) {\n\t\tif (this.players.length) {\n\t\t\tthreshold = threshold || 0;\n\t\t\tif (pointer.distance > threshold) {\n\t\t\t\tlet pointerDirection = this.getBearingFromAngle(pointer.angle, 8);\n\n\t\t\t\t// If we've been given a player position, return bearings and angles\n\t\t\t\tif (typeof this.players[0] !== 'undefined' && this.players[0].position.x !== 'undefined') {\n\t\t\t\t\tlet position = this.players[0].position;\n\t\t\t\t\tlet angleToPointer = Phaser.Math.Angle.Between(position.x, position.y, pointer.worldX, pointer.worldY);\n\t\t\t\t\tpointerDirection = this.getBearingFromAngle(angleToPointer, 8);\n\t\t\t\t\tlet pointerAngle = Number(this.mapBearingToDegrees(pointerDirection));\n\n\t\t\t\t\tthis.players[0].pointer.BEARING = pointerDirection;\n\t\t\t\t\tthis.players[0].pointer.ANGLE = angleToPointer;\n\t\t\t\t\tthis.players[0].pointer.BEARING_DEGREES = pointerAngle;\n\t\t\t\t\tthis.players[0].pointer.TIMESTAMP = this.scene.sys.time.now;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\n\t/**\n\t * Function to run on pointer down. Indicates that Mx has been pressed, which should be listened to by the player object\n\t * @param {*} pointer - The pointer object\n\t */\n\tpointerDown(pointer) {\n\t\tif (this.players.length) {\n\t\t\tlet action = '';\n\t\t\tthis.players[0].setDevice('pointer');\n\t\t\tif (pointer.leftButtonDown()) {\n\t\t\t\taction = 'M1';\n\t\t\t}\n\t\t\tif (pointer.rightButtonDown()) {\n\t\t\t\taction = 'M2';\n\t\t\t}\n\t\t\tif (pointer.middleButtonDown()) {\n\t\t\t\taction = 'M3';\n\t\t\t}\n\t\t\tif (pointer.backButtonDown()) {\n\t\t\t\taction = 'M4';\n\t\t\t}\n\t\t\tif (pointer.forwardButtonDown()) {\n\t\t\t\taction = 'M5';\n\t\t\t}\n\n\t\t\tthis.eventEmitter.emit('mergedInput', { device: 'pointer', value: 1, player: 0, action: action, state: 'DOWN' });\n\t\t\tthis.events.emit('pointer_down', action);\n\n\t\t\tthis.players[0].pointer[action] = 1;\n\n\t\t\t// Update the last button state\n\t\t\tthis.players[0].interaction.pressed.push(action);\n\t\t\tthis.players[0].interaction.last = action;\n\t\t\tthis.players[0].interaction.lastPressed = action;\n\t\t\tthis.players[0].interaction.buffer.push(action);\n\t\t\tthis.players[0].pointer.TIMESTAMP = pointer.moveTime;\n\n\t\t\t// Update timers\n\t\t\tthis.players[0].timers[action].pressed = this.scene.sys.time.now;\n\t\t\tthis.players[0].timers[action].released = 0;\n\t\t\tthis.players[0].timers[action].duration = 0;\n\t\t}\n\t}\n\n\n\t/**\n\t * Function to run on pointer up. Indicates that Mx has been released, which should be listened to by the player object\n\t * @param {*} pointer - The pointer object\n\t */\n\tpointerUp(pointer) {\n\t\tif (this.players.length) {\n\t\t\tlet action = '';\n\t\t\tif (pointer.leftButtonReleased()) {\n\t\t\t\taction = 'M1';\n\t\t\t}\n\t\t\tif (pointer.rightButtonReleased()) {\n\t\t\t\taction = 'M2';\n\t\t\t}\n\t\t\tif (pointer.middleButtonReleased()) {\n\t\t\t\taction = 'M3';\n\t\t\t}\n\t\t\tif (pointer.backButtonReleased()) {\n\t\t\t\taction = 'M4';\n\t\t\t}\n\t\t\tif (pointer.forwardButtonReleased()) {\n\t\t\t\taction = 'M5';\n\t\t\t}\n\n\t\t\tthis.eventEmitter.emit('mergedInput', { device: 'pointer', value: 1, player: 0, action: action, state: 'UP' });\n\t\t\tthis.events.emit('pointer_up', action);\n\n\t\t\tthis.players[0].pointer[action] = 0;\n\t\t\tthis.players[0].interaction.released.push(action);\n\t\t\tthis.players[0].interaction.lastReleased = action;\n\t\t\tthis.players[0].pointer.TIMESTAMP = this.scene.sys.time.now;\n\n\t\t\t// Update timers\n\t\t\tthis.players[0].timers[action].released = this.scene.sys.time.now;\n\t\t\tthis.players[0].timers[action].duration = this.players[0].timers[action].released - this.players[0].timers[action].pressed;\n\t\t\tdelete this.players[0].timers[action]._tick;\n\t\t}\n\t}\n\n\n\t/**\n     * Create new button combo.\n\t * Combos extend Phaser's keyboard combo and mimic their functionality for gamepad/player combinations.\n\t * If you requrie a keyboard entered combo, use the native Phaser.Input.Keyboard.KeyboardPlugin.createCombo function.\n\t *\n\t * @param {player} player - A player object. If more than one player should be able to execute the combo, you should create multiple buttonCombo instances.\n     * @param {(object[])} buttons - An array of buttons that comprise this combo. Use button IDs, mapped buttons or directions, e.g. ['UP', 'UP', 'DOWN', 'DOWN', 'LEFT', 'RIGHT', 'LEFT', 'RIGHT', 'RC_E', 'RC_S']\n     * @param {Phaser.Types.Input.Keyboard.KeyComboConfig} [config] - A Key Combo configuration object.\n     */\n    createButtonCombo(player, buttons, config) {\n        return new ButtonCombo(this, player, buttons, config);\n    }\n\n\n\t/**\n\t * Get the bearing from a given angle\n\t * @param {float} angle - Angle to use\n\t * @param {number} numDirections - Number of possible directions (e.g. 4 for N/S/E/W)\n\t */\n\tgetBearingFromAngle(angle, numDirections) {\n\t\tnumDirections = numDirections || 8;\n\n\t\tvar snap_interval = Phaser.Math.PI2 / numDirections;\n\n\t\tvar angleSnap = Phaser.Math.Snap.To(angle, snap_interval);\n\t\tvar angleSnapDeg = Phaser.Math.RadToDeg(angleSnap);\n\t\tvar angleSnapDir = this.bearings[angleSnapDeg];\n\n\t\treturn angleSnapDir;\n\t}\n\n\n\t/**\n\t * Given a bearing, return a direction object containing boolean flags for the four directions\n\t * @param {*} bearing\n\t */\n\tmapBearingToDirections(bearing) {\n\t\tlet thisDirection = {\n\t\t\t'UP': 0,\n\t\t\t'DOWN': 0,\n\t\t\t'LEFT': 0,\n\t\t\t'RIGHT': 0,\n\t\t\t'BEARING': bearing.toUpperCase()\n\t\t}\n\n\t\tif (bearing.toUpperCase().includes('W')) {\n\t\t\tthisDirection.LEFT = 1;\n\t\t}\n\t\tif (bearing.toUpperCase().includes('E')) {\n\t\t\tthisDirection.RIGHT = 1;\n\t\t}\n\t\tif (bearing.toUpperCase().includes('S')) {\n\t\t\tthisDirection.DOWN = 1;\n\t\t}\n\t\tif (bearing.toUpperCase().includes('N')) {\n\t\t\tthisDirection.UP = 1;\n\t\t}\n\n\t\treturn thisDirection;\n\t}\n\n\n\t/**\n\t * Given a directions object, return the applicable bearing (8 way only)\n\t * @param {*} directions\n\t */\n\tmapDirectionsToBearing(directions, threshold) {\n\t\tvar threshold = threshold || -.5\n\t\tif (directions.UP && !(directions.LEFT || directions.RIGHT)) {\n\t\t\treturn 'N';\n\t\t}\n\t\tif (directions.RIGHT && directions.UP) {\n\t\t\treturn 'NE';\n\t\t}\n\t\tif (directions.RIGHT && !(directions.UP || directions.DOWN)) {\n\t\t\treturn 'E';\n\t\t}\n\t\tif (directions.RIGHT && directions.DOWN) {\n\t\t\treturn 'SE';\n\t\t}\n\t\tif (directions.DOWN && !(directions.LEFT || directions.RIGHT)) {\n\t\t\treturn 'S';\n\t\t}\n\t\tif (directions.LEFT && directions.DOWN) {\n\t\t\treturn 'SW';\n\t\t}\n\t\tif (directions.LEFT && !(directions.UP || directions.DOWN)) {\n\t\t\treturn 'W';\n\t\t}\n\t\tif (directions.LEFT && directions.UP) {\n\t\t\treturn 'NW';\n\t\t}\n\t\treturn '';\n\t}\n\n\t/**\n\t * Given a bearing, return the snapped angle in degrees\n\t * @param {*} bearing\n\t */\n\tmapBearingToDegrees(bearing) {\n\t\tif (bearing != '') {\n\t\t\treturn Object.keys(this.bearings).find(key => this.bearings[key] === bearing);\n\t\t}\n\t\telse {\n\t\t\treturn '';\n\t\t}\n\t}\n\n\tdestroy() {\n\t\tthis.shutdown();\n\t\tthis.scene = undefined;\n\t}\n\n\t/**\n\t * Return debug object\n\t */\n\tdebug() {\n\t\t// Debug variables\n\t\tvar debug = {\n\t\t\t'input': {}\n\t\t};\n\t\tdebug.input.gamepads = [];\n\n\t\tfor (var i = 0; i < this.gamepads.length; i++) {\n\t\t\tlet pad = this.gamepads[i];\n\t\t\tlet buttons = {};\n\t\t\tlet axes = {};\n\n\t\t\tfor (var b = 0; b < pad.buttons.length; b++) {\n\t\t\t\tlet button = pad.buttons[b];\n\t\t\t\tbuttons['B' + button.index] = button.value;\n\t\t\t}\n\n\t\t\tfor (var a = 0; a < pad.axes.length; a++) {\n\t\t\t\tlet axis = pad.axes[a];\n\t\t\t\taxes['A' + axis.index] = axis.getValue();\n\t\t\t}\n\n\t\t\tdebug.input.gamepads.push({\n\t\t\t\t'ID': pad.id,\n\t\t\t\t'Index': pad.index,\n\t\t\t\t'Buttons': buttons,\n\t\t\t\t'Axes': axes\n\t\t\t});\n\t\t}\n\n\t\tdebug.players = [];\n\t\tfor (let thisPlayer of this.players) {\n\t\t\tdebug.players.push({\n\t\t\t\t'interaction': thisPlayer.interaction,\n\t\t\t\t'interaction_mapped': thisPlayer.interaction_mapped,\n//\t\t\t\t'device': thisPlayer.interaction.device,\n\t\t\t\t'buttons': thisPlayer.buttons,\n\t\t\t\t'buttons_mapped': thisPlayer.buttons_mapped,\n\t\t\t\t'timers': thisPlayer.timers,\n\t\t\t\t'pointer': thisPlayer.pointer,\n\t\t\t\t'direction': thisPlayer.direction,\n\t\t\t\t'direction_secondary': thisPlayer.direction_secondary,\n\t\t\t\t'keys': thisPlayer.keys\n\t\t\t})\n\t\t}\n\n\t\treturn debug;\n\t}\n}\n","const bearings = {\r\n    '-180': 'W',\r\n    '-168.75': 'WBN',\r\n    '-157.5': 'WNW',\r\n    '-146.25': 'NWBW',\r\n    '-135': 'NW',\r\n    '-123.75': 'NWBN',\r\n    '-112.5': 'NNW',\r\n    '-101.25': 'NBW',\r\n    '-90': 'N',\r\n    '-78.75': 'NBE',\r\n    '-67.5': 'NNE',\r\n    '-56.25': 'NEBN',\r\n    '-45': 'NE',\r\n    '-33.75': 'NEBE',\r\n    '-22.5': 'ENE',\r\n    '-11.25': 'EBN',\r\n    '0': 'E',\r\n    '11.25': 'EBS',\r\n    '22.5': 'ESE',\r\n    '33.75': 'SEBE',\r\n    '45': 'SE',\r\n    '56.25': 'SEBS',\r\n    '67.5': 'SSE',\r\n    '78.75': 'SBE',\r\n    '90': 'S',\r\n    '101.25': 'SBW',\r\n    '112.5': 'SSW',\r\n    '123.75': 'SWBS',\r\n    '135': 'SW',\r\n    '146.25': 'SWBW',\r\n    '157.5': 'WSW',\r\n    '168.75': 'WBS',\r\n    '180': 'W'\r\n};\r\n\r\nmodule.exports = bearings;","import pad_generic from './configs/pad_generic'\r\nimport pad_unlicensedSNES from './configs/pad_unlicensedSNES'\r\nimport pad_xbox360 from './configs/pad_xbox360'\r\nimport pad_dualshock from './configs/pad_dualshock'\r\n\r\nexport default class controlManager {\r\n    constructor (){\r\n    }\r\n\r\n    mapGamepad(id) {\r\n        id = id.toLowerCase();\r\n        let padConfig = pad_generic;\r\n\r\n        if (id.includes('081f') && id.includes('e401')) {\r\n            padConfig = pad_unlicensedSNES;\r\n        }\r\n        else if (id.includes('xbox') && id.includes('360')) {\r\n            padConfig = pad_xbox360;\r\n        }\r\n        else if (id.includes('054c')) {\r\n            padConfig = pad_dualshock;\r\n        }\r\n        else {\r\n            \r\n        }\r\n\r\n        return padConfig;\r\n    }\r\n\r\n    getBaseControls() {\r\n        return {\r\n            'direction': {\r\n                'UP': 0,\r\n                'DOWN': 0,\r\n                'LEFT': 0,\r\n                'RIGHT': 0,\r\n                'BEARING': '',\r\n                'BEARING_LAST': '',\r\n                'DEGREES': 0,\r\n                'DEGREES_LAST': 0,\r\n                'TIMESTAMP': 0\r\n            },\r\n            'direction_secondary': {\r\n                'UP': 0,\r\n                'DOWN': 0,\r\n                'LEFT': 0,\r\n                'RIGHT': 0,\r\n                'BEARING': '',\r\n                'DEGREES': 0,\r\n                'BEARING_LAST': '',\r\n                'DEGREES_LAST': 0,\r\n                'TIMESTAMP': 0\r\n            },\r\n            'buttons': {},\r\n            'timers' : {},\r\n            'gamepadMapping': {\r\n                RC_S: 0,\r\n                RC_E: 1,\r\n                RC_W: 2,\r\n                RC_N: 3,\r\n                START: 9,\r\n                SELECT: 8,\r\n                LB: 4,\r\n                RB: 5,\r\n                LT: 6,\r\n                RT: 7,\r\n                LS: 10,\r\n                RS: 11,\r\n                LC_N: 12,\r\n                LC_S: 13,\r\n                LC_W: 14,\r\n                LC_E: 15,\r\n                MENU: 16\r\n            },\r\n            'pointer': {\r\n                'M1': 0,\r\n                'M2': 0,\r\n                'M3': 0,\r\n                'M4': 0,\r\n                'M5': 0,\r\n                'BEARING': '',\r\n                'BEARING_DEGREES': 0,\r\n                'ANGLE': 0,\r\n                'TIMESTAMP': 0\r\n            },\r\n            'position': {x:0,y:0},\r\n            'gamepad': {},\r\n            'keys': {\r\n                'UP': [],\r\n                'DOWN': [],\r\n                'LEFT': [],\r\n                'RIGHT': [],\r\n            },\r\n            'internal': {\r\n                'fakedpadBuffer': [],\r\n                'fakedpadPressed': [],\r\n                'fakedpadReleased': [],\r\n            },\r\n            'interaction': {\r\n                'buffer': [],\r\n                'pressed': [],\r\n                'released': [],\r\n                'last': '',\r\n                'lastPressed': '',\r\n                'lastReleased': '',\r\n                'device': '',\r\n            },\r\n            'interaction_mapped': {\r\n                'pressed': [],\r\n                'released': [],\r\n                'last': '',\r\n                'lastPressed': '',\r\n                'lastReleased': '',\r\n                'gamepadType': '',\r\n            },\r\n            'buttons_mapped': {\r\n                RC_S: 0,\r\n                RC_E: 0,\r\n                RC_W: 0,\r\n                RC_N: 0,\r\n                START: 0,\r\n                SELECT: 0,\r\n                MENU: 0,\r\n                LB: 0,\r\n                RB: 0,\r\n                LT: 0,\r\n                RT: 0,\r\n                LS: 0,\r\n                RS: 0,\r\n                LC_N: 0,\r\n                LC_S: 0,\r\n                LC_W: 0,\r\n                LC_E: 0,\r\n            }\r\n        }\r\n    }\r\n\r\n\r\n\r\n    /**\r\n     * Returns a struct to hold input control information\r\n     * Set up a struct for each player in the game\r\n     * Direction and Buttons contain the input from the devices\r\n     * The keys struct contains arrays of keyboard characters that will trigger the action\r\n     */\r\n    setupControls(numberOfButtons) {\r\n        numberOfButtons = numberOfButtons || 16;\r\n\r\n        let controls = this.getBaseControls();\r\n\r\n        // Add buttons\r\n        for (let i = 0; i <= numberOfButtons; i++) {\r\n            controls.buttons['B' + i] = 0;\r\n            controls.keys['B' + i] = [];\r\n        }\r\n\r\n        // Add timers \r\n        for (let i = 0; i <= numberOfButtons; i++) {\r\n            controls.timers['B' + i] = {\r\n                'pressed': 0,\r\n                'released': 0,\r\n                'duration': 0\r\n            };\r\n        }\r\n        for (let thisDirection of ['UP', 'DOWN', 'LEFT', 'RIGHT', 'ALT_UP', 'ALT_DOWN', 'ALT_LEFT', 'ALT_RIGHT']) {\r\n            controls.timers[thisDirection] = {\r\n                'pressed': 0,\r\n                'released': 0,\r\n                'duration': 0\r\n            };\r\n        }\r\n\r\n        for (let thisPointer of ['M1', 'M2', 'M3', 'M4', 'M5']) {\r\n            controls.timers[thisPointer] = {\r\n                'pressed': 0,\r\n                'released': 0,\r\n                'duration': 0\r\n            };\r\n        }\r\n\r\n\r\n        controls.setPosition = function(x,y) {\r\n            this.position.x = x;\r\n            this.position.y = y;\r\n        }\r\n        \r\n\r\n        return controls;\r\n    }\r\n\r\n\r\n}\r\n","/**\r\n * Generic pad mapping\r\n */\r\nmodule.exports = {\r\n    padID: 'Generic',\r\n    padType: 'generic',\r\n    gamepadMapping: {\r\n        RC_S: 0,\r\n        RC_E: 1,\r\n        RC_W: 2,\r\n        RC_N: 3,\r\n        START: 9,\r\n        SELECT: 8,\r\n        LB: 4,\r\n        RB: 5,\r\n        LT: 6,\r\n        RT: 7,\r\n        LS: 10,\r\n        RS: 11,\r\n        LC_N: 12,\r\n        LC_S: 13,\r\n        LC_W: 14,\r\n        LC_E: 15\r\n    },\r\n}","/**\r\n * 081f-e401 - UnlicensedSNES\r\n */\r\nmodule.exports = {\r\n    padID: '081f-e401',\r\n    padType: 'snes',\r\n    gamepadMapping : {\r\n        RC_S: 2,\r\n        RC_E: 1,\r\n        RC_W: 3,\r\n        RC_N: 0,\r\n        START: 9,\r\n        SELECT: 8,\r\n        LB: 4,\r\n        RB: 5,\r\n        LC_N: 12,\r\n        LC_S: 13,\r\n        LC_W: 14,\r\n        LC_E: 15\r\n    }\r\n}","/**\r\n * Generic pad mapping\r\n */\r\nmodule.exports = {\r\n    padID: 'Xbox 360 controller (XInput STANDARD GAMEPAD)',\r\n    padType: 'xbox',\r\n    gamepadMapping: {\r\n        RC_S: 0,\r\n        RC_E: 1,\r\n        RC_W: 2,\r\n        RC_N: 3,\r\n        START: 9,\r\n        SELECT: 8,\r\n        LB: 4,\r\n        RB: 5,\r\n        LT: 6,\r\n        RT: 7,\r\n        LS: 10,\r\n        RS: 11,\r\n        LC_N: 12,\r\n        LC_S: 13,\r\n        LC_W: 14,\r\n        LC_E: 15,\r\n        MENU: 16\r\n    },\r\n}","/**\r\n * Dualshock mapping\r\n */\r\nmodule.exports = {\r\n    padID: 'Dualshock',\r\n    padType: 'Sony',\r\n    gamepadMapping: {\r\n        RC_S: 0,\r\n        RC_E: 1,\r\n        RC_W: 2,\r\n        RC_N: 3,\r\n        START: 9, // Options\r\n        SELECT: 8, // Share\r\n        LB: 4,\r\n        RB: 5,\r\n        LT: 6,\r\n        RT: 7,\r\n        LS: 10,\r\n        RS: 11,\r\n        LC_N: 12,\r\n        LC_S: 13,\r\n        LC_W: 14,\r\n        LC_E: 15,\r\n        MENU: 16,\r\n        TOUCH: 17\r\n    },\r\n}","import AdvanceKeyCombo from 'phaser/src/input/keyboard/combo/AdvanceKeyCombo.js';\r\nimport ResetKeyCombo from 'phaser/src/input/keyboard/combo/ResetKeyCombo.js';\r\n\r\nexport default class ButtonCombo extends Phaser.Input.Keyboard.KeyCombo {\r\n    constructor(mergedInput, player, buttons, config) {\r\n        super(mergedInput.systems.input.keyboard, buttons, config);\r\n\r\n        this.player = player;\r\n        this.mergedInput = mergedInput;\r\n        this.keyCodes = buttons; // KeyCombo expects this to be an array of keycodes, we'll be checking against button names\r\n\r\n        mergedInput.events.on('gamepad_buttondown', this.onButtonDown, this);\r\n        this.current = this.keyCodes[0];\r\n    }\r\n\r\n    onButtonDown(event) {\r\n        if (this.matched || !this.enabled) {\r\n            return;\r\n        }\r\n\r\n        var matched = this.ProcessButtonCombo(event, this);\r\n        if (matched) {\r\n            this.mergedInput.eventEmitter.emit('mergedInput', { combo: this, player: this.player, action: 'Button combo matched' });\r\n            this.mergedInput.events.emit('buttoncombomatch', { player: this.player, combo: this });\r\n\r\n            if (this.resetOnMatch) {\r\n                ResetKeyCombo(this);\r\n            }\r\n            else if (this.deleteOnMatch) {\r\n                this.destroy();\r\n            }\r\n        }\r\n    }\r\n\r\n    ProcessButtonCombo (event, combo) {\r\n        // Set a timestamp from the gamepad\r\n        event.timeStamp = this.mergedInput.systems.time.now\r\n\r\n        // Don't check buttons on a different pad\r\n        if (combo.player.index !== event.player) { \r\n            return false;\r\n        }\r\n\r\n        // Check matched\r\n        if (combo.matched) {\r\n            return true;\r\n        }\r\n        \r\n        // Compare the current action with the button pressed\r\n        let buttonMatch = false;\r\n        if (event.button === combo.current) {\r\n            buttonMatch = true;\r\n        }\r\n\r\n        let mappedButton = this.mergedInput.getMappedButton(combo.player, event.button);\r\n        if (mappedButton === combo.current) {\r\n            buttonMatch = true;\r\n        }\r\n         \r\n        let unMappedButton = this.mergedInput.getUnmappedButton(combo.player, mappedButton);\r\n        if (unMappedButton === combo.current) {\r\n            buttonMatch = true;\r\n        }\r\n\r\n        var comboMatched = false;\r\n        var keyMatched = false;\r\n\r\n        if (buttonMatch) {\r\n            //  Button was correct\r\n\r\n            if (combo.index > 0 && combo.maxKeyDelay > 0) {\r\n                //  We have to check to see if the delay between\r\n                //  the new key and the old one was too long (if enabled)\r\n\r\n                var timeLimit = combo.timeLastMatched + combo.maxKeyDelay;\r\n\r\n                //  Check if they pressed it in time or not\r\n                if (event.timeStamp <= timeLimit) {\r\n                    keyMatched = true;\r\n                    comboMatched = AdvanceKeyCombo(event, combo);\r\n                }\r\n            }\r\n            else {\r\n                keyMatched = true;\r\n\r\n                //  We don't check the time for the first key pressed, so just advance it\r\n                comboMatched = AdvanceKeyCombo(event, combo);\r\n            }\r\n        }\r\n\r\n        if (!keyMatched && combo.resetOnWrongKey) {\r\n            //  Wrong key was pressed\r\n            combo.index = 0;\r\n            combo.current = combo.keyCodes[0];\r\n        }\r\n\r\n        if (comboMatched) {\r\n            combo.timeLastMatched = event.timeStamp;\r\n            combo.matched = true;\r\n            combo.timeMatched = event.timeStamp;\r\n        }\r\n\r\n        return comboMatched;\r\n    };\r\n\r\n\r\n    destroy() {\r\n        this.mergedInput.events.off('gamepad_buttondown', this.onButtonDown);\r\n        super.destroy();\r\n    }\r\n}","/**\n * @author       Richard Davey <rich@photonstorm.com>\n * @copyright    2013-2023 Photon Storm Ltd.\n * @license      {@link https://opensource.org/licenses/MIT|MIT License}\n */\n\n/**\n * Used internally by the KeyCombo class.\n * Return `true` if it reached the end of the combo, `false` if not.\n *\n * @function Phaser.Input.Keyboard.AdvanceKeyCombo\n * @private\n * @since 3.0.0\n *\n * @param {KeyboardEvent} event - The native Keyboard Event.\n * @param {Phaser.Input.Keyboard.KeyCombo} combo - The KeyCombo object to advance.\n *\n * @return {boolean} `true` if it reached the end of the combo, `false` if not.\n */\nvar AdvanceKeyCombo = function (event, combo)\n{\n    combo.timeLastMatched = event.timeStamp;\n    combo.index++;\n\n    if (combo.index === combo.size)\n    {\n        return true;\n    }\n    else\n    {\n        combo.current = combo.keyCodes[combo.index];\n        return false;\n    }\n};\n\nmodule.exports = AdvanceKeyCombo;\n","/**\n * @author       Richard Davey <rich@photonstorm.com>\n * @copyright    2013-2023 Photon Storm Ltd.\n * @license      {@link https://opensource.org/licenses/MIT|MIT License}\n */\n\n/**\n * Used internally by the KeyCombo class.\n *\n * @function Phaser.Input.Keyboard.ResetKeyCombo\n * @private\n * @since 3.0.0\n *\n * @param {Phaser.Input.Keyboard.KeyCombo} combo - The KeyCombo to reset.\n *\n * @return {Phaser.Input.Keyboard.KeyCombo} The KeyCombo.\n */\nvar ResetKeyCombo = function (combo)\n{\n    combo.current = combo.keyCodes[0];\n    combo.index = 0;\n    combo.timeLastMatched = 0;\n    combo.matched = false;\n    combo.timeMatched = 0;\n\n    return combo;\n};\n\nmodule.exports = ResetKeyCombo;\n"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n"],"sourceRoot":""}