Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 25 additions & 10 deletions extensions/reviewed/Gamepads.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"name": "Gamepads",
"previewIconUrl": "https://resources.gdevelop-app.com/assets/Icons/gamepad-variant-outline.svg",
"shortDescription": "Add support for gamepads (or other controllers) to your game, giving access to information such as button presses, axis positions, trigger pressure, etc...",
"version": "0.9.0",
"version": "0.9.1",
"description": [
"Add support for gamepads (or other physical controllers).",
"",
Expand Down Expand Up @@ -290,7 +290,27 @@
" }\r",
"}();\r",
"\r",
"function onScenePostEvents() {\r",
"/**\r",
" * @param {gdjs.RuntimeScene} runtimeScene\r",
" */\r",
"function addFrameBeginningTaskIfNeeded(runtimeScene) {\r",
" const taskManager = runtimeScene.getAsyncTasksManager();\r",
" for (const taskWithCallback of taskManager.tasksWithCallback) {\r",
" if (taskWithCallback.asyncTask === frameBeginningTask) {\r",
" return;\r",
" }\r",
" }\r",
" // Async tasks are run before everything.\r",
" // This is a hack to make sure that button states are updated\r",
" // before mapping behavior events.\r",
" taskManager.addTask(frameBeginningTask);\r",
"}\r",
"\r",
"/**\r",
" * @param {gdjs.RuntimeScene} runtimeScene\r",
" */\r",
"function onScenePostEvents(runtimeScene) {\r",
" addFrameBeginningTaskIfNeeded(runtimeScene);\r",
" /** @type {Gamepad[]} */\r",
" const gamepads = navigator.getGamepads ? navigator.getGamepads() : [];\r",
" for (let playerId = 0; playerId < gamepads.length; playerId++) {\r",
Expand Down Expand Up @@ -471,6 +491,7 @@
" getGamepad,\r",
" onScenePostEvents,\r",
" frameBeginningTask,\r",
" addFrameBeginningTaskIfNeeded,\r",
"}"
],
"parameterObjects": "",
Expand All @@ -489,12 +510,7 @@
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
"inlineCode": [
"// Async tasks are run before everything.\r",
"// This is a hack to make sure that button states are updated\r",
"// before mapping behavior events.\r",
"runtimeScene.getAsyncTasksManager().addTask(gdjs._extensionController.frameBeginningTask);"
],
"inlineCode": "gdjs._extensionController.addFrameBeginningTaskIfNeeded(runtimeScene);",
"parameterObjects": "",
"useStrict": true,
"eventsSheetExpanded": false
Expand All @@ -512,7 +528,7 @@
{
"type": "BuiltinCommonInstructions::JsCode",
"inlineCode": [
"gdjs._extensionController.onScenePostEvents();",
"gdjs._extensionController.onScenePostEvents(runtimeScene);",
""
],
"parameterObjects": "",
Expand Down Expand Up @@ -1920,7 +1936,6 @@
{
"type": "BuiltinCommonInstructions::JsCode",
"inlineCode": [
"",
"const playerId = eventsFunctionContext.getArgument(\"PlayerId\") - 1;",
"/** @type {Gamepad[]} */",
"const gamepads = navigator.getGamepads ? navigator.getGamepads() : [];",
Expand Down
6 changes: 5 additions & 1 deletion scripts/lib/ExtensionsValidatorExceptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,11 @@ const extensionsAllowedProperties = {
javaScriptObjectAllowedProperties: [],
},
Gamepads: {
gdjsAllowedProperties: ['_extensionController', 'AsyncTask'],
gdjsAllowedProperties: [
'_extensionController',
'AsyncTask',
'RuntimeScene',
],
gdjsEvtToolsAllowedProperties: [],
runtimeSceneAllowedProperties: ['getElapsedTime', 'getAsyncTasksManager'],
javaScriptObjectAllowedProperties: [],
Expand Down