Update Gamepad API (#4134)

This commit is contained in:
daxpedda 2024-09-28 13:31:54 +02:00 committed by GitHub
parent 73460587d4
commit 4765448545
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
29 changed files with 705 additions and 768 deletions

View File

@ -25,6 +25,15 @@
* Implicitly enable reference type and multivalue transformations if the module already makes use of the corresponding target features.
[#4133](https://github.com/rustwasm/wasm-bindgen/pull/4133)
* Updated Gamepad API.
[#4134](https://github.com/rustwasm/wasm-bindgen/pull/4134)
* Deprecated `Gamepad::display_id` and `GamepadHapticActuator::type_`.
[#4134](https://github.com/rustwasm/wasm-bindgen/pull/4134)
* Removed `GamepadAxisMoveEvent`, `GamepadAxisMoveEventInit`, `GamepadButtonEvent`, `GamepadButtonEventInit` and `GamepadServiceTest`, which were seemingly never implemented by any JS environment.
[#4134](https://github.com/rustwasm/wasm-bindgen/pull/4134)
### Fixed
* Fixed linked modules emitting snippet files when not using `--split-linked-modules`.

View File

@ -454,19 +454,18 @@ FuzzingFunctions = []
GainNode = ["AudioNode", "EventTarget"]
GainOptions = []
Gamepad = []
GamepadAxisMoveEvent = ["Event", "GamepadEvent"]
GamepadAxisMoveEventInit = []
GamepadButton = []
GamepadButtonEvent = ["Event", "GamepadEvent"]
GamepadButtonEventInit = []
GamepadEffectParameters = []
GamepadEvent = ["Event"]
GamepadEventInit = []
GamepadHand = []
GamepadHapticActuator = []
GamepadHapticActuatorType = []
GamepadHapticEffectType = []
GamepadHapticsResult = []
GamepadMappingType = []
GamepadPose = []
GamepadServiceTest = []
GamepadTouch = []
Geolocation = []
GetAnimationsOptions = []
GetRootNodeOptions = []

View File

@ -26,6 +26,20 @@ extern "C" {
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Gamepad`*"]
pub fn index(this: &Gamepad) -> u32;
# [wasm_bindgen (structural , method , getter , js_class = "Gamepad" , js_name = connected)]
#[doc = "Getter for the `connected` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Gamepad/connected)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Gamepad`*"]
pub fn connected(this: &Gamepad) -> bool;
# [wasm_bindgen (structural , method , getter , js_class = "Gamepad" , js_name = timestamp)]
#[doc = "Getter for the `timestamp` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Gamepad/timestamp)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Gamepad`*"]
pub fn timestamp(this: &Gamepad) -> f64;
#[cfg(feature = "GamepadMappingType")]
# [wasm_bindgen (structural , method , getter , js_class = "Gamepad" , js_name = mapping)]
#[doc = "Getter for the `mapping` field of this object."]
@ -34,6 +48,28 @@ extern "C" {
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Gamepad`, `GamepadMappingType`*"]
pub fn mapping(this: &Gamepad) -> GamepadMappingType;
# [wasm_bindgen (structural , method , getter , js_class = "Gamepad" , js_name = axes)]
#[doc = "Getter for the `axes` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Gamepad/axes)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Gamepad`*"]
pub fn axes(this: &Gamepad) -> ::js_sys::Array;
# [wasm_bindgen (structural , method , getter , js_class = "Gamepad" , js_name = buttons)]
#[doc = "Getter for the `buttons` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Gamepad/buttons)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Gamepad`*"]
pub fn buttons(this: &Gamepad) -> ::js_sys::Array;
# [wasm_bindgen (structural , method , getter , js_class = "Gamepad" , js_name = displayId)]
#[doc = "Getter for the `displayId` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Gamepad/displayId)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Gamepad`*"]
#[deprecated]
pub fn display_id(this: &Gamepad) -> u32;
#[cfg(feature = "GamepadHand")]
# [wasm_bindgen (structural , method , getter , js_class = "Gamepad" , js_name = hand)]
#[doc = "Getter for the `hand` field of this object."]
@ -42,41 +78,13 @@ extern "C" {
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Gamepad`, `GamepadHand`*"]
pub fn hand(this: &Gamepad) -> GamepadHand;
# [wasm_bindgen (structural , method , getter , js_class = "Gamepad" , js_name = displayId)]
#[doc = "Getter for the `displayId` field of this object."]
# [wasm_bindgen (structural , method , getter , js_class = "Gamepad" , js_name = hapticActuators)]
#[doc = "Getter for the `hapticActuators` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Gamepad/displayId)"]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Gamepad/hapticActuators)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Gamepad`*"]
pub fn display_id(this: &Gamepad) -> u32;
# [wasm_bindgen (structural , method , getter , js_class = "Gamepad" , js_name = connected)]
#[doc = "Getter for the `connected` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Gamepad/connected)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Gamepad`*"]
pub fn connected(this: &Gamepad) -> bool;
# [wasm_bindgen (structural , method , getter , js_class = "Gamepad" , js_name = buttons)]
#[doc = "Getter for the `buttons` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Gamepad/buttons)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Gamepad`*"]
pub fn buttons(this: &Gamepad) -> ::js_sys::Array;
# [wasm_bindgen (structural , method , getter , js_class = "Gamepad" , js_name = axes)]
#[doc = "Getter for the `axes` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Gamepad/axes)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Gamepad`*"]
pub fn axes(this: &Gamepad) -> ::js_sys::Array;
# [wasm_bindgen (structural , method , getter , js_class = "Gamepad" , js_name = timestamp)]
#[doc = "Getter for the `timestamp` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Gamepad/timestamp)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Gamepad`*"]
pub fn timestamp(this: &Gamepad) -> f64;
pub fn haptic_actuators(this: &Gamepad) -> ::js_sys::Array;
#[cfg(feature = "GamepadPose")]
# [wasm_bindgen (structural , method , getter , js_class = "Gamepad" , js_name = pose)]
#[doc = "Getter for the `pose` field of this object."]
@ -85,11 +93,27 @@ extern "C" {
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Gamepad`, `GamepadPose`*"]
pub fn pose(this: &Gamepad) -> Option<GamepadPose>;
# [wasm_bindgen (structural , method , getter , js_class = "Gamepad" , js_name = hapticActuators)]
#[doc = "Getter for the `hapticActuators` field of this object."]
#[cfg(web_sys_unstable_apis)]
#[cfg(feature = "GamepadHapticActuator")]
# [wasm_bindgen (structural , method , getter , js_class = "Gamepad" , js_name = vibrationActuator)]
#[doc = "Getter for the `vibrationActuator` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Gamepad/hapticActuators)"]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Gamepad/vibrationActuator)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Gamepad`, `GamepadHapticActuator`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn vibration_actuator(this: &Gamepad) -> GamepadHapticActuator;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (structural , method , getter , js_class = "Gamepad" , js_name = touchEvents)]
#[doc = "Getter for the `touchEvents` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Gamepad/touchEvents)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Gamepad`*"]
pub fn haptic_actuators(this: &Gamepad) -> ::js_sys::Array;
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn touch_events(this: &Gamepad) -> Option<::js_sys::Array>;
}

View File

@ -1,47 +0,0 @@
#![allow(unused_imports)]
#![allow(clippy::all)]
use super::*;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
# [wasm_bindgen (extends = GamepadEvent , extends = Event , extends = :: js_sys :: Object , js_name = GamepadAxisMoveEvent , typescript_type = "GamepadAxisMoveEvent")]
#[derive(Debug, Clone, PartialEq, Eq)]
#[doc = "The `GamepadAxisMoveEvent` class."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GamepadAxisMoveEvent)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadAxisMoveEvent`*"]
pub type GamepadAxisMoveEvent;
# [wasm_bindgen (structural , method , getter , js_class = "GamepadAxisMoveEvent" , js_name = axis)]
#[doc = "Getter for the `axis` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GamepadAxisMoveEvent/axis)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadAxisMoveEvent`*"]
pub fn axis(this: &GamepadAxisMoveEvent) -> u32;
# [wasm_bindgen (structural , method , getter , js_class = "GamepadAxisMoveEvent" , js_name = value)]
#[doc = "Getter for the `value` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GamepadAxisMoveEvent/value)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadAxisMoveEvent`*"]
pub fn value(this: &GamepadAxisMoveEvent) -> f64;
#[wasm_bindgen(catch, constructor, js_class = "GamepadAxisMoveEvent")]
#[doc = "The `new GamepadAxisMoveEvent(..)` constructor, creating a new instance of `GamepadAxisMoveEvent`."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GamepadAxisMoveEvent/GamepadAxisMoveEvent)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadAxisMoveEvent`*"]
pub fn new(type_: &str) -> Result<GamepadAxisMoveEvent, JsValue>;
#[cfg(feature = "GamepadAxisMoveEventInit")]
#[wasm_bindgen(catch, constructor, js_class = "GamepadAxisMoveEvent")]
#[doc = "The `new GamepadAxisMoveEvent(..)` constructor, creating a new instance of `GamepadAxisMoveEvent`."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GamepadAxisMoveEvent/GamepadAxisMoveEvent)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadAxisMoveEvent`, `GamepadAxisMoveEventInit`*"]
pub fn new_with_event_init_dict(
type_: &str,
event_init_dict: &GamepadAxisMoveEventInit,
) -> Result<GamepadAxisMoveEvent, JsValue>;
}

View File

@ -1,121 +0,0 @@
#![allow(unused_imports)]
#![allow(clippy::all)]
use super::*;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = GamepadAxisMoveEventInit)]
#[derive(Debug, Clone, PartialEq, Eq)]
#[doc = "The `GamepadAxisMoveEventInit` dictionary."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadAxisMoveEventInit`*"]
pub type GamepadAxisMoveEventInit;
#[doc = "Get the `bubbles` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadAxisMoveEventInit`*"]
#[wasm_bindgen(method, getter = "bubbles")]
pub fn get_bubbles(this: &GamepadAxisMoveEventInit) -> Option<bool>;
#[doc = "Change the `bubbles` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadAxisMoveEventInit`*"]
#[wasm_bindgen(method, setter = "bubbles")]
pub fn set_bubbles(this: &GamepadAxisMoveEventInit, val: bool);
#[doc = "Get the `cancelable` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadAxisMoveEventInit`*"]
#[wasm_bindgen(method, getter = "cancelable")]
pub fn get_cancelable(this: &GamepadAxisMoveEventInit) -> Option<bool>;
#[doc = "Change the `cancelable` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadAxisMoveEventInit`*"]
#[wasm_bindgen(method, setter = "cancelable")]
pub fn set_cancelable(this: &GamepadAxisMoveEventInit, val: bool);
#[doc = "Get the `composed` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadAxisMoveEventInit`*"]
#[wasm_bindgen(method, getter = "composed")]
pub fn get_composed(this: &GamepadAxisMoveEventInit) -> Option<bool>;
#[doc = "Change the `composed` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadAxisMoveEventInit`*"]
#[wasm_bindgen(method, setter = "composed")]
pub fn set_composed(this: &GamepadAxisMoveEventInit, val: bool);
#[cfg(feature = "Gamepad")]
#[doc = "Get the `gamepad` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Gamepad`, `GamepadAxisMoveEventInit`*"]
#[wasm_bindgen(method, getter = "gamepad")]
pub fn get_gamepad(this: &GamepadAxisMoveEventInit) -> Option<Gamepad>;
#[cfg(feature = "Gamepad")]
#[doc = "Change the `gamepad` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Gamepad`, `GamepadAxisMoveEventInit`*"]
#[wasm_bindgen(method, setter = "gamepad")]
pub fn set_gamepad(this: &GamepadAxisMoveEventInit, val: Option<&Gamepad>);
#[doc = "Get the `axis` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadAxisMoveEventInit`*"]
#[wasm_bindgen(method, getter = "axis")]
pub fn get_axis(this: &GamepadAxisMoveEventInit) -> Option<u32>;
#[doc = "Change the `axis` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadAxisMoveEventInit`*"]
#[wasm_bindgen(method, setter = "axis")]
pub fn set_axis(this: &GamepadAxisMoveEventInit, val: u32);
#[doc = "Get the `value` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadAxisMoveEventInit`*"]
#[wasm_bindgen(method, getter = "value")]
pub fn get_value(this: &GamepadAxisMoveEventInit) -> Option<f64>;
#[doc = "Change the `value` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadAxisMoveEventInit`*"]
#[wasm_bindgen(method, setter = "value")]
pub fn set_value(this: &GamepadAxisMoveEventInit, val: f64);
}
impl GamepadAxisMoveEventInit {
#[doc = "Construct a new `GamepadAxisMoveEventInit`."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadAxisMoveEventInit`*"]
pub fn new() -> Self {
#[allow(unused_mut)]
let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new());
ret
}
#[deprecated = "Use `set_bubbles()` instead."]
pub fn bubbles(&mut self, val: bool) -> &mut Self {
self.set_bubbles(val);
self
}
#[deprecated = "Use `set_cancelable()` instead."]
pub fn cancelable(&mut self, val: bool) -> &mut Self {
self.set_cancelable(val);
self
}
#[deprecated = "Use `set_composed()` instead."]
pub fn composed(&mut self, val: bool) -> &mut Self {
self.set_composed(val);
self
}
#[cfg(feature = "Gamepad")]
#[deprecated = "Use `set_gamepad()` instead."]
pub fn gamepad(&mut self, val: Option<&Gamepad>) -> &mut Self {
self.set_gamepad(val);
self
}
#[deprecated = "Use `set_axis()` instead."]
pub fn axis(&mut self, val: u32) -> &mut Self {
self.set_axis(val);
self
}
#[deprecated = "Use `set_value()` instead."]
pub fn value(&mut self, val: f64) -> &mut Self {
self.set_value(val);
self
}
}
impl Default for GamepadAxisMoveEventInit {
fn default() -> Self {
Self::new()
}
}

View File

@ -1,40 +0,0 @@
#![allow(unused_imports)]
#![allow(clippy::all)]
use super::*;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
# [wasm_bindgen (extends = GamepadEvent , extends = Event , extends = :: js_sys :: Object , js_name = GamepadButtonEvent , typescript_type = "GamepadButtonEvent")]
#[derive(Debug, Clone, PartialEq, Eq)]
#[doc = "The `GamepadButtonEvent` class."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GamepadButtonEvent)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadButtonEvent`*"]
pub type GamepadButtonEvent;
# [wasm_bindgen (structural , method , getter , js_class = "GamepadButtonEvent" , js_name = button)]
#[doc = "Getter for the `button` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GamepadButtonEvent/button)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadButtonEvent`*"]
pub fn button(this: &GamepadButtonEvent) -> u32;
#[wasm_bindgen(catch, constructor, js_class = "GamepadButtonEvent")]
#[doc = "The `new GamepadButtonEvent(..)` constructor, creating a new instance of `GamepadButtonEvent`."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GamepadButtonEvent/GamepadButtonEvent)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadButtonEvent`*"]
pub fn new(type_: &str) -> Result<GamepadButtonEvent, JsValue>;
#[cfg(feature = "GamepadButtonEventInit")]
#[wasm_bindgen(catch, constructor, js_class = "GamepadButtonEvent")]
#[doc = "The `new GamepadButtonEvent(..)` constructor, creating a new instance of `GamepadButtonEvent`."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GamepadButtonEvent/GamepadButtonEvent)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadButtonEvent`, `GamepadButtonEventInit`*"]
pub fn new_with_event_init_dict(
type_: &str,
event_init_dict: &GamepadButtonEventInit,
) -> Result<GamepadButtonEvent, JsValue>;
}

View File

@ -1,106 +0,0 @@
#![allow(unused_imports)]
#![allow(clippy::all)]
use super::*;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = GamepadButtonEventInit)]
#[derive(Debug, Clone, PartialEq, Eq)]
#[doc = "The `GamepadButtonEventInit` dictionary."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadButtonEventInit`*"]
pub type GamepadButtonEventInit;
#[doc = "Get the `bubbles` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadButtonEventInit`*"]
#[wasm_bindgen(method, getter = "bubbles")]
pub fn get_bubbles(this: &GamepadButtonEventInit) -> Option<bool>;
#[doc = "Change the `bubbles` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadButtonEventInit`*"]
#[wasm_bindgen(method, setter = "bubbles")]
pub fn set_bubbles(this: &GamepadButtonEventInit, val: bool);
#[doc = "Get the `cancelable` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadButtonEventInit`*"]
#[wasm_bindgen(method, getter = "cancelable")]
pub fn get_cancelable(this: &GamepadButtonEventInit) -> Option<bool>;
#[doc = "Change the `cancelable` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadButtonEventInit`*"]
#[wasm_bindgen(method, setter = "cancelable")]
pub fn set_cancelable(this: &GamepadButtonEventInit, val: bool);
#[doc = "Get the `composed` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadButtonEventInit`*"]
#[wasm_bindgen(method, getter = "composed")]
pub fn get_composed(this: &GamepadButtonEventInit) -> Option<bool>;
#[doc = "Change the `composed` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadButtonEventInit`*"]
#[wasm_bindgen(method, setter = "composed")]
pub fn set_composed(this: &GamepadButtonEventInit, val: bool);
#[cfg(feature = "Gamepad")]
#[doc = "Get the `gamepad` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Gamepad`, `GamepadButtonEventInit`*"]
#[wasm_bindgen(method, getter = "gamepad")]
pub fn get_gamepad(this: &GamepadButtonEventInit) -> Option<Gamepad>;
#[cfg(feature = "Gamepad")]
#[doc = "Change the `gamepad` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Gamepad`, `GamepadButtonEventInit`*"]
#[wasm_bindgen(method, setter = "gamepad")]
pub fn set_gamepad(this: &GamepadButtonEventInit, val: Option<&Gamepad>);
#[doc = "Get the `button` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadButtonEventInit`*"]
#[wasm_bindgen(method, getter = "button")]
pub fn get_button(this: &GamepadButtonEventInit) -> Option<u32>;
#[doc = "Change the `button` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadButtonEventInit`*"]
#[wasm_bindgen(method, setter = "button")]
pub fn set_button(this: &GamepadButtonEventInit, val: u32);
}
impl GamepadButtonEventInit {
#[doc = "Construct a new `GamepadButtonEventInit`."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadButtonEventInit`*"]
pub fn new() -> Self {
#[allow(unused_mut)]
let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new());
ret
}
#[deprecated = "Use `set_bubbles()` instead."]
pub fn bubbles(&mut self, val: bool) -> &mut Self {
self.set_bubbles(val);
self
}
#[deprecated = "Use `set_cancelable()` instead."]
pub fn cancelable(&mut self, val: bool) -> &mut Self {
self.set_cancelable(val);
self
}
#[deprecated = "Use `set_composed()` instead."]
pub fn composed(&mut self, val: bool) -> &mut Self {
self.set_composed(val);
self
}
#[cfg(feature = "Gamepad")]
#[deprecated = "Use `set_gamepad()` instead."]
pub fn gamepad(&mut self, val: Option<&Gamepad>) -> &mut Self {
self.set_gamepad(val);
self
}
#[deprecated = "Use `set_button()` instead."]
pub fn button(&mut self, val: u32) -> &mut Self {
self.set_button(val);
self
}
}
impl Default for GamepadButtonEventInit {
fn default() -> Self {
Self::new()
}
}

