Gamepad API - Web APIs 编辑

The Gamepad API is a way for developers to access and respond to signals from gamepads and other game controllers in a simple, consistent way. It contains three interfaces, two events and one specialist function, to respond to gamepads being connected and disconnected, and to access other information about the gamepads themselves, and what buttons and other controls are currently being pressed.

Interfaces

Gamepad
Represents a gamepad/controller connected to the computer.
GamepadButton
Represents a button on one of the connected controllers.
GamepadEvent
The event object representing events fired that are related to gamepads.

Experimental Gamepad extensions

GamepadHapticActuator
Represents hardware in the controller designed to provide haptic feedback to the user (if available), most commonly vibration hardware.
GamepadPose
Represents the pose of a controller (e.g. position and orientation in 3D space) in the case of a WebVR controller. This is not used by the newer WebXR standard.

See also the extensions to the Gamepad interface, for features that allow you to access the above information.

Extensions to other interfaces

Navigator.getGamepads()
An extension to the Navigator object that returns an array of Gamepad objects, one for each connected gamepad.

Window events

Window.ongamepadconnected
Represents an event handler that will run when a gamepad is connected (when the gamepadconnected event fires).
Window.ongamepaddisconnected
Represents an event handler that will run when a gamepad is disconnected (when the gamepaddisconnected event fires).

Tutorials and guides

Specifications

SpecificationStatusComment
Gamepad ExtensionsEditor's DraftDefines the Experimental Gamepad extensions.
Gamepad
The definition of 'The Gamepad API specification' in that specification.
Working DraftInitial definition

Browser compatibility

BCD tables only load in the browser

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:96 次

字数:6238

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文