Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update gamepad.js #1018

Closed
wants to merge 2 commits into from
Closed
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
56 changes: 54 additions & 2 deletions extensions/gamepad.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
(function (Scratch) {
"use strict";

const AXIS_DEADZONE = 0.1;
const BUTTON_DEADZONE = 0.05;
var AXIS_DEADZONE = 0.1;
var BUTTON_DEADZONE = 0.05;

/**
* @param {number|'any'} index 1-indexed index
Expand Down Expand Up @@ -249,6 +249,42 @@
},
},
},

"---",

{
opcode: "deadzone",
blockType: Scratch.BlockType.COMMAND,
text: "set axis deadzone to [i]",
arguments: {
i: {
type: Scratch.ArgumentType.NUMBER,
defaultValue: "0.1",
},
},
},

{
opcode: "deadzoneButton",
blockType: Scratch.BlockType.COMMAND,
text: "set button deadzone to [i]",
arguments: {
i: {
type: Scratch.ArgumentType.NUMBER,
defaultValue: "0.05",
},
},
},
{
opcode: "getdeadzone",
blockType: Scratch.BlockType.REPORTER,
text: "get axis deadzone",
},
{
opcode: "getdeadzoneButton",
blockType: Scratch.BlockType.REPORTER,
text: "get button deadzone",
},
],
menus: {
padMenu: {
Expand Down Expand Up @@ -483,6 +519,22 @@
});
}
}
}

deadzone({ i }) {
AXIS_DEADZONE = i;
}

deadzoneButton({ i }) {
BUTTON_DEADZONE = i;
}

getdeadzone({ i }) {
return AXIS_DEADZONE;
}

getdeadzoneButton({ i }) {
return BUTTON_DEADZONE;
}
}

Expand Down
Loading