View File

@ -0,0 +1,181 @@
#![allow(unused_imports)]
#![allow(clippy::all)]
use super::*;
use wasm_bindgen::prelude::*;
#[cfg(web_sys_unstable_apis)]
#[wasm_bindgen]
extern "C" {
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = GamepadEffectParameters)]
#[derive(Debug, Clone, PartialEq, Eq)]
#[doc = "The `GamepadEffectParameters` dictionary."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadEffectParameters`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub type GamepadEffectParameters;
#[cfg(web_sys_unstable_apis)]
#[doc = "Get the `duration` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadEffectParameters`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
#[wasm_bindgen(method, getter = "duration")]
pub fn get_duration(this: &GamepadEffectParameters) -> Option<f64>;
#[cfg(web_sys_unstable_apis)]
#[doc = "Change the `duration` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadEffectParameters`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
#[wasm_bindgen(method, setter = "duration")]
pub fn set_duration(this: &GamepadEffectParameters, val: f64);
#[cfg(web_sys_unstable_apis)]
#[doc = "Get the `leftTrigger` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadEffectParameters`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
#[wasm_bindgen(method, getter = "leftTrigger")]
pub fn get_left_trigger(this: &GamepadEffectParameters) -> Option<f64>;
#[cfg(web_sys_unstable_apis)]
#[doc = "Change the `leftTrigger` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadEffectParameters`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
#[wasm_bindgen(method, setter = "leftTrigger")]
pub fn set_left_trigger(this: &GamepadEffectParameters, val: f64);
#[cfg(web_sys_unstable_apis)]
#[doc = "Get the `rightTrigger` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadEffectParameters`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
#[wasm_bindgen(method, getter = "rightTrigger")]
pub fn get_right_trigger(this: &GamepadEffectParameters) -> Option<f64>;
#[cfg(web_sys_unstable_apis)]
#[doc = "Change the `rightTrigger` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadEffectParameters`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
#[wasm_bindgen(method, setter = "rightTrigger")]
pub fn set_right_trigger(this: &GamepadEffectParameters, val: f64);
#[cfg(web_sys_unstable_apis)]
#[doc = "Get the `startDelay` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadEffectParameters`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
#[wasm_bindgen(method, getter = "startDelay")]
pub fn get_start_delay(this: &GamepadEffectParameters) -> Option<f64>;
#[cfg(web_sys_unstable_apis)]
#[doc = "Change the `startDelay` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadEffectParameters`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
#[wasm_bindgen(method, setter = "startDelay")]
pub fn set_start_delay(this: &GamepadEffectParameters, val: f64);
#[cfg(web_sys_unstable_apis)]
#[doc = "Get the `strongMagnitude` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadEffectParameters`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
#[wasm_bindgen(method, getter = "strongMagnitude")]
pub fn get_strong_magnitude(this: &GamepadEffectParameters) -> Option<f64>;
#[cfg(web_sys_unstable_apis)]
#[doc = "Change the `strongMagnitude` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadEffectParameters`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
#[wasm_bindgen(method, setter = "strongMagnitude")]
pub fn set_strong_magnitude(this: &GamepadEffectParameters, val: f64);
#[cfg(web_sys_unstable_apis)]
#[doc = "Get the `weakMagnitude` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadEffectParameters`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
#[wasm_bindgen(method, getter = "weakMagnitude")]
pub fn get_weak_magnitude(this: &GamepadEffectParameters) -> Option<f64>;
#[cfg(web_sys_unstable_apis)]
#[doc = "Change the `weakMagnitude` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadEffectParameters`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
#[wasm_bindgen(method, setter = "weakMagnitude")]
pub fn set_weak_magnitude(this: &GamepadEffectParameters, val: f64);
}
#[cfg(web_sys_unstable_apis)]
impl GamepadEffectParameters {
#[doc = "Construct a new `GamepadEffectParameters`."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadEffectParameters`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn new() -> Self {
#[allow(unused_mut)]
let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new());
ret
}
#[cfg(web_sys_unstable_apis)]
#[deprecated = "Use `set_duration()` instead."]
pub fn duration(&mut self, val: f64) -> &mut Self {
self.set_duration(val);
self
}
#[cfg(web_sys_unstable_apis)]
#[deprecated = "Use `set_left_trigger()` instead."]
pub fn left_trigger(&mut self, val: f64) -> &mut Self {
self.set_left_trigger(val);
self
}
#[cfg(web_sys_unstable_apis)]
#[deprecated = "Use `set_right_trigger()` instead."]
pub fn right_trigger(&mut self, val: f64) -> &mut Self {
self.set_right_trigger(val);
self
}
#[cfg(web_sys_unstable_apis)]
#[deprecated = "Use `set_start_delay()` instead."]
pub fn start_delay(&mut self, val: f64) -> &mut Self {
self.set_start_delay(val);
self
}
#[cfg(web_sys_unstable_apis)]
#[deprecated = "Use `set_strong_magnitude()` instead."]
pub fn strong_magnitude(&mut self, val: f64) -> &mut Self {
self.set_strong_magnitude(val);
self
}
#[cfg(web_sys_unstable_apis)]
#[deprecated = "Use `set_weak_magnitude()` instead."]
pub fn weak_magnitude(&mut self, val: f64) -> &mut Self {
self.set_weak_magnitude(val);
self
}
}
#[cfg(web_sys_unstable_apis)]
impl Default for GamepadEffectParameters {
fn default() -> Self {
Self::new()
}
}

