Gamepad.id
特性为
Gamepad
interface returns a string containing some information about the controller.
The exact syntax is not strictly specified, but in Firefox it will contain three pieces of information separated by dashes (
-
):
For example, a PS2 controller returned 810-3-USB Gamepad .
This information is intended to allow you to find a mapping for the controls on the device as well as display useful feedback to the user.
readonly attribute DOMString id;
window.addEventListener("gamepadconnected", function() {
var gp = navigator.getGamepads()[0];
gamepadInfo.innerHTML = "Gamepad connected at index " + gp.index + ": " + gp.id + ".";
});
A
string
.
| 规范 | 状态 | 注释 |
|---|---|---|
|
Gamepad
The definition of 'Gamepad.id' in that specification. |
工作草案 | 初始定义 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
id
|
Chrome
35
|
Edge 12 |
Firefox
29
|
IE No |
Opera
22
|
Safari No | WebView Android No |
Chrome Android
35
|
Firefox Android 32 |
Opera Android
22
|
Safari iOS No |
Samsung Internet Android
4.0
|
完整支持
不支持
实验。期望将来行为有所改变。
用户必须明确启用此特征。
要求使用供应商前缀或不同名称。