Skip to content

Commit 4765448

Browse files
authored
Update Gamepad API (#4134)
1 parent 7346058 commit 4765448

29 files changed

+695
-758
lines changed

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@
2525
* Implicitly enable reference type and multivalue transformations if the module already makes use of the corresponding target features.
2626
[#4133](https://github.com/rustwasm/wasm-bindgen/pull/4133)
2727

28+
* Updated Gamepad API.
29+
[#4134](https://github.com/rustwasm/wasm-bindgen/pull/4134)
30+
31+
* Deprecated `Gamepad::display_id` and `GamepadHapticActuator::type_`.
32+
[#4134](https://github.com/rustwasm/wasm-bindgen/pull/4134)
33+
34+
* Removed `GamepadAxisMoveEvent`, `GamepadAxisMoveEventInit`, `GamepadButtonEvent`, `GamepadButtonEventInit` and `GamepadServiceTest`, which were seemingly never implemented by any JS environment.
35+
[#4134](https://github.com/rustwasm/wasm-bindgen/pull/4134)
36+
2837
### Fixed
2938

3039
* Fixed linked modules emitting snippet files when not using `--split-linked-modules`.

crates/web-sys/Cargo.toml

+4-5
Original file line numberDiff line numberDiff line change
@@ -454,19 +454,18 @@ FuzzingFunctions = []
454454
GainNode = ["AudioNode", "EventTarget"]
455455
GainOptions = []
456456
Gamepad = []
457-
GamepadAxisMoveEvent = ["Event", "GamepadEvent"]
458-
GamepadAxisMoveEventInit = []
459457
GamepadButton = []
460-
GamepadButtonEvent = ["Event", "GamepadEvent"]
461-
GamepadButtonEventInit = []
458+
GamepadEffectParameters = []
462459
GamepadEvent = ["Event"]
463460
GamepadEventInit = []
464461
GamepadHand = []
465462
GamepadHapticActuator = []
466463
GamepadHapticActuatorType = []
464+
GamepadHapticEffectType = []
465+
GamepadHapticsResult = []
467466
GamepadMappingType = []
468467
GamepadPose = []
469-
GamepadServiceTest = []
468+
GamepadTouch = []
470469
Geolocation = []
471470
GetAnimationsOptions = []
472471
GetRootNodeOptions = []

crates/web-sys/src/features/gen_Gamepad.rs

+55-31
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,20 @@ extern "C" {
2626
#[doc = ""]
2727
#[doc = "*This API requires the following crate features to be activated: `Gamepad`*"]
2828
pub fn index(this: &Gamepad) -> u32;
29+
# [wasm_bindgen (structural , method , getter , js_class = "Gamepad" , js_name = connected)]
30+
#[doc = "Getter for the `connected` field of this object."]
31+
#[doc = ""]
32+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Gamepad/connected)"]
33+
#[doc = ""]
34+
#[doc = "*This API requires the following crate features to be activated: `Gamepad`*"]
35+
pub fn connected(this: &Gamepad) -> bool;
36+
# [wasm_bindgen (structural , method , getter , js_class = "Gamepad" , js_name = timestamp)]
37+
#[doc = "Getter for the `timestamp` field of this object."]
38+
#[doc = ""]
39+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Gamepad/timestamp)"]
40+
#[doc = ""]
41+
#[doc = "*This API requires the following crate features to be activated: `Gamepad`*"]
42+
pub fn timestamp(this: &Gamepad) -> f64;
2943
#[cfg(feature = "GamepadMappingType")]
3044
# [wasm_bindgen (structural , method , getter , js_class = "Gamepad" , js_name = mapping)]
3145
#[doc = "Getter for the `mapping` field of this object."]
@@ -34,49 +48,43 @@ extern "C" {
3448
#[doc = ""]
3549
#[doc = "*This API requires the following crate features to be activated: `Gamepad`, `GamepadMappingType`*"]
3650
pub fn mapping(this: &Gamepad) -> GamepadMappingType;
37-
#[cfg(feature = "GamepadHand")]
38-
# [wasm_bindgen (structural , method , getter , js_class = "Gamepad" , js_name = hand)]
39-
#[doc = "Getter for the `hand` field of this object."]
40-
#[doc = ""]
41-
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Gamepad/hand)"]
42-
#[doc = ""]
43-
#[doc = "*This API requires the following crate features to be activated: `Gamepad`, `GamepadHand`*"]
44-
pub fn hand(this: &Gamepad) -> GamepadHand;
45-
# [wasm_bindgen (structural , method , getter , js_class = "Gamepad" , js_name = displayId)]
46-
#[doc = "Getter for the `displayId` field of this object."]
47-
#[doc = ""]
48-
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Gamepad/displayId)"]
49-
#[doc = ""]
50-
#[doc = "*This API requires the following crate features to be activated: `Gamepad`*"]
51-
pub fn display_id(this: &Gamepad) -> u32;
52-
# [wasm_bindgen (structural , method , getter , js_class = "Gamepad" , js_name = connected)]
53-
#[doc = "Getter for the `connected` field of this object."]
51+
# [wasm_bindgen (structural , method , getter , js_class = "Gamepad" , js_name = axes)]
52+
#[doc = "Getter for the `axes` field of this object."]
5453
#[doc = ""]
55-
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Gamepad/connected)"]
54+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Gamepad/axes)"]
5655
#[doc = ""]
5756
#[doc = "*This API requires the following crate features to be activated: `Gamepad`*"]
58-
pub fn connected(this: &Gamepad) -> bool;
57+
pub fn axes(this: &Gamepad) -> ::js_sys::Array;
5958
# [wasm_bindgen (structural , method , getter , js_class = "Gamepad" , js_name = buttons)]
6059
#[doc = "Getter for the `buttons` field of this object."]
6160
#[doc = ""]
6261
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Gamepad/buttons)"]
6362
#[doc = ""]
6463
#[doc = "*This API requires the following crate features to be activated: `Gamepad`*"]
6564
pub fn buttons(this: &Gamepad) -> ::js_sys::Array;
66-
# [wasm_bindgen (structural , method , getter , js_class = "Gamepad" , js_name = axes)]
67-
#[doc = "Getter for the `axes` field of this object."]
65+
# [wasm_bindgen (structural , method , getter , js_class = "Gamepad" , js_name = displayId)]
66+
#[doc = "Getter for the `displayId` field of this object."]
6867
#[doc = ""]
69-
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Gamepad/axes)"]
68+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Gamepad/displayId)"]
7069
#[doc = ""]
7170
#[doc = "*This API requires the following crate features to be activated: `Gamepad`*"]
72-
pub fn axes(this: &Gamepad) -> ::js_sys::Array;
73-
# [wasm_bindgen (structural , method , getter , js_class = "Gamepad" , js_name = timestamp)]
74-
#[doc = "Getter for the `timestamp` field of this object."]
71+
#[deprecated]
72+
pub fn display_id(this: &Gamepad) -> u32;
73+
#[cfg(feature = "GamepadHand")]
74+
# [wasm_bindgen (structural , method , getter , js_class = "Gamepad" , js_name = hand)]
75+
#[doc = "Getter for the `hand` field of this object."]
7576
#[doc = ""]
76-
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Gamepad/timestamp)"]
77+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Gamepad/hand)"]
78+
#[doc = ""]
79+
#[doc = "*This API requires the following crate features to be activated: `Gamepad`, `GamepadHand`*"]
80+
pub fn hand(this: &Gamepad) -> GamepadHand;
81+
# [wasm_bindgen (structural , method , getter , js_class = "Gamepad" , js_name = hapticActuators)]
82+
#[doc = "Getter for the `hapticActuators` field of this object."]
83+
#[doc = ""]
84+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Gamepad/hapticActuators)"]
7785
#[doc = ""]
7886
#[doc = "*This API requires the following crate features to be activated: `Gamepad`*"]
79-
pub fn timestamp(this: &Gamepad) -> f64;
87+
pub fn haptic_actuators(this: &Gamepad) -> ::js_sys::Array;
8088
#[cfg(feature = "GamepadPose")]
8189
# [wasm_bindgen (structural , method , getter , js_class = "Gamepad" , js_name = pose)]
8290
#[doc = "Getter for the `pose` field of this object."]
@@ -85,11 +93,27 @@ extern "C" {
8593
#[doc = ""]
8694
#[doc = "*This API requires the following crate features to be activated: `Gamepad`, `GamepadPose`*"]
8795
pub fn pose(this: &Gamepad) -> Option<GamepadPose>;
88-
# [wasm_bindgen (structural , method , getter , js_class = "Gamepad" , js_name = hapticActuators)]
89-
#[doc = "Getter for the `hapticActuators` field of this object."]
96+
#[cfg(web_sys_unstable_apis)]
97+
#[cfg(feature = "GamepadHapticActuator")]
98+
# [wasm_bindgen (structural , method , getter , js_class = "Gamepad" , js_name = vibrationActuator)]
99+
#[doc = "Getter for the `vibrationActuator` field of this object."]
90100
#[doc = ""]
91-
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Gamepad/hapticActuators)"]
101+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Gamepad/vibrationActuator)"]
102+
#[doc = ""]
103+
#[doc = "*This API requires the following crate features to be activated: `Gamepad`, `GamepadHapticActuator`*"]
104+
#[doc = ""]
105+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
106+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
107+
pub fn vibration_actuator(this: &Gamepad) -> GamepadHapticActuator;
108+
#[cfg(web_sys_unstable_apis)]
109+
# [wasm_bindgen (structural , method , getter , js_class = "Gamepad" , js_name = touchEvents)]
110+
#[doc = "Getter for the `touchEvents` field of this object."]
111+
#[doc = ""]
112+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Gamepad/touchEvents)"]
92113
#[doc = ""]
93114
#[doc = "*This API requires the following crate features to be activated: `Gamepad`*"]
94-
pub fn haptic_actuators(this: &Gamepad) -> ::js_sys::Array;
115+
#[doc = ""]
116+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
117+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
118+
pub fn touch_events(this: &Gamepad) -> Option<::js_sys::Array>;
95119
}

crates/web-sys/src/features/gen_GamepadAxisMoveEvent.rs

-47
This file was deleted.

crates/web-sys/src/features/gen_GamepadAxisMoveEventInit.rs

-121
This file was deleted.

crates/web-sys/src/features/gen_GamepadButtonEvent.rs

-40
This file was deleted.

0 commit comments

Comments
 (0)