View File

@ -19,7 +19,53 @@ extern "C" {
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GamepadHapticActuator/type)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadHapticActuator`, `GamepadHapticActuatorType`*"]
#[deprecated]
pub fn type_(this: &GamepadHapticActuator) -> GamepadHapticActuatorType;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (structural , method , getter , js_class = "GamepadHapticActuator" , js_name = effects)]
#[doc = "Getter for the `effects` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GamepadHapticActuator/effects)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadHapticActuator`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn effects(this: &GamepadHapticActuator) -> ::js_sys::Array;
#[cfg(web_sys_unstable_apis)]
#[cfg(feature = "GamepadHapticEffectType")]
# [wasm_bindgen (method , structural , js_class = "GamepadHapticActuator" , js_name = playEffect)]
#[doc = "The `playEffect()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GamepadHapticActuator/playEffect)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadHapticActuator`, `GamepadHapticEffectType`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn play_effect(
this: &GamepadHapticActuator,
type_: GamepadHapticEffectType,
) -> ::js_sys::Promise;
#[cfg(web_sys_unstable_apis)]
#[cfg(all(
feature = "GamepadEffectParameters",
feature = "GamepadHapticEffectType",
))]
# [wasm_bindgen (method , structural , js_class = "GamepadHapticActuator" , js_name = playEffect)]
#[doc = "The `playEffect()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GamepadHapticActuator/playEffect)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadEffectParameters`, `GamepadHapticActuator`, `GamepadHapticEffectType`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn play_effect_with_params(
this: &GamepadHapticActuator,
type_: GamepadHapticEffectType,
params: &GamepadEffectParameters,
) -> ::js_sys::Promise;
# [wasm_bindgen (catch , method , structural , js_class = "GamepadHapticActuator" , js_name = pulse)]
#[doc = "The `pulse()` method."]
#[doc = ""]
@ -31,4 +77,15 @@ extern "C" {
value: f64,
duration: f64,
) -> Result<::js_sys::Promise, JsValue>;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (method , structural , js_class = "GamepadHapticActuator" , js_name = reset)]
#[doc = "The `reset()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GamepadHapticActuator/reset)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadHapticActuator`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn reset(this: &GamepadHapticActuator) -> ::js_sys::Promise;
}

