Skip to content

Commit 26c698e

Browse files
committed
add Gamepad types
1 parent f0d597c commit 26c698e

File tree

4 files changed

+82
-6
lines changed

4 files changed

+82
-6
lines changed

baselines/dom.generated.d.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ interface GainOptions extends AudioNodeOptions {
464464
}
465465

466466
interface GamepadEventInit extends EventInit {
467-
gamepad?: Gamepad;
467+
gamepad: Gamepad;
468468
}
469469

470470
interface GetNotificationOptions {
@@ -5198,12 +5198,11 @@ declare var GainNode: {
51985198
};
51995199

52005200
interface Gamepad {
5201-
readonly axes: number[];
5202-
readonly buttons: GamepadButton[];
5201+
readonly axes: ReadonlyArray<number>;
5202+
readonly buttons: ReadonlyArray<GamepadButton>;
52035203
readonly connected: boolean;
5204-
readonly displayId: number;
52055204
readonly hand: GamepadHand;
5206-
readonly hapticActuators: GamepadHapticActuator[];
5205+
readonly hapticActuators: ReadonlyArray<GamepadHapticActuator>;
52075206
readonly id: string;
52085207
readonly index: number;
52095208
readonly mapping: GamepadMappingType;
@@ -5233,7 +5232,7 @@ interface GamepadEvent extends Event {
52335232

52345233
declare var GamepadEvent: {
52355234
prototype: GamepadEvent;
5236-
new(typeArg: string, eventInitDict?: GamepadEventInit): GamepadEvent;
5235+
new(type: string, eventInitDict: GamepadEventInit): GamepadEvent;
52375236
};
52385237

52395238
interface GamepadHapticActuator {
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
enum GamepadHand {
2+
"", /* unknown, both hands, or not applicable */
3+
"left",
4+
"right"
5+
};
6+
7+
interface GamepadHapticActuator {
8+
readonly attribute GamepadHapticActuatorType type;
9+
Promise<boolean> pulse(double value, double duration);
10+
};
11+
12+
enum GamepadHapticActuatorType {
13+
"vibration"
14+
};
15+
16+
interface GamepadPose {
17+
readonly attribute boolean hasOrientation;
18+
readonly attribute boolean hasPosition;
19+
20+
readonly attribute Float32Array? position;
21+
readonly attribute Float32Array? linearVelocity;
22+
readonly attribute Float32Array? linearAcceleration;
23+
readonly attribute Float32Array? orientation;
24+
readonly attribute Float32Array? angularVelocity;
25+
readonly attribute Float32Array? angularAcceleration;
26+
};
27+
28+
partial interface Gamepad {
29+
readonly attribute GamepadHand hand;
30+
readonly attribute FrozenArray<GamepadHapticActuator> hapticActuators;
31+
readonly attribute GamepadPose? pose;
32+
};

inputfiles/idl/Gamepad.widl

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
[Exposed=Window]
2+
interface Gamepad {
3+
readonly attribute DOMString id;
4+
readonly attribute long index;
5+
readonly attribute boolean connected;
6+
readonly attribute DOMHighResTimeStamp timestamp;
7+
readonly attribute GamepadMappingType mapping;
8+
readonly attribute FrozenArray<double> axes;
9+
readonly attribute FrozenArray<GamepadButton> buttons;
10+
};
11+
12+
[Exposed=Window]
13+
interface GamepadButton {
14+
readonly attribute boolean pressed;
15+
readonly attribute boolean touched;
16+
readonly attribute double value;
17+
};
18+
19+
enum GamepadMappingType {
20+
"",
21+
"standard",
22+
};
23+
24+
[Exposed=Window]
25+
partial interface Navigator {
26+
sequence<Gamepad?> getGamepads();
27+
};
28+
29+
[Constructor(DOMString type, GamepadEventInit eventInitDict), Exposed=Window]
30+
31+
interface GamepadEvent : Event {
32+
[SameObject] readonly attribute Gamepad gamepad;
33+
};
34+
35+
dictionary GamepadEventInit : EventInit {
36+
required Gamepad gamepad;
37+
};

inputfiles/idlSources.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@
4040
"url": "https://fullscreen.spec.whatwg.org/",
4141
"title": "Fullscreen"
4242
},
43+
{
44+
"url": "https://www.w3.org/TR/gamepad/",
45+
"title": "Gamepad"
46+
},
47+
{
48+
"url": "https://w3c.github.io/gamepad/extensions.html",
49+
"title": "Gamepad Extensions"
50+
},
4351
{
4452
"url": "https://www.w3.org/TR/geolocation-API/",
4553
"title": "Geolocation"

0 commit comments

Comments
 (0)