diff --git a/extensions/reviewed/Gamepads.json b/extensions/reviewed/Gamepads.json index 38c9980b3..5ca7edf8e 100644 --- a/extensions/reviewed/Gamepads.json +++ b/extensions/reviewed/Gamepads.json @@ -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.1", + "version": "0.9.2", "description": [ "Add support for gamepads (or other physical controllers).", "", @@ -42,7 +42,8 @@ "2OwwM8ToR9dx9RJ2sAKTcrLmCB92", "taRwmWxwAFYFL9yyBwB3cwBw0BO2", "mnImQKdn8nQxwzkS5D6a1JB27V23", - "IWykYNRvhCZBN3vEgKEbBPOR3Oc2" + "IWykYNRvhCZBN3vEgKEbBPOR3Oc2", + "lBAwyTIWHKZQxqb4cop4RoKae9G2" ], "dependencies": [], "globalVariables": [], @@ -2223,6 +2224,124 @@ } ], "objectGroups": [] + }, + { + "description": "Check if a gamepad button is pressed using its numerical ID.", + "fullName": "Button pressed (by ID)", + "functionType": "Condition", + "group": "ID cheker", + "name": "IsButtonPressedByID", + "sentence": "Button ID _PARAM2_ of gamepad _PARAM1_ is pressed", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const playerId = eventsFunctionContext.getArgument(\"PlayerId\") - 1;", + "const buttonId = eventsFunctionContext.getArgument(\"ButtonID\");", + "", + "// Перевірка на валідність ID (має бути 0 або більше)", + "if (buttonId < 0) {", + " return false;", + "}", + "", + "const player = gdjs._extensionController.getPlayer(playerId);", + "// Викликаємо існуючий метод, передаючи число напряму", + "eventsFunctionContext.returnValue = player.isButtonPressed(buttonId);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Gamepad identifier: 1, 2, 3, or 4", + "name": "PlayerId", + "type": "expression" + }, + { + "description": "The index of the button (e.g., 0, 1, 18...)", + "name": "ButtonID", + "type": "expression" + } + ], + "objectGroups": [] + }, + { + "description": "Check if a gamepad button was just pressed in this frame using its numerical ID.", + "fullName": "Button released (by ID)", + "functionType": "Condition", + "group": "ID cheker", + "name": "IsButtonReleasedByID", + "sentence": "Button ID _PARAM2_ of gamepad _PARAM1_ is pressed", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const playerId = eventsFunctionContext.getArgument(\"PlayerId\") - 1;", + "const buttonId = eventsFunctionContext.getArgument(\"ButtonID\");", + "", + "if (buttonId < 0) return false;", + "", + "const player = gdjs._extensionController.getPlayer(playerId);", + "eventsFunctionContext.returnValue = player.isButtonReleased(buttonId);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Gamepad identifier: 1, 2, 3, or 4", + "name": "PlayerId", + "type": "expression" + }, + { + "description": "The index of the button (e.g., 0, 1, 18...)", + "name": "ButtonID", + "type": "expression" + } + ], + "objectGroups": [] + }, + { + "description": "Check if a gamepad button was just released in this frame using its numerical ID.", + "fullName": "Button just pressed (by ID)", + "functionType": "Condition", + "group": "ID cheker", + "name": "IsButtonJustPressedByID", + "sentence": "Button ID _PARAM2_ of gamepad _PARAM1_ was just pressed", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const playerId = eventsFunctionContext.getArgument(\"PlayerId\") - 1;", + "const buttonId = eventsFunctionContext.getArgument(\"ButtonID\");", + "", + "if (buttonId < 0) return false;", + "", + "const player = gdjs._extensionController.getPlayer(playerId);", + "eventsFunctionContext.returnValue = player.isButtonJustPressed(buttonId);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Gamepad identifier: 1, 2, 3, or 4", + "name": "PlayerId", + "type": "expression" + }, + { + "description": "The index of the button (e.g., 0, 1, 18...)", + "name": "ButtonID", + "type": "expression" + } + ], + "objectGroups": [] } ], "eventsBasedBehaviors": [