View File

@ -0,0 +1,16 @@
#![allow(unused_imports)]
#![allow(clippy::all)]
use wasm_bindgen::prelude::*;
#[cfg(web_sys_unstable_apis)]
#[wasm_bindgen]
#[doc = "The `GamepadHapticEffectType` enum."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadHapticEffectType`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum GamepadHapticEffectType {
DualRumble = "dual-rumble",
TriggerRumble = "trigger-rumble",
}

View File

@ -0,0 +1,16 @@
#![allow(unused_imports)]
#![allow(clippy::all)]
use wasm_bindgen::prelude::*;
#[cfg(web_sys_unstable_apis)]
#[wasm_bindgen]
#[doc = "The `GamepadHapticsResult` enum."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadHapticsResult`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum GamepadHapticsResult {
Complete = "complete",
Preempted = "preempted",
}

View File

@ -1,128 +0,0 @@
#![allow(unused_imports)]
#![allow(clippy::all)]
use super::*;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = GamepadServiceTest , typescript_type = "GamepadServiceTest")]
#[derive(Debug, Clone, PartialEq, Eq)]
#[doc = "The `GamepadServiceTest` class."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GamepadServiceTest)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadServiceTest`*"]
pub type GamepadServiceTest;
#[cfg(feature = "GamepadMappingType")]
# [wasm_bindgen (structural , method , getter , js_class = "GamepadServiceTest" , js_name = noMapping)]
#[doc = "Getter for the `noMapping` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GamepadServiceTest/noMapping)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadMappingType`, `GamepadServiceTest`*"]
pub fn no_mapping(this: &GamepadServiceTest) -> GamepadMappingType;
#[cfg(feature = "GamepadMappingType")]
# [wasm_bindgen (structural , method , getter , js_class = "GamepadServiceTest" , js_name = standardMapping)]
#[doc = "Getter for the `standardMapping` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GamepadServiceTest/standardMapping)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadMappingType`, `GamepadServiceTest`*"]
pub fn standard_mapping(this: &GamepadServiceTest) -> GamepadMappingType;
#[cfg(feature = "GamepadHand")]
# [wasm_bindgen (structural , method , getter , js_class = "GamepadServiceTest" , js_name = noHand)]
#[doc = "Getter for the `noHand` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GamepadServiceTest/noHand)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadHand`, `GamepadServiceTest`*"]
pub fn no_hand(this: &GamepadServiceTest) -> GamepadHand;
#[cfg(feature = "GamepadHand")]
# [wasm_bindgen (structural , method , getter , js_class = "GamepadServiceTest" , js_name = leftHand)]
#[doc = "Getter for the `leftHand` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GamepadServiceTest/leftHand)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadHand`, `GamepadServiceTest`*"]
pub fn left_hand(this: &GamepadServiceTest) -> GamepadHand;
#[cfg(feature = "GamepadHand")]
# [wasm_bindgen (structural , method , getter , js_class = "GamepadServiceTest" , js_name = rightHand)]
#[doc = "Getter for the `rightHand` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GamepadServiceTest/rightHand)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadHand`, `GamepadServiceTest`*"]
pub fn right_hand(this: &GamepadServiceTest) -> GamepadHand;
#[cfg(all(feature = "GamepadHand", feature = "GamepadMappingType",))]
# [wasm_bindgen (catch , method , structural , js_class = "GamepadServiceTest" , js_name = addGamepad)]
#[doc = "The `addGamepad()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GamepadServiceTest/addGamepad)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadHand`, `GamepadMappingType`, `GamepadServiceTest`*"]
pub fn add_gamepad(
this: &GamepadServiceTest,
id: &str,
mapping: GamepadMappingType,
hand: GamepadHand,
num_buttons: u32,
num_axes: u32,
num_haptics: u32,
) -> Result<::js_sys::Promise, JsValue>;
# [wasm_bindgen (method , structural , js_class = "GamepadServiceTest" , js_name = newAxisMoveEvent)]
#[doc = "The `newAxisMoveEvent()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GamepadServiceTest/newAxisMoveEvent)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadServiceTest`*"]
pub fn new_axis_move_event(this: &GamepadServiceTest, index: u32, axis: u32, value: f64);
# [wasm_bindgen (method , structural , js_class = "GamepadServiceTest" , js_name = newButtonEvent)]
#[doc = "The `newButtonEvent()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GamepadServiceTest/newButtonEvent)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadServiceTest`*"]
pub fn new_button_event(
this: &GamepadServiceTest,
index: u32,
button: u32,
pressed: bool,
touched: bool,
);
# [wasm_bindgen (method , structural , js_class = "GamepadServiceTest" , js_name = newButtonValueEvent)]
#[doc = "The `newButtonValueEvent()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GamepadServiceTest/newButtonValueEvent)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadServiceTest`*"]
pub fn new_button_value_event(
this: &GamepadServiceTest,
index: u32,
button: u32,
pressed: bool,
touched: bool,
value: f64,
);
# [wasm_bindgen (method , structural , js_class = "GamepadServiceTest" , js_name = newPoseMove)]
#[doc = "The `newPoseMove()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GamepadServiceTest/newPoseMove)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadServiceTest`*"]
pub fn new_pose_move(
this: &GamepadServiceTest,
index: u32,
orient: Option<&mut [f32]>,
pos: Option<&mut [f32]>,
ang_velocity: Option<&mut [f32]>,
ang_acceleration: Option<&mut [f32]>,
lin_velocity: Option<&mut [f32]>,
lin_acceleration: Option<&mut [f32]>,
);
# [wasm_bindgen (method , structural , js_class = "GamepadServiceTest" , js_name = removeGamepad)]
#[doc = "The `removeGamepad()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GamepadServiceTest/removeGamepad)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadServiceTest`*"]
pub fn remove_gamepad(this: &GamepadServiceTest, index: u32);
}

