Create a deep clone of a set of gamepads. Also works on array-like objects, such as the "array" returned from
navigator.getGamepads()
.
Returns true
if the browser seems to provide the gamepad APIs mmk.gamepad relies on for actual input.
This isn't 100% accurate, Chromium on Linux has been known to define the APIs but not implement them.
mmk.gamepad
methods should generally still "work" (e.g. noop) even if the underlying browser APIs are missing,
this method mostly exists to hint that you might not want to bother showing gamepad specific hints, or might want
to suggest a gamepad-enabled browser, depending on your game.
Attempt to decompose a Gamepad.id. The exact layout of the Gamepad.id is hideously browser specific,
non-portable, brittle, and generally badwrong to rely upon... but it's also my least bad option for identifying
specific gamepads and applying gamepad/browser/OS specific workarounds and fixes for the raw
navigator.getGamepad()
results. Some examples:
parseGamepadId(undefined) => { name: "unknown", vendor: "", product: "", hint: "unknown" }
parseGamepadId("" ) => { name: "unknown", vendor: "", product: "", hint: "unknown" }
parseGamepadId("asdf" ) => { name: "asdf", vendor: "", product: "", hint: "unknown" }
parseGamepadId("xinput" ) => { name: "xinput", vendor: "", product: "", hint: "gecko" }
parseGamepadId("054c-0ba0-DUALSHOCK®4 USB Wireless Adaptor") => {
name: "DUALSHOCK®4 USB Wireless Adaptor",
vendor: "054c",
product: "0ba0",
hint: "gecko"
}
parseGamepadId("DUALSHOCK®4 USB Wireless Adaptor (Vendor: 054c Product: 0ba0)") => {
name: "DUALSHOCK®4 USB Wireless Adaptor",
vendor: "054c",
product: "0ba0",
hint: "blink"
}
If you encounter new and exciting Gamepad.id schemas, please send them my way!
See also:
The Gamepad.id to try and parse.
Poll gamepad state, and dispatch events based on that state. Note that mmk.gamepad will automatically dispatch by default based on one of:
requestAnimationFrame(...)
setInterval(..., 10)
And that calling this method will disable that automatic dispatch mechanism.
Allows some customization of if e.g. deadzones are applied to generated events or not.
Given a Gamepad where gamepad.mapping !== "standard"
, or a gamepad where gamepad.mapping === "standard"
but the browser is suspected of incorrectly implementing the standard mapping, rearrange the axes and buttons of
the Gamepad to properly match the "standard"
mapping. As for what the "standard"
mapping is, see
See also: (W3C Gamepad Editor's Draft)[https://w3c.github.io/gamepad/#remapping] for information about the standard gamepad mapping.
Generated using TypeDoc
Create a deep clone of a gamepad.