We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS

この翻訳は不完全です。英語から この記事を翻訳 してください。

The Gamepad interface of the Gamepad API defines an individual gamepad or other controller, allowing access to information such as button presses, axis positions, and id.

A Gamepad object can be returned in one of two ways: via the gamepad property of the gamepadconnected and gamepaddisconnected events, or by grabbing any position in the array returned by the Navigator.getGamepads() method.


Gamepad.displayId 読取専用
Returns the VRDisplay.displayId of the associated VRDisplay — the VRDisplay that the gamepad is controlling the displayed scene of.
Gamepad.id 読取専用
A DOMString containing identifying information about the controller.
Gamepad.index 読取専用
An integer that is auto-incremented to be unique for each device currently connected to the system.
Gamepad.mapping 読取専用
A string indicating whether the browser has remapped the controls on the device to a known layout.
Gamepad.connected 読取専用
A boolean indicating whether the gamepad is still connected to the system.
Gamepad.buttons 読取専用
An array of gamepadButton objects representing the buttons present on the device.
Gamepad.axes 読取専用
An array representing the controls with axes present on the device (e.g. analog thumb sticks).
Gamepad.timestamp 読取専用
A DOMHighResTimeStamp representing the last time the data for this gamepad was updated. Note that this property is not currently supported anywhere.


window.addEventListener("gamepadconnected", function(e) {
  console.log("Gamepad connected at index %d: %s. %d buttons, %d axes.",
  e.gamepad.index, e.gamepad.id,
  e.gamepad.buttons.length, e.gamepad.axes.length);


Specification Status Comment
Gamepad の定義
草案 Initial defintion
displayId の定義
不明 Defines the Gamepad.displayId property.

Browser compatibility

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
General support 21.0 webkit
29.0 (29.0) 未サポート 15.0 webkit
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
General support 未サポート 32.0 (32.0) 未サポート 未サポート 未サポート

See also


このページの貢献者: chrisdavidmills
最終更新者: chrisdavidmills,