View File

@ -0,0 +1,63 @@
#![allow(unused_imports)]
#![allow(clippy::all)]
use super::*;
use wasm_bindgen::prelude::*;
#[cfg(web_sys_unstable_apis)]
#[wasm_bindgen]
extern "C" {
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = GamepadTouch , typescript_type = "GamepadTouch")]
#[derive(Debug, Clone, PartialEq, Eq)]
#[doc = "The `GamepadTouch` class."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GamepadTouch)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadTouch`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub type GamepadTouch;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (structural , method , getter , js_class = "GamepadTouch" , js_name = touchId)]
#[doc = "Getter for the `touchId` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GamepadTouch/touchId)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadTouch`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn touch_id(this: &GamepadTouch) -> u32;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (structural , method , getter , js_class = "GamepadTouch" , js_name = surfaceId)]
#[doc = "Getter for the `surfaceId` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GamepadTouch/surfaceId)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadTouch`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn surface_id(this: &GamepadTouch) -> u8;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (structural , method , getter , js_class = "GamepadTouch" , js_name = position)]
#[doc = "Getter for the `position` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GamepadTouch/position)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadTouch`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn position(this: &GamepadTouch) -> Vec<f32>;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (structural , method , getter , js_class = "GamepadTouch" , js_name = surfaceDimensions)]
#[doc = "Getter for the `surfaceDimensions` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GamepadTouch/surfaceDimensions)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadTouch`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn surface_dimensions(this: &GamepadTouch) -> Option<Vec<u32>>;
}

