1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 * The origin of this IDL file is
7 * https://w3c.github.io/gamepad/
8 * https://w3c.github.io/gamepad/extensions.html
9 * https://w3c.github.io/webvr/spec/1.1/#interface-gamepad
12 [Pref="dom.gamepad.enabled",
14 interface GamepadButton {
15 readonly attribute boolean pressed;
16 readonly attribute boolean touched;
17 readonly attribute double value;
27 * https://www.w3.org/TR/gamepad/#gamepadmappingtype-enum
28 * https://immersive-web.github.io/webxr-gamepads-module/#enumdef-gamepadmappingtype
30 enum GamepadMappingType {
36 [Pref="dom.gamepad.enabled",
40 * An identifier, unique per type of device.
42 readonly attribute DOMString id;
45 * The game port index for the device. Unique per device
46 * attached to this system.
48 readonly attribute long index;
51 * The mapping in use for this device. The empty string
52 * indicates that no mapping is in use.
54 readonly attribute GamepadMappingType mapping;
57 * The hand in use for this device. The empty string
58 * indicates that unknown, both hands, or not applicable
60 [Pref="dom.gamepad.extensions.enabled"]
61 readonly attribute GamepadHand hand;
64 * The displayId in use for as an association point in the VRDisplay API
65 * to identify which VRDisplay that the gamepad is associated with.
67 [Pref="dom.vr.enabled"]
68 readonly attribute unsigned long displayId;
71 * true if this gamepad is currently connected to the system.
73 readonly attribute boolean connected;
76 * The current state of all buttons on the device, an
77 * array of GamepadButton.
79 [Pure, Cached, Frozen]
80 readonly attribute sequence<GamepadButton> buttons;
83 * The current position of all axes on the device, an
86 [Pure, Cached, Frozen]
87 readonly attribute sequence<double> axes;
90 * Timestamp from when the data of this device was last updated.
92 readonly attribute DOMHighResTimeStamp timestamp;
95 * The current pose of the device, a GamepadPose.
97 [Pref="dom.gamepad.extensions.enabled"]
98 readonly attribute GamepadPose? pose;
101 * The current haptic actuator of the device, an array of
102 * GamepadHapticActuator.
104 [Constant, Cached, Frozen, Pref="dom.gamepad.extensions.enabled"]
105 readonly attribute sequence<GamepadHapticActuator> hapticActuators;
107 [Constant, Cached, Frozen, Pref="dom.gamepad.extensions.enabled", Pref="dom.gamepad.extensions.lightindicator"]
108 readonly attribute sequence<GamepadLightIndicator> lightIndicators;
110 [Constant, Cached, Frozen, Pref="dom.gamepad.extensions.enabled", Pref="dom.gamepad.extensions.multitouch"]
111 readonly attribute sequence<GamepadTouch> touchEvents;