if (typeof gdjs.evtsExt__Gamepads__C_Controller_X_is_connected !== "undefined") { gdjs.evtsExt__Gamepads__C_Controller_X_is_connected.registeredGdjsCallbacks.forEach(callback => gdjs._unregisterCallback(callback) ); } gdjs.evtsExt__Gamepads__C_Controller_X_is_connected = {}; gdjs.evtsExt__Gamepads__C_Controller_X_is_connected.userFunc0x11db7c8 = function GDJSInlineCode(runtimeScene, eventsFunctionContext) { "use strict"; /** @type {Gamepad[]} */ const gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []); //Get function parameter const playerId = eventsFunctionContext.getArgument("player_ID") - 1; if (playerId < 0 || playerId > 4) { console.error('Parameter gamepad identifier in condition: "Gamepad connected", is not valid number, must be between 0 and 4.'); return; } // If gamepad was disconnected it will be null (so this will return false) // If gamepad was never connected it will be undefined (so this will return false) eventsFunctionContext.returnValue = !!gamepads[playerId]; }; gdjs.evtsExt__Gamepads__C_Controller_X_is_connected.eventsList0 = function(runtimeScene, eventsFunctionContext) { { gdjs.evtsExt__Gamepads__C_Controller_X_is_connected.userFunc0x11db7c8(runtimeScene, typeof eventsFunctionContext !== 'undefined' ? eventsFunctionContext : undefined); } }; gdjs.evtsExt__Gamepads__C_Controller_X_is_connected.func = function(runtimeScene, player_ID, parentEventsFunctionContext) { var eventsFunctionContext = { _objectsMap: { }, _objectArraysMap: { }, _behaviorNamesMap: { }, getObjects: function(objectName) { return eventsFunctionContext._objectArraysMap[objectName] || []; }, getObjectsLists: function(objectName) { return eventsFunctionContext._objectsMap[objectName] || null; }, getBehaviorName: function(behaviorName) { return eventsFunctionContext._behaviorNamesMap[behaviorName] || behaviorName; }, createObject: function(objectName) { const objectsList = eventsFunctionContext._objectsMap[objectName]; if (objectsList) { const object = parentEventsFunctionContext ? parentEventsFunctionContext.createObject(objectsList.firstKey()) : runtimeScene.createObject(objectsList.firstKey()); if (object) { objectsList.get(objectsList.firstKey()).push(object); eventsFunctionContext._objectArraysMap[objectName].push(object); } return object; } return null; }, getInstancesCountOnScene: function(objectName) { const objectsList = eventsFunctionContext._objectsMap[objectName]; let count = 0; if (objectsList) { for(const objectName in objectsList.items) count += parentEventsFunctionContext ? parentEventsFunctionContext.getInstancesCountOnScene(objectName) : runtimeScene.getInstancesCountOnScene(objectName); } return count; }, getLayer: function(layerName) { return runtimeScene.getLayer(layerName); }, getArgument: function(argName) { if (argName === "player_ID") return player_ID; return ""; }, getOnceTriggers: function() { return runtimeScene.getOnceTriggers(); } }; gdjs.evtsExt__Gamepads__C_Controller_X_is_connected.eventsList0(runtimeScene, eventsFunctionContext); return !!eventsFunctionContext.returnValue; } gdjs.evtsExt__Gamepads__C_Controller_X_is_connected.registeredGdjsCallbacks = [];