View File

@ -292,4 +292,48 @@ extern "C" {
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `HtmlBodyElement`*"]
pub fn set_onunload(this: &HtmlBodyElement, value: Option<&::js_sys::Function>);
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (structural , method , getter , js_class = "HTMLBodyElement" , js_name = ongamepadconnected)]
#[doc = "Getter for the `ongamepadconnected` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLBodyElement/ongamepadconnected)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `HtmlBodyElement`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn ongamepadconnected(this: &HtmlBodyElement) -> Option<::js_sys::Function>;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (structural , method , setter , js_class = "HTMLBodyElement" , js_name = ongamepadconnected)]
#[doc = "Setter for the `ongamepadconnected` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLBodyElement/ongamepadconnected)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `HtmlBodyElement`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn set_ongamepadconnected(this: &HtmlBodyElement, value: Option<&::js_sys::Function>);
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (structural , method , getter , js_class = "HTMLBodyElement" , js_name = ongamepaddisconnected)]
#[doc = "Getter for the `ongamepaddisconnected` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLBodyElement/ongamepaddisconnected)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `HtmlBodyElement`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn ongamepaddisconnected(this: &HtmlBodyElement) -> Option<::js_sys::Function>;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (structural , method , setter , js_class = "HTMLBodyElement" , js_name = ongamepaddisconnected)]
#[doc = "Setter for the `ongamepaddisconnected` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLBodyElement/ongamepaddisconnected)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `HtmlBodyElement`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn set_ongamepaddisconnected(this: &HtmlBodyElement, value: Option<&::js_sys::Function>);
}

View File

@ -236,4 +236,51 @@ extern "C" {
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `HtmlFrameSetElement`*"]
pub fn set_onunload(this: &HtmlFrameSetElement, value: Option<&::js_sys::Function>);
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (structural , method , getter , js_class = "HTMLFrameSetElement" , js_name = ongamepadconnected)]
#[doc = "Getter for the `ongamepadconnected` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLFrameSetElement/ongamepadconnected)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `HtmlFrameSetElement`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn ongamepadconnected(this: &HtmlFrameSetElement) -> Option<::js_sys::Function>;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (structural , method , setter , js_class = "HTMLFrameSetElement" , js_name = ongamepadconnected)]
#[doc = "Setter for the `ongamepadconnected` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLFrameSetElement/ongamepadconnected)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `HtmlFrameSetElement`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn set_ongamepadconnected(this: &HtmlFrameSetElement, value: Option<&::js_sys::Function>);
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (structural , method , getter , js_class = "HTMLFrameSetElement" , js_name = ongamepaddisconnected)]
#[doc = "Getter for the `ongamepaddisconnected` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLFrameSetElement/ongamepaddisconnected)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `HtmlFrameSetElement`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn ongamepaddisconnected(this: &HtmlFrameSetElement) -> Option<::js_sys::Function>;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (structural , method , setter , js_class = "HTMLFrameSetElement" , js_name = ongamepaddisconnected)]
#[doc = "Setter for the `ongamepaddisconnected` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLFrameSetElement/ongamepaddisconnected)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `HtmlFrameSetElement`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn set_ongamepaddisconnected(
this: &HtmlFrameSetElement,
value: Option<&::js_sys::Function>,
);
}

View File

@ -379,14 +379,6 @@ extern "C" {
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Navigator`*"]
pub fn get_vr_displays(this: &Navigator) -> Result<::js_sys::Promise, JsValue>;
#[cfg(feature = "GamepadServiceTest")]
# [wasm_bindgen (method , structural , js_class = "Navigator" , js_name = requestGamepadServiceTest)]
#[doc = "The `requestGamepadServiceTest()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/requestGamepadServiceTest)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GamepadServiceTest`, `Navigator`*"]
pub fn request_gamepad_service_test(this: &Navigator) -> GamepadServiceTest;
# [wasm_bindgen (catch , method , structural , js_class = "Navigator" , js_name = requestMIDIAccess)]
#[doc = "The `requestMIDIAccess()` method."]
#[doc = ""]

View File

@ -1914,6 +1914,50 @@ extern "C" {
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Window`*"]
pub fn set_onunload(this: &Window, value: Option<&::js_sys::Function>);
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (structural , method , getter , js_class = "Window" , js_name = ongamepadconnected)]
#[doc = "Getter for the `ongamepadconnected` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Window/ongamepadconnected)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Window`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn ongamepadconnected(this: &Window) -> Option<::js_sys::Function>;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (structural , method , setter , js_class = "Window" , js_name = ongamepadconnected)]
#[doc = "Setter for the `ongamepadconnected` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Window/ongamepadconnected)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Window`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn set_ongamepadconnected(this: &Window, value: Option<&::js_sys::Function>);
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (structural , method , getter , js_class = "Window" , js_name = ongamepaddisconnected)]
#[doc = "Getter for the `ongamepaddisconnected` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Window/ongamepaddisconnected)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Window`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn ongamepaddisconnected(this: &Window) -> Option<::js_sys::Function>;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (structural , method , setter , js_class = "Window" , js_name = ongamepaddisconnected)]
#[doc = "Setter for the `ongamepaddisconnected` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Window/ongamepaddisconnected)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Window`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn set_ongamepaddisconnected(this: &Window, value: Option<&::js_sys::Function>);
#[cfg(feature = "Storage")]
# [wasm_bindgen (structural , catch , method , getter , js_class = "Window" , js_name = localStorage)]
#[doc = "Getter for the `localStorage` field of this object."]

View File

@ -2924,20 +2924,6 @@ mod gen_Gamepad;
#[allow(unused_imports)]
pub use gen_Gamepad::*;
#[cfg(feature = "GamepadAxisMoveEvent")]
#[allow(non_snake_case)]
mod gen_GamepadAxisMoveEvent;
#[cfg(feature = "GamepadAxisMoveEvent")]
#[allow(unused_imports)]
pub use gen_GamepadAxisMoveEvent::*;
#[cfg(feature = "GamepadAxisMoveEventInit")]
#[allow(non_snake_case)]
mod gen_GamepadAxisMoveEventInit;
#[cfg(feature = "GamepadAxisMoveEventInit")]
#[allow(unused_imports)]
pub use gen_GamepadAxisMoveEventInit::*;
#[cfg(feature = "GamepadButton")]
#[allow(non_snake_case)]
mod gen_GamepadButton;
@ -2945,19 +2931,12 @@ mod gen_GamepadButton;
#[allow(unused_imports)]
pub use gen_GamepadButton::*;
#[cfg(feature = "GamepadButtonEvent")]
#[cfg(feature = "GamepadEffectParameters")]
#[allow(non_snake_case)]
mod gen_GamepadButtonEvent;
#[cfg(feature = "GamepadButtonEvent")]
mod gen_GamepadEffectParameters;
#[cfg(feature = "GamepadEffectParameters")]
#[allow(unused_imports)]
pub use gen_GamepadButtonEvent::*;
#[cfg(feature = "GamepadButtonEventInit")]
#[allow(non_snake_case)]
mod gen_GamepadButtonEventInit;
#[cfg(feature = "GamepadButtonEventInit")]
#[allow(unused_imports)]
pub use gen_GamepadButtonEventInit::*;
pub use gen_GamepadEffectParameters::*;
#[cfg(feature = "GamepadEvent")]
#[allow(non_snake_case)]
@ -2994,6 +2973,20 @@ mod gen_GamepadHapticActuatorType;
#[allow(unused_imports)]
pub use gen_GamepadHapticActuatorType::*;
#[cfg(feature = "GamepadHapticEffectType")]
#[allow(non_snake_case)]
mod gen_GamepadHapticEffectType;
#[cfg(feature = "GamepadHapticEffectType")]
#[allow(unused_imports)]
pub use gen_GamepadHapticEffectType::*;
#[cfg(feature = "GamepadHapticsResult")]
#[allow(non_snake_case)]
mod gen_GamepadHapticsResult;
#[cfg(feature = "GamepadHapticsResult")]
#[allow(unused_imports)]
pub use gen_GamepadHapticsResult::*;
#[cfg(feature = "GamepadMappingType")]
#[allow(non_snake_case)]
mod gen_GamepadMappingType;
@ -3008,12 +3001,12 @@ mod gen_GamepadPose;
#[allow(unused_imports)]
pub use gen_GamepadPose::*;
#[cfg(feature = "GamepadServiceTest")]
#[cfg(feature = "GamepadTouch")]
#[allow(non_snake_case)]
mod gen_GamepadServiceTest;
#[cfg(feature = "GamepadServiceTest")]
mod gen_GamepadTouch;
#[cfg(feature = "GamepadTouch")]
#[allow(unused_imports)]
pub use gen_GamepadServiceTest::*;
pub use gen_GamepadTouch::*;
#[cfg(feature = "Geolocation")]
#[allow(non_snake_case)]

View File

@ -1,99 +1,57 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* The origin of this IDL file is
* https://w3c.github.io/gamepad/
* https://w3c.github.io/gamepad/extensions.html
* https://w3c.github.io/webvr/spec/1.1/#interface-gamepad
*/
// https://www.w3.org/TR/gamepad
[Pref="dom.gamepad.enabled"]
interface GamepadButton {
readonly attribute boolean pressed;
readonly attribute boolean touched;
readonly attribute double value;
[Exposed=Window]
interface Gamepad {
readonly attribute DOMString id;
// TODO: remove `unsigned`
readonly attribute unsigned long index;
readonly attribute boolean connected;
readonly attribute DOMHighResTimeStamp timestamp;
readonly attribute GamepadMappingType mapping;
readonly attribute FrozenArray<double> axes;
readonly attribute FrozenArray<GamepadButton> buttons;
[RustDeprecated]
readonly attribute unsigned long displayId;
};
enum GamepadHand {
"",
"left",
"right"
[Exposed=Window]
interface GamepadButton {
readonly attribute boolean pressed;
readonly attribute boolean touched;
readonly attribute double value;
};
enum GamepadMappingType {
"",
"standard"
"standard",
};
[Pref="dom.gamepad.enabled"]
interface Gamepad {
/**
* An identifier, unique per type of device.
*/
readonly attribute DOMString id;
/**
* The game port index for the device. Unique per device
* attached to this system.
*/
readonly attribute unsigned long index;
/**
* The mapping in use for this device. The empty string
* indicates that no mapping is in use.
*/
readonly attribute GamepadMappingType mapping;
/**
* The hand in use for this device. The empty string
* indicates that unknown, both hands, or not applicable
*/
[Pref="dom.gamepad.extensions.enabled"]
readonly attribute GamepadHand hand;
/**
* The displayId in use for as an association point in the VRDisplay API
* to identify which VRDisplay that the gamepad is associated with.
*/
[Pref="dom.vr.enabled"]
readonly attribute unsigned long displayId;
/**
* true if this gamepad is currently connected to the system.
*/
readonly attribute boolean connected;
/**
* The current state of all buttons on the device, an
* array of GamepadButton.
*/
[Pure, Cached, Frozen]
readonly attribute sequence<GamepadButton> buttons;
/**
* The current position of all axes on the device, an
* array of doubles.
*/
[Pure, Cached, Frozen]
readonly attribute sequence<double> axes;
/**
* Timestamp from when the data of this device was last updated.
*/
readonly attribute DOMHighResTimeStamp timestamp;
/**
* The current pose of the device, a GamepadPose.
*/
[Pref="dom.gamepad.extensions.enabled"]
readonly attribute GamepadPose? pose;
/**
* The current haptic actuator of the device, an array of
* GamepadHapticActuator.
*/
[Constant, Cached, Frozen, Pref="dom.gamepad.extensions.enabled"]
readonly attribute sequence<GamepadHapticActuator> hapticActuators;
interface GamepadHapticActuator {
[RustDeprecated]
readonly attribute GamepadHapticActuatorType type;
};
[RustDeprecated]
enum GamepadHapticActuatorType {
"vibration"
};
[Exposed=Window]
partial interface Navigator {
[Throws] sequence<Gamepad?> getGamepads();
};
[Exposed=Window]
interface GamepadEvent: Event {
// TODO: remove `optional` modifier on `eventInitDict`
constructor(DOMString type, optional GamepadEventInit eventInitDict);
// TODO: remove `?` modifier
[SameObject] readonly attribute Gamepad? gamepad;
};
dictionary GamepadEventInit : EventInit {
// TODO: add `required`
// TODO: remove `?` modifier
Gamepad? gamepad;
};

View File

@ -1,19 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
[Pref="dom.gamepad.non_standard_events.enabled",
Constructor(DOMString type, optional GamepadAxisMoveEventInit eventInitDict)]
interface GamepadAxisMoveEvent : GamepadEvent
{
readonly attribute unsigned long axis;
readonly attribute double value;
};
dictionary GamepadAxisMoveEventInit : GamepadEventInit
{
unsigned long axis = 0;
double value = 0;
};

View File

@ -1,17 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
[Pref="dom.gamepad.non_standard_events.enabled",
Constructor(DOMString type, optional GamepadButtonEventInit eventInitDict)]
interface GamepadButtonEvent : GamepadEvent
{
readonly attribute unsigned long button;
};
dictionary GamepadButtonEventInit : GamepadEventInit
{
unsigned long button = 0;
};

View File

@ -1,17 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
[Pref="dom.gamepad.enabled",
Constructor(DOMString type, optional GamepadEventInit eventInitDict)]
interface GamepadEvent : Event
{
readonly attribute Gamepad? gamepad;
};
dictionary GamepadEventInit : EventInit
{
Gamepad? gamepad = null;
};

View File

@ -0,0 +1,38 @@
// https://w3c.github.io/gamepad/extensions.html
enum GamepadHand {
"", /* unknown, both hands, or not applicable */
"left",
"right"
};
[Exposed=Window]
interface GamepadPose {
readonly attribute boolean hasOrientation;
readonly attribute boolean hasPosition;
[Throws] // TODO: remove
readonly attribute Float32Array? position;
[Throws] // TODO: remove
readonly attribute Float32Array? linearVelocity;
[Throws] // TODO: remove
readonly attribute Float32Array? linearAcceleration;
[Throws] // TODO: remove
readonly attribute Float32Array? orientation;
[Throws] // TODO: remove
readonly attribute Float32Array? angularVelocity;
[Throws] // TODO: remove
readonly attribute Float32Array? angularAcceleration;
};
partial interface Gamepad {
readonly attribute GamepadHand hand;
readonly attribute FrozenArray<GamepadHapticActuator> hapticActuators;
readonly attribute GamepadPose? pose;
};
[Exposed=Window]
partial interface GamepadHapticActuator {
[Throws] // TODO: remove
Promise<boolean> pulse(double value, double duration);
};

View File

@ -1,21 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* The origin of this IDL file is
* https://w3c.github.io/gamepad/extensions.html#gamepadhapticactuator-interface
*/
enum GamepadHapticActuatorType {
"vibration"
};
[Pref="dom.gamepad.extensions.enabled",
HeaderFile="mozilla/dom/GamepadHapticActuator.h"]
interface GamepadHapticActuator
{
readonly attribute GamepadHapticActuatorType type;
[Throws, NewObject]
Promise<boolean> pulse(double value, double duration);
};

View File

@ -1,30 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* The origin of this IDL file is
* https://w3c.github.io/gamepad/extensions.html#gamepadpose-interface
*/
[Pref="dom.gamepad.extensions.enabled"]
interface GamepadPose
{
readonly attribute boolean hasOrientation;
readonly attribute boolean hasPosition;
/**
* position, linearVelocity, and linearAcceleration are 3-component vectors.
* position is relative to a sitting space. Transforming this point with
* VRStageParameters.sittingToStandingTransform converts this to standing space.
*/
[Constant, Throws] readonly attribute Float32Array? position;
[Constant, Throws] readonly attribute Float32Array? linearVelocity;
[Constant, Throws] readonly attribute Float32Array? linearAcceleration;
/* orientation is a 4-entry array representing the components of a quaternion. */
[Constant, Throws] readonly attribute Float32Array? orientation;
/* angularVelocity and angularAcceleration are the components of 3-dimensional vectors. */
[Constant, Throws] readonly attribute Float32Array? angularVelocity;
[Constant, Throws] readonly attribute Float32Array? angularAcceleration;
};

View File

@ -1,45 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
[Pref="dom.gamepad.test.enabled"]
interface GamepadServiceTest
{
readonly attribute GamepadMappingType noMapping;
readonly attribute GamepadMappingType standardMapping;
readonly attribute GamepadHand noHand;
readonly attribute GamepadHand leftHand;
readonly attribute GamepadHand rightHand;
[Throws]
Promise<unsigned long> addGamepad(DOMString id,
GamepadMappingType mapping,
GamepadHand hand,
unsigned long numButtons,
unsigned long numAxes,
unsigned long numHaptics);
undefined removeGamepad(unsigned long index);
undefined newButtonEvent(unsigned long index,
unsigned long button,
boolean pressed,
boolean touched);
undefined newButtonValueEvent(unsigned long index,
unsigned long button,
boolean pressed,
boolean touched,
double value);
undefined newAxisMoveEvent(unsigned long index,
unsigned long axis,
double value);
undefined newPoseMove(unsigned long index,
Float32Array? orient,
Float32Array? pos,
Float32Array? angVelocity,
Float32Array? angAcceleration,
Float32Array? linVelocity,
Float32Array? linAcceleration);
};

View File

@ -153,16 +153,6 @@ partial interface Navigator {
readonly attribute NetworkInformation connection;
};
// https://dvcs.w3.org/hg/gamepad/raw-file/default/gamepad.html#navigator-interface-extension
partial interface Navigator {
[Throws, Pref="dom.gamepad.enabled"]
sequence<Gamepad?> getGamepads();
};
partial interface Navigator {
[Pref="dom.gamepad.test.enabled"]
GamepadServiceTest requestGamepadServiceTest();
};
partial interface Navigator {
[Throws, Pref="dom.vr.enabled"]
Promise<sequence<VRDisplay>> getVRDisplays();

View File

@ -0,0 +1,44 @@
// https://www.w3.org/TR/gamepad
partial interface Gamepad {
[SameObject] readonly attribute GamepadHapticActuator vibrationActuator;
};
/* TODO: requires partial or extend support.
enum GamepadMappingType {
"xr-standard",
};
*/
partial interface GamepadHapticActuator {
[SameObject] readonly attribute FrozenArray<GamepadHapticEffectType> effects;
Promise<GamepadHapticsResult> playEffect(
GamepadHapticEffectType type,
optional GamepadEffectParameters params = {}
);
Promise<GamepadHapticsResult> reset();
};
enum GamepadHapticsResult {
"complete",
"preempted"
};
enum GamepadHapticEffectType {
"dual-rumble",
"trigger-rumble"
};
dictionary GamepadEffectParameters {
unsigned long long duration = 0;
unsigned long long startDelay = 0;
double strongMagnitude = 0.0;
double weakMagnitude = 0.0;
double leftTrigger = 0.0;
double rightTrigger = 0.0;
};
partial interface mixin WindowEventHandlers {
attribute EventHandler ongamepadconnected;
attribute EventHandler ongamepaddisconnected;
};

View File

@ -0,0 +1,13 @@
// https://w3c.github.io/gamepad/extensions.html
[Exposed=Window, SecureContext]
interface GamepadTouch {
readonly attribute unsigned long touchId;
readonly attribute octet surfaceId;
readonly attribute Float32Array position;
readonly attribute Uint32Array? surfaceDimensions;
};
partial interface Gamepad {
readonly attribute FrozenArray<GamepadTouch>? touchEvents;
};